Skip to content

Commit

Permalink
merge deprecate busTime
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Jul 31, 2024
2 parents ae58018 + 8e9d368 commit c6ba3ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion can/packer_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ cdef class CANPacker:
pass

cdef vector[uint8_t] val = self.pack(addr, values)
return [addr, 0, (<char *>&val[0])[:val.size()], bus]
return [addr, (<char *>&val[0])[:val.size()], bus]
8 changes: 4 additions & 4 deletions can/parser_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ cdef class CANParser:

def update_strings(self, strings, sendcan=False):
# input format:
# [nanos, [[address, 0, data, src], ...]]
# [[nanos, [[address, 0, data, src], ...], ...]]
# [nanos, [[address, data, src], ...]]
# [[nanos, [[address, data, src], ...], ...]]
for address in self.addresses:
self.vl_all[address].clear()

Expand All @@ -93,8 +93,8 @@ cdef class CANParser:
for f in s[1]:
frame = &(can_data.frames.emplace_back())
frame.address = f[0]
frame.dat = f[2]
frame.src = f[3]
frame.dat = f[1]
frame.src = f[2]
except TypeError:
raise RuntimeError("invalid parameter")

Expand Down
12 changes: 6 additions & 6 deletions can/tests/test_packer_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_packer(self):
for b in range(6):
for i in range(256):
values = {"COUNTER": i}
addr, _, dat, bus = packer.make_can_msg("CAN_FD_MESSAGE", b, values)
addr, dat, bus = packer.make_can_msg("CAN_FD_MESSAGE", b, values)
assert addr == 245
assert bus == b
assert dat[0] == i
Expand Down Expand Up @@ -107,8 +107,8 @@ def rx_steering_msg(values, bad_checksum=False):
msg = packer.make_can_msg("STEERING_CONTROL", 0, values)
if bad_checksum:
# add 1 to checksum
msg[2] = bytearray(msg[2])
msg[2][4] = (msg[2][4] & 0xF0) | ((msg[2][4] & 0x0F) + 1)
msg[1] = bytearray(msg[1])
msg[1][4] = (msg[1][4] & 0xF0) | ((msg[1][4] & 0x0F) + 1)

parser.update_strings([0, [msg]])

Expand Down Expand Up @@ -350,6 +350,6 @@ def test_allow_undefined_msgs(self):
# discovery tests in openpilot first
packer = CANPacker("toyota_nodsu_pt_generated")

assert packer.make_can_msg("ACC_CONTROL", 0, {"UNKNOWN_SIGNAL": 0}) == [835, 0, b'\x00\x00\x00\x00\x00\x00\x00N', 0]
assert packer.make_can_msg("UNKNOWN_MESSAGE", 0, {"UNKNOWN_SIGNAL": 0}) == [0, 0, b'', 0]
assert packer.make_can_msg(0, 0, {"UNKNOWN_SIGNAL": 0}) == [0, 0, b'', 0]
assert packer.make_can_msg("ACC_CONTROL", 0, {"UNKNOWN_SIGNAL": 0}) == [835, b'\x00\x00\x00\x00\x00\x00\x00N', 0]
assert packer.make_can_msg("UNKNOWN_MESSAGE", 0, {"UNKNOWN_SIGNAL": 0}) == [0, b'', 0]
assert packer.make_can_msg(0, 0, {"UNKNOWN_SIGNAL": 0}) == [0, b'', 0]

0 comments on commit c6ba3ed

Please sign in to comment.