Receive messages from CAN bus
returns a timetable of CAN messages received on the CAN channel
message = receive(
canch. The number of messages returned is less than or equal
numMsgs. If fewer messages are available than
numMsgs specifies, the function returns the currently
available messages. If no messages are available, the function returns an empty
Inf, the function returns
all available messages. Incoming available messages are retained in a FIFO buffer,
receive returns the oldest available message
To understand the elements of a message, refer to
OutputFormat option value of
specifies that results are returned in a timetable of messages, rather than as
message objects. This output format is recommended for optimal performance and
representation of CAN messages in MATLAB®.
returns an array of CAN message objects instead of a timetable if the channel
message = receive(
'CAN'. If the channel
'CAN FD' the
receive function always returns a timetable.
Receive CAN Messages
You can receive CAN messages as a timetable or as an array of message objects.
Receive all available messages as a timetable.
canch = canChannel("Vector", "CANCaseXL 1", 1); start(canch) message = receive(canch,Inf,OutputFormat,"timetable");
Receive up to five messages as an array of message objects.
message = receive(canch,5);
canch — CAN channel
CAN channel object
CAN channel, specified as a CAN channel object. This is the channel by which you access the CAN bus.
numMsgs — Maximum number of messages to receive
numeric value |
Maximum number of messages to receive, specified as a positive numeric
message — CAN messages
timetable | CAN message object array
CAN messages from the channel, returned as the type indicated in the following table:
|Protocol Mode||Returned Type|
The variables of the returned timetables are different for CAN or CAN FD messages, according to the protocol specification.
Introduced in R2009a