22 #ifndef LELY_IO2_INTERN_LINUX_CAN_ERR_H_
23 #define LELY_IO2_INTERN_LINUX_CAN_ERR_H_
36 #include <linux/can/error.h>
42 static int can_frame2can_err(
43 const struct can_frame *frame,
struct can_err *err);
46 can_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)
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)
82 if (frame->data[2] & CAN_ERR_PROT_FORM)
84 if (frame->data[2] & CAN_ERR_PROT_STUFF)
87 if (frame->data[2] & (CAN_ERR_PROT_BIT0 | CAN_ERR_PROT_BIT1
88 | CAN_ERR_PROT_OVERLOAD))
91 if (frame->data[2] & CAN_ERR_PROT_ACTIVE)
93 if (frame->data[3] & CAN_ERR_PROT_LOC_CRC_SEQ)
97 if ((frame->can_id & CAN_ERR_TRX) && frame->data[4])
100 if (frame->can_id & CAN_ERR_ACK)
103 if (frame->can_id & CAN_ERR_BUSOFF)
120 #endif // !LELY_IO2_INTERN_LINUX_CAN_ERR_H_