diff options
-rw-r--r-- | libraries/OBD/OBD.cpp | 10 | ||||
-rw-r--r-- | libraries/OBD/OBD.h | 2 | ||||
-rw-r--r-- | libraries/OBD2UART/OBD2UART.cpp | 10 | ||||
-rw-r--r-- | libraries/OBD2UART/OBD2UART.h | 2 |
4 files changed, 12 insertions, 12 deletions
diff --git a/libraries/OBD/OBD.cpp b/libraries/OBD/OBD.cpp index d27fe7b..8dbdd29 100644 --- a/libraries/OBD/OBD.cpp +++ b/libraries/OBD/OBD.cpp @@ -291,7 +291,7 @@ float COBD::getVoltage() char buf[32]; if (sendCommand("ATRV\r", buf, sizeof(buf)) > 0) { char* p = getResultValue(buf); - if (p) return atof(p); + if (p) return (float)atof(p); } return 0; } @@ -323,12 +323,12 @@ bool COBD::isValidPID(byte pid) pid--; byte i = pid >> 3; byte b = 0x80 >> (pid & 0x7); - return pidmap[i] & b; + return (pidmap[i] & b) != 0; } byte COBD::begin() { - long baudrates[] = {38400, 115200}; + long baudrates[] = {115200, 38400}; byte version = 0; for (byte n = 0; n < sizeof(baudrates) / sizeof(baudrates[0]) && version == 0; n++) { OBDUART.begin(baudrates[n]); @@ -381,7 +381,7 @@ byte COBD::receive(char* buffer, byte bufsize, int timeout) // prompt char received break; } - if (millis() - startTime > timeout) { + if ((int)(millis() - startTime) > timeout) { // timeout break; } @@ -475,7 +475,7 @@ bool COBD::memsInit() return sendCommand("ATTEMP\r", buf, sizeof(buf)) > 0 && !strchr(buf, '?'); } -bool COBD::memsRead(int* acc, int* gyr, int* mag, int* temp) +bool COBD::memsRead(int16_t* acc, int16_t* gyr, int16_t* mag, int16_t* temp) { char buf[64]; bool success; diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h index b064f65..fa80537 100644 --- a/libraries/OBD/OBD.h +++ b/libraries/OBD/OBD.h @@ -150,7 +150,7 @@ public: // initialize MEMS sensor
virtual bool memsInit();
// read out MEMS data (acc for accelerometer, gyr for gyroscope, temp in 0.1 celcius degree)
- virtual bool memsRead(int* acc, int* gyr = 0, int* mag = 0, int* temp = 0);
+ virtual bool memsRead(int16_t* acc, int16_t* gyr = 0, int16_t* mag = 0, int16_t* temp = 0);
// send query for specified PID
virtual void sendQuery(byte pid);
// retrive and parse the response of specifie PID
diff --git a/libraries/OBD2UART/OBD2UART.cpp b/libraries/OBD2UART/OBD2UART.cpp index 0352c6a..07b92fe 100644 --- a/libraries/OBD2UART/OBD2UART.cpp +++ b/libraries/OBD2UART/OBD2UART.cpp @@ -289,7 +289,7 @@ float COBD::getVoltage() char buf[32]; if (sendCommand("ATRV\r", buf, sizeof(buf)) > 0) { char* p = getResultValue(buf); - if (p) return atof(p); + if (p) return (float)atof(p); } return 0; } @@ -321,12 +321,12 @@ bool COBD::isValidPID(byte pid) pid--; byte i = pid >> 3; byte b = 0x80 >> (pid & 0x7); - return pidmap[i] & b; + return (pidmap[i] & b) != 0; } byte COBD::begin() { - long baudrates[] = {38400, 115200}; + long baudrates[] = {115200, 38400}; byte version = 0; for (byte n = 0; n < sizeof(baudrates) / sizeof(baudrates[0]) && version == 0; n++) { OBDUART.begin(baudrates[n]); @@ -379,7 +379,7 @@ byte COBD::receive(char* buffer, byte bufsize, int timeout) // prompt char received break; } - if (millis() - startTime > timeout) { + if ((int)(millis() - startTime) > timeout) { // timeout break; } @@ -473,7 +473,7 @@ bool COBD::memsInit() return sendCommand("ATTEMP\r", buf, sizeof(buf)) > 0 && !strchr(buf, '?'); } -bool COBD::memsRead(int* acc, int* gyr, int* mag, int* temp) +bool COBD::memsRead(int16_t* acc, int16_t* gyr, int16_t* mag, int16_t* temp) { char buf[64]; bool success; diff --git a/libraries/OBD2UART/OBD2UART.h b/libraries/OBD2UART/OBD2UART.h index dd151f2..62ac18b 100644 --- a/libraries/OBD2UART/OBD2UART.h +++ b/libraries/OBD2UART/OBD2UART.h @@ -147,7 +147,7 @@ public: // initialize MEMS sensor virtual bool memsInit(); // read out MEMS data (acc for accelerometer, gyr for gyroscope, temp in 0.1 celcius degree) - virtual bool memsRead(int* acc, int* gyr = 0, int* mag = 0, int* temp = 0); + virtual bool memsRead(int16_t* acc, int16_t* gyr = 0, int16_t* mag = 0, int16_t* temp = 0); // send query for specified PID virtual void sendQuery(byte pid); // retrive and parse the response of specifie PID |