eive-tmtc/eive_tmtc/pus_tm/devs/sus.py

27 lines
1.0 KiB
Python
Raw Normal View History

2022-05-25 18:15:22 +02:00
import struct
2022-11-29 16:53:29 +01:00
from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.pus_tc.devs.sus import SetIds
2022-07-08 16:25:46 +02:00
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
2022-05-25 18:15:22 +02:00
2022-05-27 09:54:06 +02:00
def handle_sus_hk(
2022-07-05 02:12:54 +02:00
object_id: ObjectIdU32, hk_data: bytes, printer: FsfwTmTcPrinter, set_id: int
2022-05-27 09:54:06 +02:00
):
2022-05-25 18:15:22 +02:00
pw = PrintWrapper(printer)
pw.dlog(f"Received SUS HK data from {object_id}")
if set_id == SetIds.HK:
current_idx = 0
2022-05-27 09:54:06 +02:00
temperature = struct.unpack("!f", hk_data[current_idx : current_idx + 4])[0]
2022-05-25 18:15:22 +02:00
current_idx += 4
channels = []
for _ in range(6):
2022-05-27 09:54:06 +02:00
channels.append(struct.unpack("!H", hk_data[current_idx : current_idx + 2]))
2022-05-25 18:15:22 +02:00
current_idx += 2
2022-05-27 09:54:06 +02:00
pw.dlog(f"Temperature: {temperature} C")
pw.dlog(f"AIN Channel | Raw Value (hex) | Raw Value (dec)")
for idx, val in enumerate(channels):
2022-06-03 11:51:03 +02:00
pw.dlog(f"{idx} | {val[0]:#06x} |" + str(val[0]).ljust(5))
2022-05-25 18:15:22 +02:00
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7)