diff options
Diffstat (limited to 'libraries/OBD')
-rw-r--r-- | libraries/OBD/OBD.cpp | 9 | ||||
-rw-r--r-- | libraries/OBD/OBD.h | 24 |
2 files changed, 30 insertions, 3 deletions
diff --git a/libraries/OBD/OBD.cpp b/libraries/OBD/OBD.cpp index 116a68d..d27fe7b 100644 --- a/libraries/OBD/OBD.cpp +++ b/libraries/OBD/OBD.cpp @@ -259,12 +259,19 @@ bool COBD::getResult(byte& pid, int& result) return true; } -void COBD::sleep() +void COBD::enterLowPowerMode() { char buf[32]; sendCommand("ATLP\r", buf, sizeof(buf)); } +void COBD::leaveLowPowerMode() +{ + // simply send any command to wake the device up + char buf[32]; + sendCommand("ATI\r", buf, sizeof(buf), 1000); +} + char* COBD::getResultValue(char* buf) { char* p = buf; diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h index 73607c7..b064f65 100644 --- a/libraries/OBD/OBD.h +++ b/libraries/OBD/OBD.h @@ -75,6 +75,24 @@ #define PID_ENGINE_TORQUE_PERCENTAGE 0x62
#define PID_ENGINE_REF_TORQUE 0x63
+// non-OBD/custom PIDs (no mode number)
+#define PID_GPS_LATITUDE 0xA
+#define PID_GPS_LONGITUDE 0xB
+#define PID_GPS_ALTITUDE 0xC
+#define PID_GPS_SPEED 0xD
+#define PID_GPS_HEADING 0xE
+#define PID_GPS_SAT_COUNT 0xF
+#define PID_GPS_TIME 0x10
+#define PID_GPS_DATE 0x11
+#define PID_ACC 0x20
+#define PID_GYRO 0x21
+#define PID_COMPASS 0x22
+#define PID_MEMS_TEMP 0x23
+#define PID_BATTERY_VOLTAGE 0x24
+
+// custom PIDs for calculated data
+#define PID_TRIP_DISTANCE 0x30
+
typedef enum {
PROTO_AUTO = 0,
PROTO_ISO_9141_2 = 3,
@@ -115,8 +133,10 @@ public: virtual bool readPID(byte pid, int& result);
// read multiple (up to 8) OBD-II PID values, return number of values obtained
virtual byte readPID(const byte pid[], byte count, int result[]);
- // set device into
- virtual void sleep();
+ // set device into low power mode
+ virtual void enterLowPowerMode();
+ // wake up device from low power mode
+ virtual void leaveLowPowerMode();
// send AT command and receive response
virtual byte sendCommand(const char* cmd, char* buf, byte bufsize, int timeout = OBD_TIMEOUT_LONG);
// read diagnostic trouble codes (return number of DTCs read)
|