5 years ago.

Using Extended can1.read returns 0

I need help as to why this wont work (code below).

When I use CANStandard it works perfectly. Using CANExtended this if statement is false. I do know the message is received and working. Meaning I create a filter and trigger an interrupt only when a specific Extended ID is received. Code functions correctly and my data for the rx ID i'm looking for is updated. When I check can1.read(canMsg) during that same cycle - it always returns false on extended but my variables are being updated with the correct data.

thanks, Rob

CAN read returns false on Extended

    CANMessage canMsg;
    if (can1.read(canMsg)) {
        printf(" ID%08x ", canMsg.id);

Question relating to:

Comment on this question

1 Answer

4 years, 2 months ago.

I am having exactly the same issue. Is there a fix for it?


I just figured it out.

This code should clarify it:

Extended ID:

while (!can1.write(CANMessage(msgid, reinterpret_cast<char*>(&payload), 8, CANData, CANExtended))){}

Standard ID:

while (!can1.write(CANMessage(msgid, reinterpret_cast<char*>(&payload), 8))){}Standard ID


Javier, I'm not sure I follow your example. Are you stepping out of your while loop when you read from the buffer?

posted by Rob Crain 27 Jul 2015

You need to log in to post a question