mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-05 13:32:05 +08:00
Add network_type to thermald (#1030)
* add network_type to thermal log
* move get_network_type to android library
old-commit-hash: 770903520d
This commit is contained in:
+1
-1
Submodule cereal updated: 3f01dcf01c...23abef4fdb
@@ -89,3 +89,34 @@ def parse_service_call_bytes(ret):
|
||||
return r
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def get_network_type(NetworkType):
|
||||
wifi_check = parse_service_call_string(service_call(["connectivity", "2"]))
|
||||
if 'WIFI' in wifi_check:
|
||||
return NetworkType.wifi
|
||||
else:
|
||||
cell_check = parse_service_call_unpack(service_call(['phone', '59']), ">q")
|
||||
cell_networks = {
|
||||
0: NetworkType.none,
|
||||
1: NetworkType.cell2G,
|
||||
2: NetworkType.cell2G,
|
||||
4: NetworkType.cell2G,
|
||||
7: NetworkType.cell2G,
|
||||
11: NetworkType.cell2G,
|
||||
16: NetworkType.cell2G,
|
||||
3: NetworkType.cell3G,
|
||||
5: NetworkType.cell3G,
|
||||
6: NetworkType.cell3G,
|
||||
8: NetworkType.cell3G,
|
||||
9: NetworkType.cell3G,
|
||||
10: NetworkType.cell3G,
|
||||
12: NetworkType.cell3G,
|
||||
13: NetworkType.cell3G,
|
||||
14: NetworkType.cell3G,
|
||||
15: NetworkType.cell3G,
|
||||
17: NetworkType.cell3G,
|
||||
18: NetworkType.cell4G,
|
||||
19: NetworkType.cell4G,
|
||||
20: NetworkType.cell5G
|
||||
}
|
||||
return cell_networks.get(cell_check, NetworkType.none)
|
||||
|
||||
@@ -6,7 +6,7 @@ import datetime
|
||||
import psutil
|
||||
from smbus2 import SMBus
|
||||
from cereal import log
|
||||
from common.android import ANDROID
|
||||
from common.android import ANDROID, get_network_type
|
||||
from common.basedir import BASEDIR
|
||||
from common.params import Params
|
||||
from common.realtime import sec_since_boot, DT_TRML
|
||||
@@ -21,6 +21,7 @@ from selfdrive.pandad import get_expected_signature
|
||||
FW_SIGNATURE = get_expected_signature()
|
||||
|
||||
ThermalStatus = log.ThermalData.ThermalStatus
|
||||
NetworkType = log.ThermalData.NetworkType
|
||||
CURRENT_TAU = 15. # 15s time constant
|
||||
DAYS_NO_CONNECTIVITY_MAX = 7 # do not allow to engage after a week without internet
|
||||
DAYS_NO_CONNECTIVITY_PROMPT = 4 # send an offroad prompt after 4 days with no internet
|
||||
@@ -135,7 +136,6 @@ def handle_fan_uno(max_cpu_temp, bat_temp, fan_speed, ignition):
|
||||
|
||||
return new_speed
|
||||
|
||||
|
||||
def thermald_thread():
|
||||
# prevent LEECO from undervoltage
|
||||
BATT_PERC_OFF = 10 if LEON else 3
|
||||
@@ -192,6 +192,7 @@ def thermald_thread():
|
||||
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)
|
||||
|
||||
try:
|
||||
with open("/sys/class/power_supply/battery/capacity") as f:
|
||||
|
||||
Reference in New Issue
Block a user