From c995ca2ddac4b352bce34071366a8cee7724973a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 12 Apr 2022 16:10:51 +0200 Subject: [PATCH] core hk handling working --- pus_tc/devs/pdu1.py | 4 ++-- pus_tc/devs/pdu2.py | 4 ++-- pus_tm/hk_handling.py | 38 +++++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/pus_tc/devs/pdu1.py b/pus_tc/devs/pdu1.py index c7897af..a1799b0 100644 --- a/pus_tc/devs/pdu1.py +++ b/pus_tc/devs/pdu1.py @@ -211,8 +211,8 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): ) tc_queue.appendleft(command.pack_command_tuple()) 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) + tc_queue.appendleft((QueueCommands.PRINT, f"PDU1: {Info.REQUEST_CORE_HK_ONCE}")) + hk_sid = make_sid(object_id=PDU_1_HANDLER_ID, set_id=SetIds.PDU_1_CORE) 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/pdu2.py b/pus_tc/devs/pdu2.py index 0ab8829..1c8f9b7 100644 --- a/pus_tc/devs/pdu2.py +++ b/pus_tc/devs/pdu2.py @@ -233,8 +233,8 @@ def pack_pdu2_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): ) tc_queue.appendleft(command.pack_command_tuple()) 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) + tc_queue.appendleft((QueueCommands.PRINT, f"PDU2: {Info.REQUEST_CORE_HK_ONCE}")) + hk_sid = make_sid(object_id=PDU_2_HANDLER_ID, set_id=SetIds.PDU_2_CORE) 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_tm/hk_handling.py b/pus_tm/hk_handling.py index 5d59eda..ccf3dad 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -79,9 +79,13 @@ def handle_regular_hk_print( elif object_id == obj_ids.CORE_CONTROLLER_ID: return handle_core_hk_data(printer=printer, hk_data=hk_data) elif object_id == obj_ids.PDU_1_HANDLER_ID: - return handle_pdu_data(printer=printer, pdu_idx=1, hk_data=hk_data) + return handle_pdu_data( + printer=printer, pdu_idx=1, set_id=set_id, hk_data=hk_data + ) elif object_id == obj_ids.PDU_2_HANDLER_ID: - return handle_pdu_data(printer=printer, pdu_idx=2, hk_data=hk_data) + return handle_pdu_data( + printer=printer, pdu_idx=2, set_id=set_id, hk_data=hk_data + ) elif object_id == obj_ids.P60_DOCK_HANDLER: handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data) elif object_id == obj_ids.PL_PCDU_ID: @@ -434,7 +438,7 @@ PDU1_CHANNELS_NAMES = [ "SCEX", "PLOC", "ACS A Side", - "Unused Channel 8" + "Unused Channel 8", ] PDU2_CHANNELS_NAMES = [ @@ -446,16 +450,15 @@ PDU2_CHANNELS_NAMES = [ "Deployment Mechanism", "Payload PCDU CH6", "ACS B Side", - "Payload Camera" + "Payload Camera", ] -PDU_CHANNEL_NAMES = [ - PDU1_CHANNELS_NAMES, - PDU2_CHANNELS_NAMES -] +PDU_CHANNEL_NAMES = [PDU1_CHANNELS_NAMES, PDU2_CHANNELS_NAMES] -def handle_pdu_data(printer: FsfwTmTcPrinter, pdu_idx: int, set_id: int, hk_data: bytes): +def handle_pdu_data( + printer: FsfwTmTcPrinter, pdu_idx: int, set_id: int, hk_data: bytes +): if set_id == SetIds.PDU_1_AUX or set_id == SetIds.PDU_2_AUX: log_to_both(printer, "PDU AUX HK TODO") if set_id == SetIds.PDU_1_CORE or set_id == SetIds.PDU_2_CORE: @@ -465,13 +468,13 @@ def handle_pdu_data(printer: FsfwTmTcPrinter, pdu_idx: int, set_id: int, hk_data priv_idx = pdu_idx - 1 for idx in range(len(PDU1_CHANNELS_NAMES)): current_list.append( - struct.unpack("!h", hk_data[current_idx: current_idx + 2])[0] + struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0] ) current_idx += 2 voltage_list = [] for idx in range(len(PDU1_CHANNELS_NAMES)): voltage_list.append( - struct.unpack("!H", hk_data[current_idx: current_idx + 2])[0] + struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0] ) current_idx += 2 output_enb_list = [] @@ -490,12 +493,13 @@ def handle_pdu_data(printer: FsfwTmTcPrinter, pdu_idx: int, set_id: int, hk_data log_to_both(printer, content_line) fmt_str = "!IBh" inc_len = struct.calcsize(fmt_str) - ( - boot_count, - batt_mode, - temperature - ) = struct.unpack(fmt_str, hk_data[current_idx: current_idx + inc_len]) - info = f"Boot Count {boot_count} | Battery Mode {batt_mode} | Temperature {temperature}" + (boot_count, batt_mode, temperature) = struct.unpack( + fmt_str, hk_data[current_idx : current_idx + inc_len] + ) + info = ( + f"Boot Count {boot_count} | Battery Mode {batt_mode} | " + f"Temperature {temperature / 10.0}" + ) log_to_both(printer, info)