PDU1 and PDU2 HK Handling #57

Merged
meierj merged 8 commits from mueller/pdu1-pdu2-hk-handling into develop 2022-04-12 19:28:46 +02:00
3 changed files with 25 additions and 21 deletions
Showing only changes of commit c995ca2dda - Show all commits

View File

@ -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:

View File

@ -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:

View File

@ -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)