consistency change for enum names

This commit is contained in:
2023-01-16 14:13:06 +01:00
parent 87f5bf83d1
commit e7609f02b9
44 changed files with 605 additions and 614 deletions

View File

@ -50,7 +50,7 @@ SEQ_FILE_DICT = {
CARRIAGE_RETURN = 0xD
class CommandIds(enum.IntEnum):
class CommandId(enum.IntEnum):
TC_MEM_WRITE = 1
TC_MEM_READ = 2
FLASH_WRITE = 9
@ -68,7 +68,7 @@ class CommandIds(enum.IntEnum):
RELEASE_UART_TX = 21
class OpCodes:
class OpCode:
ON = ["on"]
OFF = ["off"]
NORMAL = ["normal"]
@ -104,22 +104,22 @@ class PlocReplyIds(enum.IntEnum):
@tmtc_definitions_provider
def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(OpCodes.OFF, Info.OFF)
oce.add(OpCodes.ON, Info.ON)
oce.add(OpCodes.NORMAL, Info.NORMAL)
oce.add(OpCode.OFF, Info.OFF)
oce.add(OpCode.ON, Info.ON)
oce.add(OpCode.NORMAL, Info.NORMAL)
oce.add("3", "Ploc MPSoC: Memory write")
oce.add("4", "Ploc MPSoC: Memory read")
oce.add("5", "Ploc MPSoC: Flash write")
oce.add("6", "Ploc MPSoC: Flash delete")
oce.add(OpCodes.REPLAY_START, Info.REPLAY_START)
oce.add(OpCode.REPLAY_START, Info.REPLAY_START)
oce.add("8", "Ploc MPSoC: Replay stop")
oce.add(OpCodes.DOWNLINK_PWR_ON, Info.DOWNLINK_PWR_ON)
oce.add(OpCode.DOWNLINK_PWR_ON, Info.DOWNLINK_PWR_ON)
oce.add("10", "Ploc MPSoC: Downlink pwr off")
oce.add(OpCodes.REPLAY_WRITE_SEQ, Info.REPLAY_WRITE_SEQ)
oce.add(OpCode.REPLAY_WRITE_SEQ, Info.REPLAY_WRITE_SEQ)
oce.add("12", "Ploc MPSoC: OBSW reset sequence count")
oce.add(OpCodes.VERIFY_BOOT, "Ploc MPSoC: Read DEADBEEF address")
oce.add(OpCodes.MODE_REPLAY, Info.MODE_REPLAY)
oce.add(OpCodes.MODE_IDLE, Info.MODE_IDLE)
oce.add(OpCode.VERIFY_BOOT, "Ploc MPSoC: Read DEADBEEF address")
oce.add(OpCode.MODE_REPLAY, Info.MODE_REPLAY)
oce.add(OpCode.MODE_IDLE, Info.MODE_IDLE)
oce.add("16", "Ploc MPSoC: Tc cam command send")
oce.add("17", "Ploc MPSoC: Set UART TX tristate")
oce.add("18", "Ploc MPSoC: Relesase UART TX")
@ -136,15 +136,15 @@ def pack_ploc_mpsoc_commands(p: ServiceProviderParams):
f"Generate command for PLOC MPSoC with object id: {object_id.as_hex_string}"
)
obyt = object_id.as_bytes
if op_code in OpCodes.OFF:
if op_code in OpCode.OFF:
q.add_log_cmd(f"{prefix}: {Info.OFF}")
command = pack_mode_data(obyt, Modes.OFF, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command))
if op_code in OpCodes.ON:
if op_code in OpCode.ON:
q.add_log_cmd(f"{prefix}: {Info.ON}")
data = pack_mode_data(obyt, Modes.ON, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code in OpCodes.NORMAL:
if op_code in OpCode.NORMAL:
q.add_log_cmd(f"{prefix}: {Info.NORMAL}")
data = pack_mode_data(object_id.as_bytes, Modes.NORMAL, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
@ -172,64 +172,64 @@ def pack_ploc_mpsoc_commands(p: ServiceProviderParams):
q.add_log_cmd("PLOC MPSoC: Flash delete")
data = prepare_flash_delete_cmd(object_id.as_bytes)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCodes.REPLAY_START:
if op_code in OpCode.REPLAY_START:
q.add_log_cmd(f"{prefix}: {Info.REPLAY_START}")
data = prepare_replay_start_cmd(object_id.as_bytes)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "8":
q.add_log_cmd("PLOC MPSoC: Replay stop")
data = object_id.as_bytes + struct.pack("!I", CommandIds.TC_REPLAY_STOP)
data = object_id.as_bytes + struct.pack("!I", CommandId.TC_REPLAY_STOP)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCodes.DOWNLINK_PWR_ON:
q.add_log_cmd(f"{prefix}: {OpCodes.DOWNLINK_PWR_ON}")
if op_code in OpCode.DOWNLINK_PWR_ON:
q.add_log_cmd(f"{prefix}: {OpCode.DOWNLINK_PWR_ON}")
data = prepare_downlink_pwr_on_cmd(object_id.as_bytes)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "10":
q.add_log_cmd("PLOC MPSoC: Downlink pwr off")
data = object_id.as_bytes + struct.pack("!I", CommandIds.TC_DOWNLINK_PWR_OFF)
data = object_id.as_bytes + struct.pack("!I", CommandId.TC_DOWNLINK_PWR_OFF)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCodes.REPLAY_WRITE_SEQ:
if op_code in OpCode.REPLAY_WRITE_SEQ:
q.add_log_cmd(f"{prefix}: {Info.REPLAY_WRITE_SEQ}")
data = prepare_replay_write_sequence_cmd(object_id.as_bytes)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "12":
q.add_log_cmd("PLOC MPSoC: Reset OBSW sequence count")
data = object_id.as_bytes + struct.pack("!I", CommandIds.OBSW_RESET_SEQ_COUNT)
data = object_id.as_bytes + struct.pack("!I", CommandId.OBSW_RESET_SEQ_COUNT)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCodes.VERIFY_BOOT:
if op_code in OpCode.VERIFY_BOOT:
num_words = 1
q.add_log_cmd(f"{prefix} {Info.VERIFY_BOOT}")
data = (
object_id.as_bytes
+ struct.pack("!I", CommandIds.TC_MEM_READ)
+ struct.pack("!I", CommandId.TC_MEM_READ)
+ struct.pack("!I", MemAddresses.DEADBEEF)
+ struct.pack("!H", num_words)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCodes.MODE_REPLAY:
if op_code in OpCode.MODE_REPLAY:
q.add_log_cmd("PLOC MPSoC: Tc mode replay")
data = object_id.as_bytes + struct.pack("!I", CommandIds.TC_MODE_REPLAY)
data = object_id.as_bytes + struct.pack("!I", CommandId.TC_MODE_REPLAY)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCodes.MODE_IDLE:
if op_code in OpCode.MODE_IDLE:
q.add_log_cmd("PLOC MPSoC: Tc mode idle")
data = object_id.as_bytes + struct.pack("!I", CommandIds.TC_MODE_IDLE)
data = object_id.as_bytes + struct.pack("!I", CommandId.TC_MODE_IDLE)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "16":
q.add_log_cmd("PLOC MPSoC: Tc cam command send")
cam_cmd = input("Specify cam command string: ")
data = (
object_id.as_bytes
+ struct.pack("!I", CommandIds.TC_CAM_CMD_SEND)
+ struct.pack("!I", CommandId.TC_CAM_CMD_SEND)
+ bytearray(cam_cmd, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "17":
q.add_log_cmd("PLOC MPSoC: Set UART TX tristate")
data = object_id.as_bytes + struct.pack("!I", CommandIds.SET_UART_TX_TRISTATE)
data = object_id.as_bytes + struct.pack("!I", CommandId.SET_UART_TX_TRISTATE)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "18":
q.add_log_cmd("PLOC MPSoC: Release UART TX")
data = object_id.as_bytes + struct.pack("!I", CommandIds.RELEASE_UART_TX)
data = object_id.as_bytes + struct.pack("!I", CommandId.RELEASE_UART_TX)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
@ -246,7 +246,7 @@ def generate_write_mem_command(
"""
command = (
object_id
+ struct.pack("!I", CommandIds.TC_MEM_WRITE)
+ struct.pack("!I", CommandId.TC_MEM_WRITE)
+ struct.pack("!I", memory_address)
+ struct.pack("!H", mem_len)
+ struct.pack("!I", memory_data)
@ -259,7 +259,7 @@ def prepare_mem_read_command(object_id: bytes) -> bytearray:
num_words = int(input("PLOC MPSoC specify number of words (32-bit) to read: "))
command = (
object_id
+ struct.pack("!I", CommandIds.TC_MEM_READ)
+ struct.pack("!I", CommandId.TC_MEM_READ)
+ struct.pack("!I", memory_address)
+ struct.pack("!H", num_words)
)
@ -271,7 +271,7 @@ def prepare_flash_write_cmd(object_id: bytes) -> bytearray:
mpsocFile = get_mpsoc_file()
command = (
object_id
+ struct.pack("!I", CommandIds.FLASH_WRITE)
+ struct.pack("!I", CommandId.FLASH_WRITE)
+ bytearray(obcFile, "utf-8")
+ bytearray(mpsocFile, "utf-8")
)
@ -282,7 +282,7 @@ def prepare_flash_delete_cmd(object_id: bytes) -> bytearray:
file = get_mpsoc_file()
command = (
object_id
+ struct.pack("!I", CommandIds.TC_FLASH_DELETE)
+ struct.pack("!I", CommandId.TC_FLASH_DELETE)
+ bytearray(file, "utf-8")
)
return bytearray(command)
@ -292,7 +292,7 @@ def prepare_replay_start_cmd(object_id: bytes) -> bytearray:
replay = int(input("Specify replay mode (0 - once, 1 - repeated): "))
command = (
object_id
+ struct.pack("!I", CommandIds.TC_REPLAY_START)
+ struct.pack("!I", CommandId.TC_REPLAY_START)
+ struct.pack("!B", replay)
)
return bytearray(command)
@ -303,7 +303,7 @@ def prepare_downlink_pwr_on_cmd(object_id: bytes) -> bytearray:
lane_rate = int(input("Specify lane rate (0 - 9): "))
command = (
object_id
+ struct.pack("!I", CommandIds.TC_DOWNLINK_PWR_ON)
+ struct.pack("!I", CommandId.TC_DOWNLINK_PWR_ON)
+ struct.pack("!B", mode)
+ struct.pack("!B", lane_rate)
)
@ -315,7 +315,7 @@ def prepare_replay_write_sequence_cmd(object_id: bytes) -> bytearray:
file = get_sequence_file()
command = (
object_id
+ struct.pack("!I", CommandIds.TC_REPLAY_WRITE_SEQUENCE)
+ struct.pack("!I", CommandId.TC_REPLAY_WRITE_SEQUENCE)
+ struct.pack("!B", use_decoding)
+ bytearray(file, "utf-8")
# + bytes([0])