64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
import enum
|
|
import struct
|
|
|
|
import eive_tmtc.config.object_ids as obj_ids
|
|
|
|
from eive_tmtc.pus_tm.defs import PrintWrapper
|
|
from tmtccmd.util import ObjectIdU32
|
|
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
|
|
|
|
|
|
class MgmLis3SetId(enum.IntEnum):
|
|
CORE_HK = 0
|
|
|
|
|
|
class MgmRm3100SetId(enum.IntEnum):
|
|
CORE_HK = 0
|
|
|
|
|
|
def handle_mgm_hk_data(
|
|
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
|
|
):
|
|
if object_id.as_bytes in [
|
|
obj_ids.MGM_0_LIS3_HANDLER_ID,
|
|
obj_ids.MGM_2_LIS3_HANDLER_ID,
|
|
]:
|
|
handle_mgm_lis3_hk_data(object_id, printer, set_id, hk_data)
|
|
elif object_id.as_bytes in [
|
|
obj_ids.MGM_1_RM3100_HANDLER_ID,
|
|
obj_ids.MGM_3_RM3100_HANDLER_ID,
|
|
]:
|
|
handle_mgm_rm3100_hk_data(object_id, printer, set_id, hk_data)
|
|
pass
|
|
|
|
|
|
def handle_mgm_lis3_hk_data(
|
|
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
|
|
):
|
|
if set_id == MgmLis3SetId.CORE_HK:
|
|
pw = PrintWrapper(printer)
|
|
fmt_str = "!ffff"
|
|
inc_len = struct.calcsize(fmt_str)
|
|
(field_x, field_y, field_z, temp) = struct.unpack(
|
|
fmt_str, hk_data[0 : 0 + inc_len]
|
|
)
|
|
pw.dlog(f"Received MGM LIS3 from object {object_id}")
|
|
pw.dlog(
|
|
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
|
|
)
|
|
pw.dlog(f"Temperature {temp} C")
|
|
|
|
|
|
def handle_mgm_rm3100_hk_data(
|
|
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
|
|
):
|
|
if set_id == MgmRm3100SetId.CORE_HK:
|
|
pw = PrintWrapper(printer)
|
|
fmt_str = f"!fff"
|
|
inc_len = struct.calcsize(fmt_str)
|
|
(field_x, field_y, field_z) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len])
|
|
pw.dlog(f"Received MGM LIS3 from object {object_id}")
|
|
pw.dlog(
|
|
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
|
|
)
|