diff options
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/OBD/OBD.cpp | 8 | ||||
-rw-r--r-- | libraries/OBD/OBD.h | 23 |
2 files changed, 26 insertions, 5 deletions
diff --git a/libraries/OBD/OBD.cpp b/libraries/OBD/OBD.cpp index 85e3ed0..172730e 100644 --- a/libraries/OBD/OBD.cpp +++ b/libraries/OBD/OBD.cpp @@ -75,6 +75,12 @@ bool COBD::read(byte pid, int& result) return getResult(pid, result); } +void COBD::clearDTC() +{ + write("04\r"); + receive(0, 1000); +} + bool COBD::available() { return OBDUART.available(); @@ -119,7 +125,7 @@ int COBD::normalizeData(byte pid, char* data) case PID_THROTTLE: case PID_COMMANDED_EGR: case PID_COMMANDED_EVAPORATIVE_PURGE: - case PID_FUEL_LEVEL_INPUT: + case PID_FUEL_LEVEL: case PID_RELATIVE_THROTTLE_POS: case PID_ABSOLUTE_THROTTLE_POS_B: case PID_ABSOLUTE_THROTTLE_POS_C: diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h index d2a9eb1..d47c3d3 100644 --- a/libraries/OBD/OBD.h +++ b/libraries/OBD/OBD.h @@ -44,7 +44,7 @@ #define PID_COMMANDED_EGR 0x2C
#define PID_EGR_ERROR 0x2D
#define PID_COMMANDED_EVAPORATIVE_PURGE 0x2E
-#define PID_FUEL_LEVEL_INPUT 0x2F
+#define PID_FUEL_LEVEL 0x2F
#define PID_WARMS_UPS 0x30
#define PID_DISTANCE 0x31
#define PID_EVAP_SYS_VAPOR_PRESSURE 0x32
@@ -89,23 +89,38 @@ public: COBD():dataMode(1),errors(0),m_state(OBD_DISCONNECTED) {}
/*
Serial baudrate is only adjustable for Arduino OBD-II Adapters V2
- Check out http://arduinodev.com/hardware/obd-kit/
+ Check out http://freematics.com/pages/products/arduino-obd-adapter
*/
virtual void begin(unsigned long baudrate = 0);
+ // initialize OBD-II connection
virtual bool init(byte protocol = 0);
+ // un-initialize OBD-II connection
virtual void uninit();
+ // get connection state
+ byte getState() { return m_state; }
+ // read specified OBD-II PID value
virtual bool read(byte pid, int& result);
+ // set device into
virtual void sleep();
+ // wake up device from previous sleep
virtual void wakeup();
+ // set working protocol (default auto)
virtual void setProtocol(byte h = -1);
- // Query and GetResponse for advanced usage only
+ // clear diagnostic trouble code
+ virtual void clearDTC();
+ // send query for specified PID
virtual void sendQuery(byte pid);
+ // retrive and parse the response of specifie PID
virtual bool getResult(byte& pid, int& result);
+ // determine if the PID is supported
bool isValidPID(byte pid);
- byte getState() { return m_state; }
+ // set current PID mode
byte dataMode;
+ // occurrence of errors
byte errors;
+ // bit map of supported PIDs
byte pidmap[4 * 4];
+ // current VIN
byte vin[17];
protected:
virtual char* getResponse(byte& pid, char* buffer);
|