added first code for OBD2 via CAN and K-Line

This commit is contained in:
2025-05-04 12:03:19 +02:00
parent b627f52272
commit 1ee326fd57
12 changed files with 277 additions and 53 deletions

View File

@@ -32,7 +32,6 @@ struct can_frame
// Function prototypes
void Init_CAN();
void CAN_Process();
uint32_t Process_CAN_WheelSpeed();
#endif

View File

@@ -85,7 +85,9 @@ typedef enum SpeedSource_e
#endif
SOURCE_IMPULSE,
SOURCE_GPS,
SOURCE_CAN
SOURCE_CAN,
SOURCE_OBD2_KLINE,
SOURCE_OBD2_CAN
} SpeedSource_t;
// String representation of SpeedSource enum

View File

@@ -7,10 +7,10 @@
* It includes enums for DTC active status, severity levels, and specific DTC codes.
* The file also defines an array of DTC definitions and a timestamp indicating the generation time.
*
* @note This file is auto-generated by a script on 2024-01-10 18:37:05.
* @note This file is auto-generated by a script on 2025-05-04 12:01:55.
*
* @author Marcel Peterkau
* @date 10.01.2024
* @date 04.05.2025
*/
#ifndef DTC_DEFS_H
@@ -57,7 +57,12 @@ typedef struct {
#define DTC_FAKE_DTC_INFO 14
#define DTC_FAKE_DTC_WARN 15
#define DTC_FAKE_DTC_CRIT 16
#define DTC_LAST_DTC 17
#define DTC_OBD2_KLINE_TIMEOUT 17
#define DTC_OBD2_CAN_TIMEOUT 18
#define DTC_OBD2_CAN_NO_RESPONSE 19
#define DTC_OBD2_KLINE_NO_RESPONSE 20
#define DTC_OBD2_KLINE_BAD_FRAME 21
#define DTC_LAST_DTC 22
const DTC_t dtc_definitions[] = {
{ DTC_NO_DTC , DTC_NONE }, // No Error
@@ -77,9 +82,14 @@ const DTC_t dtc_definitions[] = {
{ DTC_FAKE_DTC_INFO , DTC_INFO }, // Ein Dummy-DTC der Schwere "Info" für Debugging-Zwecke
{ DTC_FAKE_DTC_WARN , DTC_WARN }, // Ein Dummy-DTC der Schwere "Warnung" für Debugging-Zwecke
{ DTC_FAKE_DTC_CRIT , DTC_CRITICAL }, // Ein Dummy-DTC der Schwere "Kritisch" für Debugging-Zwecke
{ DTC_OBD2_KLINE_TIMEOUT , DTC_CRITICAL }, // Die Anfrage über OBD2-KLine konnte nicht gesendet werden. Prüfen Sie den K-Line-Treiber (z.B. L9637D) und die Verkabelung.
{ DTC_OBD2_CAN_TIMEOUT , DTC_CRITICAL }, // Die Anfrage an das Steuergerät über OBD2-CAN konnte nicht gesendet werden. Prüfen Sie die Verbindung zum CAN-Modul und die OBD2-Konfiguration.
{ DTC_OBD2_CAN_NO_RESPONSE , DTC_WARN }, // Es wurde innerhalb der erwarteten Zeit keine Antwort vom Steuergerät über OBD2-CAN empfangen. Prüfen Sie, ob das Fahrzeug OBD2 unterstützt und die Verbindung korrekt ist.
{ DTC_OBD2_KLINE_NO_RESPONSE , DTC_WARN }, // Es wurde innerhalb der erwarteten Zeit keine Antwort über OBD2-KLine empfangen. Prüfen Sie die Verbindung zum Steuergerät und die Protokollkompatibilität.
{ DTC_OBD2_KLINE_BAD_FRAME , DTC_WARN }, // Das empfangene Frame war unvollständig oder entsprach nicht dem erwarteten OBD2-Format. Möglicherweise inkompatibles Steuergerät.
{ DTC_LAST_DTC , DTC_NONE } // Last Error
};
#endif // DTC_DEFS_H
// CODEGENERATOR_CHECKSUM: 23dff82a4745f67041012080b05ec367c2dd44c6bb02974143b227ba49682b6f
// CODEGENERATOR_CHECKSUM: 15e9152fb712bc6ed7c3353a05b1b54dc697f3e489a6e1ff42b7e57f0fa094d4

View File

@@ -0,0 +1,10 @@
#ifndef _OBD2_CAN_H_
#define _OBD2_CAN_H_
#include <Arduino.h>
// === Funktionen ===
void Init_OBD2_CAN();
uint32_t Process_OBD2_CAN_Speed();
#endif

View File

@@ -0,0 +1,10 @@
#ifndef _OBD2_KLINE_H_
#define _OBD2_KLINE_H_
#include <Arduino.h>
// === Funktionen ===
void Init_OBD2_KLine(Stream &serial); // Übergib z.B. SoftwareSerial oder Serial1
uint32_t Process_OBD2_KLine_Speed(); // liefert mm seit letztem Aufruf
#endif