diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 4ee31547a4..8a37d5853b 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -351,8 +351,15 @@ void can_health_thread() { // set fields healthData.setUptime(health.uptime); + +#ifdef QCOM2 + healthData.setVoltage(std::stoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input"))); + healthData.setCurrent(std::stoi(util::read_file("/sys/class/hwmon/hwmon1/curr1_input"))); +#else healthData.setVoltage(health.voltage); healthData.setCurrent(health.current); +#endif + healthData.setIgnitionLine(health.ignition_line); healthData.setIgnitionCan(health.ignition_can); healthData.setControlsAllowed(health.controls_allowed); diff --git a/selfdrive/thermald/tests/test_power_monitoring.py b/selfdrive/thermald/tests/test_power_monitoring.py index 32a3ea4c92..a733930891 100755 --- a/selfdrive/thermald/tests/test_power_monitoring.py +++ b/selfdrive/thermald/tests/test_power_monitoring.py @@ -20,9 +20,6 @@ with patch("common.realtime.sec_since_boot", new=mock_sec_since_boot): from selfdrive.thermald.power_monitoring import PowerMonitoring, CAR_BATTERY_CAPACITY_uWh, \ CAR_CHARGING_RATE_W, VBATT_PAUSE_CHARGING -def actual_current_to_panda_current(actual_current): - return max(int(((3.3 - (actual_current * 8.25)) * 4096) / 3.3), 0) - TEST_DURATION_S = 50 ALL_PANDA_TYPES = [(hw_type,) for hw_type in [log.HealthData.HwType.whitePanda, log.HealthData.HwType.greyPanda, @@ -40,11 +37,10 @@ class TestPowerMonitoring(unittest.TestCase): params.delete("CarBatteryCapacity") params.delete("DisablePowerDown") - def mock_health(self, ignition, hw_type, car_voltage=12, current=0): + def mock_health(self, ignition, hw_type, car_voltage=12): health = messaging.new_message('health') health.health.hwType = hw_type health.health.voltage = car_voltage * 1e3 - health.health.current = actual_current_to_panda_current(current) health.health.ignitionLine = ignition health.health.ignitionCan = False return health