Page 1 of 1

Relation between bus errors in CANAPI2 and CANAPI4

Posted: Mon 22. Mar 2021, 10:39
by dummzeuch
I am in the process of moving our software from CANAPI2 to CANAPI4 and am a bit puzzled about the meaning of the bus errors:

CANAPI2 had these:
CAN_ERR_BUSLIGHT = $0004; // Bus error: an error counter reached the 'light' limit
CAN_ERR_BUSHEAVY = $0008; // Bus error: an error counter reached the 'heavy' limit
CAN_ERR_BUSOFF = $0010; // Bus error: the CAN controller is in bus-off state

CANAPI4 has these:
CAN_ERR_BUSWARNING = $0008; // Bus error: an error counter reached the 'warning' limit
CAN_ERR_BUSPASSIVE = $40000; // Bus error: CAN controller is in Error Passive state
CAN_ERR_BUSOFF = $0010; // Bus error: CAN controller is in Bus-off state

So CAN_ERR_BUSWARNING seems to correspond to the old CAN_ERR_BUSHEAVY.

What happended to CAN_ERR_BUSLIGHT? Is there no longer a 'light' limit?

And what is CAN_ERR_BUSPASSIVE? Is that something totally new? From the description I would have assumed that this is an error state of the hardware.

I'm tempted to translate CAN_ERR_BUSLIGHT to CAN_ERR_BUSWARNING and CAN_ERR_BUSHEAVY to CAN_ERR_BUSPASSIVE but it seems wrong.

Re: Relation between bus errors in CANAPI2 and CANAPI4

Posted: Thu 25. Mar 2021, 08:28
by K.Wolf
Hi,

As you can see from the error code values, CAN_ERR_BUSHEAVY and CAN_ERR_BUSWARNING are identical. This warning is issued when one of the error counters of the CAN controller exceeds the configured Error Warning limit, which is 96 by default. This Error Warning Limit can also be adjusted with the CAN_PARAM_ERROR_WARNING_LIMIT hardware parameter. There are two error counters, the Receive Error Counter and the Transmit Error Counter.
CAN-API 4 has renamed the error because the former name 'BUSHEAVY' did not express any association with the configured Error Warning Limit.

What is also identical is CAN_ERR_BUSOFF. The CAN controller enters Bus-off state when one of the error counters exceeds 255, where it disconnects itself from the bus.

CAN_ERR_BUSLIGHT in CAN-API 2 was some kind of 'invention' of PEAK some 25 years ago, and what made it worse was the fact that its occurrence depended on whether the hardware had reception of Error Frames enabled or not. CAN-API 4 no longer supports this kind of error/warning.

CAN_ERR_BUSPASSIVE is triggered when the hardware enters the 'Error passive' state, when one of the error counters raises above 127. Below that, the CAN controller is in 'Error active' state.

In 'Error active' state the CAN controller takes fully part in the CAN communication, and when an error occurs it signals it by sending an Active Error Flag, which consists of 6 dominant bits.

'Error passive' means that the CAN controller still takes part in bus activities, but when it detects an error it only sends a Passive Error Flag, which consists of 6 recessive bits. The CAN controller enters the 'Error active' state again when both error counters go below 128.