diff --git a/openpilot/common/api/__init__.py b/openpilot/common/api/__init__.py index 45c73e2a0..0199535a6 100644 --- a/openpilot/common/api/__init__.py +++ b/openpilot/common/api/__init__.py @@ -1,4 +1,4 @@ -from openpilot.common.api.comma_connect import CommaConnectApi +from openpilot.common.api.comma_connect import API_HOST as API_HOST, CommaConnectApi class Api: diff --git a/openpilot/common/constants.py b/openpilot/common/constants.py index 7ca425c4b..a20af5029 100644 --- a/openpilot/common/constants.py +++ b/openpilot/common/constants.py @@ -16,6 +16,10 @@ class CV: DEG_TO_RAD = np.pi / 180. RAD_TO_DEG = 1. / DEG_TO_RAD + # Length + METER_TO_FOOT = 3.28084 + METER_TO_MILE = 1. / 1609.344 + # Mass LB_TO_KG = 0.453592 diff --git a/openpilot/common/esim/base.py b/openpilot/common/esim/base.py index 472b523e2..547e36b12 100644 --- a/openpilot/common/esim/base.py +++ b/openpilot/common/esim/base.py @@ -1,6 +1,8 @@ from abc import ABC, abstractmethod from dataclasses import dataclass +WEBBING_ICCID_PREFIX = "8985235" + class LPAError(RuntimeError): pass @@ -19,7 +21,7 @@ class Profile: @property def is_comma(self) -> bool: - return self.provider == 'Webbing' and self.iccid.startswith('8985235') + return self.provider == 'Webbing' and self.iccid.startswith(WEBBING_ICCID_PREFIX) @property def display_name(self) -> str: diff --git a/openpilot/common/gpio.py b/openpilot/common/gpio.py index 8f025a2da..5f4295e7b 100644 --- a/openpilot/common/gpio.py +++ b/openpilot/common/gpio.py @@ -27,16 +27,6 @@ def gpio_read(pin: int) -> bool | None: return val -def gpio_export(pin: int) -> None: - if os.path.isdir(f"/sys/class/gpio/gpio{pin}"): - return - - try: - with open("/sys/class/gpio/export", 'w') as f: - f.write(str(pin)) - except Exception: - print(f"Failed to export gpio {pin}") - @cache def get_irq_action(irq: int) -> list[str]: try: diff --git a/openpilot/common/realtime.py b/openpilot/common/realtime.py index e0b9e8a3a..792226b08 100644 --- a/openpilot/common/realtime.py +++ b/openpilot/common/realtime.py @@ -91,8 +91,13 @@ class Ratekeeper: self.avg_dt.add_value(self._last_monitor_time - prev) lagged = False - remaining = self._next_frame_time - time.monotonic() - self._next_frame_time += self._interval + now = time.monotonic() + remaining = self._next_frame_time - now + if remaining < -self._interval: + # more than a frame behind (e.g. a stall): resync instead of running catch-up frames back-to-back + self._next_frame_time = now + self._interval + else: + self._next_frame_time += self._interval if self._print_delay_threshold is not None and remaining < -self._print_delay_threshold: print(f"{self._process_name} lagging by {-remaining * 1000:.2f} ms") lagged = True diff --git a/openpilot/common/utils.py b/openpilot/common/utils.py index a73d2b822..28b3782a4 100644 --- a/openpilot/common/utils.py +++ b/openpilot/common/utils.py @@ -5,7 +5,6 @@ import contextlib import subprocess import time import functools -from subprocess import Popen, PIPE, TimeoutExpired import zstandard as zstd LOG_COMPRESSION_LEVEL = 10 # little benefit up to level 15. level ~17 is a small step change @@ -157,20 +156,6 @@ def run_cmd_default(cmd: list[str], default: str = "", cwd=None, env=None) -> st return default -@contextlib.contextmanager -def managed_proc(cmd: list[str], env: dict[str, str]): - proc = Popen(cmd, env=env, stdout=PIPE, stderr=PIPE) - try: - yield proc - finally: - if proc.poll() is None: - proc.terminate() - try: - proc.wait(timeout=5) - except TimeoutExpired: - proc.kill() - - def tabulate(tabular_data, headers=(), tablefmt="simple", floatfmt="g", stralign="left", numalign=None): rows = [list(row) for row in tabular_data] diff --git a/openpilot/common/version.h b/openpilot/common/version.h index 5a09588e2..16b875028 100644 --- a/openpilot/common/version.h +++ b/openpilot/common/version.h @@ -1 +1 @@ -#define COMMA_VERSION "0.11.2" +#define COMMA_VERSION "0.11.3"