core hk handling working

This commit is contained in:
Robin Mueller 2022-04-12 16:10:51 +02:00
parent 259cd25b6e
commit c995ca2dda
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 25 additions and 21 deletions

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()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Requesting HK Table Once")) 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) 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) command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: 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()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE: if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Requesting HK Table Once")) 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) 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) command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I: 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: elif object_id == obj_ids.CORE_CONTROLLER_ID:
return handle_core_hk_data(printer=printer, hk_data=hk_data) return handle_core_hk_data(printer=printer, hk_data=hk_data)
elif object_id == obj_ids.PDU_1_HANDLER_ID: 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: 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: elif object_id == obj_ids.P60_DOCK_HANDLER:
handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data) handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data)
elif object_id == obj_ids.PL_PCDU_ID: elif object_id == obj_ids.PL_PCDU_ID:
@ -434,7 +438,7 @@ PDU1_CHANNELS_NAMES = [
"SCEX", "SCEX",
"PLOC", "PLOC",
"ACS A Side", "ACS A Side",
"Unused Channel 8" "Unused Channel 8",
] ]
PDU2_CHANNELS_NAMES = [ PDU2_CHANNELS_NAMES = [
@ -446,16 +450,15 @@ PDU2_CHANNELS_NAMES = [
"Deployment Mechanism", "Deployment Mechanism",
"Payload PCDU CH6", "Payload PCDU CH6",
"ACS B Side", "ACS B Side",
"Payload Camera" "Payload Camera",
] ]
PDU_CHANNEL_NAMES = [ PDU_CHANNEL_NAMES = [PDU1_CHANNELS_NAMES, PDU2_CHANNELS_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: if set_id == SetIds.PDU_1_AUX or set_id == SetIds.PDU_2_AUX:
log_to_both(printer, "PDU AUX HK TODO") log_to_both(printer, "PDU AUX HK TODO")
if set_id == SetIds.PDU_1_CORE or set_id == SetIds.PDU_2_CORE: 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 priv_idx = pdu_idx - 1
for idx in range(len(PDU1_CHANNELS_NAMES)): for idx in range(len(PDU1_CHANNELS_NAMES)):
current_list.append( 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 current_idx += 2
voltage_list = [] voltage_list = []
for idx in range(len(PDU1_CHANNELS_NAMES)): for idx in range(len(PDU1_CHANNELS_NAMES)):
voltage_list.append( 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 current_idx += 2
output_enb_list = [] 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) log_to_both(printer, content_line)
fmt_str = "!IBh" fmt_str = "!IBh"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
( (boot_count, batt_mode, temperature) = struct.unpack(
boot_count, fmt_str, hk_data[current_idx : current_idx + inc_len]
batt_mode, )
temperature info = (
) = struct.unpack(fmt_str, hk_data[current_idx: current_idx + inc_len]) f"Boot Count {boot_count} | Battery Mode {batt_mode} | "
info = f"Boot Count {boot_count} | Battery Mode {batt_mode} | Temperature {temperature}" f"Temperature {temperature / 10.0}"
)
log_to_both(printer, info) log_to_both(printer, info)