diff --git a/pus_tm/devs/mgms.py b/pus_tm/devs/mgms.py index 671902d..e88fd20 100644 --- a/pus_tm/devs/mgms.py +++ b/pus_tm/devs/mgms.py @@ -1,8 +1,44 @@ +import struct + +from pus_tm.defs import PrintWrapper +from pus_tc.devs.mgms import MgmRm3100SetIds, MgmLis3SetIds from tmtccmd.utility import ObjectId from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter +import config.object_ids as obj_ids def handle_mgm_hk_data( object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes ): + if object_id 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) pass + + +def handle_mgm_lis3_hk_data( + object_id: ObjectId, 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: ObjectId, 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}") diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index f0959fc..219e40e 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -29,8 +29,6 @@ from pus_tm.tm_tcp_server import TmTcpServer LOGGER = get_console_logger() -TM_TCP_SERVER = TmTcpServer.getInstance() - def handle_hk_packet( raw_tm: bytes, diff --git a/pus_tm/system/tcs.py b/pus_tm/system/tcs.py index 315c17f..e8d59b8 100644 --- a/pus_tm/system/tcs.py +++ b/pus_tm/system/tcs.py @@ -1,11 +1,14 @@ import struct from pus_tm.defs import PrintWrapper -from pus_tm.hk_handling import TM_TCP_SERVER +from pus_tm.tm_tcp_server import TmTcpServer from tmtccmd.utility import ObjectId from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter +TM_TCP_SERVER = TmTcpServer.getInstance() + + def handle_thermal_controller_hk_data( object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes ):