From 6d8348ccf0756c9a22b23d3d0dc81d88205098df Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Mon, 10 Jun 2024 09:39:32 +0200 Subject: [PATCH 1/3] Change error logging to event logging in athenad.py The logging for an invalid JSON RPC request in athenad.py has been changed from an error log to an event log. The event log still records the request as an error, improving clarity of error handling in the system. --- selfdrive/athena/athenad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/athena/athenad.py b/selfdrive/athena/athenad.py index 37f74bc096..443173e36d 100755 --- a/selfdrive/athena/athenad.py +++ b/selfdrive/athena/athenad.py @@ -178,7 +178,7 @@ def jsonrpc_handler(end_event: threading.Event) -> None: elif "id" in data and ("result" in data or "error" in data): log_recv_queue.put_nowait(data) else: - cloudlog.error("athena.jsonrpc_handler.invalid_request", data=data) + cloudlog.event("athena.jsonrpc_handler.invalid_request", error=True, data=data) raise Exception("not a valid request or response") except queue.Empty: pass From 12841b7bb4091cfeb437eaa815404fabad5548a8 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Mon, 10 Jun 2024 09:40:08 +0200 Subject: [PATCH 2/3] Update sunnylinkd.py to improve logging and connection timeout The commit enhances the logging in the selfdrive/athena/sunnylinkd.py by adding an info statement when the handle_long_poll function starts. It also modifies the create_connection function call, removing the fixed 30 seconds timeout, providing more flexibility for connection time. --- selfdrive/athena/sunnylinkd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/athena/sunnylinkd.py b/selfdrive/athena/sunnylinkd.py index 1b993a534b..ca537149d9 100755 --- a/selfdrive/athena/sunnylinkd.py +++ b/selfdrive/athena/sunnylinkd.py @@ -28,6 +28,7 @@ LOCAL_PORT_WHITELIST = {8022} params = Params() sunnylink_api = SunnylinkApi(params.get("SunnylinkDongleId", encoding='utf-8')) def handle_long_poll(ws: WebSocket, exit_event: threading.Event | None) -> None: + cloudlog.info("sunnylinkd.handle_long_poll started") end_event = threading.Event() threads = [ @@ -169,8 +170,7 @@ def main(exit_event: threading.Event = None): cloudlog.event("sunnylinkd.main.connecting_ws", ws_uri=ws_uri, retries=conn_retries) ws = create_connection(ws_uri, cookie="jwt=" + sunnylink_api.get_token(), - enable_multithread=True, - timeout=30.0) + enable_multithread=True) cloudlog.event("sunnylinkd.main.connected_ws", ws_uri=ws_uri, retries=conn_retries, duration=time.monotonic() - conn_start) conn_start = None From a7699c280f9e8a237d95ee16e73edaf19e0de799 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Mon, 10 Jun 2024 11:14:35 +0200 Subject: [PATCH 3/3] Change log level from info to debug in sunnylinkd.py The logging level for 'pong' and 'ping' messages in sunnylinkd.py has been changed from 'info' to 'debug'. This adjustment will help reduce the level of verbosity in the logs and focus more on significant events. --- selfdrive/athena/sunnylinkd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/athena/sunnylinkd.py b/selfdrive/athena/sunnylinkd.py index ca537149d9..b0c6e8d4dc 100755 --- a/selfdrive/athena/sunnylinkd.py +++ b/selfdrive/athena/sunnylinkd.py @@ -71,7 +71,7 @@ def ws_recv(ws: WebSocket, end_event: threading.Event) -> None: recv_queue.put_nowait(data) cloudlog.debug(f"sunnylinkd.ws_recv.recv {data}") elif opcode in (ABNF.OPCODE_PING, ABNF.OPCODE_PONG): - cloudlog.info(f"sunnylinkd.ws_recv.pong {opcode}") + cloudlog.debug(f"sunnylinkd.ws_recv.pong {opcode}") last_ping = int(time.monotonic() * 1e9) Params().put("LastSunnylinkPingTime", str(last_ping)) except WebSocketTimeoutException: @@ -89,7 +89,7 @@ def ws_ping(ws: WebSocket, end_event: threading.Event) -> None: while not end_event.is_set(): try: ws.ping() - cloudlog.info(f"sunnylinkd.ws_recv.ws_ping: Pinging") + cloudlog.debug(f"sunnylinkd.ws_recv.ws_ping: Pinging") except Exception: cloudlog.exception("sunnylinkd.ws_ping.exception") end_event.set()