Page 1 of 2
Serial Driver Timeout has no effect
Posted: Thu Jul 12, 2018 11:07 am
by wurstnase
Hi,
I'm working with the serial driver on a STM32F103.
I want to use sdGetTimeout(&SD1, OSAL_MS2I(200)) but the timeout didn't work/has no effect.
osalThreadSleep-functions work as expected.
Re: Serial Driver Timeout has no effect
Posted: Thu Jul 12, 2018 11:15 am
by wurstnase
Sorry. Add a debug. For some reason the sdGet gets random data. Pretty strange, because I can't see anything on my serial sniffer.
Probably I'm missing something different.
Re: Serial Driver Timeout has no effect
Posted: Thu Jul 12, 2018 12:18 pm
by Giovanni
To test the timeout call the function with no data in input, it must exit after the specified timeout.
Giovanni
Re: Serial Driver Timeout has no effect
Posted: Thu Jul 12, 2018 1:05 pm
by wurstnase
The serial driver is buffered?
Guess I need to flush the buffer before starting in my case.
Re: Serial Driver Timeout has no effect
Posted: Thu Jul 12, 2018 1:20 pm
by Giovanni
Correct or it would immediately return buffered data.
Giovanni
Re: Serial Driver Timeout has no effect
Posted: Thu Jul 12, 2018 1:54 pm
by wurstnase
Is there a simple way to flush?
Currently I simply have a while loop until timeout. Probably there is a better way?
Re: Serial Driver Timeout has no effect
Posted: Thu Jul 12, 2018 2:10 pm
by Giovanni
Make a read with TIME_IMMEDIATE.
Giovanni
Re: Serial Driver Timeout has no effect
Posted: Thu Jul 12, 2018 2:19 pm
by wurstnase
Perfect. Thanks.
Re: Serial Driver Timeout has no effect
Posted: Fri Jul 13, 2018 7:55 am
by wurstnase
Probably it is a good idea to add a flush in the queue directly?
Something like:
Code: Select all
#define iqFlushI(iqp) \
do { \
(iqp)->q_wrptr = (iqp)->q_rdptr; \
(iqp)->q_counter = 0; \
} while(0)
Re: Serial Driver Timeout has no effect
Posted: Fri Jul 13, 2018 8:20 am
by Giovanni
That would be iqResetI().
Giovanni