Page 1 of 1

Possible bug in chibios 3.0.3 Serial driver

Posted: Sat Oct 31, 2015 8:34 pm
by austin_boulderes
I'm writing an application which uses the Serial driver on an STM32F302 (it uses the STM32 USARTv2 serial lld). I wrote a loop which looks like the following (called in a regular thread context):

Code: Select all

while (sdGetWouldBlock(&SD1))
  sdGet(&SD1);


This caused a kernel panic with "SV#10", because sdGetWouldBlock() aliases to iqIsEmptyI(), an I-Class function. However, the documentation specifically lists it as a normal API function.

For the short term I'm just going to put the call in a lock zone, but it seems to me that either:
- The function should be renamed sdGetWouldBlockI() and the documentation appropriately updated
- The function should internally lock before calling the iq function

I also note that the function is listed as deprecated, so if possible I'd like to respect that. Is there another way to perform a buffer flush? Looking at the documentation, one doesn't immediately jump out at me.

Thanks in advance.

Re: Possible bug in chibios 3.0.3 Serial driver

Posted: Sat Oct 31, 2015 8:41 pm
by Giovanni
Hi,

It is a bug just as you described. You can reset the queues inside the SD driver using the queues API, there is no need to pull bytes one by one.

Giovanni

Re: Possible bug in chibios 3.0.3 Serial driver

Posted: Sat Oct 31, 2015 8:43 pm
by austin_boulderes
Great, thanks on both counts.

Re: Possible bug in chibios 3.0.3 Serial driver

Posted: Sun Nov 01, 2015 11:56 am
by Giovanni
Fixed in repository as bug #659.

Giovanni