rework read and write prompts for MPSoC
This commit is contained in:
parent
dd3e4c649b
commit
14c42a91ff
@ -31,14 +31,24 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
MANUAL_INPUT = "1"
|
MANUAL_INPUT = "1"
|
||||||
|
|
||||||
FLASH_WRITE_FILE_DICT = {
|
OBC_WRITE_FILE_DICT = {
|
||||||
MANUAL_INPUT: ("manual input", ""),
|
MANUAL_INPUT: ("manual input", ""),
|
||||||
"2": ("/mnt/sd0/ploc/mpsoc/flash_write.bin", "/mnt/sd0/ploc/mpsoc/flash_write.bin"),
|
"2": ("/mnt/sd0/ploc/mpsoc/flash_write.bin", "/mnt/sd0/ploc/mpsoc/flash_write.bin"),
|
||||||
}
|
}
|
||||||
|
|
||||||
MPSOC_FILE_DICT = {
|
OBC_READ_FILE_DICT = {
|
||||||
MANUAL_INPUT: ("manual input", ""),
|
MANUAL_INPUT: ("manual input", ""),
|
||||||
"2": ("0:/flash", "0:/flash"),
|
"2": ("/mnt/sd0/ploc/mpsoc/flash_read.bin", "/mnt/sd0/ploc/mpsoc/flash_read.bin"),
|
||||||
|
}
|
||||||
|
|
||||||
|
MPSOC_WRITE_FILE_DICT = {
|
||||||
|
MANUAL_INPUT: ("manual input", ""),
|
||||||
|
"2": ("0:/", "0:/"),
|
||||||
|
}
|
||||||
|
|
||||||
|
MPSOC_READ_FILE_DICT = {
|
||||||
|
MANUAL_INPUT: ("manual input", ""),
|
||||||
|
"2": ("0:/PICA", "0:/PICA"),
|
||||||
}
|
}
|
||||||
|
|
||||||
SEQ_FILE_NAMES = ["0:/EM16/231", "0:/EQ04/E-75", "0:/EQ01/E130"]
|
SEQ_FILE_NAMES = ["0:/EM16/231", "0:/EQ04/E-75", "0:/EQ01/E130"]
|
||||||
@ -337,31 +347,39 @@ def prepare_mem_read_command(object_id: bytes) -> bytearray:
|
|||||||
return bytearray(command)
|
return bytearray(command)
|
||||||
|
|
||||||
|
|
||||||
def prepare_flash_base_cmd(action_id: int, object_id: bytes) -> bytearray:
|
def prepare_flash_base_cmd(
|
||||||
obc_file = get_obc_file()
|
obc_filename: str, mpsoc_filename: str, action_id: int, object_id: bytes
|
||||||
mpsoc_file = get_mpsoc_file()
|
) -> bytearray:
|
||||||
command = bytearray(object_id)
|
command = bytearray(object_id)
|
||||||
command.extend(struct.pack("!I", action_id))
|
command.extend(struct.pack("!I", action_id))
|
||||||
command.extend(obc_file.encode("utf-8"))
|
command.extend(obc_filename.encode("utf-8"))
|
||||||
command.append(0)
|
command.append(0)
|
||||||
command.extend(mpsoc_file.encode("utf-8"))
|
command.extend(mpsoc_filename.encode("utf-8"))
|
||||||
command.append(0)
|
command.append(0)
|
||||||
return command
|
return command
|
||||||
|
|
||||||
|
|
||||||
def prepare_flash_write_cmd(object_id: bytes) -> bytearray:
|
def prepare_flash_write_cmd(object_id: bytes) -> bytearray:
|
||||||
return prepare_flash_base_cmd(ActionId.TC_FLASH_WRITE_FULL_FILE, object_id)
|
obc_file = get_obc_file(OBC_WRITE_FILE_DICT)
|
||||||
|
mpsoc_file = get_mpsoc_file(MPSOC_WRITE_FILE_DICT)
|
||||||
|
return prepare_flash_base_cmd(
|
||||||
|
obc_file, mpsoc_file, ActionId.TC_FLASH_WRITE_FULL_FILE, object_id
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def prepare_flash_read_cmd(object_id: bytes) -> bytearray:
|
def prepare_flash_read_cmd(object_id: bytes) -> bytearray:
|
||||||
cmd = prepare_flash_base_cmd(ActionId.TC_FLASH_READ_FULL_FILE, object_id)
|
mpsoc_file = get_mpsoc_file(MPSOC_READ_FILE_DICT)
|
||||||
|
obc_file = get_obc_file(OBC_READ_FILE_DICT)
|
||||||
|
cmd = prepare_flash_base_cmd(
|
||||||
|
mpsoc_file, obc_file, ActionId.TC_FLASH_READ_FULL_FILE, object_id
|
||||||
|
)
|
||||||
file_size = get_mpsoc_file_size()
|
file_size = get_mpsoc_file_size()
|
||||||
cmd.extend(struct.pack("!I", file_size))
|
cmd.extend(struct.pack("!I", file_size))
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
def prepare_flash_delete_cmd(object_id: bytes) -> bytearray:
|
def prepare_flash_delete_cmd(object_id: bytes) -> bytearray:
|
||||||
file = get_mpsoc_file()
|
file = get_mpsoc_file(MPSOC_READ_FILE_DICT)
|
||||||
command = (
|
command = (
|
||||||
object_id + struct.pack("!I", ActionId.TC_FLASH_DELETE) + file.encode("utf-8")
|
object_id + struct.pack("!I", ActionId.TC_FLASH_DELETE) + file.encode("utf-8")
|
||||||
)
|
)
|
||||||
@ -466,30 +484,30 @@ def prepare_downlink_data_modulate_cmd(object_id: bytes) -> bytearray:
|
|||||||
return bytearray(command)
|
return bytearray(command)
|
||||||
|
|
||||||
|
|
||||||
def get_obc_file() -> str:
|
def get_obc_file(input_dict: dict) -> str:
|
||||||
_LOGGER.info("Specify OBC file ")
|
_LOGGER.info("Specify OBC filename")
|
||||||
input_helper = InputHelper(FLASH_WRITE_FILE_DICT)
|
input_helper = InputHelper(input_dict)
|
||||||
key = input_helper.get_key()
|
key = input_helper.get_key()
|
||||||
if key == MANUAL_INPUT:
|
if key == MANUAL_INPUT:
|
||||||
file = input("Ploc MPSoC: Specify absolute name of flash file: ")
|
file = input("Ploc MPSoC: Specify absolute name of flash file: ")
|
||||||
else:
|
else:
|
||||||
file = FLASH_WRITE_FILE_DICT[key][1]
|
file = input_dict[key][1]
|
||||||
return file
|
return file
|
||||||
|
|
||||||
|
|
||||||
def get_mpsoc_file() -> str:
|
def get_mpsoc_file(input_dict: dict) -> str:
|
||||||
_LOGGER.info("Specify MPSoC file")
|
_LOGGER.info("Specify MPSoC filename")
|
||||||
input_helper = InputHelper(MPSOC_FILE_DICT)
|
input_helper = InputHelper(input_dict)
|
||||||
key = input_helper.get_key()
|
key = input_helper.get_key()
|
||||||
if key == MANUAL_INPUT:
|
if key == MANUAL_INPUT:
|
||||||
file = input("Ploc MPSoC: Specify absolute name file: ")
|
file = input("Ploc MPSoC: Specify absolute name file: ")
|
||||||
else:
|
else:
|
||||||
file = MPSOC_FILE_DICT[key][1]
|
file = input_dict[key][1]
|
||||||
return file
|
return file
|
||||||
|
|
||||||
|
|
||||||
def get_mpsoc_file_size() -> int:
|
def get_mpsoc_file_size() -> int:
|
||||||
file_size = int(input("Specify MPSoC file size"))
|
file_size = int(input("Specify MPSoC file size: "))
|
||||||
if file_size <= 0:
|
if file_size <= 0:
|
||||||
raise ValueError("Invalid file size")
|
raise ValueError("Invalid file size")
|
||||||
return file_size
|
return file_size
|
||||||
|
Loading…
Reference in New Issue
Block a user