update supv cmds

This commit is contained in:
Robin Müller 2022-08-18 15:46:41 +02:00
parent 77a4f49305
commit 8dfe9e63fb
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -6,11 +6,13 @@
@author J. Meier @author J. Meier
@date 10.07.2021 @date 10.07.2021
""" """
import enum
import struct import struct
from config.object_ids import PLOC_SUPV_ID, get_object_ids from config.object_ids import PLOC_SUPV_ID, get_object_ids
from config.definitions import CustomServiceList from config.definitions import CustomServiceList
from spacepackets.ecss.tc import PusTelecommand 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 from tmtccmd.config import TmtcDefinitionWrapper
from tmtccmd.config.tmtc import tmtc_definitions_provider, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider, OpCodeEntry
from tmtccmd.logging import get_console_logger from tmtccmd.logging import get_console_logger
@ -105,6 +107,10 @@ class SupvActionIds:
CONTINUE_UPDATE = 60 CONTINUE_UPDATE = 60
class SetIds:
HK_REPORT = 102
class SupvHkIds: class SupvHkIds:
HK_REPORT = 52 HK_REPORT = 52
BOOT_STATUS_REPORT = 53 BOOT_STATUS_REPORT = 53
@ -114,9 +120,19 @@ class OpCodes:
OFF = ["0", "off"] OFF = ["0", "off"]
ON = ["1", "on"] ON = ["1", "on"]
NORMAL = ["2", "nml"] NORMAL = ["2", "nml"]
HK_REPORT = ["3", "hk"] HK_TO_OBC = ["3", "hk-to-obc"]
START_MPSOC = ["4", "mpsoc-start"] REQUEST_HK = ["4", "req-hk"]
STOP_MPSOC = ["5", "mpsoc-stop"] START_MPSOC = ["5", "mpsoc-start"]
STOP_MPSOC = ["6", "mpsoc-stop"]
class Info(str, enum.Enum):
value: str
OFF = "Switch Off"
ON = "Switch On"
NML = "Switch Normal"
HK_TO_OBC = "Request HK from PLOC SUPV"
REQUEST_HK = "Request HK set from PLOC Handler"
@tmtc_definitions_provider @tmtc_definitions_provider
@ -127,10 +143,11 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper):
CustomServiceList.PLOC_MEMORY_DUMPER.value, "PLOC Memory Dumper", oce CustomServiceList.PLOC_MEMORY_DUMPER.value, "PLOC Memory Dumper", oce
) )
oce = OpCodeEntry() oce = OpCodeEntry()
oce.add(OpCodes.OFF, "Mode Off") oce.add(OpCodes.OFF, Info.OFF)
oce.add(OpCodes.ON, "Mode On") oce.add(OpCodes.ON, Info.ON)
oce.add(OpCodes.NORMAL, "Mode Normal") oce.add(OpCodes.NORMAL, Info.NML)
oce.add(OpCodes.HK_REPORT, "HK Report") oce.add(OpCodes.HK_TO_OBC, Info.HK_TO_OBC)
oce.add(OpCodes.REQUEST_HK, Info.REQUEST_HK)
oce.add(OpCodes.START_MPSOC, "PLOC Supervisor: Start MPSoC") oce.add(OpCodes.START_MPSOC, "PLOC Supervisor: Start MPSoC")
oce.add(OpCodes.STOP_MPSOC, "PLOC Supervisor: Shutdown MPSoC") oce.add(OpCodes.STOP_MPSOC, "PLOC Supervisor: Shutdown MPSoC")
oce.add("7", "PLOC Supervisor: Select MPSoC boot image") oce.add("7", "PLOC Supervisor: Select MPSoC boot image")
@ -181,22 +198,28 @@ def pack_ploc_supv_commands(p: ServiceProviderParams):
object_id = get_object_ids().get(PLOC_SUPV_ID) object_id = get_object_ids().get(PLOC_SUPV_ID)
q.add_log_cmd(f"Testing PLOC Supervisor with object id: {object_id.as_hex_string}") q.add_log_cmd(f"Testing PLOC Supervisor with object id: {object_id.as_hex_string}")
obyt = object_id.as_bytes obyt = object_id.as_bytes
prefix = "PLOC Supervisor"
if op_code in OpCodes.OFF: if op_code in OpCodes.OFF:
q.add_log_cmd("PLOC Supervisor: Set mode off") q.add_log_cmd(f"{prefix}: {Info.OFF}")
command = pack_mode_data(object_id.as_bytes, Modes.OFF, 0) command = pack_mode_data(object_id.as_bytes, Modes.OFF, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command))
if op_code in OpCodes.ON: if op_code in OpCodes.ON:
q.add_log_cmd("PLOC Supervisor: Set mode on") q.add_log_cmd(f"{prefix}: {Info.ON}")
command = pack_mode_data(object_id.as_bytes, Modes.ON, 0) command = pack_mode_data(object_id.as_bytes, Modes.ON, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command))
if op_code in OpCodes.NORMAL: if op_code in OpCodes.NORMAL:
q.add_log_cmd("PLOC Supervisor: Mode Normal") q.add_log_cmd(f"{prefix}: {Info.NML}")
command = pack_mode_data(object_id.as_bytes, Modes.NORMAL, 0) command = pack_mode_data(object_id.as_bytes, Modes.NORMAL, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command))
if op_code in OpCodes.HK_REPORT: if op_code in OpCodes.HK_TO_OBC:
q.add_log_cmd("PLOC Supervisor: TC Get Hk Report") q.add_log_cmd(f"{prefix}: {Info.HK_TO_OBC}")
command = obyt + struct.pack("!I", SupvActionIds.HK_REPORT) command = obyt + struct.pack("!I", SupvActionIds.HK_REPORT)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
if op_code in OpCodes.REQUEST_HK:
q.add_log_cmd(f"{prefix}: {Info.REQUEST_HK}")
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 == "5":
q.add_log_cmd("PLOC Supervisor: Start MPSoC") q.add_log_cmd("PLOC Supervisor: Start MPSoC")
command = obyt + struct.pack("!I", SupvActionIds.START_MPSOC) command = obyt + struct.pack("!I", SupvActionIds.START_MPSOC)