# Re: \[Question\] Sending CAN error frames

- From: Jimmy Assarsson \<hidden\>
- Date: 2021-02-03 06:43:08 
- List: linux-can
- Page: https://ratatoskr.run/linux-can/2021/02/9355355
- Thread: https://ratatoskr.run/linux-can/2021/01/9355327/t.md

```text
On 2021-02-02 20:19, Oliver Hartkopp wrote:
> On 02.02.21 12:12, Vincent MAILHOL wrote:
>
>>> The CAN_ERR_FLAG has been renamed in the documentation to indicate
>>> "error messages" from the CAN controller, as an error frame is something
>>> completely different.
>>>
>>> Now as we are talking about having CAN_ERR_FLAG in the TX path besides
>>> the vcan testing stuff, we should think about an API for the really
>>> outgoing frames.
>>>
>>> We could not only think about "create an error frame right now" but also
>>> think about a more intelligent CAN node, which also offers to destroy
>>> one or more specific CAN ID(s) at a specific bit position after
>>> detecting that CAN ID.
>>
>> My original idea was to leave it unspecified until a device was
>> actually capable of doing such a thing. But I am not against
>> defining the API now :) We might just have to wait a long time
>> for someone to actually implement it.
>>
>>> We could use the CAN_RTR_FLAG and the data[] section of the outgoing
>>> error CAN frames for such an API.
>>
>> We are not limited to the CAN_RTR_FLAG and the data[]
>>
>> First, we have to list the use cases.
>>
>> As I wrote before, there are only two forms for the error flag:
>>    - The active error flag: 6 consecutive dominant bits
>>    - The passive error flag: 6 consecutive recessive bits
>
> IMO this passive error flag stuff is pointless.
> The passive error does not have any effect on the bus. Nobody sees it. It's just a measure to continue counting error counters inside the CAN controller. IMO it's a read-only feature about the controller internal status.

I agree.

>> The device can either inject the flag either during:
>>    - bus idle
>
> Is an error flag defined at bus idle?
>
> Error flags are intended to destroy *other CAN controllers* transmissions when detecting protocol violations. There can not be a protocol violation at idle time, right?

This is what the Kvaser CAN controller does. It will wait for the bus to become idle, before an active error flag is transmitted.

>>    - while it is transmitting a frame
>
> What's the use-case for destroying your own transmission?
>
>>    - while it is receiving a frame
>
> This makes sense, especially when you can destroy specific CAN ID frames at a specific bit position.
> Or for any CAN ID at a specific bit position.
> Or for any CAN ID at an undefined bit position.

I agree.

>> The error flag can occur at any time.
>
> Sure? (see above)
>
> Of course we might also provide some pump gun mode which just sends an error flag at some (any) time.

As above.

> But for what reason?

Testing purpose, e.g if you develop software where you want to keep track of bus errors, this makes it possible to test such software in a controlled way.
We also use this ourselves when testing the transitions ERROR_ACTIVE <-> ERROR_WARNING <-> ERROR_PASSIVE, for Rx.

Regards,
jimmy
```
