Merge pull request 'MPSoC commands' (#169) from meier/mpsoc-commands into main

Reviewed-on: #169
This commit is contained in:
Robin Müller 2023-03-13 11:03:26 +01:00
commit d8367f7e62
2 changed files with 100 additions and 4 deletions

View File

@ -16,6 +16,7 @@ list yields a list of all related PRs for each release.
- Added RTD ID enum and Set ID enumeration in the RTD module. - Added RTD ID enum and Set ID enumeration in the RTD module.
- STR Temperature Set - STR Temperature Set
- Added some more MPSoC commands
## Fixed ## Fixed

View File

@ -66,6 +66,10 @@ class CommandId(enum.IntEnum):
TC_MODE_IDLE = 18 TC_MODE_IDLE = 18
SET_UART_TX_TRISTATE = 20 SET_UART_TX_TRISTATE = 20
RELEASE_UART_TX = 21 RELEASE_UART_TX = 21
TC_CAM_TAKE_PIC = 22
TC_SIMPLEX_SEND_FILE = 23
TC_DOWNLINK_DATA_MODULATE = 24
TC_MODE_SNAPSHOT = 25
class OpCode: class OpCode:
@ -78,6 +82,10 @@ class OpCode:
REPLAY_WRITE_SEQ = ["replay_write"] REPLAY_WRITE_SEQ = ["replay_write"]
DOWNLINK_PWR_ON = ["downlink_pwr_on"] DOWNLINK_PWR_ON = ["downlink_pwr_on"]
REPLAY_START = ["replay_start"] REPLAY_START = ["replay_start"]
CAM_TAKE_PIC = ["cam_take_pic"]
SIMPLEX_SEND_FILE = ["simplex_send_file"]
DOWNLINK_DATA_MODULATE = ["downlink_data_modulate"]
MODE_SNAPSHOT = ["mode_snapshot"]
class Info: class Info:
@ -90,6 +98,10 @@ class Info:
REPLAY_WRITE_SEQ = "Replay write sequence" REPLAY_WRITE_SEQ = "Replay write sequence"
DOWNLINK_PWR_ON = "Downlink Power On" DOWNLINK_PWR_ON = "Downlink Power On"
REPLAY_START = "Replay Start" REPLAY_START = "Replay Start"
CAM_TAKE_PIC = "Cam Take Picture"
SIMPLEX_SEND_FILE = "Simplex Send File"
DOWNLINK_DATA_MODULATE = "Downlink data modulate"
MODE_SNAPSHOT = "Mode Snapshot"
class MemAddresses(enum.IntEnum): class MemAddresses(enum.IntEnum):
@ -123,6 +135,10 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper):
oce.add("16", "Ploc MPSoC: Tc cam command send") oce.add("16", "Ploc MPSoC: Tc cam command send")
oce.add("17", "Ploc MPSoC: Set UART TX tristate") oce.add("17", "Ploc MPSoC: Set UART TX tristate")
oce.add("18", "Ploc MPSoC: Relesase UART TX") oce.add("18", "Ploc MPSoC: Relesase UART TX")
oce.add(OpCode.CAM_TAKE_PIC, Info.CAM_TAKE_PIC)
oce.add(OpCode.SIMPLEX_SEND_FILE, Info.SIMPLEX_SEND_FILE)
oce.add(OpCode.DOWNLINK_DATA_MODULATE, Info.DOWNLINK_DATA_MODULATE)
oce.add(OpCode.MODE_SNAPSHOT, Info.MODE_SNAPSHOT)
defs.add_service(CustomServiceList.PLOC_MPSOC.value, "Ploc MPSoC", oce) defs.add_service(CustomServiceList.PLOC_MPSOC.value, "Ploc MPSoC", oce)
@ -231,6 +247,22 @@ def pack_ploc_mpsoc_commands(p: ServiceProviderParams):
q.add_log_cmd("PLOC MPSoC: Release UART TX") q.add_log_cmd("PLOC MPSoC: Release UART TX")
data = object_id.as_bytes + struct.pack("!I", CommandId.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)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCode.CAM_TAKE_PIC:
q.add_log_cmd("PLOC MPSoC: Cam take picture")
data = prepare_cam_take_pic_cmd(object_id.as_bytes)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCode.SIMPLEX_SEND_FILE:
q.add_log_cmd("PLOC MPSoC: Simplex send file")
data = prepare_simplex_send_file_cmd(object_id.as_bytes)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCode.DOWNLINK_DATA_MODULATE:
q.add_log_cmd("PLOC MPSoC: Downlink data modulate")
data = prepare_downlink_data_modulate_cmd(object_id.as_bytes)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code in OpCode.MODE_SNAPSHOT:
q.add_log_cmd("PLOC MPSoC: Mode snapshot")
data = object_id.as_bytes + struct.pack('!I', CommandId.TC_MODE_SNAPSHOT)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
def generate_write_mem_command( def generate_write_mem_command(
@ -267,13 +299,13 @@ def prepare_mem_read_command(object_id: bytes) -> bytearray:
def prepare_flash_write_cmd(object_id: bytes) -> bytearray: def prepare_flash_write_cmd(object_id: bytes) -> bytearray:
obcFile = get_obc_file() obc_file = get_obc_file()
mpsocFile = get_mpsoc_file() mpsoc_file = get_mpsoc_file()
command = ( command = (
object_id object_id
+ struct.pack("!I", CommandId.FLASH_WRITE) + struct.pack("!I", CommandId.FLASH_WRITE)
+ bytearray(obcFile, "utf-8") + bytearray(obc_file, "utf-8")
+ bytearray(mpsocFile, "utf-8") + bytearray(mpsoc_file, "utf-8")
) )
return bytearray(command) return bytearray(command)
@ -323,6 +355,69 @@ def prepare_replay_write_sequence_cmd(object_id: bytes) -> bytearray:
return bytearray(command) return bytearray(command)
def prepare_cam_take_pic_cmd(object_id: bytes) -> bytearray:
selection = input("Use default parameter? (Y/N): ")
if selection is "Y" or selection is "y":
filename = "0:/test"
encoder_setting_y = 7
quantization_y = 0
encoder_setting_cb = 7
quantization_cb = 0
encoder_setting_cr = 7
quantization_cr = 0
bypass_compressor = 0
else:
filename = input("Specify filename: ")
encoder_setting_y = int(input("Specify encoderSetting_Y: "))
quantization_y = int(input("Specify quantization_Y: "))
encoder_setting_cb = int(input("Specify encoderSetting_Cb: "))
quantization_cb = int(input("Specify quantization_Cb: "))
encoder_setting_cr = int(input("Specify encoderSetting_Cr: "))
quantization_cr = int(input("Specify quantization_Cr: "))
bypass_compressor = int(input("Specify bypassCompressor: "))
command = (
object_id
+ struct.pack("!I", CommandId.TC_CAM_TAKE_PIC)
+ bytearray(filename, "utf-8")
+ bytes([0])
+ struct.pack('!B', encoder_setting_y)
+ struct.pack('!Q', quantization_y)
+ struct.pack('!B', encoder_setting_cb)
+ struct.pack('!Q', quantization_cb)
+ struct.pack('!B', encoder_setting_cr)
+ struct.pack('!Q', quantization_cr)
+ struct.pack('!B', bypass_compressor)
)
return bytearray(command)
def prepare_simplex_send_file_cmd(object_id: bytes) -> bytearray:
filename = input("Specify filename: ")
command = (
object_id
+ struct.pack("!I", CommandId.TC_SIMPLEX_SEND_FILE)
+ bytearray(filename, "utf-8")
+ bytes([0])
)
return bytearray(command)
def prepare_downlink_data_modulate_cmd(object_id: bytes) -> bytearray:
format = int(input("Specify format: "))
src_mem_addr = int(input("Specify srcMemAddr: "))
src_mem_len = int(input("Specify srcMemLen: "))
dest_mem_addr = int(input("Specify destMemAddr: "))
command = (
object_id
+ struct.pack("!I", CommandId.TC_DOWNLINK_DATA_MODULATE)
+ struct.pack('!B', format)
+ struct.pack('!I', src_mem_addr)
+ struct.pack('!H', src_mem_len)
+ struct.pack('!I', dest_mem_addr)
)
return bytearray(command)
def get_obc_file() -> str: def get_obc_file() -> str:
_LOGGER.info("Specify OBC file ") _LOGGER.info("Specify OBC file ")
input_helper = InputHelper(flash_write_file_dict) input_helper = InputHelper(flash_write_file_dict)