diff --git a/common/android.py b/common/android.py index 77c64ff792..71e57d2a56 100644 --- a/common/android.py +++ b/common/android.py @@ -5,6 +5,9 @@ import re import struct import subprocess import random +from cereal import log + +NetworkType = log.ThermalData.NetworkType ANDROID = os.path.isfile('/EON') @@ -90,7 +93,7 @@ def parse_service_call_bytes(ret): except Exception: return None -def get_network_type(NetworkType): +def get_network_type(): wifi_check = parse_service_call_string(service_call(["connectivity", "2"])) if wifi_check is None: return NetworkType.none diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py index fbeb580d03..2fcd9685c2 100755 --- a/selfdrive/thermald.py +++ b/selfdrive/thermald.py @@ -4,6 +4,7 @@ import json import copy import datetime import psutil +import subprocess from smbus2 import SMBus from cereal import log from common.android import ANDROID, get_network_type @@ -159,6 +160,8 @@ def thermald_thread(): usb_power = True usb_power_prev = True + network_type = NetworkType.none + current_filter = FirstOrderFilter(0., CURRENT_TAU, DT_TRML) health_prev = None fw_version_match_prev = True @@ -189,10 +192,15 @@ def thermald_thread(): if health is not None: usb_power = health.health.usbPowerMode != log.HealthData.UsbPowerMode.client + try: + network_type = get_network_type() + except subprocess.CalledProcessError: + pass + msg.thermal.freeSpace = get_available_percent(default=100.0) / 100.0 msg.thermal.memUsedPercent = int(round(psutil.virtual_memory().percent)) msg.thermal.cpuPerc = int(round(psutil.cpu_percent())) - msg.thermal.networkType = get_network_type(NetworkType) + msg.thermal.networkType = network_type try: with open("/sys/class/power_supply/battery/capacity") as f: