From 04847f3805fee671a1762d25cf72e26ab0ffead0 Mon Sep 17 00:00:00 2001 From: YassineYousfi Date: Mon, 3 Aug 2026 12:46:46 -0700 Subject: [PATCH] chestnut: add new usb vid (#38517) --- openpilot/common/hardware/usb.py | 5 ++--- openpilot/selfdrive/modeld/helpers.py | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/openpilot/common/hardware/usb.py b/openpilot/common/hardware/usb.py index 0db990ffee..538b3d818b 100644 --- a/openpilot/common/hardware/usb.py +++ b/openpilot/common/hardware/usb.py @@ -1,8 +1,7 @@ import os from pathlib import Path -CHESTNUT_VENDOR_ID = 0xADD1 -CHESTNUT_PRODUCT_ID = 0x0001 +CHESTNUT_USB_IDS = ((0xADD1, 0x0001), (0x3801, 0x0001)) USB_DEVICES_PATH = Path("/sys/bus/usb/devices") @@ -75,7 +74,7 @@ def set_usb_state(device_state, devices: list[dict]) -> None: entry.product = device["product"] entry.linkErrorCount = device["linkErrorCount"] - if (entry.vendorId, entry.productId) == (CHESTNUT_VENDOR_ID, CHESTNUT_PRODUCT_ID): + if (entry.vendorId, entry.productId) in CHESTNUT_USB_IDS: chestnut_present = True device_state.chestnutPresent = chestnut_present diff --git a/openpilot/selfdrive/modeld/helpers.py b/openpilot/selfdrive/modeld/helpers.py index 8516325140..f36259340c 100644 --- a/openpilot/selfdrive/modeld/helpers.py +++ b/openpilot/selfdrive/modeld/helpers.py @@ -7,11 +7,10 @@ import tempfile from pathlib import Path from openpilot.common.file_chunker import get_manifest_path +from openpilot.common.hardware.usb import CHESTNUT_USB_IDS, USB_DEVICES_PATH MODELS_DIR = Path(__file__).resolve().parent / 'models' TG_INPUT_DEVICES_PATH = MODELS_DIR / 'tg_input_devices.json' -USBGPU_VID = 0xADD1 -USBGPU_PID = 0x0001 def get_tg_input_devices(process_name: str, usbgpu: bool): @@ -47,10 +46,10 @@ def load_oob(f): return pickle.load(io.BytesIO(opcodes), buffers=buffers()) def usbgpu_present() -> bool: - for d in Path("/sys/bus/usb/devices").glob("*"): + for d in USB_DEVICES_PATH.glob("*"): try: - if int((d / "idVendor").read_text(), 16) == USBGPU_VID and \ - int((d / "idProduct").read_text(), 16) == USBGPU_PID: + usb_id = (int((d / "idVendor").read_text(), 16), int((d / "idProduct").read_text(), 16)) + if usb_id in CHESTNUT_USB_IDS: return True except Exception: pass