From 5c43f638acb87e4ae07cea697cf8875c06431427 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Mar 2022 17:12:48 +0200 Subject: [PATCH 01/26] form change --- pus_tc/cmd_definitions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index 8436bb4..a360947 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -134,7 +134,9 @@ def add_pl_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): info=Info.NORMAL_HPA, ) add_op_code_entry( - op_code_dict=op_code_dict, keys=OpCodes.SWITCH_OFF, info=Info.SWITCH_OFF + op_code_dict=op_code_dict, + keys=OpCodes.SWITCH_OFF, + info=Info.SWITCH_OFF ) add_op_code_entry( op_code_dict=op_code_dict, From 8b5554d6fdfb9e2d982e4a2af4f5e6d6e844794e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 13:53:26 +0200 Subject: [PATCH 02/26] updated pl pcdu commands --- pus_tc/cmd_definitions.py | 4 +-- pus_tc/devs/pdu2.py | 8 ++--- pus_tc/devs/ploc_mpsoc.py | 14 ++++---- pus_tc/devs/plpcdu.py | 52 ++++++++++++++++++++++-------- pus_tc/devs/rad_sensor.py | 8 ++--- pus_tc/devs/syrlinks_hk_handler.py | 26 +++++---------- 6 files changed, 59 insertions(+), 53 deletions(-) diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index 74d5439..a41d75e 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -134,9 +134,7 @@ def add_pl_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): info=Info.NORMAL_HPA, ) add_op_code_entry( - op_code_dict=op_code_dict, - keys=OpCodes.SWITCH_OFF, - info=Info.SWITCH_OFF + op_code_dict=op_code_dict, keys=OpCodes.SWITCH_OFF, info=Info.SWITCH_OFF ) add_op_code_entry( op_code_dict=op_code_dict, diff --git a/pus_tc/devs/pdu2.py b/pus_tc/devs/pdu2.py index db800fa..d08087d 100644 --- a/pus_tc/devs/pdu2.py +++ b/pus_tc/devs/pdu2.py @@ -215,9 +215,7 @@ def pack_pdu2_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): ) tc_queue.appendleft(command.pack_command_tuple()) if op_code == Pdu2OpCodes.PL_CAMERA_ON.value: - tc_queue.appendleft( - (QueueCommands.PRINT, "PDU2: Turn payload camera on") - ) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn payload camera on")) command = pack_set_param_command( object_id, PDUConfigTable.out_en_8.parameter_address, @@ -226,9 +224,7 @@ def pack_pdu2_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): ) tc_queue.appendleft(command.pack_command_tuple()) if op_code == Pdu2OpCodes.PL_CAMERA_OFF.value: - tc_queue.appendleft( - (QueueCommands.PRINT, "PDU2: Turn payload camera off") - ) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Turn payload camera off")) command = pack_set_param_command( object_id, PDUConfigTable.out_en_8.parameter_address, diff --git a/pus_tc/devs/ploc_mpsoc.py b/pus_tc/devs/ploc_mpsoc.py index 8872b2a..6a360af 100644 --- a/pus_tc/devs/ploc_mpsoc.py +++ b/pus_tc/devs/ploc_mpsoc.py @@ -70,16 +70,12 @@ def pack_ploc_mpsoc_commands( ) if op_code == "0": - tc_queue.appendleft( - (QueueCommands.PRINT, "PLOC MPSoC: Set mode off") - ) + tc_queue.appendleft((QueueCommands.PRINT, "PLOC MPSoC: Set mode off")) command = pack_mode_data(object_id, Modes.OFF, 0) command = PusTelecommand(service=200, subservice=1, ssc=9, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "1": - tc_queue.appendleft( - (QueueCommands.PRINT, "PLOC MPSoC: Set mode on") - ) + tc_queue.appendleft((QueueCommands.PRINT, "PLOC MPSoC: Set mode on")) command = pack_mode_data(object_id, Modes.ON, 0) command = PusTelecommand(service=200, subservice=1, ssc=10, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -142,8 +138,10 @@ def pack_ploc_mpsoc_commands( command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) elif op_code == "12": - tc_queue.appendleft((QueueCommands.PRINT, "PLOC MPSoC: Reset OBSW sequence count")) - command = object_id + struct.pack('!I', CommandIds.OBSW_RESET_SEQ_COUNT) + tc_queue.appendleft( + (QueueCommands.PRINT, "PLOC MPSoC: Reset OBSW sequence count") + ) + command = object_id + struct.pack("!I", CommandIds.OBSW_RESET_SEQ_COUNT) command = PusTelecommand(service=8, subservice=128, ssc=28, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) elif op_code == "13": diff --git a/pus_tc/devs/plpcdu.py b/pus_tc/devs/plpcdu.py index 2e631fa..cdf5e0a 100644 --- a/pus_tc/devs/plpcdu.py +++ b/pus_tc/devs/plpcdu.py @@ -52,14 +52,13 @@ class Info: NORMAL_HPA = f"{NORMAL}, HPA on" -class NormalSubmodes(enum.IntEnum): - ALL_OFF = 0 - SOLID_STATE_RELAYS_ADC_ON = 1 - DRO_ON = 2 - X8_ON = 3 - TX_ON = 4 - MPA_ON = 5 - HPA_ON = 6 +class NormalSubmodesMask(enum.IntEnum): + SOLID_STATE_RELAYS_ADC_ON = 0 + DRO_ON = 1 + X8_ON = 2 + TX_ON = 3 + MPA_ON = 4 + HPA_ON = 5 class ParamIds(enum.IntEnum): @@ -114,42 +113,67 @@ def pack_pl_pcdu_commands(tc_queue: TcQueueT, op_code: str): tc_queue=tc_queue, info=Info.NORMAL_SSR, mode=Modes.NORMAL, - submode=NormalSubmodes.SOLID_STATE_RELAYS_ADC_ON, + submode=(1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON), ) if op_code in OpCodes.NORMAL_DRO: pack_pl_pcdu_mode_cmd( tc_queue=tc_queue, info=Info.NORMAL_DRO, mode=Modes.NORMAL, - submode=NormalSubmodes.DRO_ON, + submode=( + 1 << NormalSubmodesMask.DRO_ON + | (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON) + ), ) if op_code in OpCodes.NORMAL_X8: pack_pl_pcdu_mode_cmd( tc_queue=tc_queue, info=Info.NORMAL_X8, mode=Modes.NORMAL, - submode=NormalSubmodes.X8_ON, + submode=( + 1 << NormalSubmodesMask.DRO_ON + | (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON) + | (1 << NormalSubmodesMask.X8_ON) + ), ) if op_code in OpCodes.NORMAL_TX: pack_pl_pcdu_mode_cmd( tc_queue=tc_queue, info=Info.NORMAL_TX, mode=Modes.NORMAL, - submode=NormalSubmodes.TX_ON, + submode=( + 1 << NormalSubmodesMask.DRO_ON + | (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON) + | (1 << NormalSubmodesMask.X8_ON) + | (1 << NormalSubmodesMask.TX_ON) + ), ) if op_code in OpCodes.NORMAL_MPA: pack_pl_pcdu_mode_cmd( tc_queue=tc_queue, info=Info.NORMAL_MPA, mode=Modes.NORMAL, - submode=NormalSubmodes.MPA_ON, + submode=( + 1 << NormalSubmodesMask.DRO_ON + | (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON) + | (1 << NormalSubmodesMask.X8_ON) + | (1 << NormalSubmodesMask.TX_ON) + | (1 << NormalSubmodesMask.MPA_ON) + ), ) if op_code in OpCodes.NORMAL_HPA: pack_pl_pcdu_mode_cmd( tc_queue=tc_queue, info=Info.NORMAL_HPA, mode=Modes.NORMAL, - submode=NormalSubmodes.HPA_ON, + submode=( + 1 << NormalSubmodesMask.DRO_ON + | (1 << NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON) + | (1 << NormalSubmodesMask.X8_ON) + | (1 << NormalSubmodesMask.TX_ON) + | (1 << NormalSubmodesMask.MPA_ON) + | (1 << NormalSubmodesMask.MPA_ON) + ), ) if op_code in OpCodes.UPDATE_DRO_TO_X8_WAIT: pack_wait_time_cmd( diff --git a/pus_tc/devs/rad_sensor.py b/pus_tc/devs/rad_sensor.py index 4216a23..cd66930 100644 --- a/pus_tc/devs/rad_sensor.py +++ b/pus_tc/devs/rad_sensor.py @@ -49,24 +49,24 @@ def pack_rad_sensor_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: if op_code == "3": tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Start conversions")) - command = object_id + struct.pack('!I', CommandIds.START_CONVERSIONS) + command = object_id + struct.pack("!I", CommandIds.START_CONVERSIONS) command = PusTelecommand(service=8, subservice=128, ssc=43, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "4": tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Read conversions")) - command = object_id + struct.pack('!I', CommandIds.READ_CONVERSIONS) + command = object_id + struct.pack("!I", CommandIds.READ_CONVERSIONS) command = PusTelecommand(service=8, subservice=128, ssc=44, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "5": tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Enable debug output")) - command = object_id + struct.pack('!I', CommandIds.ENABLE_DEBUG_OUTPUT) + command = object_id + struct.pack("!I", CommandIds.ENABLE_DEBUG_OUTPUT) command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "6": tc_queue.appendleft((QueueCommands.PRINT, "Rad sensor: Disable debug output")) - command = object_id + struct.pack('!I', CommandIds.DISABLE_DEBUG_OUTPUT) + command = object_id + struct.pack("!I", CommandIds.DISABLE_DEBUG_OUTPUT) command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) diff --git a/pus_tc/devs/syrlinks_hk_handler.py b/pus_tc/devs/syrlinks_hk_handler.py index 109ba79..b891e6b 100644 --- a/pus_tc/devs/syrlinks_hk_handler.py +++ b/pus_tc/devs/syrlinks_hk_handler.py @@ -43,16 +43,12 @@ def pack_syrlinks_command( ) if op_code == "0": - tc_queue.appendleft( - (QueueCommands.PRINT, "Syrlinks: Set mode off") - ) + tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Set mode off")) command = pack_mode_data(object_id, Modes.OFF, 0) command = PusTelecommand(service=200, subservice=1, ssc=9, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "1": - tc_queue.appendleft( - (QueueCommands.PRINT, "Syrlinks: Set mode on") - ) + tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Set mode on")) command = pack_mode_data(object_id, Modes.ON, 0) command = PusTelecommand(service=200, subservice=1, ssc=10, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -111,23 +107,17 @@ def pack_syrlinks_command( command = PusTelecommand(service=8, subservice=128, ssc=16, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "12": - tc_queue.appendleft( - (QueueCommands.PRINT, "Syrlinks: Write LCL config") - ) - command = object_id + struct.pack('!I', CommandIds.WRITE_LCL_CONFIG) + tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Write LCL config")) + command = object_id + struct.pack("!I", CommandIds.WRITE_LCL_CONFIG) command = PusTelecommand(service=8, subservice=128, ssc=17, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "13": - tc_queue.appendleft( - (QueueCommands.PRINT, "Syrlinks: Read RX status registers") - ) - command = object_id + struct.pack('!I', CommandIds.READ_RX_STATUS_REGISTERS) + tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Read RX status registers")) + command = object_id + struct.pack("!I", CommandIds.READ_RX_STATUS_REGISTERS) command = PusTelecommand(service=8, subservice=128, ssc=18, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "14": - tc_queue.appendleft( - (QueueCommands.PRINT, "Syrlinks: Read LCL config register") - ) - command = object_id + struct.pack('!I', CommandIds.READ_LCL_CONFIG_REGISTER) + tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Read LCL config register")) + command = object_id + struct.pack("!I", CommandIds.READ_LCL_CONFIG_REGISTER) command = PusTelecommand(service=8, subservice=128, ssc=19, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) From 0fc8369bbcb7162305c8154568e0158b778c65b3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 17:15:12 +0200 Subject: [PATCH 03/26] added p60dock hk handler --- pus_tm/hk_handling.py | 137 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index 6e23ac0..1a03bc7 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -16,6 +16,7 @@ from config.object_ids import ( GPS_HANDLER_1_ID, BPX_HANDLER_ID, CORE_CONTROLLER_ID, + P60_DOCK_HANDLER ) LOGGER = get_console_logger() @@ -45,6 +46,8 @@ def handle_user_hk_packet( return handle_bpx_hk_data(hk_data=hk_data, set_id=set_id) elif object_id == CORE_CONTROLLER_ID: return handle_core_hk_data(hk_data=hk_data, set_id=set_id) + elif object_id == P60_DOCK_HANDLER: + return handle_p60_hk_data(hk_data=hk_data) else: LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.") return HkReplyUnpacked() @@ -355,3 +358,137 @@ def handle_core_hk_data(hk_data: bytes, set_id: int) -> HkReplyUnpacked: reply.validity_buffer = hk_data[12:] reply.num_of_vars = 3 return reply + + +P60_INDEX_LIST = [ + "ACU VCC", "PDU1 VCC", "X3 IDLE", "PDU2 VCC", "ACU VBAT", "PDU1 VBAT", + "X3 IDLE VBAT", "PDU2 VBAT", "STACK VBAT", "STACK 3V3", "STACK 5V", + "GS3V3", "GS5V" +] + + +def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked: + reply = HkReplyUnpacked() + current_idx = 0 + for idx in range(0, 13): + if idx == 0: + reply.header_list.append(f"I [mA] {P60_INDEX_LIST[idx]}") + + else: + reply.header_list.append(f"I {P60_INDEX_LIST[idx]}") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + for idx in range(0, 13): + if idx == 0: + reply.header_list.append(f"U [mV] {P60_INDEX_LIST[idx]}") + else: + reply.header_list.append(f"U {P60_INDEX_LIST[idx]}") + reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + for idx in range(0, 13): + reply.header_list.append(f"OutEnb {P60_INDEX_LIST[idx]}") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + reply.header_list.append("Temp 0 [C]") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Temp 1 [C]") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Boot Cause") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("Boot Count") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("Uptime") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("Reset Cause") + reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 2 + reply.header_list.append("Battery Mode") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + reply.header_list.append("Heater On") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + reply.header_list.append("Conv 5V Enable Status") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + for idx in range(0, 13): + reply.header_list.append(f"Latchup {P60_INDEX_LIST[idx]}") + reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Dock VBAT [mV]") + reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Dock VCC Current [mA]") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Batt Charge [mA]") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Batt Voltage [mV]") + reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Batt Temp 0 [C]") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Batt Temp 1 [C]") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + for idx in range(0, 7): + reply.header_list.append(f"Device {idx} type") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + for idx in range(0, 7): + reply.header_list.append(f"Device {idx} status") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + reply.header_list.append("De-Arm Status") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + reply.header_list.append("GND WDT Reboots") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("I2C WDT Reboots") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("CAN WDT Reboots") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("CSP0 WDT Reboots") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("CSP1 WDT Reboots") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("GND WDT time left [s]") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("I2C WDT time left [s]") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("CAN WDT time left [s]") + reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + current_idx += 4 + reply.header_list.append("CSP0 WDT Pings Left") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + reply.header_list.append("CSP1 WDT Pings left") + reply.content_list.append(hk_data[current_idx]) + current_idx += 1 + reply.header_list.append("Batt Charge Current") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("Batt Discharge Current") + reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + current_idx += 2 + reply.header_list.append("ANT6 Depl Status") + reply.content_list.append(struct.unpack("!b", hk_data[current_idx: current_idx + 1])[0]) + current_idx += 1 + reply.header_list.append("AR6 Depl Status") + reply.content_list.append(struct.unpack("!b", hk_data[current_idx: current_idx + 1])[0]) + current_idx += 1 + return reply From 923929ca5511e70b460f6edeaab607b259f0bff5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 18:46:52 +0200 Subject: [PATCH 04/26] HKhandler p60dock --- gomspace/gomspace_common.py | 8 +-- pus_tc/cmd_definitions.py | 38 +++++------ pus_tc/devs/p60dock.py | 45 ++++++++----- pus_tc/devs/pdu1.py | 6 +- pus_tc/devs/pdu2.py | 6 +- pus_tm/hk_handling.py | 126 +++++++++++++++++++++++++++--------- tmtccmd | 2 +- 7 files changed, 153 insertions(+), 78 deletions(-) diff --git a/gomspace/gomspace_common.py b/gomspace/gomspace_common.py index 4130665..546730f 100644 --- a/gomspace/gomspace_common.py +++ b/gomspace/gomspace_common.py @@ -23,11 +23,11 @@ class GomspaceDeviceActionIds(enum.IntEnum): PRINT_LATCHUPS = 33 -class GomspaceOpCodes(enum.Enum): +class GomspaceOpCodes: # Request HK - REQUEST_HK_ONCE = "128" - PRINT_SWITCH_V_I = "129" - PRINT_LATCHUPS = "130" + REQUEST_HK_ONCE = ["req-hk-once", "128"] + PRINT_SWITCH_V_I = ["print-switch-vi", "129"] + PRINT_LATCHUPS = ["print-latchups", "130"] class SetIds: diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index a41d75e..fafaa78 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -180,47 +180,47 @@ def add_pl_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): - from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes + from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes, Info from pus_tc.devs.pdu1 import Pdu1OpCodes from pus_tc.devs.pdu2 import Pdu2OpCodes op_code_dict = dict() - add_op_code_entry(op_code_dict=op_code_dict, keys="0", info="P60 Tests") add_op_code_entry( op_code_dict=op_code_dict, - keys=P60OpCodes.STACK_3V3_ON.value, - info="P60 Dock: Turn stack 3V3 on", + keys=P60OpCodes.STACK_3V3_ON, + info=Info.STACK_3V3_ON, ) add_op_code_entry( op_code_dict=op_code_dict, - keys=P60OpCodes.STACK_3V3_OFF.value, - info="P60 Dock: Turn stack 3V3 off", + keys=P60OpCodes.STACK_3V3_OFF, + info=Info.STACK_3V3_OFF, ) add_op_code_entry( op_code_dict=op_code_dict, - keys=P60OpCodes.STACK_5V_ON.value, - info="P60 Dock: Turn stack 5V on", + keys=P60OpCodes.STACK_5V_ON, + info=Info.STACK_5V_ON, ) add_op_code_entry( op_code_dict=op_code_dict, - keys=P60OpCodes.STACK_5V_OFF.value, - info="P60 Dock: Turn stack 5V off", + keys=P60OpCodes.STACK_5V_OFF, + info=Info.STACK_5V_OFF, ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.REQUEST_HK_ONCE.value, + keys=GomspaceOpCodes.REQUEST_HK_ONCE, info="P60 Dock: Request HK once", ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value, + keys=GomspaceOpCodes.PRINT_SWITCH_V_I, info="P60 Dock: Print Switches, Voltages, Currents", ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.PRINT_LATCHUPS.value, + keys=GomspaceOpCodes.PRINT_LATCHUPS, info="P60 Dock: Print Latchups", ) + add_op_code_entry(op_code_dict=op_code_dict, keys=P60OpCodes.TEST, info="P60 Tests") add_service_op_code_entry( srv_op_code_dict=cmd_dict, name=CustomServiceList.P60DOCK.value, @@ -311,17 +311,17 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.REQUEST_HK_ONCE.value, + keys=GomspaceOpCodes.REQUEST_HK_ONCE, info="PDU1: Request HK once", ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value, + keys=GomspaceOpCodes.PRINT_SWITCH_V_I, info="PDU1: Print Switches, Voltages, Currents", ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.PRINT_LATCHUPS.value, + keys=GomspaceOpCodes.PRINT_LATCHUPS, info="PDU1: Print Latchups", ) add_op_code_entry( @@ -418,18 +418,18 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.REQUEST_HK_ONCE.value, + keys=GomspaceOpCodes.REQUEST_HK_ONCE, info="PDU2: Request HK once", ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value, + keys=GomspaceOpCodes.PRINT_SWITCH_V_I, info="PDU2: Print Switches, Voltages, Currents", options={OpCodeDictKeys.TIMEOUT: 2.0}, ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.PRINT_LATCHUPS.value, + keys=GomspaceOpCodes.PRINT_LATCHUPS, info="PDU2: Print Latchups", ) add_service_op_code_entry( diff --git a/pus_tc/devs/p60dock.py b/pus_tc/devs/p60dock.py index e9d08ee..e86abd4 100644 --- a/pus_tc/devs/p60dock.py +++ b/pus_tc/devs/p60dock.py @@ -12,12 +12,23 @@ from gomspace.gomspace_common import * from config.object_ids import P60_DOCK_HANDLER -class P60OpCodes(enum.Enum): - TEST = "0" - STACK_3V3_ON = "1" - STACK_3V3_OFF = "2" - STACK_5V_ON = "3" - STACK_5V_OFF = "4" +HK_SET_ID = 0x3 + + +class P60OpCodes: + STACK_3V3_ON = ["stack-3v3-on", "1"] + STACK_3V3_OFF = ["stack-3v3-off", "2"] + STACK_5V_ON = ["stack-5v-on", "3"] + STACK_5V_OFF = ["stack-5v-off", "4"] + TEST = ["test", "0"] + + +class Info: + PREFIX = "P60 Dock" + STACK_3V3_ON = f"{PREFIX}: Turn Stack 3V3 on" + STACK_3V3_OFF = f"{PREFIX}: Turn Stack 3V3 off" + STACK_5V_ON = f"{PREFIX}: Turn Stack 5V on" + STACK_5V_OFF = f"{PREFIX}: Turn Stack 5V off" class P60DockTestProcedure: @@ -76,8 +87,8 @@ class P60DockHkTable: def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str): - if op_code == P60OpCodes.STACK_3V3_ON.value: - tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning stack 3V3 on")) + if op_code in P60OpCodes.STACK_3V3_ON: + tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_3V3_ON)) command = pack_set_param_command( object_id, P60DockConfigTable.out_en_9.parameter_address, @@ -85,8 +96,8 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st Channel.on, ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == P60OpCodes.STACK_3V3_OFF.value: - tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning stack 3V3 off")) + if op_code in P60OpCodes.STACK_3V3_OFF: + tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_3V3_OFF)) command = pack_set_param_command( object_id, P60DockConfigTable.out_en_9.parameter_address, @@ -94,8 +105,8 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st Channel.off, ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == P60OpCodes.STACK_5V_ON.value: - tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning stack 5V on")) + if op_code in P60OpCodes.STACK_5V_ON: + tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_5V_ON)) command = pack_set_param_command( object_id, P60DockConfigTable.out_en_10.parameter_address, @@ -103,8 +114,8 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st Channel.on, ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == P60OpCodes.STACK_5V_OFF.value: - tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning stack 5V off")) + if op_code in P60OpCodes.STACK_5V_OFF: + tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_5V_OFF)) command = pack_set_param_command( object_id, P60DockConfigTable.out_en_10.parameter_address, @@ -112,12 +123,12 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st Channel.off, ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.REQUEST_HK_ONCE.value: + if op_code in GomspaceOpCodes.REQUEST_HK_ONCE: tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Requesting HK Table Once")) hk_sid = make_sid(object_id=P60_DOCK_HANDLER, set_id=SetIds.P60_DOCK) command = generate_one_hk_command(sid=hk_sid, ssc=0) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value: + if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: tc_queue.appendleft( (QueueCommands.PRINT, "P60 Dock: Print Switches, Voltages, Currents") ) @@ -125,7 +136,7 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: st object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.PRINT_LATCHUPS.value: + if op_code in GomspaceOpCodes.PRINT_LATCHUPS: tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Print Latchups")) command = generate_action_command( object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS diff --git a/pus_tc/devs/pdu1.py b/pus_tc/devs/pdu1.py index eaaa3c1..80e3696 100644 --- a/pus_tc/devs/pdu1.py +++ b/pus_tc/devs/pdu1.py @@ -210,12 +210,12 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): Channel.off, ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.REQUEST_HK_ONCE.value: + if op_code in GomspaceOpCodes.REQUEST_HK_ONCE: tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Requesting HK Table Once")) hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1) command = generate_one_hk_command(sid=hk_sid, ssc=0) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value: + if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: tc_queue.appendleft( (QueueCommands.PRINT, "PDU1: Print Switches, Voltages, Currents") ) @@ -223,7 +223,7 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.PRINT_LATCHUPS.value: + if op_code in GomspaceOpCodes.PRINT_LATCHUPS: tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Print Latchups")) command = generate_action_command( object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS diff --git a/pus_tc/devs/pdu2.py b/pus_tc/devs/pdu2.py index d08087d..5ac74af 100644 --- a/pus_tc/devs/pdu2.py +++ b/pus_tc/devs/pdu2.py @@ -232,12 +232,12 @@ def pack_pdu2_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): Channel.off, ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.REQUEST_HK_ONCE.value: + if op_code in GomspaceOpCodes.REQUEST_HK_ONCE: tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Requesting HK Table Once")) hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2) command = generate_one_hk_command(sid=hk_sid, ssc=0) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value: + if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: tc_queue.appendleft( (QueueCommands.PRINT, "PDU2: Print Switches, Currents, Voltahes") ) @@ -245,7 +245,7 @@ def pack_pdu2_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I ) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == GomspaceOpCodes.PRINT_LATCHUPS.value: + if op_code in GomspaceOpCodes.PRINT_LATCHUPS: tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Print Latchups")) command = generate_action_command( object_id=object_id, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index 1a03bc7..9924dcc 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -16,7 +16,7 @@ from config.object_ids import ( GPS_HANDLER_1_ID, BPX_HANDLER_ID, CORE_CONTROLLER_ID, - P60_DOCK_HANDLER + P60_DOCK_HANDLER, ) LOGGER = get_console_logger() @@ -361,9 +361,19 @@ def handle_core_hk_data(hk_data: bytes, set_id: int) -> HkReplyUnpacked: P60_INDEX_LIST = [ - "ACU VCC", "PDU1 VCC", "X3 IDLE", "PDU2 VCC", "ACU VBAT", "PDU1 VBAT", - "X3 IDLE VBAT", "PDU2 VBAT", "STACK VBAT", "STACK 3V3", "STACK 5V", - "GS3V3", "GS5V" + "ACU VCC", + "PDU1 VCC", + "X3 IDLE", + "PDU2 VCC", + "ACU VBAT", + "PDU1 VBAT", + "X3 IDLE VBAT", + "PDU2 VBAT", + "STACK VBAT", + "STACK 3V3", + "STACK 5V", + "GS3V3", + "GS5V", ] @@ -376,36 +386,52 @@ def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked: else: reply.header_list.append(f"I {P60_INDEX_LIST[idx]}") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 for idx in range(0, 13): if idx == 0: reply.header_list.append(f"U [mV] {P60_INDEX_LIST[idx]}") else: reply.header_list.append(f"U {P60_INDEX_LIST[idx]}") - reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 for idx in range(0, 13): reply.header_list.append(f"OutEnb {P60_INDEX_LIST[idx]}") reply.content_list.append(hk_data[current_idx]) current_idx += 1 reply.header_list.append("Temp 0 [C]") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Temp 1 [C]") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Boot Cause") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("Boot Count") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("Uptime") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("Reset Cause") - reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Battery Mode") reply.content_list.append(hk_data[current_idx]) @@ -418,25 +444,39 @@ def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked: current_idx += 1 for idx in range(0, 13): reply.header_list.append(f"Latchup {P60_INDEX_LIST[idx]}") - reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Dock VBAT [mV]") - reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Dock VCC Current [mA]") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Batt Charge [mA]") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Batt Voltage [mV]") - reply.content_list.append(struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Batt Temp 0 [C]") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Batt Temp 1 [C]") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 for idx in range(0, 7): reply.header_list.append(f"Device {idx} type") @@ -450,28 +490,44 @@ def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked: reply.content_list.append(hk_data[current_idx]) current_idx += 1 reply.header_list.append("GND WDT Reboots") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("I2C WDT Reboots") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("CAN WDT Reboots") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("CSP0 WDT Reboots") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("CSP1 WDT Reboots") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("GND WDT time left [s]") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("I2C WDT time left [s]") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("CAN WDT time left [s]") - reply.content_list.append(struct.unpack("!I", hk_data[current_idx: current_idx + 4])[0]) + reply.content_list.append( + struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0] + ) current_idx += 4 reply.header_list.append("CSP0 WDT Pings Left") reply.content_list.append(hk_data[current_idx]) @@ -480,15 +536,23 @@ def handle_p60_hk_data(hk_data: bytes) -> HkReplyUnpacked: reply.content_list.append(hk_data[current_idx]) current_idx += 1 reply.header_list.append("Batt Charge Current") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("Batt Discharge Current") - reply.content_list.append(struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0]) + reply.content_list.append( + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] + ) current_idx += 2 reply.header_list.append("ANT6 Depl Status") - reply.content_list.append(struct.unpack("!b", hk_data[current_idx: current_idx + 1])[0]) + reply.content_list.append( + struct.unpack("!b", hk_data[current_idx : current_idx + 1])[0] + ) current_idx += 1 reply.header_list.append("AR6 Depl Status") - reply.content_list.append(struct.unpack("!b", hk_data[current_idx: current_idx + 1])[0]) + reply.content_list.append( + struct.unpack("!b", hk_data[current_idx : current_idx + 1])[0] + ) current_idx += 1 return reply diff --git a/tmtccmd b/tmtccmd index 06aed2f..3cda2df 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 06aed2f309a105f8f0e183d359a432301eb6947d +Subproject commit 3cda2df79d2b3eb29855a29ff33df8e4d6f18ae1 From 2b7a75e32b1a5f851be928cf0d62dbc863909159 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 22:32:15 +0200 Subject: [PATCH 05/26] temporary fix for tmtc printer overhaul --- config/hook_implementations.py | 18 ++---------------- config/object_ids.py | 2 +- config/retvals.py | 2 +- pus_tm/event_handler.py | 2 +- pus_tm/factory_hook.py | 13 +++++++------ tmtccli.py | 15 ++++++--------- tmtccmd | 2 +- 7 files changed, 19 insertions(+), 35 deletions(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 3915be8..4e0790c 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -13,7 +13,7 @@ from tmtccmd.pus.obj_id import ObjectIdDictT from tmtccmd.com_if.com_interface_base import CommunicationInterface from tmtccmd.core.backend import TmTcHandler from tmtccmd.config.hook import TmTcHookBase -from tmtccmd.utility.tmtc_printer import TmTcPrinter +from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter from tmtccmd.config.globals import OpCodeDictKeys from config.definitions import CustomServiceList @@ -50,13 +50,12 @@ class EiveHookObject(TmTcHookBase): ) def assign_communication_interface( - self, com_if_key: str, tmtc_printer: TmTcPrinter + self, com_if_key: str ) -> Union[CommunicationInterface, None]: from tmtccmd.config.com_if import create_communication_interface_default return create_communication_interface_default( com_if_key=com_if_key, - tmtc_printer=tmtc_printer, json_cfg_path=self.get_json_config_file_path(), space_packet_ids=(0x0865,), ) @@ -88,19 +87,6 @@ class EiveHookObject(TmTcHookBase): object_id=object_id, action_id=action_id, custom_data=custom_data ) - @staticmethod - def handle_service_3_housekeeping( - object_id: bytes, set_id: int, hk_data: bytearray, service3_packet: Service3Base - ) -> HkReplyUnpacked: - from pus_tm.hk_handling import handle_user_hk_packet - - return handle_user_hk_packet( - object_id=object_id, - set_id=set_id, - hk_data=hk_data, - service3_packet=service3_packet, - ) - @staticmethod def handle_service_5_event( object_id: bytes, event_id: int, param_1: int, param_2: int diff --git a/config/object_ids.py b/config/object_ids.py index 08ecc6c..bbeb7d0 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -5,7 +5,7 @@ """ import os.path from tmtccmd.pus.obj_id import ObjectIdDictT -from tmtccmd.utility.fsfw import parse_fsfw_objects_csv +from tmtccmd.fsfw import parse_fsfw_objects_csv from tmtccmd.utility.logger import get_console_logger LOGGER = get_console_logger() diff --git a/config/retvals.py b/config/retvals.py index ab1a78d..b80218d 100644 --- a/config/retvals.py +++ b/config/retvals.py @@ -1,5 +1,5 @@ import os -from tmtccmd.utility.fsfw import parse_fsfw_returnvalues_csv, RetvalDictT +from tmtccmd.fsfw import parse_fsfw_returnvalues_csv, RetvalDictT from tmtccmd.utility.logger import get_console_logger DEFAULT_RETVAL_CSV_NAME = "config/returnvalues.csv" diff --git a/pus_tm/event_handler.py b/pus_tm/event_handler.py index 8d64db5..1455ce8 100644 --- a/pus_tm/event_handler.py +++ b/pus_tm/event_handler.py @@ -2,7 +2,7 @@ import os.path from config.object_ids import get_object_ids from tmtccmd.utility.logger import get_console_logger -from tmtccmd.utility.fsfw import parse_fsfw_events_csv, EventDictT, EventInfo +from tmtccmd.fsfw import parse_fsfw_events_csv, EventDictT, EventInfo LOGGER = get_console_logger() DEFAULT_EVENTS_CSV_PATH = "config/events.csv" diff --git a/pus_tm/factory_hook.py b/pus_tm/factory_hook.py index 4532bd1..20d7a75 100644 --- a/pus_tm/factory_hook.py +++ b/pus_tm/factory_hook.py @@ -13,7 +13,7 @@ from tmtccmd.tm.service_3_fsfw_housekeeping import Service3FsfwTm from tmtccmd.tm.service_20_fsfw_parameters import Service20FsfwTm from tmtccmd.tm.service_5_event import Service5Tm from tmtccmd.tm.service_200_fsfw_mode import Service200FsfwTm -from tmtccmd.utility.tmtc_printer import TmTcPrinter, PrintFormats +from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter, PrintFormats from config.definitions import PUS_APID @@ -21,13 +21,13 @@ LOGGER = get_console_logger() def ccsds_tm_handler( - apid: int, raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter + apid: int, raw_tm_packet: bytes, tmtc_printer: FsfwTmTcPrinter ) -> None: if apid == PUS_APID: pus_factory_hook(raw_tm_packet=raw_tm_packet, tmtc_printer=tmtc_printer) -def pus_factory_hook(raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter): +def pus_factory_hook(raw_tm_packet: bytes, tmtc_printer: FsfwTmTcPrinter): if len(raw_tm_packet) < 8: LOGGER.warning("Detected packet shorter than 8 bytes!") return @@ -56,9 +56,10 @@ def pus_factory_hook(raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter): ) tm_packet = PusTelemetry.unpack(raw_telemetry=raw_tm_packet) tm_packet.print_source_data(PrintFormats.HEX) - tmtc_printer.print_telemetry( - packet_if=tm_packet, info_if=tm_packet, print_raw_tm=False - ) + LOGGER.info(f"Received packet with service {service_type}") + # tmtc_printer.print_telemetry( + # packet_if=tm_packet, info_if=tm_packet, print_raw_tm=False + # ) except ValueError: # TODO: Log faulty packet LOGGER.warning("Invalid packet format detected") diff --git a/tmtccli.py b/tmtccli.py index 9561eb9..9cf2831 100755 --- a/tmtccli.py +++ b/tmtccli.py @@ -26,6 +26,7 @@ limitations under the License. @author R. Mueller """ +import logging import sys import traceback @@ -35,8 +36,8 @@ try: run_tmtc_commander, add_ccsds_handler, ) - from tmtccmd.ccsds.handler import CcsdsTmHandler - from tmtccmd.utility.logger import TMTC_LOGGER_NAME + from tmtccmd.ccsds.handler import CcsdsTmHandler, ApidHandler + from tmtccmd.utility.logger import init_console_logger except ImportError as error: run_tmtc_commander = None initialize_tmtc_commander = None @@ -47,7 +48,6 @@ except ImportError as error: try: import spacepackets - from spacepackets.log import set_custom_console_logger_name except ImportError as error: print(error) print("Python spacepackets module could not be imported") @@ -63,17 +63,14 @@ from pus_tm.factory_hook import ccsds_tm_handler def main(): - from pus_tm.event_handler import handle_event_packet - hook_obj = EiveHookObject() print(f"-- eive tmtc version {__version__} --") print(f"-- spacepackets version {spacepackets.__version__} --") - set_custom_console_logger_name(logger_name=TMTC_LOGGER_NAME) initialize_tmtc_commander(hook_object=hook_obj) ccsds_handler = CcsdsTmHandler() - ccsds_handler.add_tm_handler( - apid=PUS_APID, pus_tm_handler=ccsds_tm_handler, max_queue_len=50 - ) + init_console_logger(logging.DEBUG) + pus_handler = ApidHandler(cb=ccsds_tm_handler, queue_len=50, user_args=None) + ccsds_handler.add_tm_handler(apid=PUS_APID, handler=pus_handler) add_ccsds_handler(ccsds_handler) run_tmtc_commander(False) diff --git a/tmtccmd b/tmtccmd index 3cda2df..946c128 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 3cda2df79d2b3eb29855a29ff33df8e4d6f18ae1 +Subproject commit 946c128e111ea460034d8bf3a3d3a8f81bccb0c5 From c94e3bd0851d32ed22077eda761a4217fc519636 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 5 Apr 2022 00:51:52 +0200 Subject: [PATCH 06/26] moved logger --- .idea/runConfigurations/Unittests_in_tmtccmd.xml | 2 +- config/custom_mode_op.py | 2 +- config/globals_config.py | 2 +- config/object_ids.py | 2 +- config/retvals.py | 2 +- pus_tc/devs/ploc_mpsoc.py | 2 +- pus_tc/devs/ploc_supervisor.py | 2 +- pus_tc/devs/plpcdu.py | 2 +- pus_tc/devs/star_tracker.py | 2 +- pus_tc/system/core.py | 2 +- pus_tc/tc_packer_hook.py | 2 +- pus_tm/event_handler.py | 2 +- pus_tm/factory_hook.py | 2 +- pus_tm/hk_handling.py | 2 +- pus_tm/service_8_hook.py | 2 +- spacepackets | 2 +- tmtccli.py | 2 +- tmtccmd | 2 +- utility/input_helper.py | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.idea/runConfigurations/Unittests_in_tmtccmd.xml b/.idea/runConfigurations/Unittests_in_tmtccmd.xml index f6549f0..5cdbb08 100644 --- a/.idea/runConfigurations/Unittests_in_tmtccmd.xml +++ b/.idea/runConfigurations/Unittests_in_tmtccmd.xml @@ -4,7 +4,7 @@