Record modem initialization failures in route logs

This commit is contained in:
firestar5683
2026-11-19 21:20:38 -06:00
parent df9be543f4
commit 033f8725f4
2 changed files with 9 additions and 5 deletions
+8 -4
View File
@@ -19,6 +19,7 @@ from ipaddress import IPv4Address, AddressValueError
from enum import Enum
from openpilot.common.esim.base import WEBBING_ICCID_PREFIX
from openpilot.common.swaglog import cloudlog
logging.basicConfig(
level=logging.INFO,
@@ -302,6 +303,8 @@ class Modem:
return lines
except (RuntimeError, TimeoutError, OSError) as e:
logging.info(f"AT {cmd} failed: {e}")
if cmd in (*AT_INIT, "AT+CGMI", "AT+CGSN", "AT+QCCID", "AT+CIMI", "AT+GMR"):
cloudlog.error(f"modem: {cmd} failed: {e}")
return []
finally:
fcntl.flock(fd, fcntl.LOCK_UN)
@@ -364,7 +367,7 @@ class Modem:
fcntl.flock(fd, fcntl.LOCK_UN)
os.close(fd)
if len(ports) != 2:
logging.warning(f"found AT ports {ports} in {ttys}, retrying")
cloudlog.warning(f"modem: found AT ports {ports} in {ttys}, retrying")
return False
for link, tty in zip((AT_PORT, PPP_PORT), reversed(ports), strict=True):
@@ -383,12 +386,13 @@ class Modem:
return State.INITIALIZING
if not self._init_at_channel():
logging.warning("AT echo still on, retrying")
cloudlog.error("modem: AT channel initialization failed, retrying")
return State.INITIALIZING
identity = self._read_identity()
if not identity["iccid"] or not identity["imei"]:
logging.warning(f"identity read incomplete: {identity}, retrying")
cloudlog.error("modem: identity read incomplete: imei_present=%s iccid_present=%s, retrying",
bool(identity["imei"]), bool(identity["iccid"]))
return State.INITIALIZING
self._configure_modem(identity["modem_version"])
@@ -659,7 +663,7 @@ class Modem:
self._publish_state(state=state.value)
logging.info(f"{prev.value} -> {state.value}")
except Exception:
logging.exception(f"error in {state.value}")
cloudlog.exception(f"modem: error in {state.value}")
state = State.DISCONNECTING
time.sleep(STATE_WAIT)
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "22c9764f8c0d63b67fb62cfbaccb0210b63902caab4c3de7f934490b666df277", "schema_version": 1}
{"protected_inventory_sha256": "5ed9c20c2a229b2eb683c3829c641dff0d98f7313a1d6b1f05b42672cdf87284", "schema_version": 1}