eive-tmtc/eive_tmtc/tmtc/acs/sus.py

31 lines
1.0 KiB
Python

import enum
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class SetId(enum.IntEnum):
HK = 3
def handle_sus_hk(
object_id: ObjectIdU32, hk_data: bytes, printer: FsfwTmTcPrinter, set_id: int
):
pw = PrintWrapper(printer)
pw.dlog(f"Received SUS HK data from {object_id}")
if set_id == SetId.HK:
current_idx = 0
temperature = struct.unpack("!f", hk_data[current_idx : current_idx + 4])[0]
current_idx += 4
channels = []
for _ in range(6):
channels.append(struct.unpack("!H", hk_data[current_idx : current_idx + 2]))
current_idx += 2
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[0]:#06x} |" + str(val[0]).ljust(5))
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7)