summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorStanley Huang <stanleyhuangyc@gmail.com>2017-05-24 21:06:45 +1000
committerStanley Huang <stanleyhuangyc@gmail.com>2017-05-24 21:06:45 +1000
commitf44d57d878eaf9088dad912fcd0fa2863bf8f416 (patch)
tree2898e81d8c4083c36853a82fcb86bc369172af5f /libraries
parentfe06ee6e27833e26ea19bd740f504a9dcdf78d71 (diff)
download2021-arduino-obd-f44d57d878eaf9088dad912fcd0fa2863bf8f416.tar.gz
2021-arduino-obd-f44d57d878eaf9088dad912fcd0fa2863bf8f416.tar.bz2
2021-arduino-obd-f44d57d878eaf9088dad912fcd0fa2863bf8f416.zip
Working on ESPRIT (ESP32)
Diffstat (limited to 'libraries')
-rw-r--r--libraries/OBD2UART/OBD2UART.cpp14
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;
}