Receive messages from CAN bus
message = receive(canch, messagesrequested)
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.
The CAN channel from which to receive the message.
The maximum count of messages to receive. The specified value must be a nonzero and positive, or Inf.
|MessageReceivedFcn||Specify function to run|
|MessageReceivedFcnCount||Specify number of messages available before function is triggered|
|MessagesAvailable||Display number of messages available to be received by CAN channel|
|MessagesReceived||Display number of messages received by CAN channel|
|MessagesTransmitted||Display number of messages transmitted by CAN channel|
|ReceiveErrorCount||Display number of received errors detected by channel|
|TransmitErrorCount||Display number of transmitted errors by channel|
canch = canChannel('Vector','CANCaseXL 1',1) start(canch) message = receive(canch,5)
To receive all messages, type:
message = receive(canch,Inf)