Revision: 1.23
53
To transmit a CAN package, the programmer has to fill in the fields in the variable of
type canmsg_t and pass this canmsg_t variable as an argument to invoke the APIs. The
fields in CAN message are described below:
flags:
This field holds the information of message type. Programmers can set the message type as:
1. Standard Data Frame:
canmsg_t msg; // Declare a variable ‘msg’ of type ‘canmsg_t’
msg.flags = 0; // Setting the flags field to 0 defines the ‘msg’ as an
// ordinary standard data frame.
2. Extended Data Frame:
canmsg_t msg;
msg.flags = 1 // flags field to 1 defines the ‘msg’ as an
//extend data frame.
cob:
This field is reserved for holding a message communication object number.
id:
CAN message ID.
timestamp:
When a CAN package is received, the CAN device driver will annotate a timestamp to the
timestamp field in the canmsg_t variable and return this canmsg_t variable to the caller.
length:
The number of the data bytes which are sent or received in the ‘data’ field of CAN message. This
field is necessary while transmitting a Standard or Extended Data Frame. Programmers have to
explicitly set up this field. The length of data is 0~8.
For example:
canmsg_t msg;
msg.data[0] = 0xa1;
msg.data[1] = 0xb2;
msg.data[2] = 0xc3;