From b7a6291560a874728ff33d88d5be44a60f82692a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 May 2022 01:49:57 +0200 Subject: [PATCH] update gps hk parsing --- config/object_ids.py | 3 +-- pus_tc/cmd_definitions.py | 2 +- pus_tc/devs/gps.py | 15 ++------------- pus_tc/tc_packer_hook.py | 14 ++++---------- pus_tm/hk_handling.py | 38 +++++++++++++++++++------------------- 5 files changed, 27 insertions(+), 45 deletions(-) diff --git a/config/object_ids.py b/config/object_ids.py index c2c25b1..b0e450f 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -44,8 +44,7 @@ GYRO_0_ADIS_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x10]) GYRO_1_L3G_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x11]) GYRO_2_ADIS_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x12]) GYRO_3_L3G_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x13]) -GPS_HANDLER_0_ID = bytes([0x44, 0x13, 0x00, 0x45]) -GPS_HANDLER_1_ID = bytes([0x44, 0x13, 0x01, 0x46]) +GPS_CONTROLLER = bytes([0x44, 0x13, 0x00, 0x45]) RW1_ID = bytes([0x44, 0x12, 0x00, 0x47]) RW2_ID = bytes([0x44, 0x12, 0x01, 0x48]) RW3_ID = bytes([0x44, 0x12, 0x02, 0x49]) diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index a9f1764..ee28489 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -1,4 +1,4 @@ -from pus_tc.devs.gps import OpCodes +from pus_tc.devs.gps import add_gps_cmds from pus_tc.devs.pcdu import add_pcdu_cmds from pus_tc.devs.rad_sensor import add_rad_sens_cmds from tmtccmd.config import ( diff --git a/pus_tc/devs/gps.py b/pus_tc/devs/gps.py index db3d153..4d5824f 100644 --- a/pus_tc/devs/gps.py +++ b/pus_tc/devs/gps.py @@ -9,8 +9,6 @@ from tmtccmd.tc.definitions import TcQueueT from tmtccmd.tc.pus_8_funccmd import generate_action_command -from config.object_ids import GPS_HANDLER_1_ID, GPS_HANDLER_0_ID - LOGGER = get_console_logger() @@ -46,17 +44,8 @@ def add_gps_cmds(cmd_dict: ServiceOpCodeDictT): def pack_gps_command(object_id: bytes, tc_queue: TcQueueT, op_code: str): if op_code in OpCodes.RESET_GNSS: - if object_id == GPS_HANDLER_0_ID: - # TODO: This needs to be re-implemented - LOGGER.warning("Reset pin handling needs to be re-implemented") - return - # tc_queue.appendleft((QueueCommands.PRINT, "Resetting GPS device 0")) - elif object_id == GPS_HANDLER_1_ID: - LOGGER.warning("Reset pin handling needs to be re-implemented") - return - # tc_queue.appendleft((QueueCommands.PRINT, "Resetting GPS device 1")) - cmd = generate_action_command(object_id=object_id, action_id=int(op_code)) - tc_queue.appendleft(cmd.pack_command_tuple()) + # TODO: This needs to be re-implemented + LOGGER.warning("Reset pin handling needs to be re-implemented") if op_code in OpCodes.REQ_OS_HK: tc_queue.appendleft((QueueCommands.PRINT, f"GMSS: {Info.REQ_OS_HK}")) cmd = generate_one_hk_command(sid=make_sid(object_id=object_id, set_id=SetIds.HK), ssc=0) diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index 137877b..2964012 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -63,8 +63,6 @@ from config.object_ids import ( PLOC_SUPV_ID, STAR_TRACKER_ID, PLOC_MEMORY_DUMPER_ID, - GPS_HANDLER_0_ID, - GPS_HANDLER_1_ID, CCSDS_HANDLER_ID, PDEC_HANDLER_ID, STR_IMG_HELPER_ID, @@ -73,7 +71,7 @@ from config.object_ids import ( RW_ASSEMBLY, get_object_ids, ) - +import config.object_ids as oids LOGGER = get_console_logger() @@ -206,13 +204,9 @@ def pack_service_queue_user( ) if service == CustomServiceList.ACS.value: return pack_acs_command(tc_queue=service_queue, op_code=op_code) - if service == CustomServiceList.GPS_0.value: + if service == CustomServiceList.GPS_CTRL.value: return pack_gps_command( - object_id=GPS_HANDLER_0_ID, tc_queue=service_queue, op_code=op_code - ) - if service == CustomServiceList.GPS_1.value: - return pack_gps_command( - object_id=GPS_HANDLER_1_ID, tc_queue=service_queue, op_code=op_code + object_id=oids.GPS_CONTROLLER, tc_queue=service_queue, op_code=op_code ) if service == CustomServiceList.CCSDS_HANDLER.value: return pack_ccsds_handler_test( @@ -248,7 +242,7 @@ def pack_service_queue_user( ) if service == CustomServiceList.CONTROLLERS.value: return pack_controller_commands(tc_queue=service_queue, op_code=op_code) - LOGGER.warning("Invalid Service !") + LOGGER.warning(f"Invalid Service {service}") def create_total_tc_queue_user() -> TcQueueT: diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index 427017c..a468aaf 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -75,40 +75,40 @@ def handle_regular_hk_print( """This function is called when a Service 3 Housekeeping packet is received.""" if object_id in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]: handle_rw_hk_data(printer, object_id, set_id, hk_data) - if objb == obj_ids.SYRLINKS_HANDLER_ID: + elif objb == obj_ids.SYRLINKS_HANDLER_ID: handle_syrlinks_hk_data(printer=printer, hk_data=hk_data, set_id=set_id) - if objb == obj_ids.IMTQ_HANDLER_ID: + elif objb == obj_ids.IMTQ_HANDLER_ID: if (set_id >= ImtqSetIds.POSITIVE_X_TEST) and ( set_id <= ImtqSetIds.NEGATIVE_Z_TEST ): return handle_self_test_data(printer, hk_data) else: LOGGER.info("Service 3 TM: Syrlinks handler reply with unknown set id") - if objb == obj_ids.GPS_HANDLER_0_ID or object_id == obj_ids.GPS_HANDLER_1_ID: - handle_gps_data(printer=printer, hk_data=hk_data) - if objb == obj_ids.BPX_HANDLER_ID: - handle_bpx_hk_data(hk_data=hk_data, set_id=set_id, printer=printer) - if objb == obj_ids.CORE_CONTROLLER_ID: + elif objb == obj_ids.GPS_CONTROLLER: + return handle_gps_data(printer=printer, hk_data=hk_data) + elif objb == obj_ids.BPX_HANDLER_ID: + return handle_bpx_hk_data(hk_data=hk_data, set_id=set_id, printer=printer) + elif objb == obj_ids.CORE_CONTROLLER_ID: return handle_core_hk_data(printer=printer, hk_data=hk_data, set_id=set_id) - if objb == obj_ids.PDU_1_HANDLER_ID: + elif objb == obj_ids.PDU_1_HANDLER_ID: return handle_pdu_data( printer=printer, pdu_idx=1, set_id=set_id, hk_data=hk_data ) - if objb == obj_ids.PDU_2_HANDLER_ID: + elif objb == obj_ids.PDU_2_HANDLER_ID: return handle_pdu_data( printer=printer, pdu_idx=2, set_id=set_id, hk_data=hk_data ) - if objb == obj_ids.ACU_HANDLER_ID: + elif objb == obj_ids.ACU_HANDLER_ID: return handle_acu_hk_data(printer=printer, hk_data=hk_data, set_id=set_id) - if objb == obj_ids.RAD_SENSOR_ID: + elif objb == obj_ids.RAD_SENSOR_ID: return handle_rad_sensor_data(printer=printer, hk_data=hk_data, set_id=set_id) - if objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]: + elif objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]: return handle_rw_hk_data( printer=printer, object_id=object_id, set_id=set_id, hk_data=hk_data ) - if objb == obj_ids.P60_DOCK_HANDLER: + elif objb == obj_ids.P60_DOCK_HANDLER: handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data) - if objb in [ + elif objb in [ obj_ids.GYRO_0_ADIS_HANDLER_ID, obj_ids.GYRO_1_L3G_HANDLER_ID, obj_ids.GYRO_2_ADIS_HANDLER_ID, @@ -117,7 +117,7 @@ def handle_regular_hk_print( handle_gyros_hk_data( object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id ) - if objb in [ + elif objb in [ obj_ids.MGM_0_LIS3_HANDLER_ID, obj_ids.MGM_1_RM3100_HANDLER_ID, obj_ids.MGM_2_LIS3_HANDLER_ID, @@ -126,12 +126,12 @@ def handle_regular_hk_print( handle_mgm_hk_data( object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id ) - if objb == obj_ids.PL_PCDU_ID: + elif objb == obj_ids.PL_PCDU_ID: log_to_both(printer, "Received PL PCDU HK data") - if objb == obj_ids.THERMAL_CONTROLLER_ID: + elif objb == obj_ids.THERMAL_CONTROLLER_ID: handle_thermal_controller_hk_data( object_id=object_id, printer=printer, set_id=set_id, hk_data=hk_data ) else: - LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.") - return HkReplyUnpacked() + LOGGER.info(f"Service 3 TM: Parsing for object {object_id} and set ID {set_id} " + f"has not been implemented.")