Upload files to "/"
This commit is contained in:
71
dbc_parser.h
Normal file
71
dbc_parser.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// dbc_parser.h - DBC File Parser for CAN Database
|
||||
|
||||
#ifndef DBC_PARSER_H
|
||||
#define DBC_PARSER_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
// Maximum number of messages and signals
|
||||
#define MAX_DBC_MESSAGES 100
|
||||
#define MAX_DBC_SIGNALS 500
|
||||
|
||||
// Signal structure
|
||||
struct DbcSignal {
|
||||
char name[32];
|
||||
uint32_t startBit;
|
||||
uint32_t length;
|
||||
bool isLittleEndian;
|
||||
bool isSigned;
|
||||
float factor;
|
||||
float offset;
|
||||
float min;
|
||||
float max;
|
||||
char unit[8];
|
||||
uint32_t messageId;
|
||||
};
|
||||
|
||||
// Message structure
|
||||
struct DbcMessage {
|
||||
uint32_t id;
|
||||
char name[32];
|
||||
uint8_t dlc;
|
||||
uint16_t signalCount;
|
||||
uint16_t signalStartIndex;
|
||||
};
|
||||
|
||||
// DBC database
|
||||
struct DbcDatabase {
|
||||
DbcMessage messages[MAX_DBC_MESSAGES];
|
||||
DbcSignal signals[MAX_DBC_SIGNALS];
|
||||
uint16_t messageCount;
|
||||
uint16_t signalCount;
|
||||
bool loaded;
|
||||
};
|
||||
|
||||
extern DbcDatabase dbcDB;
|
||||
|
||||
// Parse DBC file content
|
||||
bool parseDBC(const char* content);
|
||||
|
||||
// Get message by ID
|
||||
DbcMessage* getMessageById(uint32_t id);
|
||||
|
||||
// Get signal from message by name
|
||||
DbcSignal* getSignalByName(DbcMessage* msg, const char* name);
|
||||
|
||||
// Get all signals for a message
|
||||
uint16_t getSignalsForMessage(uint32_t msgId, DbcSignal** signals);
|
||||
|
||||
// Extract signal value from raw CAN data
|
||||
float extractSignalValue(const uint8_t* data, const DbcSignal* signal);
|
||||
|
||||
// Clear database
|
||||
void clearDBC();
|
||||
|
||||
// Load DBC from SD card
|
||||
bool loadDBCFromSD(const char* filename);
|
||||
|
||||
// Save parsed DBC info to JSON for web
|
||||
void getDBCSummary(char* buffer, size_t bufferSize);
|
||||
|
||||
#endif // DBC_PARSER_H
|
||||
Reference in New Issue
Block a user