From 79e897b0353acacf0f986f22f57e9cd8cf30a0da Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Sat, 24 Apr 2021 13:27:57 +0200 Subject: [PATCH] ploc tc mem write and tc mem read test --- pus_tc/ploc.py | 21 ++++++++++++--------- pus_tc/tc_packer_hook.py | 2 +- pus_tm/service_8_hook.py | 14 ++++++-------- tmtccmd | 2 +- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/pus_tc/ploc.py b/pus_tc/ploc.py index abde171..b7955ac 100644 --- a/pus_tc/ploc.py +++ b/pus_tc/ploc.py @@ -10,7 +10,7 @@ import struct from tmtccmd.core.definitions import QueueCommands from tmtccmd.pus_tc.packer import TcQueueT -from tmtccmd.pus_tc.base import PusTelecommand +from tmtccmd.ecss.tc import PusTelecommand class PlocTestProcedure: @@ -25,8 +25,12 @@ class PlocTestProcedure: class PlocActionIds: - tc_mem_write = bytearray([0x0, 0x0, 0x7, 0x14]) - tc_mem_read = bytearray([0x0, 0x0, 0x7, 0x15]) + tc_mem_write = bytearray([0x0, 0x0, 0x0, 0x1]) + tc_mem_read = bytearray([0x0, 0x0, 0x0, 0x2]) + + +class PlocReplyIds: + tm_mem_read_report = 6 def pack_ploc_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: @@ -37,17 +41,16 @@ def pack_ploc_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: if PlocTestProcedure.all or PlocTestProcedure.test_tc_mem_write: tc_queue.appendleft((QueueCommands.PRINT, "PLOC: TC Mem Write Test")) - command = generateWriteMemCommand(object_id) memory_address = int(input("Type memory address: 0x"), 16) memory_data = int(input("Type memory data: 0x"), 16) - command = generateWriteMemCommand(object_id, struct.pack('I', memory_address), memory_data) + command = generateWriteMemCommand(object_id, struct.pack('!I', memory_address), memory_data) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if PlocTestProcedure.all or PlocTestProcedure.test_tc_mem_write: + if PlocTestProcedure.all or PlocTestProcedure.test_tc_mem_read: tc_queue.appendleft((QueueCommands.PRINT, "PLOC: TC Mem Read Test")) memory_address = int(input("Type memory address: 0x"), 16) - command = object_id + PlocActionIds.tc_mem_read + struct.pack('I', memory_address) + command = object_id + PlocActionIds.tc_mem_read + struct.pack('!I', memory_address) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -60,5 +63,5 @@ def generateWriteMemCommand(object_id: bytearray, memory_address: bytearray, mem @param memory_address The PLOC memory address where to write to. @param memory_data The data to write to the memory address specified by the bytearray memory_address. """ - command = object_id + PlocActionIds.tc_mem_write + memory_address + struct.pack('I', memory_data) - return command \ No newline at end of file + command = object_id + PlocActionIds.tc_mem_write + memory_address + struct.pack('!I', memory_data) + return command diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index 9ba5c1f..b56ba69 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -58,7 +58,7 @@ def pack_service_queue_user(service: Union[str, int], op_code: str, service_queu object_id = get_object_id(ObjIdIds.HEATER) return pack_heater_test_into(object_id, service_queue) if service == CustomServiceList.PLOC.value: - object_id = get_object_id(ObjIdIds.PLOC) + object_id = get_object_id(ObjIdIds.PLOC_ID) return pack_ploc_test_into(object_id, service_queue) LOGGER.warning("Invalid Service !") diff --git a/pus_tm/service_8_hook.py b/pus_tm/service_8_hook.py index 8933b40..55e3fa5 100644 --- a/pus_tm/service_8_hook.py +++ b/pus_tm/service_8_hook.py @@ -1,7 +1,7 @@ import struct from typing import Tuple from config.object_ids import ObjIdIds -from pus_tc.ploc import PlocActionIds +from pus_tc.ploc import PlocReplyIds def user_analyze_service_8_data( @@ -28,19 +28,17 @@ def user_analyze_service_8_data( data_string = data_string.rstrip() content_list = [data_string] elif object_id == ObjIdIds.PLOC_ID: - return handle_ploc_replies(custom_data) + return handle_ploc_replies(action_id, custom_data) else: header_list = [] content_list = [] return header_list, content_list -def handle_ploc_replies(custom_data: bytearray) -> Tuple[list, list]: +def handle_ploc_replies(action_id: int, custom_data: bytearray) -> Tuple[list, list]: header_list = [] content_list = [] - action_id = struct.unpack('!I', custom_data[0:4]) - if action_id == PlocActionIds.tc_mem_read: - header_list = ['PLOC Read Memory Data'] - memory_data = struct.unpack('!I', custom_data[4:8]) - content_list = [memory_data] + if action_id == PlocReplyIds.tm_mem_read_report: + header_list = ['PLOC Memory Address', 'PLOC Mem Len', 'PLOC Read Memory Data'] + content_list = [custom_data[:4], custom_data[4:6], custom_data[6:10]] return header_list, content_list diff --git a/tmtccmd b/tmtccmd index 563603d..1e3a1bd 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 563603d0a1b03115e473768ccd203a21ebaac50c +Subproject commit 1e3a1bd0d787feeb36b0936f29ba7ab513dfa63d