chestnut: add new usb vid (#38517)

This commit is contained in:
YassineYousfi
2026-08-03 12:46:46 -07:00
committed by GitHub
parent 9002016ac5
commit 04847f3805
2 changed files with 6 additions and 8 deletions
+2 -3
View File
@@ -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
+4 -5
View File
@@ -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