diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-04-02 14:08:48 +0800 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-04-02 14:08:48 +0800 |
commit | 7af9330e5a976b4715eb406d613dff915dc292d8 (patch) | |
tree | d9eecf81fc0ef1565e07c8d34655ceafdc5d351d /obdlogger/OBD.cpp | |
parent | 9aa713d5e441a6f428d6fdddbd61065a2ee4c286 (diff) | |
download | 2021-arduino-obd-7af9330e5a976b4715eb406d613dff915dc292d8.tar.gz 2021-arduino-obd-7af9330e5a976b4715eb406d613dff915dc292d8.tar.bz2 2021-arduino-obd-7af9330e5a976b4715eb406d613dff915dc292d8.zip |
improving OBD-II data logger
Diffstat (limited to 'obdlogger/OBD.cpp')
-rw-r--r-- | obdlogger/OBD.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/obdlogger/OBD.cpp b/obdlogger/OBD.cpp index b3da34e..938523b 100644 --- a/obdlogger/OBD.cpp +++ b/obdlogger/OBD.cpp @@ -240,12 +240,12 @@ bool COBD::Init(bool passive) strcpy_P(cmd, s_initcmd[i]); WriteData(cmd); } - n = 0; - prompted = 0; + n = 0; + prompted = 0; currentMillis = millis(); - for (;;) { - if (DataAvailable()) { - char c = ReadData(); + for (;;) { + if (DataAvailable()) { + char c = ReadData(); if (c == '>') { buffer[n] = 0; prompted++; @@ -254,16 +254,17 @@ bool COBD::Init(bool passive) } } else if (prompted) { break; - } else { - unsigned long elapsed = millis() - currentMillis; - if (elapsed > OBD_TIMEOUT_INIT) { - // init timeout - //WriteData("\r"); - return false; - } - } - } - } + } else { + unsigned long elapsed = millis() - currentMillis; + if (elapsed > OBD_TIMEOUT_INIT) { + // init timeout + //WriteData("\r"); + return false; + } + DataTimeout(); + } + } + } errors = 0; return true; } |