PowerBroker2 / ELMduino

Arduino OBD-II Bluetooth Scanner Interface Library for Car Hacking Projects
MIT License
670 stars 125 forks source link

help on code conversion from ELMduino 2.x to 3.x #263

Open miguelos6 opened 3 weeks ago

miguelos6 commented 3 weeks ago

Hi folks

For long time I used successfuly the ELMduino 2.x code, with custom PIDs (suggested by PowerBroker2) as below :

  if (myELM327.queryPID(34, 12345))
  {
    int16_t tempKm = myELM327.findResponse();    
    if (myELM327.status == ELM_SUCCESS) { km = tempKm;}
    else printError();
  }

I tried to understand and convert the same to ELMduino 3.x but the results are gibberish (not the same as on ELMduino 2.x)

my approach

  float tempKm = myELM327.processPID(34, 12345, 1, 1);
  if (myELM327.nb_rx_state == ELM_SUCCESS) { km = (int16_t)tempKm; }
  else if (myELM327.nb_rx_state != ELM_GETTING_MSG)
    myELM327.printError();

Can someone help me on this ? I'd like to test new features like DTC from 3.x...

PowerBroker2 commented 3 weeks ago

Can you post the entire sketch plus the debug output? Also note that the examples have been updated along with the codebase to help the 2.x to 3.x conversion

miguelos6 commented 3 weeks ago

I don't have debug yet, I was dumping the results on screen only.

I didn't manage to run any ELM emulator successfully :/ ELMulator from https://github.com/jimwhitelaw/ELMulator throws an error for everything while connected with android app

I just thought there is some major flaw in my understanding of above code...

miguelos6 commented 2 weeks ago

the sketch is pretty much modified version of what we discussed years ago :) https://github.com/PowerBroker2/ELMduino/issues/4#issuecomment-593643276

Will try and get the dump tomorrow...

I guess I may found what the issue is (without connecting to real OBD, but running debugs) as we found years ago

https://github.com/PowerBroker2/ELMduino/issues/4#issuecomment-591056930 query 223039 (PID 34, 12345 dec // hex 0x22 0x3039) reply 623039019F

but in 3.x version and above code I can see it's converted to 2230391 (1 at the end...) : 20:11:51.065 -> Service: 34 20:11:51.065 -> PID: 12345 20:11:51.065 -> Long query detected 20:11:51.065 -> Query string: 2230391 20:11:51.065 -> Clearing input serial buffer 20:11:51.065 -> Sending the following command/query: 2230391

miguelos6 commented 2 weeks ago

debug from ESP module : pastebin