-
Notifications
You must be signed in to change notification settings - Fork 64
/
basic_working.ino
72 lines (61 loc) · 1.49 KB
/
basic_working.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <Arduino.h>
#include "KWP2000.h"
// Different core have different way to use a Serial port
#if defined(ARDUINO_ARCH_ESP32)
HardwareSerial bike(2);
#define TX_PIN 17
#elif defined(ARDUINO_ARCH_STM32)
HardwareSerial bike(PA3, PA2); // RX and TX
#define TX_PIN PA2
#else
#define bike Serial3
#define TX_PIN 14
#endif
#define debug Serial
// Replace YOUR_MOTORBIKE with SUZUKI, KAWASAKI, YAMAHA or HONDA
KWP2000 ECU(&bike, TX_PIN, YOUR_MOTORBIKE);
void setup()
{
ECU.enableDebug(&debug, DEBUG_LEVEL_VERBOSE, 115200);
//Serial.begin(); this is not needed because we use then same serial as the debug
//ECU.enableDealerMode(pin); // This is available only on Suzuki bikes
}
void loop()
{
if (debug.available() > 0)
{
char in = debug.read();
debug.print("User Input: ");
debug.println(in);
switch (in)
{
case 'i':
while (ECU.initKline() == 0)
{
;
}
break;
case 'd':
ECU.setDealerMode(!ECU.getDealerMode());
break;
case 't':
ECU.readTroubleCodes();
break;
case 's':
ECU.requestSensorsData();
ECU.printSensorsData();
break;
case 'p':
ECU.printStatus();
break;
case 'c':
while (ECU.stopKline() == 0)
{
;
}
break;
}
in = 0;
}
ECU.keepAlive();
}