Skip to content

Commit e7d5f51

Browse files
committed
add flush() method to HardwareSerial
1 parent 1863c25 commit e7d5f51

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cores/arduino/HardwareSerial.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ int HardwareSerial::availableForWrite(void)
487487
return tail - head - 1;
488488
}
489489

490+
void HardwareSerial::flush()
491+
{
492+
flush(0);
493+
}
494+
490495
void HardwareSerial::flush(uint32_t timeout)
491496
{
492497
// If we have never written a byte, no need to flush. This special
@@ -642,7 +647,7 @@ void HardwareSerial::enableHalfDuplexRx(void)
642647
if (isHalfDuplex()) {
643648
// In half-duplex mode we have to wait for all TX characters to
644649
// be transmitted before we can receive data.
645-
flush();
650+
flush(0);
646651
if (!_rx_enabled) {
647652
_rx_enabled = true;
648653
uart_enable_rx(&_serial);

cores/arduino/HardwareSerial.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ class HardwareSerial : public Stream {
125125
virtual int peek(void);
126126
virtual int read(void);
127127
int availableForWrite(void);
128-
virtual void flush(uint32_t timeout = 0);
128+
virtual void flush();
129+
void flush(uint32_t timeout = 0);
129130
virtual size_t write(uint8_t);
130131
inline size_t write(unsigned long n)
131132
{

0 commit comments

Comments
 (0)