Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
18 changes: 16 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,33 @@ on:

jobs:
tests:
name: ./test.sh
name: ./test.sh (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ${{ github.repository == 'commaai/opendbc' && 'namespace-profile-amd64-8x16' || 'ubuntu-24.04' }}
- os: ${{ github.repository == 'commaai/opendbc' && 'namespace-profile-macos-8x14' || 'macos-latest' }}
- os: windows-latest
shell: msys2 {0}
timeout: 180 # a 4-core GitHub-hosted runner: the unit tests alone take most of a minute there
defaults:
run:
shell: ${{ matrix.shell || 'bash -e {0}' }}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
if: runner.os == 'Windows'
with:
msystem: CLANG64
path-type: inherit # uv and Git for Windows stay visible
install: mingw-w64-clang-x86_64-clang # cc for libsafety
- uses: astral-sh/setup-uv@v5
if: runner.os == 'Windows'
- uses: commaai/timeout@v1
with:
timeout: ${{ github.repository == 'commaai/opendbc' && '90' || '999' }}
timeout: ${{ matrix.timeout || (github.repository == 'commaai/opendbc' && '90' || '999') }}
- run: ./test.sh

safety_tests:
Expand Down
2 changes: 2 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ test:
run: cpplint --exclude=opendbc/can/*_pyx.cpp --recursive --quiet --counting=detailed --linelength=240 --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces opendbc/
misra:
run: opendbc/safety/tests/misra/test_misra.sh
skip:
- run: test "$(uname -o)" = Msys # TODO: drop with the cppcheck exclusion in setup.sh

# *** tests ***
unittest:
Expand Down
2 changes: 1 addition & 1 deletion opendbc/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def get_interface_attr(attr: str, combine_brands: bool = False, ignore_none: boo
result = {}
for car_folder in sorted([x[0] for x in os.walk(BASEDIR)]):
try:
brand_name = car_folder.split('/')[-1]
brand_name = os.path.basename(car_folder)
brand_values = __import__(f'opendbc.car.{brand_name}.{INTERFACE_ATTR_FILE.get(attr, "values")}', fromlist=[attr])
if hasattr(brand_values, attr) or not ignore_none:
attr_data = getattr(brand_values, attr, None)
Expand Down
2,160 changes: 1,080 additions & 1,080 deletions opendbc/dbc/ESR.dbc

Large diffs are not rendered by default.

154 changes: 77 additions & 77 deletions opendbc/dbc/mazda_rx8.dbc
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
VERSION ""
NS_ :
NS_DESC_
CM_
BA_DEF_
BA_
VAL_
CAT_DEF_
CAT_
FILTER
BA_DEF_DEF_
EV_DATA_
ENVVAR_DATA_
SGTYPE_
SGTYPE_VAL_
BA_DEF_SGTYPE_
BA_SGTYPE_
SIG_TYPE_REF_
VAL_TABLE_
SIG_GROUP_
SIG_VALTYPE_
SIGTYPE_VALTYPE_
BO_TX_BU_
BA_DEF_REL_
BA_REL_
BA_DEF_DEF_REL_
BU_SG_REL_
BU_EV_REL_
BU_BO_REL_
SG_MUL_VAL_
BS_:
BU_: PowertrainControlModule InstrumentCluster ElectricPowerSteering AntilockBrakeSystem
BO_ 129 steering: 8 ElectricPowerSteering
SG_ SteeringAngle : 23|16@0- (1,0) [0|0] "deg" Vector__XXX
BO_ 513 speed: 8 PowertrainControlModule
SG_ EngineRPM : 7|16@0+ (0.25,0) [0|0] "rpm" Vector__XXX
SG_ VehicleSpeed : 39|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
SG_ AcceleratorPos : 55|8@0+ (0.5,0) [0|0] "%" Vector__XXX
BO_ 592 throttle_body: 8 PowertrainControlModule
SG_ IntakeAirTemperature : 31|8@0+ (1,-40) [0|0] "Cel" Vector__XXX
SG_ AcceleratorPedalSensorRaw : 23|8@0+ (1,0) [0|0] "" Vector__XXX
SG_ AcceleratorPedalSensorFiltered : 55|8@0+ (1,0) [0|0] "" Vector__XXX
BO_ 658 brake_controls: 8 PowertrainControlModule
SG_ BrakePedalSwitch : 43|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ ParkingBrakeSwitch : 38|1@1+ (1,0) [0|0] "" Vector__XXX
BO_ 1056 coolant: 8 PowertrainControlModule
SG_ CoolantTemperature : 7|8@0+ (1,-40) [0|0] "Cel" Vector__XXX
BO_ 1072 instrument_cluster: 8 InstrumentCluster
SG_ FuelLevel : 7|8@0+ (0.392156,0) [0|0] "%" Vector__XXX
SG_ FuelTankSensorLeft : 15|8@0+ (1,0) [0|0] "" Vector__XXX
SG_ FuelTankSensorRight : 23|8@0+ (1,0) [0|0] "" Vector__XXX
BO_ 1200 wheel_speed: 8 AntilockBrakeSystem
SG_ WheelSpeedFL : 7|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
SG_ WheelSpeedFR : 23|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
SG_ WheelSpeedRL : 39|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
SG_ WheelSpeedRR : 55|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
CM_ SG_ 129 SteeringAngle "Steering wheel angle: positive is right and negative is left";
CM_ SG_ 513 AcceleratorPos "processed interpretation of AcceleratorPedalSensor values";
CM_ SG_ 1072 FuelTankSensorLeft "lower sensor values indicate a more full tank";
CM_ SG_ 1072 FuelTankSensorRight "lower sensor values indicate a more full tank";
VERSION ""


NS_ :
NS_DESC_
CM_
BA_DEF_
BA_
VAL_
CAT_DEF_
CAT_
FILTER
BA_DEF_DEF_
EV_DATA_
ENVVAR_DATA_
SGTYPE_
SGTYPE_VAL_
BA_DEF_SGTYPE_
BA_SGTYPE_
SIG_TYPE_REF_
VAL_TABLE_
SIG_GROUP_
SIG_VALTYPE_
SIGTYPE_VALTYPE_
BO_TX_BU_
BA_DEF_REL_
BA_REL_
BA_DEF_DEF_REL_
BU_SG_REL_
BU_EV_REL_
BU_BO_REL_
SG_MUL_VAL_

BS_:

BU_: PowertrainControlModule InstrumentCluster ElectricPowerSteering AntilockBrakeSystem


BO_ 129 steering: 8 ElectricPowerSteering
SG_ SteeringAngle : 23|16@0- (1,0) [0|0] "deg" Vector__XXX

BO_ 513 speed: 8 PowertrainControlModule
SG_ EngineRPM : 7|16@0+ (0.25,0) [0|0] "rpm" Vector__XXX
SG_ VehicleSpeed : 39|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
SG_ AcceleratorPos : 55|8@0+ (0.5,0) [0|0] "%" Vector__XXX

BO_ 592 throttle_body: 8 PowertrainControlModule
SG_ IntakeAirTemperature : 31|8@0+ (1,-40) [0|0] "Cel" Vector__XXX
SG_ AcceleratorPedalSensorRaw : 23|8@0+ (1,0) [0|0] "" Vector__XXX
SG_ AcceleratorPedalSensorFiltered : 55|8@0+ (1,0) [0|0] "" Vector__XXX

BO_ 658 brake_controls: 8 PowertrainControlModule
SG_ BrakePedalSwitch : 43|1@1+ (1,0) [0|0] "" Vector__XXX
SG_ ParkingBrakeSwitch : 38|1@1+ (1,0) [0|0] "" Vector__XXX

BO_ 1056 coolant: 8 PowertrainControlModule
SG_ CoolantTemperature : 7|8@0+ (1,-40) [0|0] "Cel" Vector__XXX

BO_ 1072 instrument_cluster: 8 InstrumentCluster
SG_ FuelLevel : 7|8@0+ (0.392156,0) [0|0] "%" Vector__XXX
SG_ FuelTankSensorLeft : 15|8@0+ (1,0) [0|0] "" Vector__XXX
SG_ FuelTankSensorRight : 23|8@0+ (1,0) [0|0] "" Vector__XXX

BO_ 1200 wheel_speed: 8 AntilockBrakeSystem
SG_ WheelSpeedFL : 7|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
SG_ WheelSpeedFR : 23|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
SG_ WheelSpeedRL : 39|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX
SG_ WheelSpeedRR : 55|16@0+ (0.01,-100) [0|0] "kph" Vector__XXX

CM_ SG_ 129 SteeringAngle "Steering wheel angle: positive is right and negative is left";
CM_ SG_ 513 AcceleratorPos "processed interpretation of AcceleratorPedalSensor values";
CM_ SG_ 1072 FuelTankSensorLeft "lower sensor values indicate a more full tank";
CM_ SG_ 1072 FuelTankSensorRight "lower sensor values indicate a more full tank";




11 changes: 8 additions & 3 deletions opendbc/safety/tests/libsafety/libsafety_py.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import subprocess
import sys
import tempfile
from pathlib import Path

Expand All @@ -23,6 +24,8 @@ def _build_libsafety(release: bool = False) -> str:
ldflags = [
'-fsanitize=undefined', '-fno-sanitize-recover=undefined',
]
if sys.platform == 'win32':
cflags += ['-mno-ms-bitfields'] # mingw's MS layout would put CANPacket_t's checksum at byte 8 instead of 5
if not release:
cflags += ['-DALLOW_DEBUG', '-fprofile-arcs', '-ftest-coverage']
ldflags += ['-fprofile-arcs', '-ftest-coverage']
Expand All @@ -44,9 +47,11 @@ def _build_libsafety(release: bool = False) -> str:
unsigned char fd : 1;
unsigned char bus : 3;
unsigned char data_len_code : 4;
unsigned char rejected : 1;
unsigned char returned : 1;
unsigned char extended : 1;
// unsigned int, not the header's unsigned char: identical bits under GCC's rules (packed), and the only
// declaration cffi lays out like the firmware under its MSVC rules on Windows (checksum at byte 5)
unsigned int rejected : 1;
unsigned int returned : 1;
unsigned int extended : 1;
unsigned int addr : 29;
unsigned char checksum;
unsigned char data[64];
Expand Down
12 changes: 10 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@ if ! command -v uv &>/dev/null; then
fi

export UV_PROJECT_ENVIRONMENT="$BASEDIR/.venv"
uv sync --all-extras --all-groups --inexact
source "$PYTHONPATH/.venv/bin/activate"
SYNC_ARGS=()
VENV_BIN=bin
if [[ "$(uname -s)" == MINGW* || "$(uname -s)" == MSYS* ]]; then
# MSYS2 shell with a native Python: the venv keeps its scripts in Scripts/
# TODO: drop the exclusion once comma-deps-cppcheck has a win_amd64 wheel on PyPI; the release-cppcheck shim cannot install on Windows
SYNC_ARGS=(--no-install-package cppcheck)
VENV_BIN=Scripts
fi
uv sync --all-extras --all-groups --inexact "${SYNC_ARGS[@]}"
source "$PYTHONPATH/.venv/$VENV_BIN/activate"
Loading