summaryrefslogtreecommitdiff
path: root/libraries/OBD2UART
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/OBD2UART')
-rw-r--r--libraries/OBD2UART/OBD2UART.cpp9
-rw-r--r--libraries/OBD2UART/OBD2UART.h24
2 files changed, 30 insertions, 3 deletions
diff --git a/libraries/OBD2UART/OBD2UART.cpp b/libraries/OBD2UART/OBD2UART.cpp
index 4e9a8de..0352c6a 100644
--- a/libraries/OBD2UART/OBD2UART.cpp
+++ b/libraries/OBD2UART/OBD2UART.cpp
@@ -257,12 +257,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/OBD2UART/OBD2UART.h b/libraries/OBD2UART/OBD2UART.h
index 706d4b8..dd151f2 100644
--- a/libraries/OBD2UART/OBD2UART.h
+++ b/libraries/OBD2UART/OBD2UART.h
@@ -72,6 +72,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,
@@ -112,8 +130,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 (return bytes received)
virtual byte sendCommand(const char* cmd, char* buf, byte bufsize, int timeout = OBD_TIMEOUT_LONG);
// read diagnostic trouble codes (return number of DTCs read)