[Rxtx] RTS_CONTROL question
Adrian Stan
adrstan1 at yahoo.com
Tue Nov 22 11:11:54 MST 2011
Hello,
I am an user of RXTX library (through Eclipse RSE Terminal).
I have an issue related to reading from a serial device. At some point, I cannot read anymore, even if data is available.
The problem is not reproducible with Putty, which reads fine till the end.
I have debugged the problem and seems to be located into function termios_to_DCB(), in file termios.c
Here, we have the following piece of code:
if ( s_termios->c_cflag & HARDWARE_FLOW_CONTROL )
{
dcb->fRtsControl = RTS_CONTROL_HANDSHAKE;
dcb->fOutxCtsFlow = TRUE;
}
else
{
dcb->fRtsControl = RTS_CONTROL_DISABLE;
dcb->fOutxCtsFlow = FALSE;
}
Here, if RTS/CTS is disabled, we are setting dcb->fRtsControl = RTS_CONTROL_DISABLE, which doesn't look right.
Maybe it should remain set to RTS_CONTROL_ENABLE.
I have modified the code accordingly:
if ( s_termios->c_cflag & HARDWARE_FLOW_CONTROL )
{
dcb->fRtsControl = RTS_CONTROL_HANDSHAKE;
dcb->fOutxCtsFlow = TRUE;
}
else
{
dcb->fOutxCtsFlow = FALSE;
}
After the modification, I could read successfully from the serial device, no more issues were encountered.
I have looked in the source code of Putty, to see how they are dealing with this situation.
The relevant piece of code is in function serial_configure(), in file WINSERV.c (from Putty source code)
static const char *serial_configure(Serial serial, HANDLE serport, Config *cfg)
{
...
DCB dcb;
...
dcb.fRtsControl = RTS_CONTROL_ENABLE;
...
switch (cfg->serflow) {
case SER_FLOW_NONE:
str = "no";
break;
case SER_FLOW_XONXOFF:
dcb.fOutX = dcb.fInX = TRUE;
str = "XON/XOFF";
break;
case SER_FLOW_RTSCTS:
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
dcb.fOutxCtsFlow = TRUE;
str = "RTS/CTS";
break;
case SER_FLOW_DSRDTR:
dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
dcb.fOutxDsrFlow = TRUE;
str = "DSR/DTR";
break;
}
...
}
So, Putty sets dcb.fRtsControl to RTS_CONTROL_HANDSHAKE if RTS/CTS is enabled, but leaves it set to DTR_CONTROL_ENABLE if RTS/CTS is NOT enabled.
Any input on this issue is highly appreciated.
Thanks for your help,
Adrian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qbang.org/pipermail/rxtx/attachments/20111122/d5f02d21/attachment-0208.htm>
More information about the Rxtx
mailing list