rzetterberg / elmobd

A Go library for talking to cars over OBD-II
MIT License
221 stars 41 forks source link

Add faster sensor reading #2

Closed rzetterberg closed 6 years ago

rzetterberg commented 6 years ago

Description

As noted in CHANGELOG.md:

Reading sensor data from my Lexus IS200 -04 was fairly slow. At worst it took almost ~2.5 seconds, and at best it took ~1.7 seconds

This is the total time it took to read 7 sensor values in series. The reason this happens is because by default the ELM327 waits 200 ms before concluding that all data has been received. To speed this up you can tell the ELM327 how much data to expect, and return as soon as that amount has been reached.

The reason why we're not seeing 7 * 200 ms all the time is because by default the ELM327 uses adaptive timing.

More information about the specifics can be found in the data shet: https://www.elmelectronics.com/wp-content/uploads/2017/01/ELM327DS.pdf