  
            # Turn off charging for about 10 sec in a thread that does not get killed on SIGINT, and perform measurement here to avoid blocking thermal
            def perform_pulse_measurement(now):
              try:
                set_battery_charging(False)
                time.sleep(5)
  
                # Measure for a few sec to get a good average
                voltages = []
                currents = []
 
</s> remove           current_power = ((get_battery_voltage() / 1000000) * (get_battery_current() / 1000000))
 </s> add           current_power = ((HARDWARE.get_battery_voltage() / 1000000) * (HARDWARE.get_battery_current() / 1000000)) </s> remove                 voltages.append(get_battery_voltage())
                currents.append(get_battery_current())
 </s> add                 voltages.append(HARDWARE.get_battery_voltage())
                currents.append(HARDWARE.get_battery_current()) </s> remove         current_power = 0
        if TICI:
          with open("/sys/class/hwmon/hwmon1/power1_input") as f:
            current_power = int(f.read()) / 1e6
        elif get_battery_status() == 'Discharging':
 </s> add         current_power = HARDWARE.get_current_power_draw()
        if current_power is not None:
          pass
        elif HARDWARE.get_battery_status() == 'Discharging': </s> remove               set_battery_charging(True)
 </s> add               HARDWARE.set_battery_charging(True) </s> remove     msg.thermal.batteryPercent = get_battery_capacity()
    msg.thermal.batteryStatus = get_battery_status()
    msg.thermal.batteryCurrent = get_battery_current()
    msg.thermal.batteryVoltage = get_battery_voltage()
    msg.thermal.usbOnline = get_usb_present()
 </s> add     msg.thermal.batteryPercent = HARDWARE.get_battery_capacity()
    msg.thermal.batteryStatus = HARDWARE.get_battery_status()
    msg.thermal.batteryCurrent = HARDWARE.get_battery_current()
    msg.thermal.batteryVoltage = HARDWARE.get_battery_voltage()
    msg.thermal.usbOnline = HARDWARE.get_usb_present()
              HARDWARE.set_battery_charging(False)
  
            # Turn off charging for about 10 sec in a thread that does not get killed on SIGINT, and perform measurement here to avoid blocking thermal
            def perform_pulse_measurement(now):
              try:
              HARDWARE.set_battery_charging(False)
                time.sleep(5)
  
                # Measure for a few sec to get a good average
                voltages = []
                currents = []
keep keep keep keep replace keep keep keep keep keep
 Move thermald hardware calls into HW abstraction layer (#2630)

* abstracted away hardware calls

* oopsie

* remove bugs

* remove bugs #2

* fix unit test

* removed print

Co-authored-by: Comma Device <device@comma.ai> 
selfdrive/thermald/power_monitoring.py