Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5f25a97

Browse filesBrowse files
ornithophilefacchinm
authored andcommitted
Add isFlushed() method to serial classes
Add isFlushed() to HardwareSerial class for AVR and to UARTClass class for SAM. This provides a non-blocking way to check if the transmit buffer is flushed.
1 parent f5cbedd commit 5f25a97
Copy full SHA for 5f25a97

File tree

Expand file treeCollapse file tree

2 files changed

+6
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-0
lines changed

‎cores/arduino/UARTClass.cpp

Copy file name to clipboardExpand all lines: cores/arduino/UARTClass.cpp
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ void UARTClass::flush( void )
142142
;
143143
}
144144

145+
bool UARTClass::isFlushed( void )
146+
{
147+
return ((_pUart->UART_SR & UART_SR_TXRDY) == UART_SR_TXRDY) && (_tx_buffer->_iTail == _tx_buffer->_iHead);
148+
}
149+
145150
size_t UARTClass::write( const uint8_t uc_data )
146151
{
147152
// Is the hardware currently busy?

‎cores/arduino/UARTClass.h

Copy file name to clipboardExpand all lines: cores/arduino/UARTClass.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class UARTClass : public HardwareSerial
5252
int peek(void);
5353
int read(void);
5454
void flush(void);
55+
bool isFlushed(void);
5556
size_t write(const uint8_t c);
5657
using Print::write; // pull in write(str) and write(buf, size) from Print
5758

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.