55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
import struct
|
|
|
|
from pus_tm.defs import PrintWrapper
|
|
from pus_tc.devs.mgms import MgmRm3100SetIds, MgmLis3SetIds
|
|
from tmtccmd.util import ObjectIdU32
|
|
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
|
|
import config.object_ids as obj_ids
|
|
|
|
|
|
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 == MgmLis3SetIds.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 == MgmRm3100SetIds.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}"
|
|
)
|