Skip to content

Commit

Permalink
CAN receive error is a comm issue (#23362)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh authored Jan 3, 2022
1 parent 162460e commit 1e41f47
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(self, sm=None, pm=None, can_sock=None):
self.v_cruise_kph_last = 0
self.mismatch_counter = 0
self.cruise_mismatch_counter = 0
self.can_error_counter = 0
self.can_rcv_error_counter = 0
self.last_blinker_frame = 0
self.saturated_count = 0
self.distance_traveled = 0
Expand Down Expand Up @@ -253,7 +253,7 @@ def update_events(self, CS):
LaneChangeState.laneChangeFinishing]:
self.events.add(EventName.laneChange)

if self.can_rcv_error or not CS.canValid:
if not CS.canValid:
self.events.add(EventName.canError)

for i, pandaState in enumerate(self.sm['pandaStates']):
Expand All @@ -273,7 +273,7 @@ def update_events(self, CS):
self.events.add(EventName.radarFault)
elif not self.sm.valid["pandaStates"]:
self.events.add(EventName.usbError)
elif not self.sm.all_alive_and_valid():
elif not self.sm.all_alive_and_valid() or self.can_rcv_error:
self.events.add(EventName.commIssue)
if not self.logged_comm_issue:
invalid = [s for s, valid in self.sm.valid.items() if not valid]
Expand Down Expand Up @@ -378,7 +378,7 @@ def data_sample(self):

# Check for CAN timeout
if not can_strs:
self.can_error_counter += 1
self.can_rcv_error_counter += 1
self.can_rcv_error = True
else:
self.can_rcv_error = False
Expand Down Expand Up @@ -663,7 +663,7 @@ def publish_logs(self, CS, start_time, actuators, lac_log):
controlsState.cumLagMs = -self.rk.remaining * 1000.
controlsState.startMonoTime = int(start_time * 1e9)
controlsState.forceDecel = bool(force_decel)
controlsState.canErrorCounter = self.can_error_counter
controlsState.canErrorCounter = self.can_rcv_error_counter

if self.joystick_mode:
controlsState.lateralControlState.debugState = lac_log
Expand Down

0 comments on commit 1e41f47

Please sign in to comment.