Say I’m doing serial I/O to my USB device, and that I’ve set ReadTotalTimeoutConstant to 1000, and all other timeout values are zero.
Then say I call WaitCommEvent(h, EV_RXCHAR) which returns and says there’s *two* bytes in the buffer (via ClearCommError(&comStat));
Scenario 1) The user issues a read request for *two* bytes. Obviously I return immediately with the two bytes from my buffer.
Scenario 2) The user issues a read to my device for *four* bytes.
In this scenario, is it “wrong” to return immediately with the two bytes? (Clearly it’s not “wrong” from a ReadFile/dwBytesRead perspective, but…)
Or should I wait first, returning when either the buffer has at least 4 bytes, or the 1000ms is reached?
If ReadTotalTimeoutConstant is > 0 and both ReadIntervalTimeout and
ReadMultiplierTimeout are 0, in the Scenario 2 you should not return
until 4 bytes are available or the timeout specified by
ReadTotalTimeoutConstant
expires.
I was never able to find any complete documentation on read timeout
handling, so I think the only sure reference is the serial.sys sources
in DDK samples (notice that not all possible combinations of values of
the 3 read timeouts seems to be explicitly handled)
Carlo
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of
xxxxx@gmail.com
Sent: gioved? 11 gennaio 2007 21.10
To: Windows System Software Devs Interest List
Subject: [ntdev] General question about serial read timeouts
Say I’m doing serial I/O to my USB device, and that I’ve set
ReadTotalTimeoutConstant to 1000, and all other timeout
values are zero.
Then say I call WaitCommEvent(h, EV_RXCHAR) which returns and
says there’s *two* bytes in the buffer (via ClearCommError(&comStat));
Scenario 1) The user issues a read request for *two* bytes.
Obviously I return immediately with the two bytes from my buffer.
Scenario 2) The user issues a read to my device for *four* bytes.
In this scenario, is it “wrong” to return immediately with
the two bytes? (Clearly it’s not “wrong” from a
ReadFile/dwBytesRead perspective, but…)
Or should I wait first, returning when either the buffer has
at least 4 bytes, or the 1000ms is reached?