added new core controller commands

This commit is contained in:
Robin Müller 2022-02-24 10:56:36 +01:00
parent a671e86400
commit 7e24589184
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 119 additions and 20 deletions

View File

@ -38,12 +38,50 @@ def add_bpx_cmd_definitions(cmd_dict: ServiceOpCodeDictT):
def add_core_controller_definitions(cmd_dict: ServiceOpCodeDictT):
from pus_tc.core import OpCodes
od = dict()
add_op_code_entry(op_code_dict=od, keys=["0", "reboot"], info="Reboot with Prompt")
add_op_code_entry(op_code_dict=od, keys=["1", "reboot_0_0"], info="Reboot 0 0")
add_op_code_entry(op_code_dict=od, keys=["2", "reboot_0_1"], info="Reboot 0 1")
add_op_code_entry(op_code_dict=od, keys=["3", "reboot_1_0"], info="Reboot 1 0")
add_op_code_entry(op_code_dict=od, keys=["4", "reboot_1_1"], info="Reboot 1 1")
add_op_code_entry(op_code_dict=od, keys=OpCodes.REBOOT, info="Reboot with Prompt")
add_op_code_entry(op_code_dict=od, keys=OpCodes.REBOOT_SELF, info="Reboot Self")
add_op_code_entry(op_code_dict=od, keys=OpCodes.REBOOT_0_0, info="Reboot 0 0")
add_op_code_entry(op_code_dict=od, keys=OpCodes.REBOOT_0_1, info="Reboot 0 1")
add_op_code_entry(op_code_dict=od, keys=OpCodes.REBOOT_1_0, info="Reboot 1 0")
add_op_code_entry(op_code_dict=od, keys=OpCodes.REBOOT_1_1, info="Reboot 1 1")
add_op_code_entry(
op_code_dict=od,
keys=OpCodes.ENABLE_REBOOT_FILE_HANDLING,
info="Enable reboot file handling",
)
add_op_code_entry(
op_code_dict=od,
keys=OpCodes.DISABLE_REBOOT_FILE_HANDLING,
info="Disable reboot file handling",
)
add_op_code_entry(
op_code_dict=od,
keys=OpCodes.RESET_ALL_REBOOT_COUNTERS,
info="Reset all reboot counters",
)
add_op_code_entry(
op_code_dict=od,
keys=OpCodes.RESET_REBOOT_COUNTER_00,
info="Reset reboot counter 0 0",
)
add_op_code_entry(
op_code_dict=od,
keys=OpCodes.RESET_REBOOT_COUNTER_01,
info="Reset reboot counter 0 1",
)
add_op_code_entry(
op_code_dict=od,
keys=OpCodes.RESET_REBOOT_COUNTER_10,
info="Reset reboot counter 1 0",
)
add_op_code_entry(
op_code_dict=od,
keys=OpCodes.RESET_REBOOT_COUNTER_11,
info="Reset reboot counter 1 1",
)
add_service_op_code_entry(
srv_op_code_dict=cmd_dict,
name=CustomServiceList.CORE.value,

View File

@ -10,16 +10,32 @@ LOGGER = get_console_logger()
class ActionIds(enum.IntEnum):
LIST_DIR_INTO_FILE = 0
SWITCH_REBOOT_FILE_HANDLING = 5
RESET_ALL_REBOOT_COUNTERS = 6
RESET_REBOOT_COUNTER_00 = 7
RESET_REBOOT_COUNTER_01 = 8
RESET_REBOOT_COUNTER_10 = 9
RESET_REBOOT_COUNTER_11 = 10
SET_MAX_REBOOT_CNT = 11
REBOOT = 32
class OpCodes(enum.Enum):
REBOOT = "reboot"
REBOOT_SELF = "reboot_self"
REBOOT_0_0 = "reboot_0_0"
REBOOT_0_1 = "reboot_0_1"
REBOOT_1_0 = "reboot_1_0"
REBOOT_1_1 = "reboot_1_1"
class OpCodes:
REBOOT = ["0", "reboot"]
REBOOT_SELF = ["1", "reboot_self"]
REBOOT_0_0 = ["2", "reboot_0_0"]
REBOOT_0_1 = ["3", "reboot_0_1"]
REBOOT_1_0 = ["4", "reboot_1_0"]
REBOOT_1_1 = ["5", "reboot_1_1"]
ENABLE_REBOOT_FILE_HANDLING = ["6", "rbh-off"]
DISABLE_REBOOT_FILE_HANDLING = ["7", "rbh-on"]
RESET_ALL_REBOOT_COUNTERS = ["8", "rbh-reset-a"]
RESET_REBOOT_COUNTER_00 = ["9", "rbh-reset-00"]
RESET_REBOOT_COUNTER_01 = ["10", "rbh-reset-01"]
RESET_REBOOT_COUNTER_10 = ["11", "rbh-reset-10"]
RESET_REBOOT_COUNTER_11 = ["12", "rbh-reset-11"]
SET_MAX_REBOOT_CNT = ["13", "rbh-max-cnt"]
class Chip(enum.IntEnum):
@ -35,7 +51,7 @@ class Copy(enum.IntEnum):
def pack_core_commands(tc_queue: TcQueueT, op_code: str):
if op_code == OpCodes.REBOOT.value:
if op_code in OpCodes.REBOOT:
reboot_self, chip_select, copy_select = determine_reboot_params()
perform_reboot_cmd(
tc_queue=tc_queue,
@ -43,30 +59,71 @@ def pack_core_commands(tc_queue: TcQueueT, op_code: str):
chip=chip_select,
copy=copy_select,
)
elif op_code == OpCodes.REBOOT_SELF.value:
elif op_code in OpCodes.REBOOT_SELF:
perform_reboot_cmd(tc_queue=tc_queue, reboot_self=True)
elif op_code == OpCodes.REBOOT_0_0.value:
elif op_code in OpCodes.REBOOT_0_0:
perform_reboot_cmd(
tc_queue=tc_queue, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_0_NOM
)
elif op_code == OpCodes.REBOOT_0_1.value:
elif op_code in OpCodes.REBOOT_0_1:
perform_reboot_cmd(
tc_queue=tc_queue,
reboot_self=False,
chip=Chip.CHIP_0,
copy=Copy.COPY_1_GOLD,
)
elif op_code == OpCodes.REBOOT_1_0.value:
elif op_code in OpCodes.REBOOT_1_0:
perform_reboot_cmd(
tc_queue=tc_queue, reboot_self=False, chip=Chip.CHIP_1, copy=Copy.COPY_0_NOM
)
elif op_code == OpCodes.REBOOT_1_1.value:
elif op_code in OpCodes.REBOOT_1_1:
perform_reboot_cmd(
tc_queue=tc_queue,
reboot_self=False,
chip=Chip.CHIP_1,
copy=Copy.COPY_1_GOLD,
)
elif op_code in OpCodes.DISABLE_REBOOT_FILE_HANDLING:
tc_queue.appendleft((QueueCommands.PRINT, "Disabling reboot file handling"))
app_data = bytearray([0])
generate_action_command(
object_id=CORE_CONTROLLER_ID,
action_id=ActionIds.SWITCH_REBOOT_FILE_HANDLING,
app_data=app_data,
)
elif op_code in OpCodes.ENABLE_REBOOT_FILE_HANDLING:
tc_queue.appendleft((QueueCommands.PRINT, "Enabling reboot file handling"))
app_data = bytearray([1])
generate_action_command(
object_id=CORE_CONTROLLER_ID,
action_id=ActionIds.SWITCH_REBOOT_FILE_HANDLING,
app_data=app_data,
)
elif op_code in OpCodes.RESET_ALL_REBOOT_COUNTERS:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting all reboot counters"))
generate_action_command(
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_ALL_REBOOT_COUNTERS
)
elif op_code in OpCodes.RESET_REBOOT_COUNTER_00:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counter 0 0"))
generate_action_command(
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_00
)
elif op_code in OpCodes.RESET_REBOOT_COUNTER_01:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counter 0 1"))
generate_action_command(
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_01
)
elif op_code in OpCodes.RESET_REBOOT_COUNTER_10:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counter 1 0"))
generate_action_command(
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_10
)
elif op_code in OpCodes.RESET_REBOOT_COUNTER_11:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counter 1 1"))
generate_action_command(
object_id=CORE_CONTROLLER_ID, action_id=ActionIds.RESET_REBOOT_COUNTER_11
)
def determine_reboot_params() -> (bool, Chip, Copy):

View File

@ -134,7 +134,9 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SCEX_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn Solar Cell Experiment on"))
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU1: Turn Solar Cell Experiment on")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_5.parameter_address,
@ -143,7 +145,9 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SCEX_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn Solar Cell Experiment off"))
tc_queue.appendleft(
(QueueCommands.PRINT, "PDU1: Turn Solar Cell Experiment off")
)
command = pack_set_param_command(
object_id,
PDUConfigTable.out_en_5.parameter_address,