autowp / arduino-mcp2515

Arduino MCP2515 CAN interface library
MIT License
793 stars 279 forks source link

How to send / Received extended Frame #82

Open sfJonas opened 2 years ago

sfJonas commented 2 years ago

Hello,

I have two Arduino with a MCP2515 module on each. I installed your library and ran your CAN_write code on one, and your CAN_read code on the other. I did these changes in the code, to send the extended frame : canMsg2.can_id = 0x18DAF41F | CAN_EFF_FLAG; mcp2515.sendMessage(MCP2515::TXB1, &canMsg2); The sender transmits the message with canMsg2.can_id = 0x18DAF41F, But de read receives the message with canMsg2.can_id = 98DAF41F Could you help me to solve this problem?

maincraft-io commented 1 year ago

Has same problem and fixed by this trick :) It's just demo how to CUT 0x8..... (do not use it in another situations)

Sender side:

packet.can_id = 0x12345678 | CAN_EFF_FLAG;
packet.can_dlc = 6;

Reciever side:

canid_t can_id = canMsg.can_id;
can_id = can_id & (~CAN_EFF_FLAG);