arduino / arduino/ArduinoCore-avr
Add "overflow()" to HardwareSerial
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi
it would be nice, to have an overflow handler in the HardwareSerial class. This would be handy if you have code (i.e. rendering a display) where you can not fetch the data and the serial buffer would overflow otherwise...
This could be simply achieved by
```c++
//HardwareSerial.cpp line 92
bool handle_serial_overflow() **attribute**((weak));
bool handle_serial_overflow(){ return false}
inline void store_char(unsigned char c, ring_buffer *buffer)
{
int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE;
if (i != buffer->tail) {
buffer->buffer[buffer->head] = c;
buffer->head = i;
}
//*******************\* overflow handling *******************************
else if( handle_serial_overflow()) {
store_char(c, buffer);
}
//************************************************************
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.