Skip to content

Commit

Permalink
CANPacker: fix incorrect counters assignment (#1047)
Browse files Browse the repository at this point in the history
* fix counter

* catch this issue in test case
  • Loading branch information
deanlee committed Jun 6, 2024
1 parent 2ed4225 commit b0ca681
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions can/packer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ std::vector<uint8_t> CANPacker::pack(uint32_t address, const std::vector<SignalP
}
set_value(ret, sig, ival);

counter_set = counter_set || (sigval.name == "COUNTER");
if (counter_set) {
if (sigval.name == "COUNTER") {
counters[address] = sigval.value;
counter_set = true;
}
}

Expand Down
1 change: 1 addition & 0 deletions can/tests/test_packer_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test_packer_counter(self):
cnt = random.randint(0, 255)
msg = packer.make_can_msg("CAN_FD_MESSAGE", 0, {
"COUNTER": cnt,
"SIGNED": 0
})
dat = can_list_to_can_capnp([msg, ])
parser.update_strings([dat])
Expand Down

0 comments on commit b0ca681

Please sign in to comment.