implemented boot report status parsing

This commit is contained in:
Robin Müller 2022-08-22 17:09:03 +02:00
parent 3479f5607d
commit bb23e4f021
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -11,6 +11,7 @@ import struct
from config.object_ids import PLOC_SUPV_ID, get_object_ids
from config.definitions import CustomServiceList
from pus_tm.defs import PrintWrapper
from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.config import TmtcDefinitionWrapper
@ -112,11 +113,7 @@ class SupvActionIds:
class SetIds:
HK_REPORT = 102
class SupvHkIds:
HK_REPORT = 52
BOOT_STATUS_REPORT = 53
BOOT_STATUS_REPORT = 103
class OpCodes:
@ -127,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"]
@ -139,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"
@ -159,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")
@ -224,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))
@ -270,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)
@ -719,4 +722,34 @@ def get_event_buffer_path() -> str:
def handle_supv_hk_data(set_id: int, hk_data: bytes, printer: FsfwTmTcPrinter):
pass
pw = PrintWrapper(printer)
current_idx = 0
if set_id == SetIds.HK_REPORT:
pass
elif set_id == SetIds.BOOT_STATUS_REPORT:
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:
pass