25 #define CAN_ERROR_BIT _CAN_ERROR_BIT
26 #define CAN_ERROR_STUFF _CAN_ERROR_STUFF
27 #define CAN_ERROR_CRC _CAN_ERROR_CRC
28 #define CAN_ERROR_FORM _CAN_ERROR_FORM
29 #define CAN_ERROR_ACK _CAN_ERROR_ACK
30 #define CAN_ERROR_OTHER _CAN_ERROR_OTHER
34 #undef CAN_ERROR_OTHER
38 #undef CAN_ERROR_STUFF
41 #if !LELY_NO_STDIO && LELY_HAVE_VCI
57 const CANMSG *msg_ = msg;
60 if (msg_->uMsgInfo.Bits.type != CAN_MSGTYPE_ERROR)
63 enum can_state state = pstate ? *pstate : 0;
64 enum can_error error = perror ? *perror : 0;
66 switch (msg_->abData[0]) {
75 if (msg_->abData[1] & CAN_STATUS_BUSOFF) {
77 }
else if (msg_->abData[1] & CAN_STATUS_ERRLIM) {
95 const CANMSG *msg = src;
99 if (msg->uMsgInfo.Bits.type != CAN_MSGTYPE_DATA) {
104 memset(dst, 0,
sizeof(*dst));
106 if (msg->uMsgInfo.Bits.ext) {
112 if (msg->uMsgInfo.Bits.rtr)
116 memcpy(dst->
data, msg->abData, dst->
len);
129 if (src->
flags & CAN_FLAG_EDL) {
135 memset(msg, 0,
sizeof(*msg));
137 msg->uMsgInfo.Bits.type = CAN_MSGTYPE_DATA;
140 msg->uMsgInfo.Bits.ext = 1;
146 msg->uMsgInfo.Bits.rtr = 1;
148 memcpy(msg->abData, src->
data, msg->uMsgInfo.Bits.dlc);
can_error
The error flags of a CAN bus, which are not mutually exclusive.
@ CAN_ERROR_FORM
A form error.
@ CAN_ERROR_BIT
A single bit error.
@ CAN_ERROR_STUFF
A bit stuffing error.
@ CAN_ERROR_ACK
An acknowledgment error.
@ CAN_ERROR_CRC
A CRC sequence error.
@ CAN_ERROR_OTHER
One or more other errors.
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).
@ CAN_FLAG_IDE
The Identifier Extension (IDE) flag.
@ CAN_FLAG_RTR
The Remote Transmission Request (RTR) flag (unavailable in CAN FD format frames).
#define CAN_MASK_EID
The mask used to extract the 29-bit Extended Identifier from a CAN frame.
#define CAN_MAX_LEN
The maximum number of bytes in the payload of a CAN format frame.
#define CAN_MASK_BID
The mask used to extract the 11-bit Base Identifier from a CAN frame.
This header file is part of the utilities library; it contains the byte order (endianness) function d...
uint_least32_t htole32(uint_least32_t x)
Converts a 32-bit unsigned integer from host to little-endian byte order.
This header file is part of the utilities library; it contains the native and platform-independent er...
@ ERRNUM_INVAL
Invalid argument.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
#define MIN(a, b)
Returns the minimum of a and b.
This is the internal header file of the CAN bus operation queue functions.
This header file is part of the C11 and POSIX compatibility library; it includes <string....
A CAN or CAN FD format frame.
uint_least8_t data[CAN_MSG_MAX_LEN]
The frame payload (in case of a data frame).
uint_least32_t id
The identifier (11 or 29 bits, depending on the CAN_FLAG_IDE flag).
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 len
The number of bytes in data (or the requested number of bytes in case of a remote frame).
This header file is part of the CAN library; it contains the IXXAT VCI V4 interface declarations.
int CANMSG2can_msg(const void *src, struct can_msg *dst)
Converts an IXXAT VCI CAN message to a can_msg frame.
int CANMSG_is_error(const void *msg, enum can_state *pstate, enum can_error *perror)
Checks if an IXXAT VCI CAN message is an error message and parses the bus state and error flags if it...
int can_msg2CANMSG(const struct can_msg *src, void *dst)
Converts a can_msg frame to an IXXAT VCI CAN message.