diff options
author | Stanley Huang <stanleyhuangyc@gmail.com> | 2014-04-04 11:23:32 +0800 |
---|---|---|
committer | Stanley Huang <stanleyhuangyc@gmail.com> | 2014-04-04 11:23:32 +0800 |
commit | f9f937f54c528aefe5f9504f8bb3f341f3dcb7aa (patch) | |
tree | ff22a2e1d6913b441d7aab24e9ac49c345fe36cf | |
parent | 52ec349f08b80cfe773c2919b392b02f9f071b7f (diff) | |
download | 2021-arduino-obd-f9f937f54c528aefe5f9504f8bb3f341f3dcb7aa.tar.gz 2021-arduino-obd-f9f937f54c528aefe5f9504f8bb3f341f3dcb7aa.tar.bz2 2021-arduino-obd-f9f937f54c528aefe5f9504f8bb3f341f3dcb7aa.zip |
Minor updates
-rw-r--r-- | libraries/OBD/OBD.cpp | 4 | ||||
-rw-r--r-- | libraries/OBD/OBD.h | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/libraries/OBD/OBD.cpp b/libraries/OBD/OBD.cpp index 3dba269..cd5290e 100644 --- a/libraries/OBD/OBD.cpp +++ b/libraries/OBD/OBD.cpp @@ -225,14 +225,14 @@ byte COBD::receive(char* buffer, int timeout) unsigned char n = 0;
bool prompted = false;
- buffer[0] = 0;
+ if (buffer) buffer[0] = 0;
for (;;) {
if (available()) {
char c = read();
if (n > 2 && c == '>') {
// prompt char received
prompted = true;
- } else if (n < OBD_RECV_BUF_SIZE - 1) {
+ } else if (n < OBD_RECV_BUF_SIZE - 1 && buffer) {
buffer[n++] = c;
if (c == '.') {
n = 0;
diff --git a/libraries/OBD/OBD.h b/libraries/OBD/OBD.h index 22d9f12..2718eb2 100644 --- a/libraries/OBD/OBD.h +++ b/libraries/OBD/OBD.h @@ -10,7 +10,7 @@ #define OBD_TIMEOUT_SHORT 2000 /* ms */
#define OBD_TIMEOUT_LONG 7000 /* ms */
#define OBD_SERIAL_BAUDRATE 38400
-#define OBD_RECV_BUF_SIZE 80
+#define OBD_RECV_BUF_SIZE 128
#ifndef OBDUART
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega644P__)
@@ -155,7 +155,7 @@ public: // GPS API
bool gpsQuery(GPS_DATA* gpsdata);
void gpsSetup(uint32_t baudrate, const char* cmds = 0);
-private:
+protected:
bool sendCommand(byte cmd, uint8_t data = 0, byte* payload = 0, byte payloadBytes = 0);
byte receive(char* buffer, int timeout = OBD_TIMEOUT_SHORT);
byte m_addr;
|