Created
April 22, 2025 16:01
-
-
Save JVital2013/bc65848ccf9c6fe7dc16f185b2802591 to your computer and use it in GitHub Desktop.
SatDump Stats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Required packages: requests, rich | |
# sudo apt install python3-requests python3-rich | |
# [or] | |
# pip install rich requests | |
# | |
# Run SatDump with stats server | |
# satdump live goes_hrit goes16 --source rtlsdr --samplerate 1.536e6 --frequency 1694.1e6 --gain 42 --http_server 0.0.0.0:8080 | |
import requests | |
from rich.console import Console | |
from rich.table import Table | |
from rich.live import Live | |
URL = "http://127.0.0.1:8080/api" | |
def fetch_data(): | |
try: | |
response = requests.get(URL, timeout=1) | |
response.raise_for_status() | |
return response.json() | |
except Exception as e: | |
return {"error": str(e)} | |
def build_table(data): | |
table = Table(title="SatDump Statistics", title_style="bold cyan", expand=True) | |
# Gray text for metric names | |
table.add_column("Metric", style="bright_black", no_wrap=True, min_width=44, max_width=44) | |
table.add_column("Value", style="bold green", no_wrap=True, min_width=20, max_width=20) | |
if "error" in data: | |
table.add_row("ERROR", data["error"]) | |
return table | |
for module_name, stats in data.items(): | |
for key, value in stats.items(): | |
label = key | |
display_value = str(value) | |
if label == "deframer_lock": | |
label = "Deframer Lock" | |
elif label == "rs_avg": | |
label = "Reed-Solomon Average" | |
elif label == "viterbi_ber": | |
label = "Viterbi Ber" | |
elif label == "viterbi_lock": | |
label = "Viterbi Lock" | |
display_value = "True" if value == 1 else "False" | |
elif label == "freq": | |
label = "Frequency Offset (Hz)" | |
elif label == "peak_snr": | |
label = "SNR (Peak)" | |
elif label == "snr": | |
label = "SNR (Current)" | |
table.add_row(label, display_value) | |
return table | |
def main(): | |
console = Console() | |
try: | |
with Live(console=console, screen=True, refresh_per_second=4) as live: | |
while True: | |
data = fetch_data() | |
table = build_table(data) | |
live.update(table) | |
except KeyboardInterrupt: | |
console.clear() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment