From c56afd24349d1b4bdf1befe0622a30a2c15c9b48 Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Mon, 4 May 2015 10:51:15 +1000 Subject: Fix setBaudRate(), add necessary delay in receive() --- libraries/OBD/OBD.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libraries/OBD/OBD.cpp') diff --git a/libraries/OBD/OBD.cpp b/libraries/OBD/OBD.cpp index bf778bf..72955f0 100644 --- a/libraries/OBD/OBD.cpp +++ b/libraries/OBD/OBD.cpp @@ -378,8 +378,9 @@ void COBD::end() bool COBD::setBaudRate(unsigned long baudrate) { char buf[OBD_RECV_BUF_SIZE]; - sprintf(buf, "ATBR2 %lu\r", baudrate); - OBDUART.print(buf); + OBDUART.print("ATBR1 "); + OBDUART.print(baudrate); + OBDUART.print('\r'); if (receive(buf) && strstr(buf, "OK")) { OBDUART.end(); OBDUART.begin(baudrate); @@ -503,6 +504,7 @@ byte COBDI2C::receive(char* buffer, int timeout) { uint32_t start = millis(); byte offset = 0; + delay(10); do { Wire.requestFrom((byte)I2C_ADDR, (byte)MAX_PAYLOAD_SIZE, (byte)1); -- cgit v1.2.3