J
Joshua Moore
I'm trying to convert from a lot of invoked code to c# 2.0 SerialPort code.
I can't find a way to set fOutxCtsFlow to true (maybe CTSEnable?) and
fRtsControl = RTS_CONTROL_HANDSHAKE (RtsEnable?). Also, do I need to set
the handshaking? Below is the old and attempted new (that continually gets
a timeout error on read. I upped the read timeout, but it's way too long
NOT for it to be a handshaking or other issue than the readtimeout setting.
Thanks in advance, Joshua Moore
Part of the old code to open the serialport connection was:
DCB dcb;
GetCommState(m_CommHandle, &dcb);
dcb.BaudRate = 57600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.fOutxCtsFlow = TRUE;
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
SetCommState(m_CommHandle, &dcb);
NEW CODE:
serialPort = new System.IO.Ports.SerialPort("COM1", 57600,
System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
serialPort.Handshake = System.IO.Ports.Handshake.RequestToSend;
// serialPort.ReadBufferSize = 2047;
// serialPort.WriteBufferSize = 2047;
serialPort.RtsEnable = true;
serialPort.ReadTimeout = 800;
serialPort.WriteTimeout = 30;
I can't find a way to set fOutxCtsFlow to true (maybe CTSEnable?) and
fRtsControl = RTS_CONTROL_HANDSHAKE (RtsEnable?). Also, do I need to set
the handshaking? Below is the old and attempted new (that continually gets
a timeout error on read. I upped the read timeout, but it's way too long
NOT for it to be a handshaking or other issue than the readtimeout setting.
Thanks in advance, Joshua Moore
Part of the old code to open the serialport connection was:
DCB dcb;
GetCommState(m_CommHandle, &dcb);
dcb.BaudRate = 57600;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.fOutxCtsFlow = TRUE;
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
SetCommState(m_CommHandle, &dcb);
NEW CODE:
serialPort = new System.IO.Ports.SerialPort("COM1", 57600,
System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
serialPort.Handshake = System.IO.Ports.Handshake.RequestToSend;
// serialPort.ReadBufferSize = 2047;
// serialPort.WriteBufferSize = 2047;
serialPort.RtsEnable = true;
serialPort.ReadTimeout = 800;
serialPort.WriteTimeout = 30;