Serial Driver Timeout has no effect

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Serial Driver Timeout has no effect

Post 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.
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: Serial Driver Timeout has no effect

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Serial Driver Timeout has no effect

Post by Giovanni »

To test the timeout call the function with no data in input, it must exit after the specified timeout.

Giovanni
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: Serial Driver Timeout has no effect

Post by wurstnase »

The serial driver is buffered?
Guess I need to flush the buffer before starting in my case.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Serial Driver Timeout has no effect

Post by Giovanni »

Correct or it would immediately return buffered data.

Giovanni
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: Serial Driver Timeout has no effect

Post by wurstnase »

Is there a simple way to flush?
Currently I simply have a while loop until timeout. Probably there is a better way?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Serial Driver Timeout has no effect

Post by Giovanni »

Make a read with TIME_IMMEDIATE.

Giovanni
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: Serial Driver Timeout has no effect

Post by wurstnase »

Perfect. Thanks.
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: Serial Driver Timeout has no effect

Post 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)
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Serial Driver Timeout has no effect

Post by Giovanni »

That would be iqResetI().

Giovanni
Post Reply