David Ching
2008-02-15 19:46:45 UTC
Hello,
I have successfully opened a COM port, COM6. It is actually a virtual COM
port provided by a Microchip USB device. I can read/write to the device
using the default parameters fine.
But when I try to set the parameters with SetCommState(), the function
returns FALSE, and GetLastError() is 31 which is "A device attached to the
system is not functioning".
Here is the DCB that SetCommState gets, nothing unusual:
DCBlength: 28
BaudRate: 9600
fBinary: 1
fParity: 0
fOutxCtsFlow: 0
fOutxDsrFlow: 0
fDtrControl: 0
fDsrSensitivity: 0
fTXContinueOnXoff: 0
fOutX: 0
fInX: 0
fErrorChar: 0
fNull: 0
fRtsControl: 1
fAbortOnError: 0
fDummy2: 0
wReserved: 0
XonLim: 0
XoffLim: 0
ByteSize: 8
Parity: 0
StopBits: 0
XonChar: 0
XoffChar: 0
ErrorChar: 0
EofChar: 0
EvtChar: 0
wReserved1: 0
The same code works fine for ordinary COM ports, but not for the MicroChip
CDC USB one. This is a pain because most serial port libraries call
SetCommState() after the CreateFile() succeeds, and when SetCommState()
fails, the library reports the port cannot be opened. Thus, we are severely
limited in the serial port libraries we can use.
Is there any way SetCommState() can be fixed?
Thanks,
David
I have successfully opened a COM port, COM6. It is actually a virtual COM
port provided by a Microchip USB device. I can read/write to the device
using the default parameters fine.
But when I try to set the parameters with SetCommState(), the function
returns FALSE, and GetLastError() is 31 which is "A device attached to the
system is not functioning".
Here is the DCB that SetCommState gets, nothing unusual:
DCBlength: 28
BaudRate: 9600
fBinary: 1
fParity: 0
fOutxCtsFlow: 0
fOutxDsrFlow: 0
fDtrControl: 0
fDsrSensitivity: 0
fTXContinueOnXoff: 0
fOutX: 0
fInX: 0
fErrorChar: 0
fNull: 0
fRtsControl: 1
fAbortOnError: 0
fDummy2: 0
wReserved: 0
XonLim: 0
XoffLim: 0
ByteSize: 8
Parity: 0
StopBits: 0
XonChar: 0
XoffChar: 0
ErrorChar: 0
EofChar: 0
EvtChar: 0
wReserved1: 0
The same code works fine for ordinary COM ports, but not for the MicroChip
CDC USB one. This is a pain because most serial port libraries call
SetCommState() after the CreateFile() succeeds, and when SetCommState()
fails, the library reports the port cannot be opened. Thus, we are severely
limited in the serial port libraries we can use.
Is there any way SetCommState() can be fixed?
Thanks,
David