Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into master3
Browse files Browse the repository at this point in the history
  • Loading branch information
eFiniLan committed Jul 25, 2024
2 parents bad8a01 + cff2af8 commit 92830e3
Show file tree
Hide file tree
Showing 38 changed files with 79 additions and 482 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Build opendbc
run: ${{ env.RUN }} "cd ../ && scons -j$(nproc) --minimal"
- name: Unit tests
run: ${{ env.RUN }} "pytest"
run: ${{ env.RUN }} "pytest -n logical"

static-analysis:
name: static analysis
Expand Down
18 changes: 0 additions & 18 deletions acura_ilx_2016_can_generated.dbc
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT";


CM_ "Imported file _community.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR
SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR
SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR

BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
SG_ INTERCEPTOR_GAS : 7|16@0+ (1,0) [0|1] "" EON
SG_ INTERCEPTOR_GAS2 : 23|16@0+ (1,0) [0|1] "" EON
SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON
SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON
SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON

VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;


CM_ "Imported file _honda_common.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM
SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON
Expand Down
18 changes: 0 additions & 18 deletions acura_rdx_2018_can_generated.dbc
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
CM_ "AUTOGENERATED FILE, DO NOT EDIT";


CM_ "Imported file _community.dbc starts here";
BO_ 512 GAS_COMMAND: 6 EON
SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR
SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR
SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR
SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR
SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR

BO_ 513 GAS_SENSOR: 6 INTERCEPTOR
SG_ INTERCEPTOR_GAS : 7|16@0+ (1,0) [0|1] "" EON
SG_ INTERCEPTOR_GAS2 : 23|16@0+ (1,0) [0|1] "" EON
SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON
SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON
SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON

VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ;


CM_ "Imported file _honda_common.dbc starts here";
BO_ 304 GAS_PEDAL_2: 8 PCM
SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON
Expand Down
13 changes: 3 additions & 10 deletions can/tests/test_checksums.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#!/usr/bin/env python3
import unittest

from opendbc.can.parser import CANParser
from opendbc.can.packer import CANPacker
from opendbc.can.tests.test_packer_parser import can_list_to_can_capnp


class TestCanChecksums(unittest.TestCase):
class TestCanChecksums:

def test_honda_checksum(self):
"""Test checksums for Honda standard and extended CAN ids"""
Expand Down Expand Up @@ -34,9 +31,5 @@ def test_honda_checksum(self):
can_strings = [can_list_to_can_capnp(msgs), ]
parser.update_strings(can_strings)

self.assertEqual(parser.vl['LKAS_HUD']['CHECKSUM'], std)
self.assertEqual(parser.vl['LKAS_HUD_A']['CHECKSUM'], ext)


if __name__ == "__main__":
unittest.main()
assert parser.vl['LKAS_HUD']['CHECKSUM'] == std
assert parser.vl['LKAS_HUD_A']['CHECKSUM'] == ext
20 changes: 7 additions & 13 deletions can/tests/test_dbc_exceptions.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
#!/usr/bin/env python3

import unittest
import pytest

from opendbc.can.parser import CANParser, CANDefine
from opendbc.can.packer import CANPacker
from opendbc.can.tests import TEST_DBC


class TestCanParserPackerExceptions(unittest.TestCase):
class TestCanParserPackerExceptions:
def test_civic_exceptions(self):
dbc_file = "honda_civic_touring_2016_can_generated"
dbc_invalid = dbc_file + "abcdef"
msgs = [("STEERING_CONTROL", 50)]
with self.assertRaises(RuntimeError):
with pytest.raises(RuntimeError):
CANParser(dbc_invalid, msgs, 0)
with self.assertRaises(RuntimeError):
with pytest.raises(RuntimeError):
CANPacker(dbc_invalid)
with self.assertRaises(RuntimeError):
with pytest.raises(RuntimeError):
CANDefine(dbc_invalid)
with self.assertRaises(KeyError):
with pytest.raises(KeyError):
CANDefine(TEST_DBC)

parser = CANParser(dbc_file, msgs, 0)
with self.assertRaises(RuntimeError):
with pytest.raises(RuntimeError):
parser.update_strings([b''])

# Everything is supposed to work below
CANParser(dbc_file, msgs, 0)
CANParser(dbc_file, [], 0)
CANPacker(dbc_file)
CANDefine(dbc_file)


if __name__ == "__main__":
unittest.main()
15 changes: 4 additions & 11 deletions can/tests/test_dbc_parser.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#!/usr/bin/env python3
import unittest

from opendbc.can.parser import CANParser
from opendbc.can.tests import ALL_DBCS


class TestDBCParser(unittest.TestCase):
class TestDBCParser:
def test_enough_dbcs(self):
# sanity check that we're running on the real DBCs
self.assertGreater(len(ALL_DBCS), 20)
assert len(ALL_DBCS) > 20

def test_parse_all_dbcs(self):
def test_parse_all_dbcs(self, subtests):
"""
Dynamic DBC parser checks:
- Checksum and counter length, start bit, endianness
Expand All @@ -20,9 +17,5 @@ def test_parse_all_dbcs(self):
"""

for dbc in ALL_DBCS:
with self.subTest(dbc=dbc):
with subtests.test(dbc=dbc):
CANParser(dbc, [], 0)


if __name__ == "__main__":
unittest.main()
37 changes: 14 additions & 23 deletions can/tests/test_define.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
#!/usr/bin/env python3
import unittest

from opendbc.can.can_define import CANDefine
from opendbc.can.tests import ALL_DBCS


class TestCADNDefine(unittest.TestCase):
class TestCADNDefine:
def test_civic(self):

dbc_file = "honda_civic_touring_2016_can_generated"
defs = CANDefine(dbc_file)

self.assertDictEqual(defs.dv[399], defs.dv['STEER_STATUS'])
self.assertDictEqual(defs.dv[399],
{'STEER_STATUS':
{7: 'PERMANENT_FAULT',
6: 'TMP_FAULT',
5: 'FAULT_1',
4: 'NO_TORQUE_ALERT_2',
3: 'LOW_SPEED_LOCKOUT',
2: 'NO_TORQUE_ALERT_1',
0: 'NORMAL'}
}
)

def test_all_dbcs(self):
assert defs.dv[399] == defs.dv['STEER_STATUS']
assert defs.dv[399] == {'STEER_STATUS':
{7: 'PERMANENT_FAULT',
6: 'TMP_FAULT',
5: 'FAULT_1',
4: 'NO_TORQUE_ALERT_2',
3: 'LOW_SPEED_LOCKOUT',
2: 'NO_TORQUE_ALERT_1',
0: 'NORMAL'}
}

def test_all_dbcs(self, subtests):
# Asserts no exceptions on all DBCs
for dbc in ALL_DBCS:
with self.subTest(dbc=dbc):
with subtests.test(dbc=dbc):
CANDefine(dbc)


if __name__ == "__main__":
unittest.main()
Loading

0 comments on commit 92830e3

Please sign in to comment.