Skip to content

Commit 9a5ecf9

Browse files
authored
Merge pull request #148 from ISSUIUC/cleanup/midas-base-improvements
System-wide Feather Duo software improvements (MIDAS-BASE)
2 parents fbca78e + 7af2877 commit 9a5ecf9

File tree

4 files changed

+49
-33
lines changed

4 files changed

+49
-33
lines changed

ground/gss_combiner/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Ground Station Data Ingestion
2+
3+
Something more will be written here later, for now:
4+
5+
```pip install -r requirements.txt```
6+
and then
7+
```python gui_main.py```
8+
9+
to run MIDAS-Base

ground/gss_combiner/gui_main.py

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def is_port_taken(port):
2929
bool: True if the port is taken, False otherwise.
3030
"""
3131
try:
32-
ser = serial.Serial(port)
32+
ser = serial.Serial(port, write_timeout=1, timeout=2)
3333
return False, ser # Port is free
3434
except serial.SerialException as e:
3535
return True, None
@@ -524,7 +524,10 @@ def perform_action(self):
524524
target_device.has_errored = False
525525
target_device.reset()
526526
target_device.stat = "STARTUP..."
527-
target_device.meta = f"{self.stage_sel.get().upper()} (LOG: {"YES" if should_log else "NO"})"
527+
log_str = "NO"
528+
if should_log:
529+
log_str = "YES"
530+
target_device.meta = f"{self.stage_sel.get().upper()} (LOG: {log_str})"
528531
target_device.stage_sel = self.stage_sel.get()
529532
target_device.pipe_conn, child_conn = multiprocessing.Pipe()
530533
target_device.proc = multiprocessing.Process(target=run_standalone_worker, args=(child_conn, ip, self.selected_device, self.stage_sel.get(), should_log))
@@ -537,36 +540,6 @@ def inspect_window(self):
537540
self.open_terminal_window(self.selected_device)
538541
# Add real logic here
539542

540-
def show_json_window(self):
541-
window = tk.Toplevel(self)
542-
543-
title = "Data"
544-
json_data = {"hello": "world", "bruh": "moment"}
545-
window.title(title)
546-
window.geometry("600x400")
547-
548-
label = ttk.Label(window, text=title, font=("Helvetica", 14, "bold"))
549-
label.pack(pady=5)
550-
551-
# Text widget with scrollbar
552-
text_frame = ttk.Frame(window)
553-
text_frame.pack(fill="both", expand=True, padx=10, pady=5)
554-
555-
scrollbar = ttk.Scrollbar(text_frame)
556-
scrollbar.pack(side="right", fill="y")
557-
558-
text = tk.Text(text_frame, wrap="none", yscrollcommand=scrollbar.set, bg="#1e1e1e", fg="#d4d4d4", insertbackground="white")
559-
text.pack(fill="both", expand=True)
560-
scrollbar.config(command=text.yview)
561-
562-
# Pretty-print the JSON
563-
pretty_json = json.dumps(json_data, indent=4)
564-
text.insert("1.0", pretty_json)
565-
text.config(state="disabled") # Make it read-only
566-
567-
# Optional: allow closing with Esc
568-
window.bind("<Escape>", lambda e: window.destroy())
569-
570543
def open_terminal_window(self, device):
571544
global devices
572545
term_win = tk.Toplevel(self)
@@ -616,6 +589,7 @@ def send_command(event=None):
616589
output.insert("end", f">> {command}\n", "user_in")
617590
output.config(state="disabled")
618591
output.see("end")
592+
619593
target_device.pipe_conn.send(command + "\n")
620594
input_var.set("")
621595

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pyserial
2+
paho-mqtt

ground/gss_combiner/standalone.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
import threading
88
import sys
99
import queue
10+
import os
1011

1112
import serial # PySerial
1213
import paho.mqtt.client as mqtt
1314
import time
1415

1516
import argparse
1617

18+
import re
1719
import util.logger
1820

1921
stdin_q = queue.Queue()
@@ -35,6 +37,7 @@ def __init__(self, com_port, server_uri, stage, should_log) -> None:
3537
self.__outfile_raw = None
3638

3739
if(self.__should_log):
40+
os.makedirs("outputs", exist_ok=True)
3841
self.__outfile = open(f"./outputs/{time.time()}_log.telem", "w+")
3942
self.__outfile_raw = open(f"./outputs/{time.time()}_raw_log.txt", "w+")
4043

@@ -102,6 +105,7 @@ def on_message(client, userdata, msg):
102105
self.__in_buf = ""
103106

104107
self.__out_all = False
108+
self.__filter = ".*"
105109

106110

107111
def process_packet(self, packet_json):
@@ -164,7 +168,9 @@ def run(self) -> None:
164168
if len(packets) > 0:
165169
if self.__out_all:
166170
for p in packets:
167-
print(f"[F] {p.strip()}", flush=True)
171+
172+
if re.findall(self.__filter, p.strip()):
173+
print(f"[F] {p.strip()}", flush=True)
168174

169175
# Process stdin
170176
if not stdin_q.empty():
@@ -178,13 +184,38 @@ def run(self) -> None:
178184
is_internal = True
179185
print("[CMD] PONG", flush=True)
180186

187+
if line.startswith("FILTER"):
188+
is_internal = True
189+
181190
if line == "OUT_ALL":
182191
is_internal = True
183192
self.__out_all = True
184193
print("[CMD] OUT_ALL - Now outputting all serial data.")
185194
print("Note: Serial data from the feather will be formatted like below:")
186195
print("[F] This is a sample serial output.", flush=True)
187196

197+
if line.startswith("FILTER "):
198+
f = line[7:]
199+
200+
201+
if not self.__out_all:
202+
print("[CMD] Automatically invoking OUT_ALL...")
203+
print("[CMD] OUT_ALL - Now outputting all serial data.")
204+
print("Note: Serial data from the feather will be formatted like below:")
205+
print("[F] This is a sample serial output.", flush=True)
206+
207+
if f == "*":
208+
f = ".*"
209+
210+
if f.lower() == "boo":
211+
f = "is_sustainer\": 0"
212+
213+
if f.lower() == "sus":
214+
f = "is_sustainer\": 1"
215+
216+
self.__filter = f
217+
print(f"[CMD] Filter set to {self.__filter}", flush=True)
218+
188219
if line == "OUT_DEFAULT":
189220
is_internal = True
190221
self.__out_all = False

0 commit comments

Comments
 (0)