hi
i get the code running on arduino mega 2560
when i look in the com port i get lin debugging begins
but there is no outpot data
i checked if o connected the wiring good
and power to the steering wheel remote buttons etc
this is my code
#include <SoftwareSerial.h>
// https://github.com/zapta/linbus/tree/master/analyzer/arduino
#include "lin_frame.h"
// Pins we use for MCP2004
#define RX_PIN 10
#define TX_PIN 11
#define FAULT_PIN 14
#define CS_PIN 8
#define SYN_FIELD 0x55
SoftwareSerial LINBusSerial(RX_PIN, TX_PIN);
byte b, i, n;
LinFrame frame;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
// Open serial communications to host (PC) and wait for port to open:
Serial.begin(9600, SERIAL_8E1);
Serial.println("LIN Debugging begins");
LINBusSerial.begin(115200);
pinMode(CS_PIN, OUTPUT);
digitalWrite(CS_PIN, HIGH);
pinMode(FAULT_PIN, OUTPUT);
digitalWrite(FAULT_PIN, HIGH);
frame = LinFrame();
}
void loop() {
if (LINBusSerial.available()) {
b = LINBusSerial.read();
n = frame.num_bytes();
if (b == SYN_FIELD && n > 2 && frame.get_byte(n - 1) == 0) {
//Added delay for better read if I delete this is doesn't read anything
delay(10);
digitalWrite(LED_BUILTIN, HIGH);
frame.pop_byte();
handle_frame();
frame.reset();
digitalWrite(LED_BUILTIN, LOW);
} else if (n == LinFrame::kMaxBytes) {
frame.reset();
} else {
frame.append_byte(b);
}
}
}
void handle_frame() {
if (!frame.isValid())
return;
dump_frame();
}
void dump_frame() {
for (i = 0; i < frame.num_bytes(); i++) {
Serial.print(frame.get_byte(i), HEX);
Serial.print(" ");
}
Serial.println();
}