CAN Bus Errors
The CAN protocol automatically handles protocol errors in hardware - this is what makes CAN robust. If a CAN node receives a message with an error it can destroy the message and cause the transmitter to resend. The CAN node destroys the message by sending an error frame (see the picture below).
CAN bus nodes can detect errors in different ways. For example, a CRC checksum error occurs when the receiver calculates a checksum different than what it received. This means the receiver didn't receive what the transmitter sent. When the CRC error happens a receiver generates an error frame and this causes the transmitter to retransmit the message.
The error frame is six to twelve dominate bits (zeros) and directly violates the bit stuffing rules of CAN. After the dominant bits and passive eight bit delimiter is sent followed by and inter frame separation time (IFS).
The CAN node keeps track of how many times it received or transmitted error frames using error counters. When these error counters reach certain limits the CAN node is first partially disabled (error passive mode) and then totally disabled (bus off mode). This avoids the possibility that a broken node disabling the bus by constantly generating error frames. There are specific rules about how these error counters are incremented or decremented - please consult the CAN spec for details.
When an error occurs on the CAN bus an error frame is generated. This is a frame with 6 or more dominant bits followed by a idle bus delimiter. See a bigger picture.