UART: How to find number of bytes that can be written non-blocking

mikkeldamsgaard
Posts: 5
Joined: Mon May 16, 2022 8:07 am

UART: How to find number of bytes that can be written non-blocking

Postby mikkeldamsgaard » Sat Feb 04, 2023 8:02 pm

Given that you are using a TX buffer in the UART driver, how can I determine exactly how many bytes can be sent to the driver before it blocks/waits?

I thought that uart_get_tx_buffer_free_size would deliver that number, but having tested it, that is not the case. Looking at the implementation and the default ISR, then that method only takes the "first" delivered buffer into account and does not cater for the fact that the the first buffer is not removed from the ringbuffer before it is fully read, so that method is optimistic.

/Mikkel

Who is online

Users browsing this forum: Baidu [Spider] and 303 guests