Merge branch 'mueller/update-ploc-supv-cmds' of https://egit.irs.uni-stuttgart.de/eive/eive-tmtc into mueller/update-ploc-supv-cmds

This commit is contained in:
Robin Müller 2022-08-22 17:20:59 +02:00
commit 7dfe92be8c
2 changed files with 36 additions and 14 deletions

View File

@ -41,7 +41,7 @@ def handle_service_1_fsfw_packet(wrapper: VerificationWrapper, raw_tm: bytes):
)
error_param_1_str = (
f"Error Parameter 1: hex {fsfw_wrapper.error_param_1:#010x} "
f"dec{fsfw_wrapper.error_param_1} "
f"dec {fsfw_wrapper.error_param_1} "
)
error_param_2_str = (
f"Error Parameter 2: hex {fsfw_wrapper.error_param_2:#010x} "

View File

@ -116,11 +116,6 @@ class SetIds:
BOOT_STATUS_REPORT = 103
class SupvHkIds:
HK_REPORT = 52
BOOT_STATUS_REPORT = 53
class OpCodes:
OFF = ["0", "off"]
ON = ["1", "on"]
@ -129,6 +124,7 @@ class OpCodes:
REQUEST_HK = ["4", "req-hk"]
START_MPSOC = ["5", "mpsoc-start"]
STOP_MPSOC = ["6", "mpsoc-stop"]
REQ_BOOT_STATUS_REPORT = ["13", "boot-report"]
START_UPDATE = ["42", "start-update"]
PERFORM_UPDATE = ["update"]
MEM_CHECK = ["mem-check"]
@ -141,6 +137,7 @@ class Info(str, enum.Enum):
NML = "Switch Normal"
HK_TO_OBC = "Request HK from PLOC SUPV"
REQUEST_HK = "Request HK set from PLOC Handler"
REQ_BOOT_STATUS_REPORT = "Request boot status report"
MEM_CHECK = "Memory Check"
@ -161,7 +158,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper):
oce.add("10", "PLOC Supervisor: Set time reference")
oce.add("11", "PLOC Supervisor: Set boot timeout")
oce.add("12", "PLOC Supervisor: Disable Hk")
oce.add("13", "PLOC Supervisor: Request boot status report")
oce.add(OpCodes.REQ_BOOT_STATUS_REPORT, Info.REQ_BOOT_STATUS_REPORT)
oce.add("17", "PLOC Supervisor: Enable latchup alert")
oce.add("18", "PLOC Supervisor: Disable latchup alert")
oce.add("20", "PLOC Supervisor: Set alert limit")
@ -226,7 +223,7 @@ def pack_ploc_supv_commands(p: ServiceProviderParams):
sid = make_sid(object_id.as_bytes, SetIds.HK_REPORT)
cmd = generate_one_hk_command(sid)
q.add_pus_tc(cmd)
elif op_code == "5":
elif op_code in OpCodes.START_MPSOC:
q.add_log_cmd("PLOC Supervisor: Start MPSoC")
command = obyt + struct.pack("!I", SupvActionIds.START_MPSOC)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
@ -272,12 +269,16 @@ def pack_ploc_supv_commands(p: ServiceProviderParams):
q.add_log_cmd("PLOC Supervisor: Disable HK")
command = object_id.as_bytes + struct.pack("!I", SupvActionIds.DISABLE_HK)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
if op_code == "13":
q.add_log_cmd("PLOC Supervisor: Request boot status report")
if op_code in OpCodes.REQ_BOOT_STATUS_REPORT:
q.add_log_cmd(Info.REQ_BOOT_STATUS_REPORT)
command = object_id.as_bytes + struct.pack(
"!I", SupvActionIds.GET_BOOT_STATUS_REPORT
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
q.add_wait_seconds(2.0)
sid = make_sid(object_id.as_bytes, SetIds.BOOT_STATUS_REPORT)
req_hk = generate_one_hk_command(sid)
q.add_pus_tc(req_hk)
if op_code == "17":
q.add_log_cmd("PLOC Supervisor: Enable latchup alert")
command = pack_lachtup_alert_cmd(object_id.as_bytes, True)
@ -722,13 +723,34 @@ def get_event_buffer_path() -> str:
def handle_supv_hk_data(set_id: int, hk_data: bytes, printer: FsfwTmTcPrinter):
pw = PrintWrapper(printer)
current_idx = 0
if set_id == SetIds.HK_REPORT:
# TODO: Implement
pass
elif set_id == SetIds.BOOT_STATUS_REPORT:
# TODO: Implement
pass
fmt_str = "!BBIIBBBBBB"
inc_len = struct.calcsize(fmt_str)
(
soc_state,
power_cycles,
boot_after_ms,
boot_timeout_ms,
active_nvm,
bp_0_state,
bp_1_state,
bp_2_state,
boot_state,
boot_cycles
) = struct.unpack(fmt_str, hk_data[0: 0 + inc_len])
current_idx += inc_len
pw.dlog(
f"SoC state (0:off, 1:booting, 2:update, 3:operating, 4:shutdown, 5:reset): {soc_state}"
)
pw.dlog(f"Power Cycles {power_cycles}")
pw.dlog(f"Boot after {boot_after_ms} ms | Boot timeout {boot_timeout_ms} ms")
pw.dlog(f"Active NVM: {active_nvm}")
pw.dlog(f"BP0 State {bp_0_state} | BP1 State {bp_1_state} | BP2 State {bp_2_state}")
pw.dlog(f"Boot State {boot_state} | Boot Cycles {boot_cycles}")
pw.printer.print_validity_buffer(hk_data[current_idx:], 10)
else:
pw.dlog(f"PLOC SUPV: HK handling not implemented for set ID {set_id}")
pw.dlog(f"Raw Data: 0x[{hk_data.hex(sep=',')}]")
pass