eive-tmtc/eive_tmtc/tmtc/acs/sus.py
Robin Mueller dccbf89da1
All checks were successful
EIVE/-/pipeline/head This commit looks good
some more fixes
2024-05-08 10:49:20 +02:00

32 lines
1.0 KiB
Python

import enum
import struct
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.util import ObjectIdU32
from tmtccmd.fsfw.tmtc_printer import get_validity_buffer_str
class SetId(enum.IntEnum):
HK = 3
def handle_sus_hk(
object_id: ObjectIdU32, hk_data: bytes, pw: PrintWrapper, set_id: int
):
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("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))
pw.dlog(
get_validity_buffer_str(validity_buffer=hk_data[current_idx:], num_vars=7)
)