diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-06-27 14:42:45 +0800 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2013-06-27 14:42:45 +0800 |
commit | 17abc0d3cf9b226b06e5d62790a8d5e576846571 (patch) | |
tree | fd7eed9168345015b03db5b62cbb8119766a5452 /libraries/OBD/OBD.h | |
parent | b74448509a44bc2be9a006827ede79be883efbd4 (diff) | |
download | 2021-arduino-obd-17abc0d3cf9b226b06e5d62790a8d5e576846571.tar.gz 2021-arduino-obd-17abc0d3cf9b226b06e5d62790a8d5e576846571.tar.bz2 2021-arduino-obd-17abc0d3cf9b226b06e5d62790a8d5e576846571.zip |
update library API
Diffstat (limited to 'libraries/OBD/OBD.h')
-rw-r--r-- | libraries/OBD/OBD.h | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h index e97ab67..144d0a9 100644 --- a/libraries/OBD/OBD.h +++ b/libraries/OBD/OBD.h @@ -1,7 +1,7 @@ /************************************************************************* -* OBD-II (ELM327) data accessing library for Arduino +* Arduino Library for OBD-II UART Adapter * Distributed under GPL v2.0 -* Copyright (c) 2012 Stanley Huang <stanleyhuangyc@gmail.com> +* Copyright (c) 2012~2013 Stanley Huang <stanleyhuangyc@gmail.com> * All rights reserved. *************************************************************************/ @@ -44,32 +44,33 @@ class COBD { public: COBD():dataMode(1),errors(0) {} - bool Init(bool passive = false); - bool ReadSensor(byte pid, int& result, bool passive = false); - bool IsValidPID(byte pid); - void Sleep(int seconds); + void begin(int baudrate = OBD_SERIAL_BAUDRATE); + bool init(bool passive = false); + bool readSensor(byte pid, int& result, bool passive = false); + bool isValidPID(byte pid); + void sleep(int seconds); // Query and GetResponse for advanced usage only - void Query(byte pid); - char* GetResponse(byte& pid, char* buffer); - bool GetResponseParsed(byte& pid, int& result); + void sendQuery(byte pid); + char* getResponse(byte& pid, char* buffer); + bool getResponseParsed(byte& pid, int& result); byte dataMode; byte errors; //char recvBuf[OBD_RECV_BUF_SIZE]; protected: - static int GetConvertedValue(byte pid, char* data); - static int GetPercentageValue(char* data) + static int normalizeData(byte pid, char* data); + static int getPercentageValue(char* data) { return (int)hex2uint8(data) * 100 / 255; } - static int GetLargeValue(char* data) + static int getLargeValue(char* data) { return hex2uint16(data); } - static int GetSmallValue(char* data) + static int getSmallValue(char* data) { return hex2uint8(data); } - static int GetTemperatureValue(char* data) + static int getTemperatureValue(char* data) { return (int)hex2uint8(data) - 40; } @@ -77,7 +78,7 @@ protected: virtual char read(); virtual void write(const char* s); virtual void write(const char c); - virtual void InitIdleLoop() {} - virtual void DataIdleLoop() {} + virtual void initIdleLoop() {} + virtual void dataIdleLoop() {} byte pidmap[4 * 4]; }; |