Behavior of sdReadTimeout
Posted: Thu Apr 10, 2014 7:15 pm
I have a serial device that sends a byte once every 100ms at 115200 baud.
When I call sdReadTimeout, I expect it to timeout after the specified time, regardless of the incoming traffic pattern. So, given the following code, we would expect to return after at most 1sec:
However, what I see is sdReadTimeout takes ~1min to timeout.
This seems to be because internally, qwait is called with the same 'time' value each time some data is received, without decrementing 'time' accordingly.
Of course, there are workarounds, but I'm just wondering if this behavior is intentional. (?)
When I call sdReadTimeout, I expect it to timeout after the specified time, regardless of the incoming traffic pattern. So, given the following code, we would expect to return after at most 1sec:
Code: Select all
uint8_t buf[512];
sdReadTimeout(&SD1,buf,sizeof(buf),MS2ST(1000));
However, what I see is sdReadTimeout takes ~1min to timeout.
This seems to be because internally, qwait is called with the same 'time' value each time some data is received, without decrementing 'time' accordingly.
Code: Select all
// from chIQReadTimeout in chqueues.c
...
if (qwait((GenericQueue *)iqp, time) != Q_OK) {
...
Of course, there are workarounds, but I'm just wondering if this behavior is intentional. (?)