raylib ui: fix Firehose param loading (#35548)

fix
pull/35547/head^2
Shane Smiskol 1 week ago committed by GitHub
parent cd657f35f0
commit e9fe40755c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      selfdrive/ui/layouts/settings/firehose.py

@ -1,4 +1,5 @@
import pyray as rl import pyray as rl
import json
import time import time
import threading import threading
@ -40,7 +41,7 @@ class FirehoseLayout(Widget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.params = Params() self.params = Params()
self.segment_count = int(self.params.get(self.PARAM_KEY, encoding='utf8') or 0) self.segment_count = self._get_segment_count()
self.scroll_panel = GuiScrollPanel() self.scroll_panel = GuiScrollPanel()
self.running = True self.running = True
@ -48,6 +49,14 @@ class FirehoseLayout(Widget):
self.update_thread.start() self.update_thread.start()
self.last_update_time = 0 self.last_update_time = 0
def _get_segment_count(self) -> int:
stats = self.params.get(self.PARAM_KEY, encoding='utf8')
try:
return int(json.loads(stats).get("firehose", 0))
except json.JSONDecodeError:
cloudlog.error(f"Failed to decode firehose stats: {stats}")
return 0
def __del__(self): def __del__(self):
self.running = False self.running = False
if self.update_thread and self.update_thread.is_alive(): if self.update_thread and self.update_thread.is_alive():

Loading…
Cancel
Save