From 5cd568815a7fb13a7099202f9e7f5bcd2588354d Mon Sep 17 00:00:00 2001 From: kaunis Date: Fri, 7 Jun 2024 22:43:33 +0300 Subject: [PATCH] added loading telemetry from recent TLM text files --- SatsDecoder/ui.py | 14 ++++++++++++++ SatsDecoder/utils.py | 2 ++ 2 files changed, 16 insertions(+) diff --git a/SatsDecoder/ui.py b/SatsDecoder/ui.py index 028fbae..642c7dc 100644 --- a/SatsDecoder/ui.py +++ b/SatsDecoder/ui.py @@ -579,6 +579,16 @@ def __init__(self, master, config, name): self.dv_frame = DataViewFrame(self) self.dv_frame.grid(column=1, row=0, rowspan=2, sticky=tk.NSEW, padx=2, pady=2) + def openfiles(self): + path = HOMEDIR + files = filedialog.askopenfilenames(title='Choose packets', initialdir=path, filetypes=(("TLM file", "*.txt"), ("All files", "*.*"))) + for f in files: + file = open(f, 'r') + line = file.readline().strip() + x = bytes.fromhex(line) + self.feed(x) + file.close() + def named_conn_btn(self, _=None, **kw): m = utils.ConnMode(self.conn_mode.current()) d = { @@ -586,6 +596,7 @@ def named_conn_btn(self, _=None, **kw): utils.ConnMode.TCP_CLI: ('Connect', 'Disconnect'), utils.ConnMode.TCP_SRV: ('Start', 'Stop'), utils.ConnMode.HEX: ('Run', 'Stop'), + utils.ConnMode.HEX_TXT: ('Load packets', 'Stop'), } self.con_btn.config(text=d[m]['d' in kw]) @@ -618,9 +629,12 @@ def con(self): m = utils.ConnMode(self.conn_mode.current()) if m == utils.ConnMode.HEX: self._hex_values() + elif m == utils.ConnMode.HEX_TXT: + self.openfiles() else: self.stop() if self.sk else self._start() + def set_merge_mode(self): if self.decoder.ir: self.decoder.ir.set_merge_mode(self.merge_mode_v.get()) diff --git a/SatsDecoder/utils.py b/SatsDecoder/utils.py index 5a75a0a..d087ec4 100644 --- a/SatsDecoder/utils.py +++ b/SatsDecoder/utils.py @@ -21,6 +21,7 @@ class ConnMode(enum.IntEnum): TCP_CLI = 1 TCP_SRV = 2 HEX = 3 + HEX_TXT = 4 con_mode_names = { @@ -28,6 +29,7 @@ class ConnMode(enum.IntEnum): ConnMode.TCP_CLI: 'TCP Client', ConnMode.TCP_SRV: 'TCP Server', ConnMode.HEX: 'HEX values', + ConnMode.HEX_TXT: 'HEX from TLM file', }