mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-10-28 01:03:55 +08:00
hardwared: log usb-c connected (#39010)
hardwared: log usb cable connected
This commit is contained in:
@@ -695,6 +695,7 @@ struct PeripheralState {
|
||||
|
||||
struct UsbState {
|
||||
devices @0 :List(Device);
|
||||
connected @1 :Bool;
|
||||
|
||||
struct Device {
|
||||
busnum @0 :UInt8;
|
||||
|
||||
@@ -36,6 +36,10 @@ def read_int(path: Path, base: int = 10) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def cable_connected() -> bool:
|
||||
return read_int(TYPEC_CC_ORIENTATION_PATH) != 0
|
||||
|
||||
|
||||
def usb_devices() -> list[Path]:
|
||||
try:
|
||||
devices = (d for d in USB_DEVICES_PATH.glob("*") if (d / "idVendor").exists())
|
||||
@@ -91,3 +95,4 @@ def set_usb_state(device_state, devices: list[dict]) -> None:
|
||||
chestnut_present = True
|
||||
|
||||
device_state.chestnutPresent = chestnut_present
|
||||
device_state.usbState.connected = cable_connected()
|
||||
|
||||
@@ -12,7 +12,7 @@ from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.selfdrive.ui.lib.prime_state import PrimeState
|
||||
from openpilot.system.ui.lib.application import gui_app
|
||||
from openpilot.common.hardware import HARDWARE, PC
|
||||
from openpilot.common.hardware.usb import TYPEC_CC_ORIENTATION_PATH, get_usb_state, is_chestnut_usb_id, read_int
|
||||
from openpilot.common.hardware.usb import cable_connected, get_usb_state, is_chestnut_usb_id
|
||||
from openpilot.selfdrive.modeld.helpers import chestnut_compiled
|
||||
|
||||
BACKLIGHT_OFFROAD = 65 if HARDWARE.get_device_type() == "mici" else 50
|
||||
@@ -252,7 +252,7 @@ class UIState:
|
||||
self.chestnut_active = self.params.get("ChestnutActive")
|
||||
self.chestnut_loading = self.params.get_bool("ChestnutLoading")
|
||||
now = time.monotonic()
|
||||
if read_int(TYPEC_CC_ORIENTATION_PATH) != 0:
|
||||
if cable_connected():
|
||||
self.usb_disconnected_ts = None
|
||||
if not self.usb_connected:
|
||||
self.usb_connected = True
|
||||
|
||||
Reference in New Issue
Block a user