Main Content

transmit

Send CAN messages to CAN bus

Description

transmit(canch,msgs) sends the specified messages onto the bus via the CAN channel.

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.

example

Examples

collapse all

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)

Input Arguments

collapse all

CAN channel, specified as a CAN channel object. This is the channel by which you access the CAN bus.

Messages to transmit, specified as a timetable of CAN messages, a message object, or an array of message objects. These messages are transmitted via a CAN channel to the bus.

Version History

Introduced in R2009a