Skip to content

Commit 3f41934

Browse files
committed
Lin Scan example
1 parent 1014f8f commit 3f41934

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <Arduino.h>
2+
#include <Lin_Interface.hpp>
3+
4+
// using UART 1 for LinBus
5+
Lin_Interface LinBus(1);
6+
7+
// data to be filled by bus request
8+
float Cap_Max = 0.0;
9+
float Cap_Available = 0.0;
10+
uint8_t Cap_Configured = 0;
11+
uint8_t CalibByte = 0x00;
12+
bool CalibrationDone = false;
13+
14+
int LIN_ScanIDs()
15+
{
16+
int Result = 0;
17+
Serial.print("\n\n############# LIN ID scan started\n");
18+
// Scan all IDs
19+
for (int i = 0; i <= 0x3F; i++)
20+
{
21+
if (LinBus.readFrame(i))
22+
{
23+
Result++;
24+
}
25+
delay(10);
26+
}
27+
Serial.print("############# Chk Sum valid on ");
28+
Serial.print(Result);
29+
Serial.print(" Frames\n############# LIN ID scan finished\n\n");
30+
31+
return Result;
32+
}
33+
34+
void setup()
35+
{
36+
Serial.begin(115200);
37+
38+
// configure baud rate
39+
Serial.print("configure Lin-Bus to 19200 Baud\n");
40+
LinBus.baud = 19200;
41+
42+
LIN_ScanIDs();
43+
}
44+
45+
void loop()
46+
{
47+
delay(5000);
48+
}

0 commit comments

Comments
 (0)