22 #ifndef LELY_CAN_MSG_H_ 23 #define LELY_CAN_MSG_H_ 31 #define CAN_MASK_BID UINT32_C(0x000007ff) 34 #define CAN_MASK_EID UINT32_C(0x1fffffff) 41 #define CAN_FLAG_IDE 0x01 47 #define CAN_FLAG_RTR 0x02 55 #define CAN_FLAG_EDL 0x04 62 #define CAN_FLAG_BRS 0x08 68 #define CAN_FLAG_ESI 0x10 70 #endif // !LELY_NO_CANFD 76 #define CANFD_MAX_LEN 64 82 #define CAN_MSG_MAX_LEN CAN_MAX_LEN 84 #define CAN_MSG_MAX_LEN CANFD_MAX_LEN 108 #define CAN_MSG_INIT \ 110 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } \ 114 #define CAN_MSG_INIT \ 118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \ 190 #endif // !LELY_CAN_MSG_H_ A CAN or CAN FD format frame.
uint_least32_t id
The identifier (11 or 29 bits, depending on the CAN_FLAG_IDE flag).
uint_least8_t len
The number of bytes in data (or the requested number of bytes in case of a remote frame)...
Exact calculation based of frame content and CRC.
Simple worst case estimate.
int snprintf_can_msg(char *s, size_t n, const struct can_msg *msg)
Prints the contents of a CAN or CAN FD format frame to a string buffer.
uint_least8_t data[CAN_MSG_MAX_LEN]
The frame payload (in case of a data frame).
int can_msg_bits(const struct can_msg *msg, enum can_msg_bits_mode mode)
Computes the size (in bits) of the specified CAN format frame on the CAN bus.
Simple calculation assuming no bit stuffing.
This header file is part of the C11 and POSIX compatibility library; it includes <stddef.h> and defines any missing functionality.
int asprintf_can_msg(char **ps, const struct can_msg *msg)
Equivalent to snprintf_can_msg(), except that it allocates a string large enough to hold the output...
This header file is part of the C11 and POSIX compatibility library; it includes <stdint.h> and defines any missing functionality.
uint_least8_t flags
The flags (any combination of CAN_FLAG_IDE, CAN_FLAG_RTR, CAN_FLAG_EDL, CAN_FLAG_BRS and CAN_FLAG_ESI...
can_msg_bits_mode
The method used to compute te size (in bits) of a CAN frame.
#define CAN_MSG_MAX_LEN
The maximum number of bytes in the payload of a can_msg struct.
This is the public header file of the CAN library.