Serialport XON/XOFF Handshake State

Hello all

I found the following problem/speciallty in SerialPort I/O with XON/XOFF handshaking.
When the SerielPort is opened and set to xonxoff handshaking it is ready to send files, so it is in xon state. When I send a file to the reciever and my device recieves an xoff after the transmition is complete it is then in xoff mode.
After this I can't send anymore files because the port is blocked in xoff and my reciever won't send an xon to start. The other thing is I don't know wich state it's in. I have to close and reopen the port to get back into xon mode, then I can send the second file.
Does anyone know if the serialport can be reset to the one or other mode without opening and closing the port This uses to much overhead to do each time.
I would like to have a property in the API that can be used to get and set the software handshaking state as with the RTS enable property when using hardware handshaking.
I don't know if this is an issue just with the .NET CF 2.0 or also with .NET Framework for the desktop.

Thanks for any comments
Thomas




Answer this question

Serialport XON/XOFF Handshake State

  • nirva

    Hi Anthony

    Thank you very much for taking your time to answer my message.

    I am writing a software that communictas with a variety of CNC Controlers, some of them more than 10 years old. They don't always behave the way I would like them to, so I have to programm around thier shortcomings.

    The thing is this. The controller actually does send an XON to start :-) and I want to make my app wait for this XON to arrive before it starts sending, this would usualy be the case but only AFTER recieving data the first time. The port is in XON state after being newly opened wich meens it will start sending right away without waiting for the XON from the reciever.
    So what I did is I implemented waiting for XON from the reciever in the serial ports recieve event (chr(17)) and then started sending after turning back on XONXOFFHandshaking.
    The problem arises out of the fact that when the SerialPort is first opened it is in XON mode. After recieving the data it is in XOFF mode. These are two different starting states. It should be possible to change, with a property on the port, these states, as with the RTS signal.
    Now I could just check if it is the first transmition or not and use my XON wait implementation only when it is the first transmition. Then I coudn't always output a string on the UI though, to tell the user that the app is waiting for the transmiton to start.
    I thought someone would know a diffrent work around to this, other than restarting the port every time to recieve new data.

    Thanks again for everyones time, this is really a great forum.

    Cheers
    Thomas

  • Nima Amin

    Hi,

    May I ask what caused your receiver not send an xon on start You may try writing the following values from the receiver to indicate Xon/Xoff:

    Software Handshaking Characters
    Character
    Integer Value
    Description
    Xon
    17
    Resume data transmission.
    Xoff
    19
    Pause data transmission.

    In software flow control, when the receiver fills up the modem buffer it sends an Xoff to tell the sender to stop sending data. When the modem has room for more data, Xon should be sent so that the sender can continue sending the remaining data. It looks like, therefore, that the receiver is responsible for sending the Xon so that the serial port can continue sending data out.

    Cheers,

    Anthony Wong [MSFT]


  • Serialport XON/XOFF Handshake State