From da18ebab775cbfce8b5b520af7eba07a090a355d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 25 May 2022 18:15:22 +0200 Subject: [PATCH 1/2] added sus hk parsing --- pus_tm/devs/sus.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pus_tm/devs/sus.py diff --git a/pus_tm/devs/sus.py b/pus_tm/devs/sus.py new file mode 100644 index 0000000..1c05504 --- /dev/null +++ b/pus_tm/devs/sus.py @@ -0,0 +1,21 @@ +import struct + +from pus_tm.defs import PrintWrapper +from pus_tc.devs.sus import SetIds +from tmtccmd.utility import ObjectId +from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter + + +def handle_sus_hk(object_id: ObjectId, hk_data: bytes, printer: FsfwTmTcPrinter, set_id: int): + pw = PrintWrapper(printer) + pw.dlog(f"Received SUS HK data from {object_id}") + if set_id == SetIds.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 + printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7) + -- 2.43.0 From 3e087dc803fad8ba1894ff8f9819af38d255969e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 27 May 2022 09:54:06 +0200 Subject: [PATCH 2/2] complete sus hk parsing --- pus_tm/devs/sus.py | 13 +++++++++---- pus_tm/hk_handling.py | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/pus_tm/devs/sus.py b/pus_tm/devs/sus.py index 1c05504..62a11ce 100644 --- a/pus_tm/devs/sus.py +++ b/pus_tm/devs/sus.py @@ -6,16 +6,21 @@ from tmtccmd.utility import ObjectId from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter -def handle_sus_hk(object_id: ObjectId, hk_data: bytes, printer: FsfwTmTcPrinter, set_id: int): +def handle_sus_hk( + object_id: ObjectId, hk_data: bytes, printer: FsfwTmTcPrinter, set_id: int +): pw = PrintWrapper(printer) pw.dlog(f"Received SUS HK data from {object_id}") if set_id == SetIds.HK: current_idx = 0 - temperature = struct.unpack('!f', hk_data[current_idx : current_idx + 4])[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])) + channels.append(struct.unpack("!H", hk_data[current_idx : current_idx + 2])) current_idx += 2 + pw.dlog(f"Temperature: {temperature} C") + pw.dlog(f"AIN Channel | Raw Value (hex) | Raw Value (dec)") + for idx, val in enumerate(channels): + pw.dlog(f"{idx} | {val:#06x} | {str(val).ljust(5)}") printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=7) - diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index cad39ab..518a541 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -2,6 +2,7 @@ import struct from pus_tm.devs.rad_sensor import handle_rad_sensor_data +from pus_tm.devs.sus import handle_sus_hk from pus_tm.system.tcs import handle_thermal_controller_hk_data, TM_TCP_SERVER from tmtccmd.config.definitions import HkReplyUnpacked from tmtccmd.tm.pus_3_fsfw_hk import ( @@ -117,6 +118,23 @@ def handle_regular_hk_print( return handle_rw_hk_data( printer=printer, object_id=object_id, set_id=set_id, hk_data=hk_data ) + if objb in [ + obj_ids.SUS_0_N_LOC_XFYFZM_PT_XF, + obj_ids.SUS_1_N_LOC_XBYFZM_PT_XB, + obj_ids.SUS_2_N_LOC_XFYBZB_PT_YB, + obj_ids.SUS_3_N_LOC_XFYBZF_PT_YF, + obj_ids.SUS_4_N_LOC_XMYFZF_PT_ZF, + obj_ids.SUS_5_N_LOC_XFYMZB_PT_ZB, + obj_ids.SUS_6_R_LOC_XFYBZM_PT_XF, + obj_ids.SUS_7_R_LOC_XBYBZM_PT_XB, + obj_ids.SUS_8_R_LOC_XBYBZB_PT_YB, + obj_ids.SUS_9_R_LOC_XBYBZB_PT_YF, + obj_ids.SUS_10_R_LOC_XMYBZF_PT_ZF, + obj_ids.SUS_11_R_LOC_XBYMZB_PT_ZB, + ]: + handle_sus_hk( + object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id + ) if objb == obj_ids.P60_DOCK_HANDLER: handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data) if objb in [ @@ -145,4 +163,3 @@ def handle_regular_hk_print( ) else: LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.") - return HkReplyUnpacked() -- 2.43.0