22#ifndef LELY_IO2_INTERN_LINUX_CAN_ERR_H_
23#define LELY_IO2_INTERN_LINUX_CAN_ERR_H_
36#include <linux/can/error.h>
42static int can_frame2can_err(
43 const struct can_frame *frame,
struct can_err *err);
46can_frame2can_err(
const struct can_frame *frame,
struct can_err *err)
50 if (!(frame->can_id & CAN_ERR_FLAG))
53 if (frame->can_dlc != CAN_ERR_DLC) {
61 if (frame->can_id & CAN_ERR_RESTARTED)
64 if (frame->can_id & CAN_ERR_TX_TIMEOUT)
65 error |= CAN_ERROR_OTHER;
67 if (frame->can_id & CAN_ERR_CRTL) {
68#ifdef CAN_ERR_CRTL_ACTIVE
69 if (frame->data[1] & CAN_ERR_CRTL_ACTIVE)
73 if (frame->data[1] & (CAN_ERR_CRTL_RX_PASSIVE
74 | CAN_ERR_CRTL_TX_PASSIVE))
79 if (frame->can_id & CAN_ERR_PROT) {
80 if (frame->data[2] & CAN_ERR_PROT_BIT)
81 error |= CAN_ERROR_BIT;
82 if (frame->data[2] & CAN_ERR_PROT_FORM)
83 error |= CAN_ERROR_FORM;
84 if (frame->data[2] & CAN_ERR_PROT_STUFF)
85 error |= CAN_ERROR_STUFF;
87 if (frame->data[2] & (CAN_ERR_PROT_BIT0 | CAN_ERR_PROT_BIT1
88 | CAN_ERR_PROT_OVERLOAD))
90 error |= CAN_ERROR_OTHER;
91 if (frame->data[2] & CAN_ERR_PROT_ACTIVE)
93 if (frame->data[3] & CAN_ERR_PROT_LOC_CRC_SEQ)
94 error |= CAN_ERROR_CRC;
97 if ((frame->can_id & CAN_ERR_TRX) && frame->data[4])
98 error |= CAN_ERROR_OTHER;
100 if (frame->can_id & CAN_ERR_ACK)
101 error |= CAN_ERROR_ACK;
103 if (frame->can_id & CAN_ERR_BUSOFF)
can_error
The error flags of a CAN bus, which are not mutually exclusive.
can_state
The states of a CAN node, depending on the TX/RX error count.
@ CAN_STATE_BUSOFF
The bus off state (TX/RX error count >= 256).
@ CAN_STATE_PASSIVE
The error passive state (TX/RX error count < 256).
@ CAN_STATE_ACTIVE
The error active state (TX/RX error count < 128).
This header file is part of the I/O library; it contains the CAN bus declarations for Linux.
This is the public header file of the utilities library.
This header file is part of the I/O library; it contains CAN bus error definitions.
This is the internal header file of the Windows-specific I/O declarations.
int state
The state of the CAN node (one of CAN_STATE_ACTIVE, CAN_STATE_PASSIVE or CAN_STATE_BUSOFF).
int error
The error flags of the CAN bus (any combination of CAN_ERROR_BIT, CAN_ERROR_STUFF,...