C++ CAN Packer, add test for scale/offset (#455)

This commit is contained in:
Willem Melching 2021-10-20 15:48:15 +02:00 committed by GitHub
parent df8d3e63f0
commit c7caba4a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -58,6 +58,29 @@ class TestCanParserPacker(unittest.TestCase):
idx += 1
def test_scale_offset(self):
"""Test that both scale and offset are correctly preserved"""
dbc_file = "honda_civic_touring_2016_can_generated"
signals = [
("USER_BRAKE", "VSA_STATUS", 0),
]
checks = [("VSA_STATUS", 50)]
parser = CANParser(dbc_file, signals, checks, 0)
packer = CANPacker(dbc_file)
idx = 0
for brake in range(0, 100):
values = {"USER_BRAKE": brake}
msgs = packer.make_can_msg("VSA_STATUS", 0, values, idx)
bts = can_list_to_can_capnp([msgs])
parser.update_string(bts)
self.assertAlmostEqual(parser.vl["VSA_STATUS"]["USER_BRAKE"], brake)
idx += 1
def test_subaru(self):
# Subuaru is little endian