Skip to content

Commit b14a86a

Browse files
committed
Serial: drop characters if the ringbuffer is full
As reported by @savejeff in #334
1 parent 56f1b3d commit b14a86a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cores/arduino/Serial.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,13 @@ void UART::on_rx() {
132132
return;
133133
}
134134
#endif
135-
while(_serial->obj->readable() && rx_buffer.availableForStore()) {
135+
while(_serial->obj->readable()) {
136136
char c;
137137
core_util_critical_section_enter();
138138
_serial->obj->read(&c, 1);
139-
rx_buffer.store_char(c);
139+
if (rx_buffer.availableForStore()) {
140+
rx_buffer.store_char(c);
141+
}
140142
core_util_critical_section_exit();
141143
}
142144
}

0 commit comments

Comments
 (0)