iwanders / OBD9141

A class to read an ISO 9141-2 port found in OBD-II ports.
MIT License
227 stars 70 forks source link

I need to add delay in between each PID request #28

Open Jonoox opened 4 years ago

Jonoox commented 4 years ago

Hello, I'm using MC33660 chip with 540 ohm K-line pull-up and I tried your reader_time example, modified it to support soft serial as I'm using Arduino Uno with only one HW serial.

When I have three PIDs in the loop, just like in example reader_softserial which polls 0x11, 0x0C, 0x0D, I'm only getting 0x11 and then 0x0D, without the middle one 0x0C. But if I add an delay(10) in between each PID poll, I get all of them. Looks like a timing problem, my ECU isn't ready to receive another request right after sending response to the one before. I haven't hooked up logic analyser yet. 10ms delay at each PID is not a problem for me, the response time is still much faster than on ELM327 so I'm good with that, but can I add a delay somewhere to the library so I won't have to enter it manually every time?

iwanders commented 4 years ago

Always happy to hear that things are working :)

I considered adding this delay, but since the specification doesn't state anything about the necessary delay between PID's I think it's very much dependent on the hardware. So I made the call not to add it. The readme states this in the timing section.

There is no delay parameter for the minimum duration between two requests, that is up to the user.

If you want to manually add it to the library, you can add it in the getPID function. But I feel that functionality should not be provided by the library as it makes the system blocking.