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

controlsd: cleanup parsing android log #23421

Merged
merged 5 commits into from
Jan 14, 2022
Merged
Changes from 4 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
23 changes: 7 additions & 16 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
SafetyModel = car.CarParams.SafetyModel

IGNORED_SAFETY_MODES = [SafetyModel.silent, SafetyModel.noOutput]

CSID_MAP = {"0": EventName.roadCameraError, "1": EventName.wideRoadCameraError, "2": EventName.driverCameraError}

class Controls:
def __init__(self, sm=None, pm=None, can_sock=None):
Expand Down Expand Up @@ -311,25 +311,16 @@ def update_events(self, CS):
self.events.add(EventName.fcw)

if TICI:
logs = messaging.drain_sock(self.log_sock, wait_for_one=False)
messages = []
for m in logs:
for m in messaging.drain_sock(self.log_sock, wait_for_one=False):
try:
messages.append(m.androidLog.message)
msg = m.androidLog.message
if any(err in msg for err in ("ERROR_CRC", "ERROR_ECC", "ERROR_STREAM_UNDERFLOW", "APPLY FAILED")):
csid = msg.split("CSID:")[-1].split(" ")[0]
if evt := CSID_MAP.get(csid, None):
self.events.add(evt)
adeebshihadeh marked this conversation as resolved.
Show resolved Hide resolved
except UnicodeDecodeError:
pass

for err in ("ERROR_CRC", "ERROR_ECC", "ERROR_STREAM_UNDERFLOW", "APPLY FAILED"):
for m in messages:
if err not in m:
continue

csid = m.split("CSID:")[-1].split(" ")[0]
evt = {"0": EventName.roadCameraError, "1": EventName.wideRoadCameraError,
"2": EventName.driverCameraError}.get(csid, None)
if evt is not None:
self.events.add(evt)

# TODO: fix simulator
if not SIMULATION:
if not NOSENSOR:
Expand Down