What should the program do when parity fails?

Hi, If I set the second parameter of Serial.begin(speed, config) to SERIAL_8E2, namely, Serial.begin(9600, SERIAL_8E2), what should the program do when parity fails? Is there an interrupt function (arduino) when parity fails?
Best regards.

the message should not be processed as normal

if you don't expect there to be any errors, you to investigate the cause in the hardware and correct it

if there is the possibility of error, there should be a mechanism to retransmit the message, such as ACK/NACK in response to each message and storage of the message by the transmitter so that it can be retransmitted.

You have to check the parity of the incoming bytes yourself. It is not done in the background as part of the reception. As you check them, you get to decide what to do when there is a parity error.

EDIT: See post #4 below. AVR does handle parity. My mistake.

You are apparently only checking VERTICAL parity. That is, the parity of each byte. To be other than a bother, you also need a horizontal parity byte for the entire message text. Then you have a chance of knowing which bit of the bad byte is wrong and can fix it. For more than a single bit in a single byte, you need a much more rugged error checking method.

Paul

In the AVR core, characters with incorrect parity are thrown away and you will not see them. Framing errors are ignored so characters with a bad stop bit are received as valid. Data Overrun errors are ignored so if the interrupts are turned off for too long the characters are just lost.

johnwasser:
In the AVR core, characters with incorrect parity are thrown away and you will not see them. Framing errors are ignored so characters with a bad stop bit are received as valid. Data Overrun errors are ignored so if the interrupts are turned off for too long the characters are just lost.

And that is why people use various CRCC schemes to detect errors.

Paul

wanggaoteng:
Hi, If I set the second parameter of Serial.begin(speed, config) to SERIAL_8E2, namely, Serial.begin(9600, SERIAL_8E2), what should the program do when parity fails? I

I think the consensus is that checking the parity bit is just a waste of time.

If you are concerned about data errors then include a checksum as part of the message and verify the received message against the checksum. If it fails the test then discard the message and ask for it to be repeated.

...R

a correct checksum is not a guarantee that a message is correct. I learned this decoding CDMA messages at different rates. Multiple rates had correct checksums

gciurpita:
a correct checksum is not a guarantee that a message is correct. I learned this decoding CDMA messages at different rates. Multiple rates had correct checksums

That all depends on the type of CRCC and the number of modified bits in the message. Some CRCC schemes use 16 bit CRCC, two bytes for the check.

Paul