Skip to content

Commit

Permalink
Squashed 'opendbc/' changes from f1e69a6cf..4c59163aa
Browse files Browse the repository at this point in the history
4c59163aa two spaces before inline comment
e92e74311 whitespace after comma
5d33ec0f1 two spaces before inline comment
73685b609 fix linter complaint about whitespace around operators
b15edbc1b fix linter complaint about inline comment whitespace
4ac30725b clean up blank lines
0430bfa5c run pre commit in ci (#268)
2ade6eeba Subaru DBC update (#242)
d1185a53e Toyota ACC_CONTROL PERMIT_BRAKING and ACCEL_CMT_ALT speculated definition (#258)
e6766bbbb Update SCC ECU Messages for OP Long Dev. (#267)
b49b9ee75 Add DAW (#175)
3b5cccba0 Fixed up cell voltage readings and added more commands (#220)
8b0449327 Mazda: add missing static bits, tidy up endianness  (#263)
124719992 Add BSD_RCTA to Subaru Global (#244)
af1821f84 fix endianness in signal from new hyundai message
7ef41084b Add gas/brake message for hyundai EVs, from @TK211X
472aabb4f Subaru preglobal update (#260)
45c0d9ecc fix lta message (#262)
11343c108 Library cleanup (#261)
67d70cb86 Fix Toyota message size

git-subtree-dir: opendbc
git-subtree-split: 4c59163aa31b58436fad2f8cbadeacd564887276
  • Loading branch information
Vehicle Researcher committed May 31, 2020
1 parent e0ab166 commit 3e4a769
Show file tree
Hide file tree
Showing 37 changed files with 939 additions and 852 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
set -e
docker build -t opendbc .
name: "Build"
- name: Static analysis
run: |
docker run opendbc bash -c "cd opendbc && git init && git add -A && pre-commit run --all"
- run: |
docker run opendbc bash -c "python -m unittest discover opendbc"
name: "Unit tests"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.mypy_cache/
*.pyc
*.os
*.tmp
Expand Down
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: master
hooks:
- id: check-ast
- id: check-json
- id: check-xml
- id: check-yaml
- repo: https://github.com/pre-commit/mirrors-mypy
rev: master
hooks:
- id: mypy
- repo: https://github.com/PyCQA/flake8
rev: master
hooks:
- id: flake8
args:
- --select=F
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
- --disable=R,C,W
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ubuntu:16.04

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
RUN apt-get update && apt-get install -y libzmq3-dev capnproto libcapnp-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

RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
Expand All @@ -10,16 +10,16 @@ RUN pyenv rehash

COPY requirements.txt /tmp/
RUN pip install -r /tmp/requirements.txt
RUN pip install pre-commit==2.4.0 pylint==2.5.2

ENV PYTHONPATH=/project

WORKDIR /project
# TODO: Add tag to cereal
RUN git clone https://github.com/commaai/cereal.git /project/cereal
RUN /project/cereal/install_capnp.sh

WORKDIR /project

COPY SConstruct .
COPY . /project/opendbc

RUN rm -rf /project/opendbc/.git
RUN scons -c && scons -j$(nproc)
2 changes: 1 addition & 1 deletion can/can_define.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from opendbc.can.parser_pyx import CANDefine # pylint: disable=no-name-in-module, import-error
from opendbc.can.parser_pyx import CANDefine # pylint: disable=no-name-in-module, import-error
assert CANDefine
26 changes: 13 additions & 13 deletions can/dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, fn):

name = dat.group(2)
size = int(dat.group(3))
ids = int(dat.group(1), 0) # could be hex
ids = int(dat.group(1), 0) # could be hex
if ids in self.msgs:
sys.exit("Duplicate address detected %d %s" % (ids, self.name))

Expand All @@ -73,15 +73,15 @@ def __init__(self, fn):
print("bad SG {0}".format(l))

sgname = dat.group(1)
start_bit = int(dat.group(go+2))
signal_size = int(dat.group(go+3))
is_little_endian = int(dat.group(go+4))==1
is_signed = dat.group(go+5)=='-'
factor = int_or_float(dat.group(go+6))
offset = int_or_float(dat.group(go+7))
tmin = int_or_float(dat.group(go+8))
tmax = int_or_float(dat.group(go+9))
units = dat.group(go+10)
start_bit = int(dat.group(go + 2))
signal_size = int(dat.group(go + 3))
is_little_endian = int(dat.group(go + 4)) == 1
is_signed = dat.group(go + 5) == '-'
factor = int_or_float(dat.group(go + 6))
offset = int_or_float(dat.group(go + 7))
tmin = int_or_float(dat.group(go + 8))
tmax = int_or_float(dat.group(go + 9))
units = dat.group(go + 10)

self.msgs[ids][1].append(
DBCSignal(sgname, start_bit, signal_size, is_little_endian,
Expand All @@ -94,15 +94,15 @@ def __init__(self, fn):
if dat is None:
print("bad VAL {0}".format(l))

ids = int(dat.group(1), 0) # could be hex
ids = int(dat.group(1), 0) # could be hex
sgname = dat.group(2)
defvals = dat.group(3)

defvals = defvals.replace("?",r"\?") #escape sequence in C++
defvals = defvals.replace("?", r"\?") # escape sequence in C++
defvals = defvals.split('"')[:-1]

# convert strings to UPPER_CASE_WITH_UNDERSCORES
defvals[1::2] = [d.strip().upper().replace(" ","_") for d in defvals[1::2]]
defvals[1::2] = [d.strip().upper().replace(" ", "_") for d in defvals[1::2]]
defvals = '"'+"".join(str(i) for i in defvals)+'"'

self.def_vals[ids].append((sgname, defvals))
Expand Down
5 changes: 2 additions & 3 deletions can/packer_pyx_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_ext_filename(self, ext_name):


sourcefiles = ['packer_pyx.pyx']
extra_compile_args = ["-std=c++11"]
extra_compile_args = ["-std=c++14"]
ARCH = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() # pylint: disable=unexpected-keyword-arg

if ARCH == "aarch64":
Expand All @@ -54,7 +54,7 @@ def get_ext_filename(self, ext_name):
extra_compile_args=extra_compile_args,
include_dirs=[
BASEDIR,
os.path.join(BASEDIR, 'phonelibs', 'capnp-cpp/include'),
os.path.join(BASEDIR, 'phonelibs'),
],
extra_link_args=[
os.path.join(BASEDIR, 'opendbc', 'can', libdbc),
Expand All @@ -66,4 +66,3 @@ def get_ext_filename(self, ext_name):

if platform.system() == "Darwin":
os.system("install_name_tool -change opendbc/can/libdbc.dylib "+BASEDIR+"/opendbc/can/libdbc.dylib packer_pyx.so")

2 changes: 1 addition & 1 deletion can/parser.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from opendbc.can.parser_pyx import CANParser # pylint: disable=no-name-in-module, import-error
from opendbc.can.parser_pyx import CANParser # pylint: disable=no-name-in-module, import-error
assert CANParser
5 changes: 2 additions & 3 deletions can/parser_pyx_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_ext_filename(self, ext_name):


sourcefiles = ['parser_pyx.pyx']
extra_compile_args = ["-std=c++11"]
extra_compile_args = ["-std=c++14"]
ARCH = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() # pylint: disable=unexpected-keyword-arg

if ARCH == "aarch64":
Expand All @@ -54,7 +54,7 @@ def get_ext_filename(self, ext_name):
extra_compile_args=extra_compile_args,
include_dirs=[
BASEDIR,
os.path.join(BASEDIR, 'phonelibs', 'capnp-cpp/include'),
os.path.join(BASEDIR, 'phonelibs'),
],
extra_link_args=[
os.path.join(BASEDIR, 'opendbc', 'can', libdbc),
Expand All @@ -66,4 +66,3 @@ def get_ext_filename(self, ext_name):

if platform.system() == "Darwin":
os.system("install_name_tool -change opendbc/can/libdbc.dylib "+BASEDIR+"/opendbc/can/libdbc.dylib parser_pyx.so")

8 changes: 4 additions & 4 deletions can/process_dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ def process(in_fn, out_fn):

can_dbc = dbc(in_fn)

msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not in ("COUNTER", "CHECKSUM"))) # process counter and checksums first
# process counter and checksums first
msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not in ("COUNTER", "CHECKSUM")))
for address, ((msg_name, msg_size), msg_sigs) in sorted(can_dbc.msgs.items()) if msg_sigs]

def_vals = {a: sorted(set(b)) for a, b in can_dbc.def_vals.items()} # remove duplicates
def_vals = {a: sorted(set(b)) for a, b in can_dbc.def_vals.items()} # remove duplicates
def_vals = sorted(def_vals.items())

if can_dbc.name.startswith(("honda_", "acura_")):
Expand All @@ -46,7 +47,7 @@ def process(in_fn, out_fn):
checksum_start_bit = 0
counter_start_bit = 0
little_endian = True
elif can_dbc.name.startswith(("subaru_")):
elif can_dbc.name.startswith(("subaru_global_")):
checksum_type = "subaru"
checksum_size = 8
counter_size = None
Expand Down Expand Up @@ -123,4 +124,3 @@ def main():

if __name__ == '__main__':
main()

11 changes: 7 additions & 4 deletions generator/toyota/_toyota_2017.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ BO_ 180 SPEED: 8 XXX
SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX

BO_ 353 DSU_SPEED: 8 XXX
BO_ 353 DSU_SPEED: 7 XXX
SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX

BO_ 452 ENGINE_RPM: 8 CGW
SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS

BO_ 466 PCM_CRUISE: 8 XXX
SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX
SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX
Expand Down Expand Up @@ -128,10 +128,11 @@ BO_ 835 ACC_CONTROL: 8 DSU
SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX
SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX
SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX
SG_ SET_ME_1 : 30|1@0+ (1,0) [0|1] "" HCU
SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU
SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU
SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX

BO_ 836 PRE_COLLISION_2: 8 DSU
SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX
Expand Down Expand Up @@ -285,6 +286,8 @@ CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active";
CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control";
CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control";
CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking";
CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was "SET_ME_1" and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG.";
CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file.";
CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit";
CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel";
CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces";
Expand Down
4 changes: 3 additions & 1 deletion generator/toyota/toyota_nodsu_pt.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ CM_ "IMPORT _comma.dbc"
CM_ "IMPORT _toyota_nodsu_bsm.dbc"

BO_ 401 STEERING_LTA: 8 XXX
SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX
SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX
SG_ SETME_X3 : 29|2@0+ (1,0) [0|3] "" XXX
SG_ PERCENTAGE : 39|8@0+ (1,0) [0|255] "" XXX
Expand All @@ -12,6 +11,9 @@ BO_ 401 STEERING_LTA: 8 XXX
SG_ STEER_ANGLE_CMD : 15|16@0- (0.0573,0) [-540|540] "" XXX
SG_ STEER_REQUEST : 25|1@0+ (1,0) [0|1] "" XXX
SG_ BIT : 30|1@0+ (1,0) [0|1] "" XXX
SG_ COUNTER : 6|6@0+ (1,0) [0|255] "" XXX
SG_ STEER_REQUEST_2 : 0|1@0+ (1,0) [0|1] "" XXX
SG_ SETME_X1 : 7|1@0+ (1,0) [0|1] "" XXX

BO_ 550 BRAKE_MODULE: 8 XXX
SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX
Expand Down
Loading

0 comments on commit 3e4a769

Please sign in to comment.