From 3a1c7c62887eb377c498bd9cdac47b93f40c85ba Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 8 Apr 2022 14:46:01 +0200 Subject: [PATCH] update HK handling --- gomspace/gomspace_common.py | 12 +++++++++--- pus_tc/cmd_definitions.py | 14 ++++++++++---- pus_tc/devs/p60dock.py | 17 +++++++++++++---- pus_tc/devs/pdu1.py | 2 +- pus_tc/devs/pdu2.py | 2 +- pus_tc/devs/plpcdu.py | 2 +- pus_tc/tc_packer_hook.py | 4 ++-- pus_tm/hk_handling.py | 13 +++++++------ 8 files changed, 44 insertions(+), 22 deletions(-) diff --git a/gomspace/gomspace_common.py b/gomspace/gomspace_common.py index 684d730..e7fa956 100644 --- a/gomspace/gomspace_common.py +++ b/gomspace/gomspace_common.py @@ -25,9 +25,15 @@ class GomspaceDeviceActionIds(enum.IntEnum): class GomspaceOpCodes: # Request HK - REQUEST_HK_ONCE = ["req-hk-once", "128"] - PRINT_SWITCH_V_I = ["print-switch-vi", "129"] - PRINT_LATCHUPS = ["print-latchups", "130"] + REQUEST_CORE_HK_ONCE = ["hk-core", "128"] + REQUEST_AUX_HK_ONCE = ["hk-aux", "129"] + PRINT_SWITCH_V_I = ["print-switch-vi", "130"] + PRINT_LATCHUPS = ["print-latchups", "131"] + + +class Info: + REQUEST_CORE_HK_ONCE = "Requesting Core HK once" + REQUEST_AUX_HK_ONCE = "Requesting Aux HK once" class SetIds: diff --git a/pus_tc/cmd_definitions.py b/pus_tc/cmd_definitions.py index fafaa78..c5646c9 100644 --- a/pus_tc/cmd_definitions.py +++ b/pus_tc/cmd_definitions.py @@ -183,6 +183,7 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): from pus_tc.devs.p60dock import P60OpCodes, GomspaceOpCodes, Info from pus_tc.devs.pdu1 import Pdu1OpCodes from pus_tc.devs.pdu2 import Pdu2OpCodes + from gomspace.gomspace_common import Info as GsInfo op_code_dict = dict() add_op_code_entry( @@ -207,8 +208,13 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.REQUEST_HK_ONCE, - info="P60 Dock: Request HK once", + keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, + info=GsInfo.REQUEST_CORE_HK_ONCE, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=GomspaceOpCodes.REQUEST_AUX_HK_ONCE, + info=GsInfo.REQUEST_AUX_HK_ONCE, ) add_op_code_entry( op_code_dict=op_code_dict, @@ -311,7 +317,7 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.REQUEST_HK_ONCE, + keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info="PDU1: Request HK once", ) add_op_code_entry( @@ -418,7 +424,7 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): ) add_op_code_entry( op_code_dict=op_code_dict, - keys=GomspaceOpCodes.REQUEST_HK_ONCE, + keys=GomspaceOpCodes.REQUEST_CORE_HK_ONCE, info="PDU2: Request HK once", ) add_op_code_entry( diff --git a/pus_tc/devs/p60dock.py b/pus_tc/devs/p60dock.py index 2f358ca..dbdc59a 100644 --- a/pus_tc/devs/p60dock.py +++ b/pus_tc/devs/p60dock.py @@ -90,7 +90,7 @@ class P60DockHkTable: wdt_gnd_left = TableEntry(bytearray([0x00, 0xA8]), TableEntry.uint32_size) -def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str): +def pack_p60dock_cmds(object_id: bytearray, tc_queue: TcQueueT, op_code: str): if op_code in P60OpCodes.STACK_3V3_ON: tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_3V3_ON)) command = pack_set_param_command( @@ -127,9 +127,18 @@ 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 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) + if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: + tc_queue.appendleft( + (QueueCommands.PRINT, "P60 Dock: Requesting HK Core HK Once") + ) + hk_sid = make_sid(object_id=P60_DOCK_HANDLER, set_id=SetIds.P60_CORE) + command = generate_one_hk_command(sid=hk_sid, ssc=0) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE: + tc_queue.appendleft( + (QueueCommands.PRINT, "P60 Dock: Requesting HK Aux HK Once") + ) + hk_sid = make_sid(object_id=P60_DOCK_HANDLER, set_id=SetIds.P60_AUX) command = generate_one_hk_command(sid=hk_sid, ssc=0) tc_queue.appendleft(command.pack_command_tuple()) if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: diff --git a/pus_tc/devs/pdu1.py b/pus_tc/devs/pdu1.py index 80e3696..c7897af 100644 --- a/pus_tc/devs/pdu1.py +++ b/pus_tc/devs/pdu1.py @@ -210,7 +210,7 @@ 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 in GomspaceOpCodes.REQUEST_HK_ONCE: + if op_code in GomspaceOpCodes.REQUEST_CORE_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) diff --git a/pus_tc/devs/pdu2.py b/pus_tc/devs/pdu2.py index 5ac74af..0ab8829 100644 --- a/pus_tc/devs/pdu2.py +++ b/pus_tc/devs/pdu2.py @@ -232,7 +232,7 @@ 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 in GomspaceOpCodes.REQUEST_HK_ONCE: + if op_code in GomspaceOpCodes.REQUEST_CORE_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) diff --git a/pus_tc/devs/plpcdu.py b/pus_tc/devs/plpcdu.py index 7fddabc..dd6f027 100644 --- a/pus_tc/devs/plpcdu.py +++ b/pus_tc/devs/plpcdu.py @@ -225,7 +225,7 @@ def pack_failure_injection_cmd(tc_queue: TcQueueT, param_id: int, print_str: str tc_queue.appendleft(cmd.pack_command_tuple()) -def pack_pl_pcdu_mode_cmd(tc_queue: TcQueueT, info: str, mode: int, submode: int): +def pack_pl_pcdu_mode_cmd(tc_queue: TcQueueT, info: str, mode: Modes, submode: int): tc_queue.appendleft( ( QueueCommands.PRINT, diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index c53c6bb..50bb8c6 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -16,7 +16,7 @@ from tmtccmd.pus.service_17_test import pack_service_17_ping_command from tmtccmd.logging import get_current_time_string from pus_tc.service_200_mode import pack_service200_test_into -from pus_tc.devs.p60dock import pack_p60dock_test_into +from pus_tc.devs.p60dock import pack_p60dock_cmds from pus_tc.devs.pdu2 import pack_pdu2_commands from pus_tc.devs.pdu1 import pack_pdu1_commands from pus_tc.devs.bpx_batt import pack_bpx_commands @@ -101,7 +101,7 @@ def pack_service_queue_user( return pack_service200_test_into(tc_queue=service_queue) if service == CustomServiceList.P60DOCK.value: object_id = P60_DOCK_HANDLER - return pack_p60dock_test_into( + return pack_p60dock_cmds( object_id=object_id, tc_queue=service_queue, op_code=op_code ) if service == CustomServiceList.PDU1.value: diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index 85e3dde..2f133ec 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -87,7 +87,7 @@ def handle_regular_hk_print( elif object_id == CORE_CONTROLLER_ID: return handle_core_hk_data(printer=printer, hk_data=hk_data) elif object_id == P60_DOCK_HANDLER: - handle_p60_hk_data(printer=printer, hk_data=hk_data) + handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data) elif object_id == PL_PCDU_ID: log_to_both(printer, "Received PL PCDU HK data") else: @@ -432,7 +432,7 @@ WDT_LIST = ["GND", "I2C", "CAN", "CSP0", "CSP1"] def handle_p60_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes): if set_id == SetIds.P60_CORE: - log_to_both(printer, "P60 Core HK") + log_to_both(printer, "Received P60 Core HK. Voltages in mV, currents in mA") current_idx = 0 current_list = [] for idx in range(13): @@ -472,17 +472,18 @@ def handle_p60_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes): ) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len]) current_idx += inc_len batt_info = ( - f"Batt Mode {batt_mode} | Boot Count {boot_count} | " - f"Batt: Current {batt_current} | Volt {batt_voltage}" + f"Batt: Mode {batt_mode} | Boot Count {boot_count} | " + f"Charge current {batt_current} | Voltage {batt_voltage}" ) temps = f"In C: Temp 0 {temp_0 / 10.0} | Temp 1 {temp_1 / 10.0} | " log_to_both(printer, temps) log_to_both(printer, batt_info) printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=9) if set_id == SetIds.P60_AUX: - log_to_both(printer, "P60 AUX HK") + log_to_both(printer, "Received P60 AUX HK. Voltages in mV, currents in mA") current_idx = 0 latchup_list = [] + log_to_both(printer, "P60 Dock Latchups") for idx in range(0, 13): latchup_list.append( struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0] @@ -559,7 +560,7 @@ def handle_p60_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes): ) log_to_both(printer, misc_info) batt_info = ( - f"Batt Temp 0 {batt_temp_0 / 10.0} | Batt Temp 1 {batt_temp_1 / 10.0}" + f"Batt Temp 0 {batt_temp_0 / 10.0} | Batt Temp 1 {batt_temp_1 / 10.0} | " f"Charge Current {batt_charge_current} | Discharge Current {batt_discharge_current}" ) log_to_both(printer, batt_info)