From 8d036bcd4fed1211ad5b15ddae7b42e61e22fcfd Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 13 Feb 2023 14:14:56 +0100 Subject: [PATCH 1/3] Added the following commands (not tested yet): * TcCamTakePic * TcSimplexSendFile * TcDownlinkDataModulate * TcModeSnapshot --- eive_tmtc/tmtc/payload/ploc_mpsoc.py | 94 ++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 5 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_mpsoc.py b/eive_tmtc/tmtc/payload/ploc_mpsoc.py index 9b5f0b9..f5088eb 100644 --- a/eive_tmtc/tmtc/payload/ploc_mpsoc.py +++ b/eive_tmtc/tmtc/payload/ploc_mpsoc.py @@ -66,6 +66,10 @@ class CommandId(enum.IntEnum): TC_MODE_IDLE = 18 SET_UART_TX_TRISTATE = 20 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: @@ -78,7 +82,10 @@ class OpCode: REPLAY_WRITE_SEQ = ["replay_write"] DOWNLINK_PWR_ON = ["downlink_pwr_on"] 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: ON = "On" @@ -90,6 +97,10 @@ class Info: REPLAY_WRITE_SEQ = "Replay write sequence" DOWNLINK_PWR_ON = "Downlink Power On" 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): @@ -123,6 +134,10 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper): 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") + oce.add(OpCode.CAM_TAKE_PIC, OpCode.CAM_TAKE_PIC) + oce.add(OpCode.SIMPLEX_SEND_FILE, OpCode.SIMPLEX_SEND_FILE) + oce.add(OpCode.DOWNLINK_DATA_MODULATE, OpCode.DOWNLINK_DATA_MODULATE) + oce.add(OpCode.MODE_SNAPSHOT, OpCode.MODE_SNAPSHOT) defs.add_service(CustomServiceList.PLOC_MPSOC.value, "Ploc MPSoC", oce) @@ -231,6 +246,23 @@ def pack_ploc_mpsoc_commands(p: ServiceProviderParams): q.add_log_cmd("PLOC MPSoC: 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)) + if op_code == 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 == 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 == 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 == 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( @@ -267,13 +299,13 @@ def prepare_mem_read_command(object_id: bytes) -> bytearray: def prepare_flash_write_cmd(object_id: bytes) -> bytearray: - obcFile = get_obc_file() - mpsocFile = get_mpsoc_file() + obc_file = get_obc_file() + mpsoc_file = get_mpsoc_file() command = ( object_id + struct.pack("!I", CommandId.FLASH_WRITE) - + bytearray(obcFile, "utf-8") - + bytearray(mpsocFile, "utf-8") + + bytearray(obc_file, "utf-8") + + bytearray(mpsoc_file, "utf-8") ) return bytearray(command) @@ -323,6 +355,58 @@ def prepare_replay_write_sequence_cmd(object_id: bytes) -> bytearray: return bytearray(command) +def prepare_cam_take_pic_cmd(object_id: bytes) -> bytearray: + 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: _LOGGER.info("Specify OBC file ") input_helper = InputHelper(flash_write_file_dict) From 56630b05c2d49651823892876c80d0885b25b9b4 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 28 Feb 2023 09:13:14 +0100 Subject: [PATCH 2/3] bugfix in mpsoc commands --- eive_tmtc/tmtc/payload/ploc_mpsoc.py | 47 +++++++++++++++++----------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_mpsoc.py b/eive_tmtc/tmtc/payload/ploc_mpsoc.py index f5088eb..c263ef9 100644 --- a/eive_tmtc/tmtc/payload/ploc_mpsoc.py +++ b/eive_tmtc/tmtc/payload/ploc_mpsoc.py @@ -87,6 +87,7 @@ class OpCode: DOWNLINK_DATA_MODULATE = ["downlink_data_modulate"] MODE_SNAPSHOT = ["mode_snapshot"] + class Info: ON = "On" OFF = "Off" @@ -134,10 +135,10 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper): 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") - oce.add(OpCode.CAM_TAKE_PIC, OpCode.CAM_TAKE_PIC) - oce.add(OpCode.SIMPLEX_SEND_FILE, OpCode.SIMPLEX_SEND_FILE) - oce.add(OpCode.DOWNLINK_DATA_MODULATE, OpCode.DOWNLINK_DATA_MODULATE) - oce.add(OpCode.MODE_SNAPSHOT, OpCode.MODE_SNAPSHOT) + 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) @@ -246,25 +247,24 @@ def pack_ploc_mpsoc_commands(p: ServiceProviderParams): q.add_log_cmd("PLOC MPSoC: 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)) - if op_code == OpCode.CAM_TAKE_PIC: + 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 == OpCode.SIMPLEX_SEND_FILE: + 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 == OpCode.DOWNLINK_DATA_MODULATE: + 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 == OpCode.MODE_SNAPSHOT: + 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) + 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( object_id: bytes, memory_address: int, memory_data: int, mem_len: int ) -> bytearray: @@ -356,14 +356,25 @@ def prepare_replay_write_sequence_cmd(object_id: bytes) -> bytearray: def prepare_cam_take_pic_cmd(object_id: bytes) -> bytearray: - 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: ")) + 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) From e862df4d06a502b059315bc6254a3b513686b52e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Mar 2023 11:02:57 +0100 Subject: [PATCH 3/3] some more MPSoC commands --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 393b4cb..9fd2a9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. - STR Temperature Set +- Added some more MPSoC commands ## Fixed