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

31 lines
1.0 KiB
Python
Raw Normal View History

2023-02-17 20:00:46 +01:00
import enum
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
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
2023-02-17 20:00:46 +01:00
class SetId(enum.IntEnum):
2023-02-01 16:25:17 +01:00
HK = 3
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}")
2023-01-16 14:13:06 +01:00
if set_id == SetId.HK:
2022-05-25 18:15:22 +02:00
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)