eive-tmtc/eive_tmtc/pus_tm/devs/mgms.py

55 lines
1.8 KiB
Python
Raw Normal View History

2022-05-19 14:50:24 +02:00
import struct
2022-11-29 16:53:29 +01:00
from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.pus_tc.devs.mgms import MgmRm3100SetIds, MgmLis3SetIds
2022-07-08 16:25:46 +02:00
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
2022-11-29 16:53:29 +01:00
import eive_tmtc.config.object_ids as obj_ids
2022-05-19 13:20:22 +02:00
def handle_mgm_hk_data(
2022-07-05 02:12:54 +02:00
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
2022-05-19 13:20:22 +02:00
):
2022-07-04 15:22:53 +02:00
if object_id.as_bytes in [
obj_ids.MGM_0_LIS3_HANDLER_ID,
obj_ids.MGM_2_LIS3_HANDLER_ID,
]:
2022-05-19 14:50:24 +02:00
handle_mgm_lis3_hk_data(object_id, printer, set_id, hk_data)
2022-07-04 15:22:53 +02:00
elif object_id.as_bytes in [
obj_ids.MGM_1_RM3100_HANDLER_ID,
obj_ids.MGM_3_RM3100_HANDLER_ID,
]:
2022-06-03 18:04:59 +02:00
handle_mgm_rm3100_hk_data(object_id, printer, set_id, hk_data)
2022-05-19 13:20:22 +02:00
pass
2022-05-19 14:50:24 +02:00
def handle_mgm_lis3_hk_data(
2022-07-05 02:12:54 +02:00
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
2022-05-19 14:50:24 +02:00
):
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(
2022-07-04 15:22:53 +02:00
fmt_str, hk_data[0 : 0 + inc_len]
2022-05-19 14:50:24 +02:00
)
pw.dlog(f"Received MGM LIS3 from object {object_id}")
2022-05-19 18:47:23 +02:00
pw.dlog(
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
)
2022-05-19 14:50:24 +02:00
pw.dlog(f"Temperature {temp} C")
def handle_mgm_rm3100_hk_data(
2022-07-05 02:12:54 +02:00
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
2022-05-19 14:50:24 +02:00
):
if set_id == MgmRm3100SetIds.CORE_HK:
pw = PrintWrapper(printer)
fmt_str = f"!fff"
inc_len = struct.calcsize(fmt_str)
2022-05-19 18:47:23 +02:00
(field_x, field_y, field_z) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len])
2022-05-19 14:50:24 +02:00
pw.dlog(f"Received MGM LIS3 from object {object_id}")
2022-05-19 18:47:23 +02:00
pw.dlog(
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
)