mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-01 19:42:07 +08:00
Decrease build time for dbc files
This commit is contained in:
+3
-89
@@ -1,17 +1,13 @@
|
||||
#ifndef SELFDRIVE_CAN_COMMON_H
|
||||
#define SELFDRIVE_CAN_COMMON_H
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "common_dbc.h"
|
||||
#include <capnp/serialize.h>
|
||||
#include "cereal/gen/cpp/log.capnp.h"
|
||||
|
||||
#define MAX_BAD_COUNTER 5
|
||||
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
// Helper functions
|
||||
unsigned int honda_checksum(unsigned int address, uint64_t d, int l);
|
||||
@@ -22,74 +18,6 @@ unsigned int pedal_checksum(uint64_t d, int l);
|
||||
uint64_t read_u64_be(const uint8_t* v);
|
||||
uint64_t read_u64_le(const uint8_t* v);
|
||||
|
||||
struct SignalPackValue {
|
||||
const char* name;
|
||||
double value;
|
||||
};
|
||||
|
||||
struct SignalParseOptions {
|
||||
uint32_t address;
|
||||
const char* name;
|
||||
double default_value;
|
||||
};
|
||||
|
||||
struct MessageParseOptions {
|
||||
uint32_t address;
|
||||
int check_frequency;
|
||||
};
|
||||
|
||||
struct SignalValue {
|
||||
uint32_t address;
|
||||
uint16_t ts;
|
||||
const char* name;
|
||||
double value;
|
||||
};
|
||||
|
||||
|
||||
enum SignalType {
|
||||
DEFAULT,
|
||||
HONDA_CHECKSUM,
|
||||
HONDA_COUNTER,
|
||||
TOYOTA_CHECKSUM,
|
||||
PEDAL_CHECKSUM,
|
||||
PEDAL_COUNTER,
|
||||
VOLKSWAGEN_CHECKSUM,
|
||||
VOLKSWAGEN_COUNTER,
|
||||
};
|
||||
|
||||
struct Signal {
|
||||
const char* name;
|
||||
int b1, b2, bo;
|
||||
bool is_signed;
|
||||
double factor, offset;
|
||||
bool is_little_endian;
|
||||
SignalType type;
|
||||
};
|
||||
|
||||
struct Msg {
|
||||
const char* name;
|
||||
uint32_t address;
|
||||
unsigned int size;
|
||||
size_t num_sigs;
|
||||
const Signal *sigs;
|
||||
};
|
||||
|
||||
struct Val {
|
||||
const char* name;
|
||||
uint32_t address;
|
||||
const char* def_val;
|
||||
const Signal *sigs;
|
||||
};
|
||||
|
||||
struct DBC {
|
||||
const char* name;
|
||||
size_t num_msgs;
|
||||
const Msg *msgs;
|
||||
const Val *vals;
|
||||
size_t num_vals;
|
||||
};
|
||||
|
||||
|
||||
class MessageState {
|
||||
public:
|
||||
uint32_t address;
|
||||
@@ -129,17 +57,3 @@ public:
|
||||
std::vector<SignalValue> query_latest();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
|
||||
|
||||
struct SignalPackValue {
|
||||
const char* name;
|
||||
double value;
|
||||
};
|
||||
|
||||
struct SignalParseOptions {
|
||||
uint32_t address;
|
||||
const char* name;
|
||||
double default_value;
|
||||
};
|
||||
|
||||
struct MessageParseOptions {
|
||||
uint32_t address;
|
||||
int check_frequency;
|
||||
};
|
||||
|
||||
struct SignalValue {
|
||||
uint32_t address;
|
||||
uint16_t ts;
|
||||
const char* name;
|
||||
double value;
|
||||
};
|
||||
|
||||
enum SignalType {
|
||||
DEFAULT,
|
||||
HONDA_CHECKSUM,
|
||||
HONDA_COUNTER,
|
||||
TOYOTA_CHECKSUM,
|
||||
PEDAL_CHECKSUM,
|
||||
PEDAL_COUNTER,
|
||||
VOLKSWAGEN_CHECKSUM,
|
||||
VOLKSWAGEN_COUNTER,
|
||||
};
|
||||
|
||||
struct Signal {
|
||||
const char* name;
|
||||
int b1, b2, bo;
|
||||
bool is_signed;
|
||||
double factor, offset;
|
||||
bool is_little_endian;
|
||||
SignalType type;
|
||||
};
|
||||
|
||||
struct Msg {
|
||||
const char* name;
|
||||
uint32_t address;
|
||||
unsigned int size;
|
||||
size_t num_sigs;
|
||||
const Signal *sigs;
|
||||
};
|
||||
|
||||
struct Val {
|
||||
const char* name;
|
||||
uint32_t address;
|
||||
const char* def_val;
|
||||
const Signal *sigs;
|
||||
};
|
||||
|
||||
struct DBC {
|
||||
const char* name;
|
||||
size_t num_msgs;
|
||||
const Msg *msgs;
|
||||
const Val *vals;
|
||||
size_t num_vals;
|
||||
};
|
||||
|
||||
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); \
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "common.h"
|
||||
#include "common_dbc.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "common.h"
|
||||
#include "common_dbc.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
@@ -7,13 +5,8 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#include <capnp/serialize.h>
|
||||
#include "cereal/gen/cpp/log.capnp.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define DEBUG(...)
|
||||
|
||||
Reference in New Issue
Block a user