when does UART write fail?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
User avatar
russian
Posts: 368
Joined: Mon Oct 29, 2012 3:17 am
Has thanked: 16 times
Been thanked: 14 times

when does UART write fail?

Post by russian »

In what case would UART serial driver fail to write some bytes out?

I've realized that sometimes after 10 seconds, sometimes after five minutes my chSequentialStreamWrite which uses SD3 would hang up. The thread was in WTQUEUE state indefinitely, so I've moved to chnWriteTimeout method instead and it now sometimes fails to write all 100 bytes at 115KB in 10 seconds. When would this happen? I am pretty sure only one thread is accessing SD3. Could I be exhausting any buffer? Should I increase SERIAL_BUFFERS_SIZE ?

ChibiOS 2.6.3
User avatar
russian
Posts: 368
Joined: Mon Oct 29, 2012 3:17 am
Has thanked: 16 times
Been thanked: 14 times

Re: when does UART write fail?

Post by russian »

PS: all consecutive invocations of write() do not actually write anything, looks like the queue is constantly full.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: when does UART write fail?

Post by Giovanni »

Hi,

This is a known bug in 2.6.x, it has already been fixed in repository and will be fixed in 2.6.5/3.0.0.

Giovanni
User avatar
russian
Posts: 368
Joined: Mon Oct 29, 2012 3:17 am
Has thanked: 16 times
Been thanked: 14 times

Re: when does UART write fail?

Post by russian »

Looks like fresh serial_lld.c has solved this issue, thank you for the hint.

So, in real life UART should never fail? Is it safe to put an assertion that write() method writes all bytes?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: when does UART write fail?

Post by Giovanni »

It always writes all bytes unless you specify TIME_IMMEDIATE, in that case it just fills the buffer as much as possible without waiting.

Giovanni
Post Reply