Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Som4567 opened this issue Jan 6, 2022 · 1 comment

Comments

@Som4567
Copy link

Som4567 commented Jan 6, 2022

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
Copy link
Owner

pierremolinaro commented Jan 9, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants