Is there a Serial.available() function for xmos uart?
-
- Member++
- Posts: 29
- Joined: Wed Dec 28, 2011 4:15 pm
Is there a Serial.available() function for xmos uart?
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?
-
- Respected Member
- Posts: 395
- Joined: Tue May 18, 2010 12:25 am
When you use the UART component, you have to pass a reference to a state variable:
This gives you how many bytes has been received:
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.
Code: Select all
uart_rx_client_state rxState;
Code: Select all
rxState.received_bytes
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.