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

32 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
2023-05-25 11:31:06 +02:00
from tmtccmd.fsfw.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(
2023-05-24 13:44:45 +02:00
object_id: ObjectIdU32, hk_data: bytes, pw: PrintWrapper, set_id: int
2022-05-27 09:54:06 +02:00
):
2022-05-25 18:15:22 +02:00
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")
2023-06-10 14:42:28 +02:00
pw.dlog("AIN Channel | Raw Value (hex) | Raw Value (dec)")
2022-05-27 09:54:06 +02:00
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))
2023-05-24 13:44:45 +02:00
FsfwTmTcPrinter.get_validity_buffer(
validity_buffer=hk_data[current_idx:], num_vars=7
)