Fixes
parent
ee793c2129
commit
46fce4dd56
|
@ -69,7 +69,7 @@ unsigned int chrysler_checksum(unsigned int address, uint64_t d, int l) {
|
||||||
|
|
||||||
// Static lookup table for fast computation of CRC8 poly 0x2F, aka 8H2F/AUTOSAR
|
// Static lookup table for fast computation of CRC8 poly 0x2F, aka 8H2F/AUTOSAR
|
||||||
uint8_t crc8_lut_8h2f[256];
|
uint8_t crc8_lut_8h2f[256];
|
||||||
uint8_t crc8_lut_d5[256];
|
uint8_t crc8_lut_1d[256];
|
||||||
|
|
||||||
void gen_crc_lookup_table(uint8_t poly, uint8_t crc_lut[]) {
|
void gen_crc_lookup_table(uint8_t poly, uint8_t crc_lut[]) {
|
||||||
uint8_t crc;
|
uint8_t crc;
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sysconfig
|
||||||
|
import platform
|
||||||
|
from distutils.core import Extension, setup # pylint: disable=import-error,no-name-in-module
|
||||||
|
|
||||||
|
from Cython.Build import cythonize
|
||||||
|
from Cython.Distutils import build_ext
|
||||||
|
|
||||||
|
|
||||||
|
ANNOTATE = os.getenv('ANNOTATE') is not None
|
||||||
|
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../"))
|
||||||
|
|
||||||
|
|
||||||
|
def get_ext_filename_without_platform_suffix(filename):
|
||||||
|
name, ext = os.path.splitext(filename)
|
||||||
|
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
|
||||||
|
|
||||||
|
if ext_suffix == ext:
|
||||||
|
return filename
|
||||||
|
|
||||||
|
ext_suffix = ext_suffix.replace(ext, '')
|
||||||
|
idx = name.find(ext_suffix)
|
||||||
|
|
||||||
|
if idx == -1:
|
||||||
|
return filename
|
||||||
|
else:
|
||||||
|
return name[:idx] + ext
|
||||||
|
|
||||||
|
|
||||||
|
class BuildExtWithoutPlatformSuffix(build_ext):
|
||||||
|
def get_ext_filename(self, ext_name):
|
||||||
|
filename = super().get_ext_filename(ext_name)
|
||||||
|
return get_ext_filename_without_platform_suffix(filename)
|
||||||
|
|
||||||
|
|
||||||
|
extra_compile_args = ["-std=c++1z", "-Wno-nullability-completeness"]
|
||||||
|
ARCH = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() # pylint: disable=unexpected-keyword-arg
|
||||||
|
if ARCH == "aarch64":
|
||||||
|
extra_compile_args += ["-Wno-deprecated-register"]
|
||||||
|
|
||||||
|
if platform.system() == "Darwin":
|
||||||
|
libdbc = "libdbc.dylib"
|
||||||
|
else:
|
||||||
|
libdbc = "libdbc.so"
|
||||||
|
|
||||||
|
extra_link_args = [os.path.join(BASEDIR, 'opendbc', 'can', libdbc)]
|
||||||
|
include_dirs = [
|
||||||
|
BASEDIR,
|
||||||
|
os.path.join(BASEDIR, 'phonelibs'),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Build CAN Parser
|
||||||
|
|
||||||
|
setup(name='CAN parser',
|
||||||
|
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
|
||||||
|
ext_modules=cythonize(
|
||||||
|
Extension(
|
||||||
|
"parser_pyx",
|
||||||
|
language="c++",
|
||||||
|
sources=['parser_pyx.pyx'],
|
||||||
|
extra_compile_args=extra_compile_args,
|
||||||
|
include_dirs=include_dirs,
|
||||||
|
extra_link_args=extra_link_args,
|
||||||
|
),
|
||||||
|
nthreads=4,
|
||||||
|
annotate=ANNOTATE
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if platform.system() == "Darwin":
|
||||||
|
os.system("install_name_tool -change opendbc/can/libdbc.dylib " + BASEDIR + "/opendbc/can/libdbc.dylib parser_pyx.so")
|
||||||
|
|
||||||
|
|
||||||
|
# Build CAN Packer
|
||||||
|
|
||||||
|
setup(name='CAN packer',
|
||||||
|
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
|
||||||
|
ext_modules=cythonize(
|
||||||
|
Extension(
|
||||||
|
"packer_pyx",
|
||||||
|
language="c++",
|
||||||
|
sources=['packer_pyx.pyx'],
|
||||||
|
extra_compile_args=extra_compile_args,
|
||||||
|
include_dirs=include_dirs,
|
||||||
|
extra_link_args=extra_link_args,
|
||||||
|
),
|
||||||
|
nthreads=4,
|
||||||
|
annotate=ANNOTATE
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if platform.system() == "Darwin":
|
||||||
|
os.system("install_name_tool -change opendbc/can/libdbc.dylib " + BASEDIR + "/opendbc/can/libdbc.dylib packer_pyx.so")
|
|
@ -37,7 +37,7 @@ const Signal sigs_{{address}}[] = {
|
||||||
.type = SignalType::PEDAL_CHECKSUM,
|
.type = SignalType::PEDAL_CHECKSUM,
|
||||||
{% elif address in [512, 513] and sig.name == "COUNTER_PEDAL" %}
|
{% elif address in [512, 513] and sig.name == "COUNTER_PEDAL" %}
|
||||||
.type = SignalType::PEDAL_COUNTER,
|
.type = SignalType::PEDAL_COUNTER,
|
||||||
{% if checksum_type == "ocelot" and sig.name == "CHECKSUM" %}
|
{% elif checksum_type == "ocelot" and sig.name == "CHECKSUM" %}
|
||||||
.type = SignalType::OCELOT_CHECKSUM,
|
.type = SignalType::OCELOT_CHECKSUM,
|
||||||
{% elif checksum_type == "ocelot" and sig.name == "COUNTER" %}
|
{% elif checksum_type == "ocelot" and sig.name == "COUNTER" %}
|
||||||
.type = SignalType::OCELOT_COUNTER,
|
.type = SignalType::OCELOT_COUNTER,
|
||||||
|
|
|
@ -106,8 +106,9 @@ uint64_t CANPacker::pack(uint32_t address, const std::vector<SignalPackValue> &s
|
||||||
unsigned int chksm = chrysler_checksum(address, ReverseBytes(ret), message_lookup[address].size);
|
unsigned int chksm = chrysler_checksum(address, ReverseBytes(ret), message_lookup[address].size);
|
||||||
ret = set_value(ret, sig, chksm);
|
ret = set_value(ret, sig, chksm);
|
||||||
} else if (sig.type == SignalType::OCELOT_CHECKSUM) {
|
} else if (sig.type == SignalType::OCELOT_CHECKSUM) {
|
||||||
unsigned int chksm = chrysler_checksum(ret, message_lookup[address].size);
|
unsigned int chksm = ocelot_checksum(ret, message_lookup[address].size);
|
||||||
ret = set_value(ret, sig, chksm);
|
ret = set_value(ret, sig, chksm);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
//WARN("CHECKSUM signal type not valid\n");
|
//WARN("CHECKSUM signal type not valid\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ cdef class CANDefine():
|
||||||
self.dbc = dbc_lookup(dbc_name)
|
self.dbc = dbc_lookup(dbc_name)
|
||||||
if not self.dbc:
|
if not self.dbc:
|
||||||
raise RuntimeError("Can't lookup" + dbc_name)
|
raise RuntimeError("Can't lookup" + dbc_name)
|
||||||
|
|
||||||
num_vals = self.dbc[0].num_vals
|
num_vals = self.dbc[0].num_vals
|
||||||
|
|
||||||
address_to_msg_name = {}
|
address_to_msg_name = {}
|
||||||
|
|
|
@ -61,12 +61,12 @@ def process(in_fn, out_fn):
|
||||||
checksum_start_bit = 7
|
checksum_start_bit = 7
|
||||||
counter_start_bit = None
|
counter_start_bit = None
|
||||||
little_endian = False
|
little_endian = False
|
||||||
elif can_dbc.name.startswith(("ocelot_")):
|
elif can_dbc.name.startswith(("ocelot_")):
|
||||||
checksum_type = "ocelot"
|
checksum_type = "ocelot"
|
||||||
checksum_size = 8
|
checksum_size = 8
|
||||||
counter_size = 4
|
counter_size = 4
|
||||||
checksum_start_bit = 0
|
checksum_start_bit = 0
|
||||||
counter_start_bit = 4
|
counter_start_bit = 0
|
||||||
little_endian = True
|
little_endian = True
|
||||||
else:
|
else:
|
||||||
checksum_type = None
|
checksum_type = None
|
||||||
|
|
Loading…
Reference in New Issue