I want to read some data from a device connected to a COM port.
HANDLE handle =
CreateFileW
(L"\\\\.\\COM3", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
gives me a valid
HANDLE
which is then configured viaGetCommState
andSetCommState
.OVERLAPPED ol = {0};
char buffer[1024];
ol.Offset = 0;
ol.OffsetHigh = 0;
ReadFileEx
(handle, buffer, 1, &ol, NULL);
The problem is, that this call doesn't succeed and
GetLastError()
returns 87 (ERROR_INVALID_PARAMETER
).
What could I try to be able to read from the device?