I'm using winapi (in C) to read a batch from a comport using the following creating the port:
hSerial= CreateFile(COM5,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL |FILE_FLAG_NO_BUFFERING,
NULL);
and then reading a batch into Data which is lengthIn long :
ReadFile(hSerial,Data,lengthIn,lengthOut,NULL)
lengthOut represents the amount of data actually read.
I need to make sure I actually read lengthIn bytes at each iteration and not less, how do I do that? How do I make sure lengthIn=lengthOut each time?
I think it has something to do with the attribute while creating the port (like the FILE_FLAG_NO_BUFFERING), but I'm not sure which one and how.