Skip to content
This repository was archived by the owner on Apr 13, 2024. It is now read-only.

Commit 0fea888

Browse files
committed
Squashed 'opendbc/' changes from c0eba09..bdcd31df
bdcd31df reducing precision 1263500c scale is supposed to be 0-255 7c4d34a shorter scale, shift aftert scale 7971a608 maybe scale was too long be5b34b7 fingers crossed 0-1 is the desired range... 27368e96 accidental dup 79fe914e Added Pedal entries 63540dd2 add interceptor a1aa3b7 Cleanup of Nissan DBC (commaai#218) c1f7648 reverting changes to Chrysler: speed message seems different from car to car 2de8e9e Chrysler: Speed msg is 5 bytes f4ac315 Chrysler: add counter to 514 0fb62cf Toyota Blind Spot Monitor (TSS2-only?) (commaai#219) 2ae0327 GitHub actions (commaai#217) fbbba94 GM: use common gear VALs dacd8b4 Chrysler commonize gear VALs d338b9f Add support for 2019 Civic Sedan Diesel. Split GAS_PEDAL_2 out to each car. (commaai#215) d68f8ff Clean up .gitignore e82757b Add Lexus NX300H (commaai#214) 745a2bb Removed non high voltage items. Added units. fafd091 Added High Voltage Management to powertrain file. 15b6b31 Update subaru_global_2017.dbc a12af19 Add steering error signal in subaru global d411c17 correct max value 881c065 add electrical gear and fix driver torque 1bbac4b Add reference to CANdevStudio in README file 8f70ea0 Adds 2016 Honda CR-V Executive 5081966 One more fix fa5dc68 Fix honda dbc files after steer torque addition e4dfb2f update honda steering signals (commaai#208) 53fc448 added generator test (commaai#207) cb27d6e Honda Nidec: add new ACC_HUD signals to all other cars other than the CIVIC 6e6779f build on mac AND linux, also gotta not use these python files 79dbfc1 build on mac 4f82d01 gitignore 5cb8345 Honda FCM: diagnostic signals d309cdc Added linter to opendbc (commaai#203) d452706 add requirements.txt ec3b459 deterministic dependency order a265d35 Azure pipelines ci (commaai#202) bce9a2e packer depends on libdbc 5d5fdd6 no more python version of libdbc, everything through cython 541705b move CANDefine to parser code da25c52 add test for can define 0ba7926 unify can packer and parser 25d8800 consistent naming a5c640a fix linter be210fe remove obsolete make file ffd9dca opendbc needs cereal b559f63 remove more make d092949 seems to work now 41e8083 don't make 3254d1f think scons works eb78f6a scons sort of working 0ef1e35 fix gitignore e155e01 Can migration (commaai#199) 3eded83 Honda: correct steering torque sensor sign to be consistent with standard convention (left+) 32f70e2 Fix outback endianness consistency (commaai#196) a7da471 Update subaru_outback_2015_eyesight.dbc (commaai#195) git-subtree-dir: opendbc git-subtree-split: bdcd31dff8e38467281e1b0f865abe978b04d990
1 parent 67c4121 commit 0fea888

File tree

88 files changed

+4584
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+4584
-375
lines changed

.github/workflows/tests.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-16.04
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- run: |
12+
set -e
13+
docker build -t opendbc .
14+
name: "Build"
15+
- run: |
16+
docker run opendbc bash -c "python -m unittest discover opendbc"
17+
name: "Unit tests"
18+
- run: |
19+
docker run opendbc bash -c "cd opendbc/can/tests/linter_python; PYTHONPATH=/ ./flake8_opendbc.sh"
20+
docker run opendbc bash -c "cd opendbc/can/tests/linter_python; PYTHONPATH=/ ./pylint_opendbc.sh"
21+
name: "Python linter"
22+
- run: |
23+
docker run opendbc bash -c "cd opendbc/can/tests/; PYTHONPATH=/ ./test_generator.sh"
24+
name: "Generator test"

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
*.pyc
2+
*.os
3+
*.tmp
4+
*.dylib
25
.*.swp
6+
.DS_Store
7+
8+
can/*.so
9+
can/build/
10+
can/obj/
11+
can/packer_pyx.cpp
12+
can/parser_pyx.cpp
13+
can/packer_impl.cpp

Dockerfile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from ubuntu:16.04
2+
3+
RUN apt-get update && apt-get install -y libzmq3-dev clang wget git autoconf libtool curl make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
4+
5+
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
6+
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
7+
RUN pyenv install 3.7.3
8+
RUN pyenv global 3.7.3
9+
RUN pyenv rehash
10+
11+
COPY requirements.txt /tmp/
12+
RUN pip install -r /tmp/requirements.txt
13+
14+
ENV PYTHONPATH=/project
15+
16+
# TODO: Add tag to cereal
17+
RUN git clone https://github.com/commaai/cereal.git /project/cereal
18+
RUN /project/cereal/install_capnp.sh
19+
20+
WORKDIR /project
21+
22+
COPY SConstruct .
23+
COPY . /project/opendbc
24+
25+
RUN scons -c && scons -j$(nproc)

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Wondering what's the DBC file format? [Here](http://www.socialledge.com/sjsu/ind
1616

1717
Use [panda](https://github.com/commaai/panda) to connect your car to a computer.
1818

19+
### How to use reverse engineered DBC
20+
To create custom CAN simulations or send reverse engineered signals back to the car you can use [CANdevStudio](https://github.com/GENIVI/CANdevStudio) project.
21+
1922
### DBC file preprocessor
2023

2124
DBC files for different models of the same brand have a lot of overlap. Therefore, we wrote a preprocessor to create DBC files from a brand DBC file and a model specific DBC file. The source DBC files can be found in the generator folder. After changing one of the files run the generator.py script to regenerate the output files. These output files will be placed in the root of the opendbc repository and are suffixed by _generated.
@@ -42,7 +45,7 @@ For example:
4245
SG_ VEHICLE_SPEED : 7|15@0+ (0.01,0) [0|250] "kph" PCM
4346
```
4447
45-
- Signal's size: always use the smallest amount of bits possible. For example, let's say I'm reverse engineering the gas pedal position and I've determined that it's in a 3 bytes message. For 0% pedal position I read a message value of `0x00 0x00 0x00`, while for 100% of pedal position I read `0x64 0x00 0x00`: clearly, the gas pedal position is within the first byte of the message and I might be tempted to define the signal `GAS_POS` as:
48+
- Signal size: always use the smallest amount of bits possible. For example, let's say I'm reverse engineering the gas pedal position and I've determined that it's in a 3 bytes message. For 0% pedal position I read a message value of `0x00 0x00 0x00`, while for 100% of pedal position I read `0x64 0x00 0x00`: clearly, the gas pedal position is within the first byte of the message and I might be tempted to define the signal `GAS_POS` as:
4649
```
4750
SG_ GAS_POS : 7|8@0+ (1,0) [0|100] "%" PCM
4851
```

SConstruct

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import os
2+
import subprocess
3+
4+
zmq = 'zmq'
5+
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
6+
7+
cereal_dir = Dir('.')
8+
9+
cpppath = [
10+
'#',
11+
'#cereal',
12+
"#cereal/messaging",
13+
"#opendbc/can",
14+
'/usr/lib/include',
15+
]
16+
17+
AddOption('--test',
18+
action='store_true',
19+
help='build test files')
20+
21+
AddOption('--asan',
22+
action='store_true',
23+
help='turn on ASAN')
24+
25+
ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] if GetOption('asan') else []
26+
ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else []
27+
28+
env = Environment(
29+
ENV=os.environ,
30+
CC='clang',
31+
CXX='clang++',
32+
CCFLAGS=[
33+
"-g",
34+
"-fPIC",
35+
"-O2",
36+
"-Werror=implicit-function-declaration",
37+
"-Werror=incompatible-pointer-types",
38+
"-Werror=int-conversion",
39+
"-Werror=return-type",
40+
"-Werror=format-extra-args",
41+
] + ccflags_asan,
42+
LDFLAGS=ldflags_asan,
43+
LINKFLAGS=ldflags_asan,
44+
45+
CFLAGS="-std=gnu11",
46+
CXXFLAGS="-std=c++14",
47+
CPPPATH=cpppath,
48+
)
49+
50+
Export('env', 'zmq', 'arch')
51+
52+
cereal = [File('#cereal/libcereal.a')]
53+
messaging = [File('#cereal/libmessaging.a')]
54+
Export('cereal', 'messaging')
55+
56+
SConscript(['cereal/SConscript'])
57+
SConscript(['opendbc/can/SConscript'])

acura_ilx_2016_can_generated.dbc

+15-5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA
8686
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
8787
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON
8888

89+
BO_ 427 STEER_MOTOR_TORQUE: 3 EPS
90+
SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON
91+
SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON
92+
SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON
93+
SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON
94+
SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON
95+
8996
BO_ 432 STANDSTILL: 7 VSA
9097
SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON
9198
SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON
@@ -164,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS
164171
SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY
165172
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
166173
SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY
167-
SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY
174+
SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY
168175
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
169176
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
170177
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
@@ -174,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS
174181
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
175182
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
176183
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
177-
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
178-
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
179184
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
185+
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
186+
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
187+
SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY
180188
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
189+
SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY
181190
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
182191
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
183192

@@ -271,10 +280,11 @@ BO_ 342 STEERING_SENSORS: 6 EPS
271280
SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON
272281

273282
BO_ 399 STEER_STATUS: 7 EPS
274-
SG_ STEER_TORQUE_SENSOR : 7|16@0- (1,0) [-31000|31000] "tbd" EON
275-
SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON
283+
SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON
284+
SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON
276285
SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON
277286
SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON
287+
SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON
278288
SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON
279289
SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON
280290

acura_rdx_2018_can_generated.dbc

+14-5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ BO_ 420 VSA_STATUS: 8 VSA
8686
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON
8787
SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON
8888

89+
BO_ 427 STEER_MOTOR_TORQUE: 3 EPS
90+
SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON
91+
SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON
92+
SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON
93+
SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON
94+
SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON
95+
8996
BO_ 432 STANDSTILL: 7 VSA
9097
SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON
9198
SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON
@@ -164,7 +171,7 @@ BO_ 780 ACC_HUD: 8 ADAS
164171
SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY
165172
SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY
166173
SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY
167-
SG_ BOH_2 : 35|1@0+ (1,0) [0|1] "" BDY
174+
SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY
168175
SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY
169176
SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY
170177
SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY
@@ -174,10 +181,12 @@ BO_ 780 ACC_HUD: 8 ADAS
174181
SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY
175182
SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY
176183
SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY
177-
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
178-
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
179184
SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY
185+
SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY
186+
SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY
187+
SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY
180188
SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY
189+
SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY
181190
SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY
182191
SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY
183192

@@ -259,8 +268,8 @@ BO_ 392 GEARBOX: 6 XXX
259268
SG_ GEAR : 36|5@0+ (1,0) [0|31] "" EON
260269

261270
BO_ 399 STEER_STATUS: 6 EPS
262-
SG_ STEER_TORQUE_SENSOR : 7|12@0- (1,0) [-2047.5|2047.5] "tbd" EON
263-
SG_ STEER_TORQUE_MOTOR : 23|16@0- (1,0) [-31000|31000] "tbd" EON
271+
SG_ STEER_TORQUE_SENSOR : 7|12@0- (-1,0) [-2047.5|2047.5] "tbd" EON
272+
SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON
264273
SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON
265274
SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON
266275
SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON

can/SConscript

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Import('env', 'cereal')
2+
3+
import os
4+
from opendbc.can.process_dbc import process
5+
6+
dbcs = []
7+
for x in sorted(os.listdir('../')):
8+
if x.endswith(".dbc"):
9+
def compile_dbc(target, source, env):
10+
process(source[0].path, target[0].path)
11+
in_fn = [os.path.join('../', x), 'dbc_template.cc']
12+
out_fn = os.path.join('dbc_out', x.replace(".dbc", ".cc"))
13+
dbc = env.Command(out_fn, in_fn, compile_dbc)
14+
dbcs.append(dbc)
15+
16+
17+
libdbc = env.SharedLibrary('libdbc', ["dbc.cc", "parser.cc", "packer.cc", "common.cc"]+dbcs, LIBS=["capnp", "kj"])
18+
19+
# packer
20+
env.Command(['packer_pyx.so'],
21+
[libdbc, 'packer_pyx.pyx', 'packer_pyx_setup.py'],
22+
"cd opendbc/can && python3 packer_pyx_setup.py build_ext --inplace")
23+
24+
# parser
25+
env.Command(['parser_pyx.so'],
26+
[libdbc, cereal, 'parser_pyx_setup.py', 'parser_pyx.pyx', 'common.pxd'],
27+
"cd opendbc/can && python3 parser_pyx_setup.py build_ext --inplace")

can/__init__.py

Whitespace-only changes.

can/can_define.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from opendbc.can.parser_pyx import CANDefine # pylint: disable=no-name-in-module, import-error
2+
assert CANDefine

0 commit comments

Comments
 (0)