Skip to content

Commit 4758478

Browse files
committed
Lin Scan example
1 parent 1014f8f commit 4758478

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

example/lin-scan/platformio.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env:esp32doit-devkit-v1]
12+
platform = espressif32
13+
board = esp32doit-devkit-v1
14+
framework = arduino
15+
lib_deps =
16+
https://github.com/mestrode/Lin-Interface-Library

example/lin-scan/src/main.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <Arduino.h>
2+
#include <Lin_Interface.hpp>
3+
4+
// using UART 1 for LinBus
5+
Lin_Interface LinBus(1);
6+
7+
int LIN_ScanIDs()
8+
{
9+
int Result = 0;
10+
Serial.print("\n\n############# LIN ID scan started\n");
11+
// Scan all IDs
12+
for (int i = 0; i <= 0x3F; i++)
13+
{
14+
if (LinBus.readFrame(i))
15+
{
16+
Result++;
17+
}
18+
delay(10);
19+
}
20+
Serial.print("############# Chk Sum valid on ");
21+
Serial.print(Result);
22+
Serial.print(" Frames\n############# LIN ID scan finished\n\n");
23+
24+
return Result;
25+
}
26+
27+
void setup()
28+
{
29+
Serial.begin(115200);
30+
31+
// configure baud rate
32+
Serial.print("configure Lin-Bus to 19200 Baud\n");
33+
LinBus.baud = 19200;
34+
35+
LIN_ScanIDs();
36+
37+
Serial.print("May you want to try other Baud rates?\n");
38+
}
39+
40+
void loop()
41+
{
42+
delay(5000);
43+
}

0 commit comments

Comments
 (0)