修正 dashcamd 和 safeguardd 無法啟動的錯誤

This commit is contained in:
Rick Lan
2019-07-02 22:50:24 +10:00
parent 54da0f0fb9
commit 47294b083f
2 changed files with 9 additions and 12 deletions
+6 -7
View File
@@ -27,13 +27,12 @@ def main(gctx=None):
if not os.path.exists(dashcam_videos):
os.makedirs(dashcam_videos)
context = zmq.Context()
thermal_sock = messaging.sub_sock(context, service_list['thermal'].port)
poller = zmq.Poller()
sock = messaging.sub_sock(service_list['thermal'].port, poller)
poller.poll(timeout=0)
while 1:
if params.get("d_enableDashcam") == "1":
# get health of board, log this in "thermal"
msg = messaging.recv_sock(thermal_sock, wait=True)
now = datetime.datetime.now()
file_name = now.strftime("%Y-%m-%d_%H-%M-%S")
@@ -45,13 +44,13 @@ def main(gctx=None):
# we should clean up files here if use too much spaces
# when used spaces greater than max available storage
# or when free space is less than 10%
print(used_spaces)
print(max_storage)
# get health of board, log this in "thermal"
msg = messaging.recv_sock(sock, wait=True)
if used_spaces >= max_storage or 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(thermal_sock, wait=True)
msg = messaging.recv_sock(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:
os.system("rm -fr %s" % (dashcam_videos + file))
@@ -15,9 +15,9 @@ mediaplayer = '/data/openpilot/selfdrive/dragonpilot/mediaplayer/'
def main(gctx=None):
context = zmq.Context()
poller = zmq.Poller()
controls_state_sock = messaging.sub_sock(context, service_list['controlsState'].port, conflate=True, poller=poller)
sock = messaging.sub_sock(service_list['controlsState'].port, poller)
poller.poll(timeout=0)
last_v_ego = 0.
last_active = False
@@ -31,9 +31,7 @@ def main(gctx=None):
v_ego = 0
active = False
for socket, event in poller.poll(100):
if socket is controls_state_sock:
controls_state = messaging.recv_one(socket)
controls_state = messaging.recv_sock(sock, wait=True)
if controls_state is not None:
v_ego = controls_state.controlsState.vEgo