update HK handling

This commit is contained in:
Robin Mueller 2022-04-08 14:46:01 +02:00
parent 5189b20b0e
commit 3a1c7c6288
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
8 changed files with 44 additions and 22 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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