Skip to content

Commit 08ce1f6

Browse files
patricklaffpistm
authored andcommitted
Update HardwareSerial.h
Signed-off-by: patricklaf <[email protected]>
1 parent 5eb19be commit 08ce1f6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

cores/arduino/HardwareSerial.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,14 @@ void HardwareSerial::begin(unsigned long baud, byte config)
449449
uart_init(&_serial, (uint32_t)baud, databits, parity, stopbits, _rx_invert, _tx_invert, _data_invert);
450450
enableHalfDuplexRx();
451451
uart_attach_rx_callback(&_serial, _rx_complete_irq);
452+
453+
_ready = true;
452454
}
453455

454456
void HardwareSerial::end()
455457
{
458+
_ready = false;
459+
456460
// wait for transmission of outgoing data
457461
flush(TX_TIMEOUT);
458462

cores/arduino/HardwareSerial.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class HardwareSerial : public Stream {
146146
using Print::write; // pull in write(str) from Print
147147
operator bool()
148148
{
149-
return true;
149+
return _ready;
150150
}
151151

152152
void setRx(uint32_t _rx);
@@ -189,6 +189,7 @@ class HardwareSerial : public Stream {
189189
#endif // HAL_UART_MODULE_ENABLED && !HAL_UART_MODULE_ONLY
190190

191191
private:
192+
bool _ready;
192193
bool _rx_enabled;
193194
uint8_t _config;
194195
unsigned long _baud;

0 commit comments

Comments
 (0)