replay
从 CAN 总线重新传输报文
说明
replay(
根据报文时间戳的相对差异,在 canch
,msgs
)canch
通道上重新传输指定的报文。replay 函数还可将来自 MATLAB® 的报文重播到 Simulink®。
要了解报文包含的元素,请参考 canMessage
。
示例
在 CAN 通道上重播报文
在两个通道之间使用环回连接,使得:
第一个通道以 2 秒为间隔传输报文。
第二个通道接收这些报文。
replay
函数以原始延迟重新传输报文。
两个接收数组 msgRx1
和 msgRx2
中报文之间的时间戳差异是相等的。
ch1 = canChannel('Vector','CANcaseXL 1',1); ch2 = canChannel('Vector','CANcaseXL 1',2); start(ch1) start(ch2) msgTx1 = canMessage(500,false,8); msgTx2 = canMessage(750,false,8); % The first channel transmits messages 2 seconds apart. transmit(ch1,msgTx1) pause(2) 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) pause(2) msgRx2 = receive(ch1,Inf);
输入参数
canch
— CAN 设备通道
CAN 通道对象
CAN 设备通道,指定为 CAN 通道对象,报文将在此通道上重新传输。
示例: canChannel('NI','CAN1')
msgs
— 要重播的报文
报文时间表 | CAN 报文对象或数组对象
要重播的报文,指定为 CAN 报文时间表、报文对象或报文对象数组。
版本历史记录
在 R2009a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)