summaryrefslogtreecommitdiff
path: root/libraries/OBD
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2015-09-19 16:18:01 +1000
committerStanley Huang <stanleyhuangyc@gmail.com>2015-09-19 16:18:01 +1000
commit6eeb9120c5dd32b5d515a656421db4b405639447 (patch)
treeeef14dbbea6d1989f225d33bf85935a68bd91c45 /libraries/OBD
parentb8b89405a7fe4b373055217e17ba6c27c36705ad (diff)
download2021-arduino-obd-6eeb9120c5dd32b5d515a656421db4b405639447.tar.gz
2021-arduino-obd-6eeb9120c5dd32b5d515a656421db4b405639447.tar.bz2
2021-arduino-obd-6eeb9120c5dd32b5d515a656421db4b405639447.zip
Minor update
Diffstat (limited to 'libraries/OBD')
-rw-r--r--libraries/OBD/OBD.cpp19
-rw-r--r--libraries/OBD/OBD.h9
2 files changed, 15 insertions, 13 deletions
diff --git a/libraries/OBD/OBD.cpp b/libraries/OBD/OBD.cpp
index c28c1f2..4242cf3 100644
--- a/libraries/OBD/OBD.cpp
+++ b/libraries/OBD/OBD.cpp
@@ -426,37 +426,38 @@ bool COBD::getGPSData(GPS_DATA* gdata)
for (p = s; *p; p++) {
char c = *p;
if (c == ',' || c == '>' || c <= 0x0d) {
+ long value = atol(s);
switch (index) {
case 0:
- gdata->date = (uint32_t)atol(s);
+ gdata->date = (uint32_t)value;
break;
case 1:
- gdata->time = (uint32_t)atol(s);
+ gdata->time = (uint32_t)value;
break;
case 2:
- gdata->lat = atol(s);
+ gdata->lat = value;
break;
case 3:
- gdata->lon = atol(s);
+ gdata->lon = value;
break;
case 4:
- gdata->alt = atoi(s);
+ gdata->alt = value;
break;
case 5:
- gdata->speed = atof(s);
+ gdata->speed = value;
break;
case 6:
- gdata->heading = atoi(s);
+ gdata->heading = value;
break;
case 7:
- gdata->sat = atoi(s);
+ gdata->sat = value;
break;
}
index++;
s = p + 1;
}
}
- return index > 7;
+ return index >= 4;
}
#ifdef DEBUG
diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h
index 74e4225..90944e9 100644
--- a/libraries/OBD/OBD.h
+++ b/libraries/OBD/OBD.h
@@ -12,6 +12,7 @@
#define OBD_TIMEOUT_SHORT 2000 /* ms */
#define OBD_TIMEOUT_LONG 7000 /* ms */
+#define OBD_TIMEOUT_GPS 200 /* ms */
#define OBD_SERIAL_BAUDRATE 38400
#define OBD_RECV_BUF_SIZE 128
@@ -98,10 +99,10 @@ typedef struct {
uint32_t time;
int32_t lat;
int32_t lon;
- int alt;
- float speed;
- int heading;
- int sat;
+ int16_t alt;
+ uint8_t speed;
+ uint8_t sat;
+ int16_t heading;
} GPS_DATA;
uint16_t hex2uint16(const char *p);