This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

receive

Receive messages from CAN bus

Syntax

message = receive(canch,messagesrequested,'OutputFormat','timetable')
message = receive(canch,messagesrequested)

Description

example

message = receive(canch,messagesrequested,'OutputFormat','timetable') returns a timetable of CAN messages received on the CAN channel canch. The number of messages returned is less than or equal to messagesrequested. If fewer messages are available than messagesrequested specifies, the function returns the currently available messages. If no messages are available, the function returns an empty array. If messagesrequested is Inf, the function returns all available messages.

To understand the elements of a message, refer to canMessage.

Specifying the 'OutputFormat' option value of 'timetable' results in a timetable of messages. This output format is recommended for optimal performance and representation of CAN messages within MATLAB®.

message = receive(canch,messagesrequested) returns an array of CAN message objects instead of a timetable if the channel ProtocolMode is 'CAN'.

Note

If the channel ProtocolMode is 'CAN FD' the receive function returns a timetable, whether you specify an 'OutputFormat' or not.

Examples

collapse all

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)

Input Arguments

collapse all

CAN channel, specified as a CAN channel object. This is the channel by which you access the CAN bus.

Example: canChannel

Maximum number of messages to receive, specified as a positive numeric value or Inf.

Example: Inf

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

CAN messages from the channel, returned as a timetable of messages or an array of CAN message objects.

See Also

Functions

Introduced in R2009a