diff --git a/can/tests/test_packer_parser.py b/can/tests/test_packer_parser.py index ecba4fd..2121359 100644 --- a/can/tests/test_packer_parser.py +++ b/can/tests/test_packer_parser.py @@ -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