diff --git a/selfdrive/pandad/pandad.cc b/selfdrive/pandad/pandad.cc index 7c91fe361..7fbfcb5b1 100644 --- a/selfdrive/pandad/pandad.cc +++ b/selfdrive/pandad/pandad.cc @@ -1,7 +1,6 @@ #include "selfdrive/pandad/pandad.h" #include -#include #include #include #include @@ -24,14 +23,6 @@ ExitHandler do_exit; -struct HwmonState { - std::atomic voltage{0}; - std::atomic current{0}; - std::atomic initialized{false}; -}; - -HwmonState hwmon_state; - bool check_connected(Panda *panda) { if (!panda->connected()) { do_exit = true; @@ -114,26 +105,6 @@ void can_recv(Panda *panda, PubMaster *pm) { } } -void hwmon_thread() { - util::set_thread_name("pandad_hwmon"); - - while (!do_exit) { - double read_time = millis_since_boot(); - uint32_t voltage = Hardware::get_voltage(); - uint32_t current = Hardware::get_current(); - read_time = millis_since_boot() - read_time; - if (read_time > 50) { - LOGW("reading hwmon took %lfms", read_time); - } - - hwmon_state.voltage.store(voltage); - hwmon_state.current.store(current); - hwmon_state.initialized.store(true); - - util::sleep_for(500); - } -} - void fill_panda_state(cereal::PandaState::Builder &ps, cereal::PandaState::PandaType hw_type, const health_t &health) { ps.setVoltage(health.voltage_pkt); ps.setCurrent(health.current_pkt); @@ -264,7 +235,8 @@ std::optional send_panda_states(PubMaster *pm, Panda *panda, bool is_onroa } void send_peripheral_state(Panda *panda, PubMaster *pm) { - if (!hwmon_state.initialized.load()) { + auto health_opt = panda->get_state(); + if (!health_opt) { return; } @@ -276,18 +248,9 @@ void send_peripheral_state(Panda *panda, PubMaster *pm) { auto ps = evt.initPeripheralState(); ps.setPandaType(panda->hw_type); - ps.setVoltage(hwmon_state.voltage.load()); - ps.setCurrent(hwmon_state.current.load()); - - // fall back to panda's voltage and current measurement - if (ps.getVoltage() == 0 && ps.getCurrent() == 0) { - auto health_opt = panda->get_state(); - if (health_opt) { - health_t health = *health_opt; - ps.setVoltage(health.voltage_pkt); - ps.setCurrent(health.current_pkt); - } - } + health_t health = *health_opt; + ps.setVoltage(health.voltage_pkt); + ps.setCurrent(health.current_pkt); uint16_t fan_speed_rpm = panda->get_fan_speed(); ps.setFanSpeedRpm(fan_speed_rpm); @@ -399,9 +362,8 @@ void pandad_run(Panda *panda) { const bool spoofing_started = getenv("STARTED") != nullptr; const bool fake_send = getenv("FAKESEND") != nullptr; - // Start helper threads for event-driven sendcan and slow non-Panda reads. + // Start helper thread for event-driven sendcan. std::thread send_thread(can_send_thread, panda, fake_send); - std::thread hardware_thread(hwmon_thread); RateKeeper rk("pandad", 100); SubMaster sm({"selfdriveState", "deviceState"}); @@ -457,7 +419,6 @@ void pandad_run(Panda *panda) { } send_thread.join(); - hardware_thread.join(); } void pandad_main_thread(std::string serial) { diff --git a/system/athena/registration.py b/system/athena/registration.py index ecc102edf..8548a544f 100755 --- a/system/athena/registration.py +++ b/system/athena/registration.py @@ -54,17 +54,16 @@ def register(show_spinner=False) -> str | None: # Block until we get the imei serial = HARDWARE.get_serial() start_time = time.monotonic() - imei1: str | None = None - imei2: str | None = None - while imei1 is None and imei2 is None: + imei: str | None = None + while imei is None: try: - imei1, imei2 = HARDWARE.get_imei(0), HARDWARE.get_imei(1) + imei = HARDWARE.get_imei() except Exception: cloudlog.exception("Error getting imei, trying again...") time.sleep(1) if time.monotonic() - start_time > 60 and show_spinner: - spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})") + spinner.update(f"registering device - serial: {serial}, IMEI: {imei}") backoff = 0 start_time = time.monotonic() @@ -74,7 +73,7 @@ def register(show_spinner=False) -> str | None: cast(str, private_key), algorithm=jwt_algo) cloudlog.info("getting pilotauth") resp = api_get("v2/pilotauth/", method='POST', timeout=15, - imei=imei1, imei2=imei2, serial=serial, public_key=public_key, register_token=register_token) + imei=imei, imei2="", serial=serial, public_key=public_key, register_token=register_token) if resp.status_code in (402, 403): cloudlog.info(f"Unable to register device, got {resp.status_code}") @@ -89,7 +88,7 @@ def register(show_spinner=False) -> str | None: time.sleep(backoff) if time.monotonic() - start_time > 60 and show_spinner: - spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})") + spinner.update(f"registering device - serial: {serial}, IMEI: {imei}") if show_spinner: spinner.close() diff --git a/system/hardware/base.h b/system/hardware/base.h index 3eded659a..3cb8add78 100644 --- a/system/hardware/base.h +++ b/system/hardware/base.h @@ -12,8 +12,6 @@ class HardwareNone { public: static std::string get_name() { return ""; } static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::UNKNOWN; } - static int get_voltage() { return 0; } - static int get_current() { return 0; } static std::string get_serial() { return "cccccc"; } @@ -24,6 +22,4 @@ public: static void set_ir_power(int percentage) {} static bool PC() { return false; } - static bool TICI() { return false; } - static bool AGNOS() { return false; } }; diff --git a/system/hardware/base.py b/system/hardware/base.py index 0e4fb0b61..bf6523db7 100644 --- a/system/hardware/base.py +++ b/system/hardware/base.py @@ -85,7 +85,7 @@ class HardwareBase(ABC): def get_device_type(self): pass - def get_imei(self, slot) -> str: + def get_imei(self) -> str: return "" def get_serial(self): @@ -142,18 +142,12 @@ class HardwareBase(ABC): def get_gpu_usage_percent(self): return 0 - def get_modem_version(self): - return None - def get_modem_temperatures(self): return [] def initialize_hardware(self): pass - def has_internal_panda(self) -> bool: - return False - def reset_internal_panda(self): pass @@ -163,11 +157,5 @@ class HardwareBase(ABC): def get_modem_data_usage(self): return -1, -1 - def get_voltage(self) -> float: - return 0. - - def get_current(self) -> float: - return 0. - def set_ir_power(self, percent: int): pass diff --git a/system/hardware/hardwared.py b/system/hardware/hardwared.py index 5db73403e..d047ee37c 100755 --- a/system/hardware/hardwared.py +++ b/system/hardware/hardwared.py @@ -17,7 +17,7 @@ from openpilot.common.filter_simple import FirstOrderFilter from openpilot.common.params import Params from openpilot.common.realtime import DT_HW from openpilot.selfdrive.selfdrived.alertmanager import set_offroad_alert -from openpilot.system.hardware import HARDWARE, TICI, AGNOS, PC +from openpilot.system.hardware import HARDWARE, TICI, PC from openpilot.system.loggerd.config import get_available_percent from openpilot.system.statsd import statlog from openpilot.common.swaglog import cloudlog @@ -107,8 +107,6 @@ def hw_state_thread(end_event, hw_queue): count = 0 prev_hw_state = None - modem_version = None - while not end_event.is_set(): # these are expensive calls. update every 10s if (count % int(10. / DT_HW)) == 0: @@ -118,13 +116,6 @@ def hw_state_thread(end_event, hw_queue): if len(modem_temps) == 0 and prev_hw_state is not None: modem_temps = prev_hw_state.modem_temps - # Log modem version once - if AGNOS and (modem_version is None): - modem_version = HARDWARE.get_modem_version() - - if modem_version is not None: - cloudlog.event("modem version", version=modem_version) - tx, rx = HARDWARE.get_modem_data_usage() hw_state = HardwareState( diff --git a/system/hardware/pc/hardware.h b/system/hardware/pc/hardware.h index 71f58b188..c3545f3e5 100644 --- a/system/hardware/pc/hardware.h +++ b/system/hardware/pc/hardware.h @@ -9,6 +9,4 @@ public: static std::string get_name() { return "pc"; } static cereal::InitData::DeviceType get_device_type() { return cereal::InitData::DeviceType::PC; } static bool PC() { return true; } - static bool TICI() { return util::getenv("TICI", 0) == 1; } - static bool AGNOS() { return util::getenv("TICI", 0) == 1; } }; diff --git a/system/hardware/pc/hardware.py b/system/hardware/pc/hardware.py index f3d527429..37775d9bb 100644 --- a/system/hardware/pc/hardware.py +++ b/system/hardware/pc/hardware.py @@ -1,12 +1,10 @@ from cereal import log from openpilot.system.hardware.base import HardwareBase -NetworkType = log.DeviceState.NetworkType - - class Pc(HardwareBase): def get_device_type(self): return "pc" def get_network_type(self): - return NetworkType.wifi + # some stuff is gated on wifi, so just assume for now + return log.DeviceState.NetworkType.wifi diff --git a/system/hardware/tici/hardware.h b/system/hardware/tici/hardware.h index a06ce43b3..95a6d4e01 100644 --- a/system/hardware/tici/hardware.h +++ b/system/hardware/tici/hardware.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -22,7 +21,6 @@ public: static cereal::InitData::DeviceType get_device_type() { static const std::map device_map = { - {"tici", cereal::InitData::DeviceType::TICI}, {"tizi", cereal::InitData::DeviceType::TIZI}, {"mici", cereal::InitData::DeviceType::MICI} }; @@ -31,9 +29,6 @@ public: return it->second; } - static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); } - static int get_current() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input").c_str()); } - static std::string get_serial() { static std::string serial(""); if (serial.empty()) { @@ -54,8 +49,7 @@ public: static void set_ir_power(int percent) { auto device = get_device_type(); - if (device == cereal::InitData::DeviceType::TICI || - device == cereal::InitData::DeviceType::TIZI) { + if (device == cereal::InitData::DeviceType::TIZI) { return; } diff --git a/system/hardware/tici/hardware.py b/system/hardware/tici/hardware.py index 6f3d7e870..35bf4cd08 100644 --- a/system/hardware/tici/hardware.py +++ b/system/hardware/tici/hardware.py @@ -147,9 +147,7 @@ class Tici(HardwareBase): def get_sim_lpa(self) -> LPABase: return TiciLPA() - def get_imei(self, slot): - if slot != 0: - return "" + def get_imei(self): return self.get_modem_state().get('imei', '') def get_network_info(self): @@ -233,9 +231,6 @@ class Tici(HardwareBase): return super().get_network_metered(network_type) - def get_modem_version(self): - return self.get_modem_state().get('modem_version') or None - def get_modem_temperatures(self): return self.get_modem_state().get('temperatures', []) @@ -390,9 +385,6 @@ class Tici(HardwareBase): ms = self.get_modem_state() return ms.get('tx_bytes', -1), ms.get('rx_bytes', -1) - def has_internal_panda(self): - return True - def reset_internal_panda(self): gpio_init(GPIO.STM_RST_N, True) gpio_init(GPIO.STM_BOOT0, True) diff --git a/system/hardware/tici/precise_power_measure.py b/system/hardware/tici/precise_power_measure.py deleted file mode 100755 index 52fe0850a..000000000 --- a/system/hardware/tici/precise_power_measure.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 -import numpy as np -from openpilot.system.hardware.tici.power_monitor import sample_power - -if __name__ == '__main__': - print("measuring for 5 seconds") - for _ in range(3): - pwrs = sample_power() - print(f"mean {np.mean(pwrs):.2f} std {np.std(pwrs):.2f}")