From ceb4720c4a89735fb1ef128b66a7e582270043da Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Sun, 12 Feb 2017 23:01:21 +1100 Subject: Improved compatibility --- libraries/OBD/OBD.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'libraries/OBD/OBD.h') diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h index 711ee8e..f106e41 100644 --- a/libraries/OBD/OBD.h +++ b/libraries/OBD/OBD.h @@ -13,7 +13,6 @@ #define OBD_TIMEOUT_SHORT 1000 /* ms */ #define OBD_TIMEOUT_LONG 5000 /* ms */ #define OBD_TIMEOUT_GPS 200 /* ms */ -#define OBD_SERIAL_BAUDRATE 38400 #ifndef OBDUART #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168P__) @@ -102,8 +101,8 @@ class COBD { public: COBD():dataMode(1),errors(0),m_state(OBD_DISCONNECTED) {} - // begin serial UART - virtual void begin(); + // begin serial UART, return the version number on success and 0 on failure + virtual byte begin(); // initialize OBD-II connection virtual bool init(OBD_PROTOCOLS protocol = PROTO_AUTO); // un-initialize OBD-II connection @@ -129,7 +128,7 @@ public: // get VIN as a string, buffer length should be >= OBD_RECV_BUF_SIZE virtual bool getVIN(char* buffer, byte bufsize); // initialize MEMS sensor - virtual bool memsInit() { return version > 10; } + virtual bool memsInit(); // read out MEMS data (acc for accelerometer, gyr for gyroscope, temp in 0.1 celcius degree) virtual bool memsRead(int* acc, int* gyr = 0, int* mag = 0, int* temp = 0); // send query for specified PID @@ -138,14 +137,14 @@ public: virtual bool getResult(byte& pid, int& result); // determine if the PID is supported virtual bool isValidPID(byte pid); + // get adapter firmware version + virtual byte getVersion(); // set current PID mode byte dataMode; - // occurrence of errors + // number of subsequent errors byte errors; // bit map of supported PIDs byte pidmap[4 * 4]; - // adapter version - byte version; protected: virtual char* getResponse(byte& pid, char* buffer, byte bufsize); virtual byte receive(char* buffer, byte bufsize, int timeout = OBD_TIMEOUT_SHORT); @@ -200,10 +199,9 @@ typedef struct { class COBDI2C : public COBD { public: - void begin(); + byte begin(); void end(); bool readPID(byte pid, int& result); - byte readPID(const byte pid[], byte count, int result[]); void write(const char* s); // API not applicable bool setBaudRate(unsigned long baudrate) { return false; } -- cgit v1.2.3