From f44d57d878eaf9088dad912fcd0fa2863bf8f416 Mon Sep 17 00:00:00 2001 From: Stanley Huang Date: Wed, 24 May 2017 21:06:45 +1000 Subject: Working on ESPRIT (ESP32) --- libraries/OBD2UART/OBD2UART.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'libraries/OBD2UART') diff --git a/libraries/OBD2UART/OBD2UART.cpp b/libraries/OBD2UART/OBD2UART.cpp index 07b92fe..0cb72f1 100644 --- a/libraries/OBD2UART/OBD2UART.cpp +++ b/libraries/OBD2UART/OBD2UART.cpp @@ -9,6 +9,10 @@ //#define DEBUG Serial +#ifdef ESP32 +extern HardwareSerial Serial1; +#endif + uint16_t hex2uint16(const char *p) { char c = *p; @@ -328,9 +332,15 @@ byte COBD::begin() { long baudrates[] = {115200, 38400}; byte version = 0; - for (byte n = 0; n < sizeof(baudrates) / sizeof(baudrates[0]) && version == 0; n++) { + for (byte n = 0; n < sizeof(baudrates) / sizeof(baudrates[0]); n++) { +#ifndef ESP32 OBDUART.begin(baudrates[n]); - version = getVersion(); +#else + OBDUART.begin(baudrates[n], SERIAL_8N1, 16, 17); +#endif + version = getVersion(); + if (version != 0) break; + OBDUART.end(); } return version; } -- cgit v1.2.3