Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023-04-26 #5

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b79b8f5
CANParser: pass string by referer (#796)
deanlee Mar 27, 2023
21b8f28
GM: Add single pedal mode signals for Bolt EV/EUV (#789)
nworb-cire Mar 27, 2023
ee9f7e6
dbc.cc: put check for duplicate message name behind flag (#800)
pd0wm Mar 27, 2023
1f0e04f
libdbc: build both static and shared library (#786)
deanlee Mar 27, 2023
636a61b
More on Nissan (#746)
rusefillc Mar 27, 2023
8c5f9c4
hyundai_2015_ccan.dbc: fix signal scale (#732)
seonghoony Mar 28, 2023
cc966f5
CANPacker: pass values by reference in cython (#803)
deanlee Mar 28, 2023
bb3bc2b
VW PQ: corrections to EPB_1 (#804)
FLcruising Mar 30, 2023
0ff2503
CANParser: add performance test (#801)
deanlee Mar 31, 2023
9a1de83
CANParser: use emplace_back to reduce the cost of copying values (#797)
deanlee Mar 31, 2023
f01929f
CANParser: improve cython performance (#802)
deanlee Apr 2, 2023
9c851fa
CI: set PYTHONWARNINGS=error (#806)
adeebshihadeh Apr 2, 2023
8a3c9a7
honda_civic_ex_2022: add BRAKE_MODULE (#811)
sshane Apr 7, 2023
f9837ff
Subaru: add infotainment status message (#809)
jnewb1 Apr 8, 2023
3c81860
test parser: bump up one signal threshold
adeebshihadeh Apr 8, 2023
f50e9d7
CANParser: add msg name to debug prints (#813)
adeebshihadeh Apr 13, 2023
933d784
Honda Radarless: add a cruise related signal (#807)
sshane Apr 14, 2023
342c032
VW MQB: Cleanup HCA control message (#805)
jyoung8607 Apr 15, 2023
82779a8
pre-commit: autoupdate hooks (#818)
github-actions[bot] Apr 16, 2023
613cd27
CI: add job to update pre-commit hooks (#817)
adeebshihadeh Apr 16, 2023
003baff
switch to pat
adeebshihadeh Apr 16, 2023
7191f44
CI: split up jobs + update requirements (#819)
adeebshihadeh Apr 16, 2023
b7546cd
remove duplicate signal names from Honda DBCs (#822)
pd0wm Apr 17, 2023
9eec533
DBC parser: assert no duplicate signal names in msg (#821)
pd0wm Apr 17, 2023
d40e429
Subaru: more infotainment signals (#823)
sshane Apr 17, 2023
5adb62b
fix parser perf test (#827)
adeebshihadeh Apr 21, 2023
8faada0
refactor CANParser to improve performance (#795)
deanlee Apr 23, 2023
7d46ed3
Reverted ignored checks
eFiniLan Apr 23, 2023
23b83b5
Toyota: add comment for CLUTCH->ACC_FAULTED (#829)
sshane Apr 25, 2023
35d8104
Merge remote-tracking branch 'origin' into 2023-04-26
eFiniLan Apr 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: repo

on:
schedule:
- cron: "0 15 * * 2"
workflow_dispatch:

jobs:
pre-commit-autoupdate:
name: pre-commit autoupdate
runs-on: ubuntu-20.04
container:
image: ghcr.io/commaai/opendbc:latest
steps:
- uses: actions/checkout@v3
- name: pre-commit autoupdate
run: |
git config --global --add safe.directory '*'
pre-commit autoupdate
- name: Create Pull Request
uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5
with:
token: ${{ secrets.ACTIONS_CREATE_PR_PAT }}
commit-message: Update pre-commit hook versions
title: 'pre-commit: autoupdate hooks'
branch: pre-commit-updates
base: master
delete-branch: true
63 changes: 43 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,55 @@ name: tests
on: [push, pull_request]

env:
RUN: docker run --shm-size 1G --rm opendbc /bin/sh -c
RUN: docker run -v $GITHUB_WORKSPACE:/project/opendbc -w /project/opendbc -e PYTHONWARNINGS=error --shm-size 1G --rm opendbc /bin/bash -c
BUILD: |
docker pull $(grep -ioP '(?<=^from)\s+\S+' Dockerfile) || true
docker pull ghcr.io/commaai/opendbc:latest || true
docker build --cache-from ghcr.io/commaai/opendbc:latest -t opendbc -f Dockerfile .
PYTHONWARNINGS: error

jobs:
test:
unit-tests:
name: unit tests
runs-on: ubuntu-20.04
#strategy:
# fail-fast: false
# matrix:
# run: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: eval "$BUILD"
- name: Static analysis
run: |
docker run opendbc bash -c "cd opendbc && git init && git add -A && pre-commit run --all"
- name: Generator test
run: |
docker run opendbc bash -c "cd opendbc/generator && ./test_generator.py"
- name: Unit tests
run: |
docker run opendbc bash -c "python -m unittest discover opendbc"
- name: Push to dockerhub
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/opendbc'
run: |
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
docker tag opendbc ghcr.io/commaai/opendbc:latest
docker push ghcr.io/commaai/opendbc:latest
- uses: actions/checkout@v3
- name: Build Docker image
run: eval "$BUILD"
- name: Build opendbc
run: ${{ env.RUN }} "cd ../ && scons -j$(nproc)"
- name: Unit tests
run: ${{ env.RUN }} "python -m unittest discover ."

static-analysis:
name: static analysis
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: eval "$BUILD"
- name: Build opendbc
run: ${{ env.RUN }} "cd ../ && scons -j$(nproc)"
- name: pre-commit
# TODO: a package pre-commit installs has a warning, remove the unset once that's fixed
run: ${{ env.RUN }} "unset PYTHONWARNINGS && pre-commit run --all"
- name: Generator test
run: ${{ env.RUN }} "generator/test_generator.py"

docker-push:
name: docker push
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'commaai/opendbc'
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: eval "$BUILD"
- name: Push to dockerhub
run: |
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
docker tag opendbc ghcr.io/commaai/opendbc:latest
docker push ghcr.io/commaai/opendbc:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.sconsign.dblite

can/*.so
can/*.a
can/build/
can/obj/
can/packer_pyx.cpp
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-ast
- id: check-yaml
- id: check-merge-conflict
- id: check-symlinks
- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
rev: v2.2.4
hooks:
- id: codespell
exclude: '\.dbc$'
args:
- --check-hidden
- --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.971
rev: v1.2.0
hooks:
- id: mypy
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8
exclude: 'site_scons/'
Expand Down
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,14 @@ RUN pip install --no-cache-dir pre-commit==2.15.0 pylint==2.5.2

ENV PYTHONPATH=/project

RUN git config --global --add safe.directory '*'

WORKDIR /project
# TODO: Add tag to cereal
RUN git clone https://github.com/commaai/cereal.git /project/cereal && \
cd /project/cereal && \
git checkout 959ff79963b80829be9902d146c31fda44dbbd20
git checkout 959ff79963b80829be9902d146c31fda44dbbd20 && \
rm -rf .git && \
scons -j$(nproc)

COPY SConstruct .
COPY ./site_scons /project/site_scons
COPY . /project/opendbc

RUN rm -rf /project/opendbc/.git && \
rm -rf /project/cereal/.git
RUN scons -c && scons -j$(nproc)
2 changes: 1 addition & 1 deletion acura_ilx_2016_can_generated.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ BO_ 829 LKAS_HUD: 5 ADAS
SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY
SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY
SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY
SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY
SG_ BOH_2 : 23|2@0+ (1,0) [0|4] "" BDY
SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY
SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY
SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY
Expand Down
2 changes: 1 addition & 1 deletion acura_rdx_2018_can_generated.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ BO_ 829 LKAS_HUD: 5 ADAS
SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY
SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY
SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY
SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY
SG_ BOH_2 : 23|2@0+ (1,0) [0|4] "" BDY
SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY
SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY
SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY
Expand Down
6 changes: 3 additions & 3 deletions acura_rdx_2020_can_generated.dbc
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ BO_ 13274 LKAS_HUD_A: 5 ADAS
SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY
SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY
SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY
SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY
SG_ BOH_2 : 23|2@0+ (1,0) [0|4] "" BDY
SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY
SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY
SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY
Expand All @@ -378,7 +378,7 @@ BO_ 13275 LKAS_HUD_B: 8 ADAS
SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY
SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY
SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY
SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY
SG_ BOH_2 : 23|2@0+ (1,0) [0|4] "" BDY
SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY
SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY
SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY
Expand Down Expand Up @@ -436,7 +436,7 @@ BO_ 829 LKAS_HUD: 5 ADAS
SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY
SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY
SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY
SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY
SG_ BOH_2 : 23|2@0+ (1,0) [0|4] "" BDY
SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY
SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY
SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY
Expand Down
9 changes: 8 additions & 1 deletion can/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import os
envDBC = env.Clone()
dbc_file_path = '-DDBC_FILE_PATH=\'"%s"\'' % (envDBC.Dir("..").abspath)
envDBC['CXXFLAGS'] += [dbc_file_path]
libdbc = envDBC.SharedLibrary('libdbc', ["dbc.cc", "parser.cc", "packer.cc", "common.cc"], LIBS=[common, "capnp", "kj", "zmq"])
src = ["dbc.cc", "parser.cc", "packer.cc", "common.cc"]
libs = [common, "capnp", "kj", "zmq"]

# shared library for openpilot
libdbc = envDBC.SharedLibrary('libdbc', src, LIBS=libs)

# static library for tools like cabana
envDBC.Library('libdbc_static', src, LIBS=libs)

# Build packer and parser
lenv = envCython.Clone()
Expand Down
4 changes: 3 additions & 1 deletion can/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ unsigned int pedal_checksum(uint32_t address, const Signal &sig, const std::vect

class MessageState {
public:
std::string name;
uint32_t address;
unsigned int size;

Expand Down Expand Up @@ -80,11 +81,12 @@ class CANParser {
CANParser(int abus, const std::string& dbc_name, bool ignore_checksum, bool ignore_counter);
#ifndef DYNAMIC_CAPNP
void update_string(const std::string &data, bool sendcan);
void update_strings(const std::vector<std::string> &data, std::vector<SignalValue> &vals, bool sendcan);
void UpdateCans(uint64_t sec, const capnp::List<cereal::CanData>::Reader& cans);
#endif
void UpdateCans(uint64_t sec, const capnp::DynamicStruct::Reader& cans);
void UpdateValid(uint64_t sec);
std::vector<SignalValue> query_latest();
void query_latest(std::vector<SignalValue> &vals, uint64_t last_ts = 0);
};

class CANPacker {
Expand Down
5 changes: 2 additions & 3 deletions can/common.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ cdef extern from "common.h":
bool can_valid
bool bus_timeout
CANParser(int, string, vector[MessageParseOptions], vector[SignalParseOptions])
void update_string(string, bool)
vector[SignalValue] query_latest()
void update_strings(vector[string]&, vector[SignalValue]&, bool)

cdef cppclass CANPacker:
CANPacker(string)
vector[uint8_t] pack(uint32_t, vector[SignalPackValue])
vector[uint8_t] pack(uint32_t, vector[SignalPackValue]&)
2 changes: 1 addition & 1 deletion can/common_dbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ typedef struct ChecksumState {
} ChecksumState;
#ifndef QCOM
DBC* dbc_parse(const std::string& dbc_path);
DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, ChecksumState *checksum = nullptr);
DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, ChecksumState *checksum = nullptr, bool allow_duplicate_msg_name=false);
const DBC* dbc_lookup(const std::string& dbc_name);
std::vector<std::string> get_dbc_names();
#else
Expand Down
14 changes: 11 additions & 3 deletions can/dbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ void set_signal_type(Signal& s, ChecksumState* chk, const std::string& dbc_name,
}
}

DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, ChecksumState *checksum) {
DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, ChecksumState *checksum, bool allow_duplicate_msg_name) {
uint32_t address = 0;
std::set<uint32_t> address_set;
std::set<std::string> msg_name_set;
std::map<uint32_t, std::set<std::string>> signal_name_sets;
std::map<uint32_t, std::vector<Signal>> signals;
DBC* dbc = new DBC;
dbc->name = dbc_name;
Expand Down Expand Up @@ -138,8 +139,11 @@ DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, Ch
// check for duplicates
DBC_ASSERT(address_set.find(address) == address_set.end(), "Duplicate message address: " << address << " (" << msg.name << ")");
address_set.insert(address);
DBC_ASSERT(msg_name_set.find(msg.name) == msg_name_set.end(), "Duplicate message name: " << msg.name);
msg_name_set.insert(msg.name);

if (!allow_duplicate_msg_name) {
DBC_ASSERT(msg_name_set.find(msg.name) == msg_name_set.end(), "Duplicate message name: " << msg.name);
msg_name_set.insert(msg.name);
}
} else if (startswith(line, "SG_ ")) {
// new signal
int offset = 0;
Expand All @@ -166,6 +170,10 @@ DBC* dbc_parse_from_stream(const std::string &dbc_name, std::istream &stream, Ch
sig.msb = sig.start_bit;
}
DBC_ASSERT(sig.lsb < (64 * 8) && sig.msb < (64 * 8), "Signal out of bounds: " << line);

// Check for duplicate signal names
DBC_ASSERT(signal_name_sets[address].find(sig.name) == signal_name_sets[address].end(), "Duplicate signal name: " << sig.name);
signal_name_sets[address].insert(sig.name);
} else if (startswith(line, "VAL_ ")) {
// new signal value/definition
bool ret = std::regex_search(line, match, val_regexp);
Expand Down
Loading