UART TX Ring Buffer Fill Level

gfvalvo
Posts: 36
Joined: Thu Dec 24, 2020 3:06 pm

UART TX Ring Buffer Fill Level

Postby gfvalvo » Tue Dec 21, 2021 5:53 pm

Is it possible to determine the UART TX Ring Buffer Fill Level or equivalently the space available?

I'd like to call uart_write_bytes() and specify the number of bytes to be written to a value no higher than space available in the ring buffer. That way I can be assured that the function will return immediately after copying the bytes and not wait for more space to become available. That could easily be accomplished if the API had a call that returns either the space available or the fill level.

Victoria Nope
Posts: 75
Joined: Fri Dec 04, 2020 9:56 pm

Re: UART TX Ring Buffer Fill Level

Postby Victoria Nope » Tue Dec 21, 2021 8:38 pm

Would not uart_tx_chars function fit for your needs? According to docs (have not checked the source), it should return immediately when the TX FIFO is full, returning number of bytes enqueued.

gfvalvo
Posts: 36
Joined: Thu Dec 24, 2020 3:06 pm

Re: UART TX Ring Buffer Fill Level

Postby gfvalvo » Tue Dec 21, 2021 8:54 pm

I believe uart_tx_chars() bypasses the (potentially large) ring buffer in memory and writes as many characters as it can directly into the UART's hardware FIFO. That's not what I want as the hardware FIFO is likely pretty small.

Anyway, that's my impression from reading the docs. But, they do play kind of fast and loose with the terms "FIFO" and "BUFFER". So, I may be wrong,

gfvalvo
Posts: 36
Joined: Thu Dec 24, 2020 3:06 pm

Re: UART TX Ring Buffer Fill Level

Postby gfvalvo » Tue Dec 21, 2021 11:52 pm

gfvalvo wrote:
Tue Dec 21, 2021 8:54 pm
I believe uart_tx_chars() bypasses the (potentially large) ring buffer in memory and writes as many characters as it can directly into the UART's hardware FIFO.
From the docs:
Another function for writing data to the Tx FIFO buffer is uart_tx_chars(). Unlike uart_write_bytes(), this function will not block until space is available. Instead, it will write all data which can immediately fit into the hardware Tx FIFO, and then return the number of bytes that were written.
Google has failed me on what the size of the "hardware Tx FIFO" is. But, I doubt it's very large.

Who is online

Users browsing this forum: arunbm123, Baidu [Spider], chegewara, Majestic-12 [Bot] and 88 guests