diff options
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/OBD2UART/OBD2UART.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
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; } |