Re: [Question] Sending CAN error frames

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue. 2 févr. 2021 à 19:14, Oliver Hartkopp <socketcan@xxxxxxxxxxxx> wrote:
> On 02.02.21 11:00, Vincent MAILHOL wrote:
> >>> If CAN_CTRLMODE_TX_ERR has been added to the kernel and
> >>> can_dropped_invalid_skb() is updated, then a CAN frame with CAN_ERR_FLAG set
> >>> would be either send as an error frame or dropped by can_dropped_invalid_skb().
> >>>
> >>> So it would be echoed only if the driver supports CAN_CTRLMODE_TX_ERR and it's
> >>> enabled.
> >>
> >> ACK.
> >
> > The echo would be special here.  We have to remember that the
> > payload of the CAN_ERR_FLAG frames is an arbitrary design. This
> > payload has no meaning for the data link.
> >
> > When we echo back the frame, only the DLC, CAN ID and payload of
> > the TX frame are irrelevant (except for vcan).
> >
> > My current idea would be to follow what Kvaser did: they send the
> > frame and the device reports the error flag (c.f. the example
> > given by Jimmy above). So the echo feature would not be used
> > for error flags.
>
> In fact I would suggest to think a about a proper API (aka CAN frame
> content definition) for outgoing CAN frames with the CAN_ERR_FLAG set.
>
> 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

The device can either inject the flag either during:
  - bus idle
  - while it is transmitting a frame
  - while it is receiving a frame
The error flag can occur at any time.


My first proposal would be:

 1/ One flag to specify the error flag form (active or
    passive). Passive error flags can not be used when receiving
    a frame.

 2/ One flag to specify if we inject during bus idle or not.

 3/ One flag to specify if we inject while transmitting or
    receiving a frame.

 4/ If injecting while receiving, have the ability to specify
    the CAN ID, DLC and flag filters (EFF, SFF, RTR, BRS...) of
    the frame on which we want to inject the error flag. I do not
    see the need for a complex filter. I would propose to either
    have an exact match or no match (e.g. inject on next frame
    whatever this frame is).

 5/ One flag to specify if injection while transmitting is done
    on exact match or on any frames (if done on any frames,
    the filters 4/ are ignored). This flag is ignore for bus idle or
    while receiving.

 6/ If we inject while receiving, do it on the next normal frame
    we transmit (no filter). The userland have to send two frame:
    one with CAN_ERR_FLAG and one normal one on which we
    will inject the error flag in order to use the feature.

 7/ Have an offset: the bit index on which we want to inject the
    error flag. I am not yet sure if we should ignore bitstuffing
    or not. If the bus is idle, wait offset bit times before
    injecting. Else, start counting the bits from the Start of
    Frame.


The flags 1/, 2/, 3/, 5/ and the offset 7/ goes into the data[]
payload, the filters 3/ goes into their respective field (CAN ID,
DLC, FF, SFF, RTR, BRS flags).



Yours sincerely,
Vincent



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux