Search code examples
javaioserial-portobd-ii

Serial IO: sleeping when communicating with a serial device (via OBD2)


I am trying to use a Java library to communicate with a car via the serial port using OBD2 protocol. The protocol is simple: you send an ASCII string (e.g. "01 0d"), and the car answers with an ASCII value. I've found many libraries in the web, but there is one concept I don't understand in the examples. After every send command, the programmer put a call to sleep. Why is that? For example:

send(pid)
sleep(200)
receive(response)

I don't understand, because read is a blocking function call, so I should be able to wait on read. Why is the additional call to sleep?


Solution

  • I did a bunch of work with the (Mitsubishi/Subaru) MUT-II protocol a few years ago, which uses the ISO9141 protocol and it was the same way. 200ms pause after every single request. It was later confirmed by the community/forums that the only pause that was actually necessary was the one after the initial 5 baud init, once changed to 10400 no more pauses were necessary.