2022-05-25 18:15:22 +02:00
|
|
|
import struct
|
|
|
|
|
|
|
|
from pus_tm.defs import PrintWrapper
|
|
|
|
from pus_tc.devs.sus import SetIds
|
|
|
|
from tmtccmd.utility import ObjectId
|
|
|
|
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
|
|
|
|
|
|
|
|
|
2022-05-27 09:54:06 +02:00
|
|
|
def handle_sus_hk(
|
|
|
|
object_id: ObjectId, hk_data: bytes, printer: FsfwTmTcPrinter, set_id: int
|
|
|
|
):
|
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):
|
|
|
|
pw.dlog(f"{idx} | {val:#06x} | {str(val).ljust(5)}")
|
2022-05-25 18:15:22 +02:00
|
|
|
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7)
|