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
Contact:

Serial Driver Timeout has no effect

Postby wurstnase » Thu Jul 12, 2018 11:07 am

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.
\o/ Nico

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

Re: Serial Driver Timeout has no effect

Postby wurstnase » Thu Jul 12, 2018 11:15 am

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.
\o/ Nico

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Serial Driver Timeout has no effect

Postby Giovanni » Thu Jul 12, 2018 12:18 pm

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
Contact:

Re: Serial Driver Timeout has no effect

Postby wurstnase » Thu Jul 12, 2018 1:05 pm

The serial driver is buffered?
Guess I need to flush the buffer before starting in my case.
\o/ Nico

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Serial Driver Timeout has no effect

Postby Giovanni » Thu Jul 12, 2018 1:20 pm

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
Contact:

Re: Serial Driver Timeout has no effect

Postby wurstnase » Thu Jul 12, 2018 1:54 pm

Is there a simple way to flush?
Currently I simply have a while loop until timeout. Probably there is a better way?
\o/ Nico

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Serial Driver Timeout has no effect

Postby Giovanni » Thu Jul 12, 2018 2:10 pm

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
Contact:

Re: Serial Driver Timeout has no effect

Postby wurstnase » Thu Jul 12, 2018 2:19 pm

Perfect. Thanks.
\o/ Nico

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

Re: Serial Driver Timeout has no effect

Postby wurstnase » Fri Jul 13, 2018 7:55 am

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)
\o/ Nico

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Serial Driver Timeout has no effect

Postby Giovanni » Fri Jul 13, 2018 8:20 am

That would be iqResetI().

Giovanni


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 10 guests