Send CAN messages to CAN bus
transmit( sends the message or array of messages onto the bus via the CAN channel. canch,message)
For more information on the elements of a message, see canMessage.
Note
The transmit function ignores the
Timestamp property and the
Error property.
CAN is a peer-to-peer network, so when transmitting messages on a physical bus at least one other node must be present to properly acknowledge the message. Without another node, the transmission will fail as an error frame, and the device will continually retry to transmit.
Define a CAN message and transmit it to the CAN bus.
message = canMessage (250,false,8); message.Data = ([45 213 53 1 3 213 123 43]); canch = canChannel('MathWorks','Virtual 1',1); start(canch) transmit(canch,message)
Transmit an array of three CAN messages.
transmit(canch,[message0,message1,message2])
Transmit a CAN message on a remote frame, using the message Remote property.
message = canMessage(250,false,8); message.Data = ([45 213 53 1 3 213 123 43]); message.Remote = true; canch = canChannel('MathWorks','Virtual 1',1); start(canch) transmit(canch,message)