diff options
author | Stanley Huang <stanleyhuangyc@live.com> | 2016-06-26 21:01:19 +0800 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@live.com> | 2016-06-26 21:01:19 +0800 |
commit | 3655eb4501a8c191a01fa03c74a8f562d664a23e (patch) | |
tree | ecbfd079f9cc8921e337c7a5ed1d853f1c4fd2c7 /libraries/OBD2UART/OBD2UART.h | |
parent | 243b5fa4ddd06b845a68abccb0a109584cf0fa38 (diff) | |
download | 2021-arduino-obd-3655eb4501a8c191a01fa03c74a8f562d664a23e.tar.gz 2021-arduino-obd-3655eb4501a8c191a01fa03c74a8f562d664a23e.tar.bz2 2021-arduino-obd-3655eb4501a8c191a01fa03c74a8f562d664a23e.zip |
Added new APIs
Diffstat (limited to 'libraries/OBD2UART/OBD2UART.h')
-rw-r--r-- | libraries/OBD2UART/OBD2UART.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libraries/OBD2UART/OBD2UART.h b/libraries/OBD2UART/OBD2UART.h index 618b8c6..eaab88d 100644 --- a/libraries/OBD2UART/OBD2UART.h +++ b/libraries/OBD2UART/OBD2UART.h @@ -95,10 +95,10 @@ typedef enum { uint16_t hex2uint16(const char *p); uint8_t hex2uint8(const char *p); -class COBD2UART +class COBD { public: - COBD2UART():dataMode(1),errors(0),m_state(OBD_DISCONNECTED) {} + COBD():dataMode(1),errors(0),m_state(OBD_DISCONNECTED) {} // begin serial UART virtual void begin(); // initialize OBD-II connection @@ -121,10 +121,16 @@ public: virtual byte sendCommand(const char* cmd, char* buf, byte bufsize, int timeout = OBD_TIMEOUT_LONG); // clear diagnostic trouble code virtual void clearDTC(); - // get battery voltage (in 0.1V, e.g. 125 for 12.5V, works without ECU) + // get battery voltage (works without ECU) virtual float getVoltage(); // get VIN as a string, buffer length should be >= OBD_RECV_BUF_SIZE virtual bool getVIN(char* buffer, byte bufsize); + // get device temperature + virtual float getTemperature(); + // get accelerometer data + virtual bool readAccel(int& x, int& y, int& z); + // get gyroscope data + virtual bool readGyro(int& x, int& y, int& z); // send query for specified PID virtual void sendQuery(byte pid); // retrive and parse the response of specifie PID @@ -167,5 +173,6 @@ private: { return (int)hex2uint8(data) - 40; } + char* getResultValue(char* buf); }; |