NMEA2000 manufacturer names and a bit more logging

This commit is contained in:
2026-01-31 15:14:26 +01:00
parent 2eabe931d8
commit 3729fcb0f1
4 changed files with 247 additions and 37 deletions

View File

@@ -1,5 +1,4 @@
#ifndef _NMEA2KTWAI_H
#define _NMEA2KTWAI_H
#pragma once
#include "NMEA2000.h"
// #include "GwTimer.h"
@@ -15,7 +14,7 @@ public:
ST_DISABLED,
ST_ERROR
} STATE;
typedef struct{
typedef struct {
//see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/twai.html#_CPPv418twai_status_info_t
uint32_t rx_errors = 0;
uint32_t tx_errors = 0;
@@ -31,10 +30,12 @@ public:
static const char *stateStr(const STATE &st);
virtual bool CANOpen();
virtual ~Nmea2kTwai() {};
// static const int LOG_ERR = 0;
// static const int LOG_INFO = 1;
// static const int LOG_DEBUG = 2;
// static const int LOG_MSG = 3;
struct ManufacturerEntry {
uint16_t code;
const char* name;
};
const char* GetManufacturerName(uint16_t code);
protected:
virtual bool CANSendFrame(unsigned long id, unsigned char len, const unsigned char *buf, bool wait_sent=true);
@@ -44,19 +45,19 @@ protected:
to change size of library send frame buffer size.
See e.g. NMEA2000_teensy.cpp. */
virtual void InitCANFrameBuffers();
virtual void logDebug(int level,const char *fmt,...){}
// virtual void logDebug(int level,const char *fmt,...){}
static const ManufacturerEntry ManufacturerTable[];
private:
void initDriver();
bool startRecovery();
bool checkRecovery();
Status logStatus();
gpio_num_t TxPin;
Status logStatus();
gpio_num_t TxPin;
gpio_num_t RxPin;
uint32_t txTimeouts = 0;
// GwIntervalRunner timers;
bool disabled = false;
unsigned long lastRecoveryStart=0;
};
unsigned long lastRecoveryStart = 0;
#endif
};