receive

Receive messages from CAN bus

Syntax

message = receive(canch, messagesrequested)

Description

message = receive(canch, messagesrequested) returns an array of CAN message objects 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 infinite, the function returns all available messages.

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

Input Arguments

canch

The CAN channel from which to receive the message.

messagesrequested

The maximum count of messages to receive. The specified value must be a nonzero and positive, or Inf.

Output Arguments

message

An array of CAN message objects received from the channel.

Properties

Receive Message Properties

MessageReceivedFcnSpecify function to run
MessageReceivedFcnCountSpecify number of messages available before function is triggered
MessagesAvailableDisplay number of messages available to be received by CAN channel
MessagesReceivedDisplay number of messages received by CAN channel
MessagesTransmittedDisplay number of messages transmitted by CAN channel

Error Log Properties

ReceiveErrorCountDisplay number of received errors detected by channel
TransmitErrorCountDisplay number of transmitted errors by channel

Examples

canch = canChannel('Vector','CANCaseXL 1',1)
start(canch)
message = receive(canch,5)

To receive all messages, type:

message = receive(canch,Inf)
Was this topic helpful?