-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Component: CoreRelated to the code for the standard Arduino APIRelated to the code for the standard Arduino API
Milestone
Description
Sometimes one wants to know the amount of free places in the transmit buffer
The function to check this is straightforward.
int room()
{
return (SERIAL_BUFFER_SIZE + tx_buffer.head - tx_buffer.tail) % SERIAL_BUFFER_SIZE;
}
// % can be optimized with an if ()
this makes it possible to check and fill up the ring buffer to the max (esp when using low baud rates) without overflow.
The name room() is not as ambiguous as space which already has a meaning in serial communication. Available() is already used for receive.
Metadata
Metadata
Assignees
Labels
Component: CoreRelated to the code for the standard Arduino APIRelated to the code for the standard Arduino API