diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-09-12 17:41:38 +0800 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-09-12 17:41:38 +0800 |
commit | 0f5028c8deac559b4dafc867ef45dd48b65cc151 (patch) | |
tree | 6a08be881692b899c96c0bcfde9789e4015b54ff /libraries/OBD/OBD.h | |
parent | a6a0c6cd9459543d8086ee30d7ac737d336bf11a (diff) | |
download | 2021-arduino-obd-0f5028c8deac559b4dafc867ef45dd48b65cc151.tar.gz 2021-arduino-obd-0f5028c8deac559b4dafc867ef45dd48b65cc151.tar.bz2 2021-arduino-obd-0f5028c8deac559b4dafc867ef45dd48b65cc151.zip |
update library header file
Diffstat (limited to 'libraries/OBD/OBD.h')
-rw-r--r-- | libraries/OBD/OBD.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h index b13056d..1bdaeb1 100644 --- a/libraries/OBD/OBD.h +++ b/libraries/OBD/OBD.h @@ -7,9 +7,8 @@ #define OBD_TIMEOUT_SHORT 2000 /* ms */ #define OBD_TIMEOUT_LONG 7000 /* ms */ -#define OBD_TIMEOUT_INIT 3000 /* ms */ #define OBD_SERIAL_BAUDRATE 38400 -#define OBD_RECV_BUF_SIZE 64 +#define OBD_RECV_BUF_SIZE 128 #ifndef OBDUART #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega644P__) @@ -37,13 +36,18 @@ #define PID_RUNTIME 0x1F #define PID_DISTANCE 0x31 +// states +#define OBD_DISCONNECTED 0 +#define OBD_CONNECTING 1 +#define OBD_CONNECTED 2 + unsigned int hex2uint16(const char *p); unsigned char hex2uint8(const char *p); class COBD { public: - COBD():dataMode(1),errors(0) {} + COBD():dataMode(1),errors(0),m_state(OBD_DISCONNECTED) {} void begin(); bool init(bool passive = false); bool readSensor(byte pid, int& result, bool passive = false); @@ -53,12 +57,15 @@ public: void sendQuery(byte pid); char* getResponse(byte& pid, char* buffer); bool getResponseParsed(byte& pid, int& result); + byte getState() { return m_state; } byte dataMode; byte errors; byte pidmap[4 * 4]; byte vin[17]; //char recvBuf[OBD_RECV_BUF_SIZE]; protected: + byte receive(char* buffer); + void debugOutput(const char* s); static int normalizeData(byte pid, char* data); static int getPercentageValue(char* data) { @@ -80,6 +87,6 @@ protected: virtual char read(); virtual void write(const char* s); virtual void write(const char c); - virtual void initIdleLoop() {} virtual void dataIdleLoop() {} + byte m_state; }; |