mirror of https://github.com/rusefi/opendbc.git
C++ CAN Packer, add test for scale/offset (#455)
This commit is contained in:
parent
df8d3e63f0
commit
c7caba4a5c
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue