Possible bug in chibios 3.0.3 Serial driver

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Post Reply
austin_boulderes
Posts: 10
Joined: Wed Nov 05, 2014 9:38 pm
Has thanked: 1 time
Been thanked: 1 time

Possible bug in chibios 3.0.3 Serial driver

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

Re: Possible bug in chibios 3.0.3 Serial driver

Post 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
austin_boulderes
Posts: 10
Joined: Wed Nov 05, 2014 9:38 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Possible bug in chibios 3.0.3 Serial driver

Post by austin_boulderes »

Great, thanks on both counts.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Possible bug in chibios 3.0.3 Serial driver

Post by Giovanni »

Fixed in repository as bug #659.

Giovanni
Post Reply