Nissan Consult and Arduino

Ha a challenge! (but not willing to dive into the libs ..)

Can you make a short list of

  • what works as expected
  • what works but not as expected
  • what does not work at all

Q1: can you read any register from the car over the interface?

Can you add a counter in this loop? or a print of millis() to see how long it takes to initialize?

  while (myConsult.initEcu() == false) {
    // Failed to connect
    delay(1000);
    
    // Output to LCD
    lcd.write(ESC); //clear screen
    lcd.write(clr);
    lcd.write(ESC);
    lcd.write(line);
    lcd.write(0x28); //line2
    lcd.print("Failed to connect!!!");  //print on line 2
  }

dived a bit in the lib.

  • The library uses the Serial port at 9600 baud.
  • You could connect to it using a terminal program and a sniffer (logic ananlyzer)

What I do not trust is the only call that seems to work from your post.

// code deliberately not in code blocks to allow highlight


boolean Consult::initEcu()
{
// Byte we will read from ecu
int ecuByte;

// Verify we have set the Serial
if (_consultSerial == NULL) {
return false;
}

// First stop any streams
stopEcuStream();

// Make 2 attempts to init
for (int x=0; x<2; x++) {
// Send init sequence
writeEcu(0xFF);
writeEcu(0xFF);
writeEcu(0xEF);

// Read from ecu
if (readEcuWithTimeout(&ecuByte, 2)) {
if (ecuByte == 0x10) {
// We initialized it!
}
else {
// Already initialized
}
// Send stop command
stopEcuStream();
return true; <<<<<<<<<<<<<<<<<<< there is no condition preventing reaching this statement
}
delay(250);
}

return false;
}


This states I do two attempts and if (it thinks) it can read a byte ( due to static noise?) no matter what I will always return true.

So in short, the lib probably did not make any connection at all but saw some signal on the serial line and interpreted that as a byte.

Way to proceed is to get a logic analyzer and see what is on the line.

Did you connect the TX and RX crossed or not? The TX of the Nissan should probably on the RX of the Arduino and vv.

Hope this helps a bit.