What will happen in CAN?

Rasmi Ranjan Nayak picture Rasmi Ranjan Nayak · May 28, 2012 · Viewed 8.1k times · Source

I had an interview. The interviewer asked me:

If two nodes are sending two messages of the same identifier (0x100) with different data, who will win the arbitration? Which message will be there on the bus?

If node 1 wins then what about node 2's message? When will node 2's message be sent?

Answer

Kiran.vanam picture Kiran.vanam · Oct 1, 2012

There are two cases here

  1. Same ID and the same DATA field
  2. Same ID with a different DATA field

CASE 1: when two nodes are trying to transmit the same ID and the same data field, the CAN will see it as a single message, and it will send it on the CAN bus. Here you really can't say if node 1 is sending or node 2 is sending, because both has the same ID and data.

CASE 2: here the data field is different. Until the arbitration field there will be no problem. Since the data is different for both the nodes you will get a bus error. This is because your data field is protected by a CRC and bit stuffing also will come into the picture.