Main Content
write
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
write(
writes CAN messages onto the bus via the CAN channel.ch
,identifier
,isExtended
,dataArray
)
write(
writes the CAN message created using the ch
,CANMessage
)canMessage
of Vehicle Network Toolbox™ onto the bus.
Examples
Transmit a CAN Message
Transmit messages to the CAN bus.
arduinoObj = arduino('COM24', 'Uno', 'Libraries', 'CAN'); ch = canChannel(arduinoObj,"Sparkfun CAN-Bus Shield", "BusSpeed", 500e3); write(ch,1,true,[1:8]);
Transmit a CAN Message using Vehicle Network Toolbox
Transmit messages to the CAN bus.
arduinoObj = arduino('COM24', 'Uno', 'Libraries', 'CAN'); ch = canChannel(arduinoObj,"Sparkfun CAN-Bus Shield", "BusSpeed", 500e3); message = canMessage(500,false,5); message.Data = [200:204]; write(ch,message);
Input Arguments
Version History
Introduced in R2020a