2019-11-22 21:46:33 -08:00
|
|
|
# distutils: language = c++
|
|
|
|
#cython: language_level=3
|
|
|
|
|
|
|
|
from libc.stdint cimport uint32_t, uint64_t, uint16_t
|
|
|
|
from libcpp.vector cimport vector
|
|
|
|
from libcpp.map cimport map
|
|
|
|
from libcpp.string cimport string
|
|
|
|
from libcpp.unordered_set cimport unordered_set
|
|
|
|
from libcpp cimport bool
|
|
|
|
|
|
|
|
|
2019-12-03 08:43:05 -08:00
|
|
|
cdef extern from "common_dbc.h":
|
2019-11-22 21:46:33 -08:00
|
|
|
ctypedef enum SignalType:
|
|
|
|
DEFAULT,
|
|
|
|
HONDA_CHECKSUM,
|
|
|
|
HONDA_COUNTER,
|
|
|
|
TOYOTA_CHECKSUM,
|
|
|
|
PEDAL_CHECKSUM,
|
|
|
|
PEDAL_COUNTER,
|
|
|
|
VOLKSWAGEN_CHECKSUM,
|
2020-04-13 15:06:28 -07:00
|
|
|
VOLKSWAGEN_COUNTER,
|
2020-04-30 14:06:26 -07:00
|
|
|
SUBARU_CHECKSUM,
|
|
|
|
CHRYSLER_CHECKSUM
|
2019-11-22 21:46:33 -08:00
|
|
|
|
|
|
|
cdef struct Signal:
|
|
|
|
const char* name
|
|
|
|
int b1, b2, bo
|
|
|
|
bool is_signed
|
|
|
|
double factor, offset
|
|
|
|
SignalType type
|
|
|
|
|
|
|
|
cdef struct Msg:
|
|
|
|
const char* name
|
|
|
|
uint32_t address
|
|
|
|
unsigned int size
|
|
|
|
size_t num_sigs
|
|
|
|
const Signal *sigs
|
|
|
|
|
|
|
|
cdef struct Val:
|
|
|
|
const char* name
|
|
|
|
uint32_t address
|
|
|
|
const char* def_val
|
|
|
|
const Signal *sigs
|
|
|
|
|
|
|
|
cdef struct DBC:
|
|
|
|
const char* name
|
|
|
|
size_t num_msgs
|
|
|
|
const Msg *msgs
|
|
|
|
const Val *vals
|
|
|
|
size_t num_vals
|
|
|
|
|
|
|
|
cdef struct SignalParseOptions:
|
|
|
|
uint32_t address
|
|
|
|
const char* name
|
|
|
|
double default_value
|
|
|
|
|
|
|
|
|
|
|
|
cdef struct MessageParseOptions:
|
|
|
|
uint32_t address
|
|
|
|
int check_frequency
|
|
|
|
|
|
|
|
cdef struct SignalValue:
|
|
|
|
uint32_t address
|
|
|
|
uint16_t ts
|
|
|
|
const char* name
|
|
|
|
double value
|
|
|
|
|
2019-12-03 08:43:05 -08:00
|
|
|
cdef struct SignalPackValue:
|
|
|
|
const char * name
|
|
|
|
double value
|
|
|
|
|
|
|
|
|
|
|
|
cdef extern from "common.h":
|
2019-11-22 21:46:33 -08:00
|
|
|
cdef const DBC* dbc_lookup(const string);
|
|
|
|
|
|
|
|
cdef cppclass CANParser:
|
|
|
|
bool can_valid
|
|
|
|
CANParser(int, string, vector[MessageParseOptions], vector[SignalParseOptions])
|
|
|
|
void update_string(string, bool)
|
|
|
|
vector[SignalValue] query_latest()
|
2019-12-03 08:43:05 -08:00
|
|
|
|
|
|
|
cdef cppclass CANPacker:
|
|
|
|
CANPacker(string)
|
|
|
|
uint64_t pack(uint32_t, vector[SignalPackValue], int counter)
|