This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Retransmit messages from CAN bus


replay(canch, message)


replay(canch, message) retransmits the message or messages message on the channel canch, based on the relative differences of their timestamps. The replay function also replays messages from MATLAB to Simulink

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

Input Arguments


The CAN channel that you specify to transmit the messages.


An array of message objects to replay.


This example uses a loopback connection between two channels where:

  • The first channel transmits messages 2 seconds apart.

  • The second channel receives them.

  • The replay function retransmits the messages with the original delay.

ch1 = canChannel('Vector', 'CANcaseXL 1', 1)
ch2 = canChannel('Vector', 'CANcaseXL 1', 2)
msgTx1 = canMessage(500, false, 8)
msgTx2 = canMessage(750, false, 8)
%The first channel transmits messages 2 seconds apart
transmit(ch1, msgTx1)
transmit(ch1, msgTx2)
%The second channel receives them
msgRx1 = receive(ch2, Inf)
%The replay function retransmits the messages with the original delay.
replay(ch2, msgRx1)
msgRx2 = receive(ch1, Inf)

The timestamp differentials between messages in the two receive arrays, msgRx1 and msgRx2, are equal.

Introduced in R2009a

Was this topic helpful?