LIN Transeiver or Library or my code not working?!

Hello from Germany!

I am currently try to connect to a Seat (Volkswagen) Steering Wheel which communicate via LIN Bus 2.0.

The Library i’m using is this one: https://github.com/macchina/LIN

My code for sending and receiving data is the following:

#include <lin_stack.h>

lin_stack LIN1(2); // Creating LIN Stack
byte data_size=8; // length of byte array
byte data[8]; // byte array for received data

void setup() {
SerialUSB.begin(115200);
delay(3000);

LIN1.setSerial();
LIN1.busWakeUp();
}

void loop() {
// Request data
LIN1.writeRequest(0x0E);

// read data
byte a = LIN1.read(data, data_size);

// if data received, print it
if(a == 1){
SerialUSB.println(“New Lin Data: “);
for (int i=0; i<8; i++){SerialUSB.println(data[i],HEX);}
SerialUSB.println(”—”);
}
}

Inside the Libraray I needed to edit the file lin_stack.cpp at the “readStream” funtction because at line 216 of that file code was missing to actually give back received data:

  	Serial2.readBytes(rec,data_size);
  	for(int j=0;j<data_size;j++){
  		data[j] = rec[j];
  	}

With that change I was able to getting follwing data out of my requests:
8E, 8, 7, 20, 23, 4 , 8, 0

The problem: The received data should be this (Lin Analyzer):
Frame ID: 8E
Frame Data: 81, 00, 00, 00, 52, 00, 00 ,00
Checksum: 9D

To be clear: The request the Macchina M2 is sending reaches the steering wheel which responds, but this response i can only read on the external Lin Bus Analyzer, and not on the M2.

I checked it with Microchips Lin Bus Analyzer, so the problem must be on the Macchina M2 side.
The question: Is the fault part the hardware, the library or my code?

Can anyone help?

Thanks in advance,
Yannic

2 Likes