mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-08-22 00:33:48 +08:00
ea800c8f74
version: dragonpilot v0.9.2 beta for EON/C2 date: 2023-03-27T06:11:06 dp-dev(priv2) master commit: 0a08aa2b73a505e11e4c98ac6c5989464b7d339f
101 lines
2.1 KiB
C++
101 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
|
|
|
|
struct SignalPackValue {
|
|
std::string name;
|
|
double value;
|
|
};
|
|
|
|
struct SignalParseOptions {
|
|
uint32_t address;
|
|
std::string name;
|
|
};
|
|
|
|
struct MessageParseOptions {
|
|
uint32_t address;
|
|
int check_frequency;
|
|
};
|
|
|
|
struct SignalValue {
|
|
uint32_t address;
|
|
uint64_t ts_nanos;
|
|
std::string name;
|
|
double value; // latest value
|
|
std::vector<double> all_values; // all values from this cycle
|
|
};
|
|
|
|
enum SignalType {
|
|
DEFAULT,
|
|
COUNTER,
|
|
HONDA_CHECKSUM,
|
|
TOYOTA_CHECKSUM,
|
|
PEDAL_CHECKSUM,
|
|
VOLKSWAGEN_MQB_CHECKSUM,
|
|
XOR_CHECKSUM,
|
|
SUBARU_CHECKSUM,
|
|
CHRYSLER_CHECKSUM,
|
|
HKG_CAN_FD_CHECKSUM,
|
|
};
|
|
|
|
struct Signal {
|
|
std::string name;
|
|
int start_bit, msb, lsb, size;
|
|
bool is_signed;
|
|
double factor, offset;
|
|
bool is_little_endian;
|
|
SignalType type;
|
|
unsigned int (*calc_checksum)(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
|
|
};
|
|
|
|
struct Msg {
|
|
std::string name;
|
|
uint32_t address;
|
|
unsigned int size;
|
|
std::vector<Signal> sigs;
|
|
};
|
|
|
|
struct Val {
|
|
std::string name;
|
|
uint32_t address;
|
|
std::string def_val;
|
|
std::vector<Signal> sigs;
|
|
};
|
|
|
|
struct DBC {
|
|
std::string name;
|
|
std::vector<Msg> msgs;
|
|
std::vector<Val> vals;
|
|
};
|
|
|
|
typedef struct ChecksumState {
|
|
int checksum_size;
|
|
int counter_size;
|
|
int checksum_start_bit;
|
|
int counter_start_bit;
|
|
bool little_endian;
|
|
SignalType checksum_type;
|
|
unsigned int (*calc_checksum)(uint32_t address, const Signal &sig, const std::vector<uint8_t> &d);
|
|
} ChecksumState;
|
|
#ifndef QCOM
|
|
DBC* dbc_parse(const std::string& dbc_path);
|
|
DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, ChecksumState *checksum = nullptr);
|
|
const DBC* dbc_lookup(const std::string& dbc_name);
|
|
std::vector<std::string> get_dbc_names();
|
|
#else
|
|
std::vector<const DBC*>& get_dbcs();
|
|
const DBC* dbc_lookup(const std::string& dbc_name);
|
|
|
|
void dbc_register(const DBC* dbc);
|
|
|
|
#define dbc_init(dbc) \
|
|
static void __attribute__((constructor)) do_dbc_init_ ## dbc(void) { \
|
|
dbc_register(&dbc); \
|
|
}
|
|
#endif
|