Merge branch 'devel-en' into devel-zhs

# Conflicts:
#	apk/ai.comma.plus.frame.apk
This commit is contained in:
dragonpilot
2019-09-02 11:50:24 +10:00
4 changed files with 32 additions and 12 deletions
+1
View File
@@ -284,6 +284,7 @@ struct ThermalData {
thermalStatus @14 :ThermalStatus;
chargingError @17 :Bool;
chargingDisabled @18 :Bool;
ipAddr @19 :Text;
enum ThermalStatus {
green @0; # all processes run
+2 -6
View File
@@ -1,7 +1,6 @@
#!/usr/bin/env python2.7
import time
import zmq
import selfdrive.messaging as messaging
from selfdrive.services import service_list
import subprocess
@@ -45,10 +44,7 @@ def main(gctx=None):
# we want to disable all app when boot
system("pm disable %s ; pm disable %s ; pm disable %s" % (tomtom, autonavi, mixplorer))
poller = zmq.Poller()
sock = messaging.sub_sock(service_list['thermal'].port, poller)
poller.poll(timeout=1000)
thermal_sock = messaging.sub_sock(service_list['thermal'].port)
while dragon_enable_tomtom or dragon_enable_autonavi or dragon_enable_mixplorer:
@@ -77,7 +73,7 @@ def main(gctx=None):
auto_tomtom = not manual_tomtom and dragon_enable_tomtom and dragon_boot_tomtom
auto_autonavi = not manual_autonavi and dragon_enable_autonavi and dragon_boot_autonavi
msg = messaging.recv_sock(sock, wait=True)
msg = messaging.recv_sock(thermal_sock, wait=True)
started = msg.thermal.started
# car on
if started:
+3 -6
View File
@@ -10,7 +10,6 @@
import os
import time
import datetime
import zmq
import selfdrive.messaging as messaging
from selfdrive.services import service_list
import subprocess
@@ -29,9 +28,7 @@ def main(gctx=None):
if not os.path.exists(dashcam_videos):
os.makedirs(dashcam_videos)
poller = zmq.Poller()
sock = messaging.sub_sock(service_list['thermal'].port, poller)
poller.poll(timeout=1000)
thermal_sock = messaging.sub_sock(service_list['thermal'].port)
while 1:
if params.get("DragonEnableDashcam") == "1":
now = datetime.datetime.now()
@@ -47,12 +44,12 @@ def main(gctx=None):
# get health of board, log this in "thermal"
start_time = time.time()
msg = messaging.recv_sock(sock, wait=True)
msg = messaging.recv_sock(thermal_sock, wait=True)
if used_spaces >= max_storage or (msg is not None and msg.thermal.freeSpace < freespace_limit):
# get all the files in the dashcam_videos path
files = [f for f in sorted(os.listdir(dashcam_videos)) if os.path.isfile(dashcam_videos + f)]
for file in files:
msg = messaging.recv_sock(sock, wait=True)
msg = messaging.recv_sock(thermal_sock, wait=True)
# delete file one by one and once it has enough space for 1 video, we stop deleting
if used_spaces - last_used_spaces < max_size_per_file or msg.thermal.freeSpace < freespace_limit:
system("rm -fr %s" % (dashcam_videos + file))
+26
View File
@@ -13,6 +13,9 @@ from common.numpy_fast import clip
from common.filter_simple import FirstOrderFilter
params = Params()
import subprocess
import re
ThermalStatus = log.ThermalData.ThermalStatus
CURRENT_TAU = 15. # 15s time constant
@@ -149,6 +152,9 @@ def thermald_thread():
# Make sure charging is enabled
charging_disabled = False
os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled')
ts_last_ip = 0.
last_ip_addr = '255.255.255.255'
ip_addr = '255.255.255.255'
while 1:
health = messaging.recv_sock(health_sock, wait=True)
@@ -176,6 +182,26 @@ def thermald_thread():
msg.thermal.batteryVoltage = int(f.read())
with open("/sys/class/power_supply/usb/present") as f:
msg.thermal.usbOnline = bool(int(f.read()))
# update ip every 5 seconds
ts = sec_since_boot()
if ts - ts_last_ip > 5.:
try:
result = subprocess.check_output(["service", "call", "connectivity", "2"]).strip().split("\n")
except subprocess.CalledProcessError:
return False
data = ''.join(''.join(w.decode("hex")[::-1] for w in l[14:49].split()) for l in result[1:])
if "\x00".join("WIFI") in data:
result = subprocess.check_output(["ifconfig", "wlan0"])
ip_addr = re.findall(r"inet addr:((\d+\.){3}\d+)", result)[0][0]
ts_last_ip = ts
else:
ip_addr = ''
else:
ip_addr = last_ip_addr
msg.thermal.ipAddr = ip_addr
last_ip_addr = ip_addr
current_filter.update(msg.thermal.batteryCurrent / 1e6)