Is there a Serial.available() function for xmos uart?

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
User avatar
mifay
Member++
Posts: 29
Joined: Wed Dec 28, 2011 4:15 pm

Is there a Serial.available() function for xmos uart?

Post by mifay »

I've looked around a little in xmos uart modules and I couldn't find an equivalent to Arduino's Serial.available() function. Does someone know an equivalent function?


User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am
Contact:

Post by rp181 »

When you use the UART component, you have to pass a reference to a state variable:

Code: Select all

uart_rx_client_state rxState;
This gives you how many bytes has been received:

Code: Select all

rxState.received_bytes
However, i don't believe that this resets to zero after you read the bytes from the buffer.

I just briefly looked into the code, but you may also want to look in the source files (especially uart_rx_impl) about how the struct buffer_state is used.
Post Reply