CAN (canbus)

transmit()

CAN::transmit, transmit, CAN.transmit

Add a message to the queue to be transmitted to the CAN bus as soon as possible.

// SYNTAX
can.transmit(message);

Parameters:

  • message: the message to be transmitted

Returns: boolean true if the message was added to the queue, false if the transmit queue was full.

// EXAMPLE
CANChannel can(CAN_D1_D2);
CANMessage message;
message.id = 0x100;
message.len = 1;
message.data[0] = 42;
can.transmit(message);

Note: Since the CAN bus requires at least one other CAN node to acknowledge transmitted messages if the Photon or Electron is alone on the bus (such as when using a CAN shield with no other CAN node connected) then messages will never be transmitted and the transmit queue will fill up.