I did some searches but did not find info on this. I am trying to understand what sort of error handling the Arduino HardwareSerial routines perform. Apparently little to none, from what I can tell.
First, I tried to boil down the Rx ISR code in the HardwareSerial.cpp file (for the ATmega328) to the bare minimum, and came up with the following. It appears to do a parity error check, but no others.
ISR(USART0_RX_vect)
{
if (bit_is_clear(UCSR0A, UPE0)) {
unsigned char c = UDR0;
store_char(c, &rx_buffer);
} else {
unsigned char c = UDR0;
};
}
Secondly, the ATmega328 d/s says the following:
20.11.2 UCSRnA – USART Control and Status Register n A
• Bit 4 – FEn: Frame Error
This bit is set if the next character in the receive buffer had a Frame Error when received. I.e., when the first stop
bit of the next character in the receive buffer is zero. This bit is valid until the receive buffer (UDRn) is read. The
FEn bit is zero when the stop bit of received data is one. Always set this bit to zero when writing to UCSRnA.• Bit 3 – DORn: Data OverRun
This bit is set if a Data OverRun condition is detected. A Data OverRun occurs when the receive buffer is full (two
characters), it is a new character waiting in the Receive Shift Register, and a new start bit is detected. This bit is
valid until the receive buffer (UDRn) is read. Always set this bit to zero when writing to UCSRnA.• Bit 2 – UPEn: USART Parity Error
This bit is set if the next character in the receive buffer had a Parity Error when received and the Parity Checking
was enabled at that point (UPMn1 = 1). This bit is valid until the receive buffer (UDRn) is read. Always set this bit to
zero when writing to UCSRnA.
All 3 items say "This bit is valid until the receive buffer (UDRn) is read".
So, putting 1 and 2 together, it appears that any Rx character that invokes an FE, DOR, or UPE error will likely be incorrect in the c = UDR0; assignment, but UART reception will NOT be disrupted in any way, and it will go on to receive any follow-on characters ok. IOW, such errors will just trigger flags, but they'll have no effect if ignored. The data will just be wrong.
Yes, no, maybe?