Lely core libraries
2.3.4
|
Go to the documentation of this file.
22 #ifndef LELY_IO2_INTERN_LINUX_CAN_MSG_H_
23 #define LELY_IO2_INTERN_LINUX_CAN_MSG_H_
45 const struct canfd_frame *src,
struct can_msg *dst);
47 const struct can_msg *src,
struct canfd_frame *dst);
56 if (src->can_id & CAN_ERR_FLAG) {
61 memset(dst, 0,
sizeof(*dst));
63 if (src->can_id & CAN_EFF_FLAG) {
64 dst->
id = src->can_id & CAN_EFF_MASK;
67 dst->
id = src->can_id & CAN_SFF_MASK;
69 if (src->can_id & CAN_RTR_FLAG)
74 memcpy(dst->
data, src->data, dst->
len);
92 memset(dst, 0,
sizeof(*dst));
93 dst->can_id = src->
id;
95 dst->can_id &= CAN_EFF_MASK;
96 dst->can_id |= CAN_EFF_FLAG;
98 dst->can_id &= CAN_SFF_MASK;
102 dst->can_id |= CAN_RTR_FLAG;
104 memcpy(dst->data, src->
data, dst->can_dlc);
117 if (src->can_id & CAN_ERR_FLAG) {
122 memset(dst, 0,
sizeof(*dst));
124 if (src->can_id & CAN_EFF_FLAG) {
125 dst->
id = src->can_id & CAN_EFF_MASK;
128 dst->
id = src->can_id & CAN_SFF_MASK;
130 if (src->flags & CANFD_BRS)
132 if (src->flags & CANFD_ESI)
135 memcpy(dst->
data, src->data, dst->
len);
151 memset(dst, 0,
sizeof(*dst));
152 dst->can_id = src->
id;
154 dst->can_id &= CAN_EFF_MASK;
155 dst->can_id |= CAN_EFF_FLAG;
157 dst->can_id &= CAN_SFF_MASK;
161 dst->flags |= CANFD_BRS;
163 dst->flags |= CANFD_ESI;
165 memcpy(dst->data, src->
data, dst->len);
170 #endif // !LELY_NO_CANFD
178 #endif // !LELY_IO2_INTERN_LINUX_CAN_MSG_H_
uint_least8_t flags
The flags (any combination of CAN_FLAG_IDE, CAN_FLAG_RTR, CAN_FLAG_FDF, CAN_FLAG_BRS and CAN_FLAG_ESI...
uint_least8_t data[CAN_MSG_MAX_LEN]
The frame payload (in case of a data frame).
@ CAN_FLAG_ESI
The Error State Indicator (ESI) flag (only available in CAN FD format frames).
@ CAN_FLAG_BRS
The Bit Rate Switch (BRS) flag (only available in CAN FD format frames).
#define CANFD_MAX_LEN
The maximum number of bytes in the payload of a CAN FD format frame.
int can_msg2canfd_frame(const struct can_msg *src, struct canfd_frame *dst)
Converts a can_msg frame to a SocketCAN CAN FD frame.
A CAN or CAN FD format frame.
uint_least8_t len
The number of bytes in data (or the requested number of bytes in case of a remote frame).
#define MIN(a, b)
Returns the minimum of a and b.
#define CAN_MAX_LEN
The maximum number of bytes in the payload of a CAN format frame.
int canfd_frame2can_msg(const struct canfd_frame *src, struct can_msg *dst)
Converts a SocketCAN CAN FD frame to a can_msg frame.
int can_msg2can_frame(const struct can_msg *src, struct can_frame *dst)
Converts a can_msg frame to a SocketCAN CAN frame.
@ CAN_FLAG_RTR
The Remote Transmission Request (RTR) flag (unavailable in CAN FD format frames).
@ CAN_FLAG_FDF
The FD Format (FDF) flag, formerly known as Extended Data Length (EDL).
int can_frame2can_msg(const struct can_frame *src, struct can_msg *dst)
Converts a SocketCAN CAN frame to a can_msg frame.
@ CAN_FLAG_IDE
The Identifier Extension (IDE) flag.
uint_least32_t id
The identifier (11 or 29 bits, depending on the CAN_FLAG_IDE flag).