pierremolinaro / acan2515

MCP2515 CAN Controller Driver for Arduino
MIT License
74 stars 29 forks source link

CAN extended only sending standard ID #14

Closed EVenthusiest closed 2 years ago

EVenthusiest commented 4 years ago

Great library you have here and incredibly well documented. I have two devices CAN lines connected to each other sending data back and forth. The chip with the ACAN library can receive CAN packets no problem but when it transmits packets extended ID's become standard ID's. This is not a problem with receiving so I am a little stumped what could be the issue. I have attached my code of transmitting below. Thank you so much for your help.

            can1.poll();

    CAN1_Transmit_Frame.rtr = false;
    CAN1_Transmit_Frame.ext == true;
    CAN1_Transmit_Frame.id = 0x180238f1;
    CAN1_Transmit_Frame.len = 8;
    //CAN1_Transmit_Frame.id;

    CAN1_Transmit_Frame.data64 = mcu_power_control.controller_out;

    Serial.print(CAN1_Transmit_Frame.id,HEX);
    Serial.println(",");

    bool can_attempt = can1.tryToSend(CAN1_Transmit_Frame);
    if (can_attempt)
    {
        Serial.print("packet_sent");
    }
pierremolinaro commented 4 years ago

Thank you very much for your message.

I think the problem in your code is the following line:

CAN1_Transmit_Frame.ext == true; It does not perform an assignment, but a comparison. Unfortunatly the Arduino's C++ compiler settings do not detect this. Best regards, Pierre Le 6 févr. 2020 à 20:27, EVenthusiest notifications@github.com a écrit :

Great library you have here and incredibly well documented. I have two devices CAN lines connected to each other sending data back and forth. The chip with the ACAN library can receive CAN packets no problem but when it transmits packets extended ID's become standard ID's. This is not a problem with receiving so I am a little stumped what could be the issue. I have attached my code of transmitting below. Thank you so much for your help.

        can1.poll();

CAN1_Transmit_Frame.rtr = false; CAN1_Transmit_Frame.ext == true; CAN1_Transmit_Frame.id = 0x180238f1; CAN1_Transmit_Frame.len = 8; //CAN1_Transmit_Frame.id;

CAN1_Transmit_Frame.data64 = mcu_power_control.controller_out;

Serial.print(CAN1_Transmit_Frame.id,HEX); Serial.println(",");

bool can_attempt = can1.tryToSend(CAN1_Transmit_Frame); if (can_attempt) { Serial.print("packet_sent"); } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pierremolinaro/acan2515/issues/14?email_source=notifications&email_token=AEWKZVGFSW6KLMGEBPB7SHLRBRQATA5CNFSM4KRCTLLKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4ILTRKPA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWKZVC5KBEV2T4XZCBOTWTRBRQATANCNFSM4KRCTLLA.