I'm new to Arduino and CAN bus. I'm studying some code examples which contain "tCAN message". My guess it defines a class for of CAN messages. I did a lot of search but found no information on it except for sample codes. Can anyone help me out. Thank you!

Some code from the example project:

void activateCAN()
    tCAN message_act;
    message_act.id = 0x750;
    message_act.header.rtr = 0;
    message_act.header.length = 8;
    message_act.data[0] = 0x00;
    message_act.data[1] = 0x00;
    message_act.data[2] = 0x00;
    message_act.data[3] = 0x00;
    message_act.data[4] = 0x00; 
    message_act.data[5] = 0x00;  
    message_act.data[6] = 0x00;
    message_act.data[7] = 0x00;

    mcp2515_bit_modify(CANCTRL, (1 << REQOP2) | (1 << REQOP1) | (1 << REQOP0), 0);
    mcp2515_send_message(&message_act); //SEND MESSAGE
//******CAN ACTIVATION*****ENDS****//

tCAN will be a struct that defines the structure of the CAN message being sent. The name tCAN is not a standard and will have been chosen by the author of the library you are using. At a guess it's using a variant of Hungarian Notation, and the t prefix means type - so it's probably been typedef'd from a struct to a type name.

I am not familiar with CAN, but if there are standard message formats this struct will correspond with one of them. You can find the actual structure within the header file for your chosen library (or maybe in the example sketch code itself?).

  • Thank you for the explanation.
    – Spring
    Jun 29 '19 at 4:17

tCAN here is a struct that defines a CAN frame to be sent over the network.


There are several types of frames, standard, extended, and FD (flexible data).

The tables in the linked Wikipedia article describe the physical protocol. The struct won’t have a corresponding field for every section of the protocol, because the library will take care of setting the constant or calculatable things, like the CRC and End of Frame. You just have to set the relevant details, like ID, (maybe) data length and the data itself.

If you have trouble, check your baud rates and ensure you’re sending the expected kind of frame. Most hobbyist will use standard frames, but many industrial grade pieces of equipment will use Extended or FD frames.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.