i am opening a USB device:
for communication using CreateFile
:
HANDLE hUsb = CreateFile("\\.\LCLD9",
GENERIC_READ | GENERIC_WRITE,
0,
null,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0);
The call succeeds (i.e. hUsb is not equal to INVALID_HANDLE_VALUE
). But then it comes time to do what we do with every serial port:
- SetupComm (set receive and transit buffer sizes)
- SetCommState (set flow-control, baud rate, etc)
- SetCommTimeouts (set timeouts)
Each of these calls returns a GetLastError() code of 1
. E.g.:
SetupComm(hUsb, 1024, 1024);
Why are operations to configure the serial device failing when using a "USB" serial device, but work when using a "virtual COM port"? Do USB devices not support such baud rates, buffers, flow control, and timeouts?
If this is a limitation/feature of Universal Serial devices, how can i detect that a handle refers to a "Universal Serial Device", rather than a "COMM Port"? For example, the user is the one who specifies which port to use:
- \.\COM5
- \.\LCLD9
Other serial functions that fail when talking to Universal Serial Bus serial device:
GetCommModemStatus
(with error code 1)ReadFile
(with error code 6)PurgeComm
(with error code 6)WriteFile
(with error code 6)
Which begs the larger question, how do you communicate with a USB device once it's been opened with CreateFile
?