Kvaser Linux CANLIB

Sending Messages

Outgoing CAN messages are buffered in a transmit queue and sent on a First-In First-Out basis. Use canWrite to send a message on the bus.

You can use canWriteSync() to wait until the messages in the queue have been sent.

Example. Sending a CAN message.

    char msg[8];
    ...
    stat = canWrite(hnd, 234, msg, 8, 0);

Using Extended CAN (CAN 2.0B)

"Standard" CAN has 11-bit identifiers in the range 0 - 2047. "Extended" CAN, also called CAN 2.0B, has 29-bit identifiers. You specify which kind of identifiers you want to use in your call to canWrite: if you set the canMSG_EXT flag in the flag argument, the message will be transmitted with a 29-bit identifier. Conversely, received 29-bit-identifier messages have the canMSG_EXT flag set.

Note:
Not all CAN controllers support CAN 2.0B.

Example. Sending a CAN message using extended CAN.

    char msg[8];
    ...
    stat = canWrite(hnd, 23456, msg, 8, canMSG_EXT);