Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make CANParser.vl_all not use a defaultdict #1437

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions opendbc/can/parser_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ cdef class CANParser:

self.vl[address] = {name: 0.0 for name in signal_names}
self.vl[name] = self.vl[address]
self.vl_all[address] = defaultdict(list)
self.vl_all[address] = {name: [] for name in signal_names}
self.vl_all[name] = self.vl_all[address]
self.ts_nanos[address] = {name: 0.0 for name in signal_names}
self.ts_nanos[name] = self.ts_nanos[address]
Expand All @@ -71,8 +71,6 @@ cdef class CANParser:
# input format:
# [nanos, [[address, data, src], ...]]
# [[nanos, [[address, data, src], ...], ...]]
for address in self.addresses:
self.vl_all[address].clear()

cdef vector[CanData] can_data_array

Expand All @@ -95,7 +93,8 @@ cdef class CANParser:
except TypeError:
raise RuntimeError("invalid parameter")

updated_addrs = self.can.update(can_data_array)
cdef set updated_addrs = self.can.update(can_data_array)

for addr in updated_addrs:
vl = self.vl[addr]
vl_all = self.vl_all[addr]
Expand All @@ -108,6 +107,12 @@ cdef class CANParser:
vl_all[name] = state.all_vals[i]
ts_nanos[name] = state.last_seen_nanos

# Clear vl_all for unupdated addresses
for addr in self.addresses:
if addr not in updated_addrs:
for value in self.vl_all[addr].values():
value.clear()

return updated_addrs

@property
Expand Down
Loading