pierremolinaro / acan2517

Arduino CAN driver for MCP2517FD CAN Controller (in CAN 2.0B mode)
MIT License
22 stars 10 forks source link

My car Nexa has only implemented J1979 so no passive reading of CAN data. How to send and receive response #16

Open Som4567 opened 2 years ago

Som4567 commented 2 years ago

Hi My car Nexa has only implemented J1979 so I am not able to read raw CAN data using MCP2515 and also with MCP2517FD but with MCP2515 I am able to send requests to CAN like RPM and able to receive responses.

My question is using MCP2517 how can I send the request and receive a response like the below code for MCP2515:

`if (useStandardAddressing) { CAN.beginPacket(0x7df, 8); } else { CAN.beginExtendedPacket(0x18db33f1, 8); } CAN.write(0x02); // number of additional bytes CAN.write(0x01); // show current data CAN.write(0x0c); // engine RPM CAN.endPacket();

// wait for response while (CAN.parsePacket() == 0 || CAN.read() < 3 || // correct length CAN.read() != 0x41 || // correct mode CAN.read() != 0x0c); // correct PID

float rpm = ((CAN.read() * 256.0) + CAN.read()) / 4.0;

Serial.print("Engine RPM = "); Serial.println(rpm);`

pierremolinaro commented 2 years ago

Hello,

My librairies work only under Arduino, ACAN2515 with MCP2515, and ACAN2517 and ACAN2517FD with the MCP2517FD / MCP2518FD.

What is your system ? If you use an other system and / or other library, I can't help you.

However, the MC2517FD is not compatible with the MCP2515. If your code works with the MCP2515, it will not work with MCP2517FD, you should also change the library.

Pierre

Le 6 janv. 2022 à 15:13, Som4567 @.***> a écrit :

Hi My car Nexa has only implemented J1979 so I am not able to read raw CAN data using MCP2515 and also with MCP2517FD but with MCP2515 I am able to send requests to CAN like RPM and able to receive responses.

My question is using MCP2517 how can I send the request and receive response like below code for MCp2515:

`if (useStandardAddressing) { CAN.beginPacket(0x7df, 8); } else { CAN.beginExtendedPacket(0x18db33f1, 8); } CAN.write(0x02); // number of additional bytes CAN.write(0x01); // show current data CAN.write(0x0c); // engine RPM CAN.endPacket();

// wait for response while (CAN.parsePacket() == 0 || CAN.read() < 3 || // correct length CAN.read() != 0x41 || // correct mode CAN.read() != 0x0c); // correct PID

float rpm = ((CAN.read() * 256.0) + CAN.read()) / 4.0;

Serial.print("Engine RPM = "); Serial.println(rpm);`

— Reply to this email directly, view it on GitHub https://github.com/pierremolinaro/acan2517/issues/16, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWKZVBP2AZVOT5V5VYZQN3UUWPQJANCNFSM5LMNM36Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.