From e9dfb922a70e60043fc5da816a1944403758e823 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" <robin.mueller.m@gmail.com> Date: Sat, 5 Sep 2020 12:46:12 +0200 Subject: [PATCH] moved sd card ID to global config --- config/obsw_config.py | 5 +++-- tc/obsw_pus_tc_packer.py | 6 +++--- tc/obsw_tc_gps.py | 8 ++++---- tc/obsw_tc_service23.py | 23 +++++++++++------------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/config/obsw_config.py b/config/obsw_config.py index db122b0..6b9ebc4 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -19,9 +19,10 @@ Mission/Device specific information. # TODO: Automate / Autofill this file with the MIB parser # Object IDs -GPS0_ObjectId = bytearray([0x44, 0x10, 0x1F, 0x00]) -GPS1_ObjectId = bytearray([0x44, 0x20, 0x20, 0x00]) +GPS0_DEVICE_ID = bytearray([0x44, 0x10, 0x1F, 0x00]) +GPS1_DEVICE_ID = bytearray([0x44, 0x20, 0x20, 0x00]) DUMMY_DEVICE_ID = bytearray([0x44, 0x00, 0xAF, 0xFE]) +SD_CARD_HANDLER_ID = bytearray([0x4D, 0x00, 0x73, 0xAD]) # Commands DUMMY_COMMAND_1 = struct.pack(">I", 666) diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py index 26fb866..23920de 100644 --- a/tc/obsw_pus_tc_packer.py +++ b/tc/obsw_pus_tc_packer.py @@ -55,11 +55,11 @@ class ServiceQueuePacker: return pack_dummy_device_test_into(service_queue) if service == "GPS0": # Object ID: GPS Device - object_id = g.GPS0_ObjectId + object_id = g.GPS0_DEVICE_ID return pack_gps_test_into(object_id, service_queue) if service == "GPS1": # Object ID: GPS Device - object_id = g.GPS1_ObjectId + object_id = g.GPS1_DEVICE_ID return pack_gps_test_into(object_id, service_queue) if service == "Error": return pack_error_testing_into(service_queue) @@ -79,7 +79,7 @@ def create_total_tc_queue() -> TcQueueT: tc_queue = pack_service17_test_into(tc_queue) tc_queue = pack_service200_test_into(tc_queue) tc_queue = pack_dummy_device_test_into(tc_queue) - object_id = g.GPS0_ObjectId + object_id = g.GPS0_DEVICE_ID tc_queue = pack_gps_test_into(object_id, tc_queue) return tc_queue diff --git a/tc/obsw_tc_gps.py b/tc/obsw_tc_gps.py index e7edd53..9d9e1eb 100644 --- a/tc/obsw_tc_gps.py +++ b/tc/obsw_tc_gps.py @@ -12,9 +12,9 @@ from tc.obsw_tc_service2 import pack_mode_data import config.obsw_config as g def pack_gps_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: - if object_id == g.GPS0_ObjectId: + if object_id == g.GPS0_DEVICE_ID: gps_string = "GPS0" - elif object_id == g.GPS1_ObjectId: + elif object_id == g.GPS1_DEVICE_ID: gps_string = "GPS1" else: gps_string = "unknown" @@ -31,12 +31,12 @@ def pack_gps_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: tc_queue.appendleft(command.pack_command_tuple()) # Enable HK report sid_gps = 0 - if object_id == g.GPS0_ObjectId: + if object_id == g.GPS0_DEVICE_ID: sid_gps = g.GPS0_SID tc_queue.appendleft(("print", "Testing " + gps_string + ": Enable HK Reporting")) command = PusTelecommand(service=3, subservice=5, ssc=13, app_data=sid_gps) tc_queue.appendleft(command.pack_command_tuple()) - elif object_id == g.GPS1_ObjectId: + elif object_id == g.GPS1_DEVICE_ID: sid_gps = g.GPS1_SID tc_queue.appendleft(("print", "Testing " + gps_string + ": Enable HK Reporting")) command = PusTelecommand(service=3, subservice=5, ssc=14, app_data=sid_gps) diff --git a/tc/obsw_tc_service23.py b/tc/obsw_tc_service23.py index a9bb17b..a7ed1a5 100644 --- a/tc/obsw_tc_service23.py +++ b/tc/obsw_tc_service23.py @@ -5,8 +5,7 @@ Created: 21.01.2020 07:48 @author: Jakob Meier """ import math -from collections import deque -import time +import config.obsw_config as g from tc.obsw_pus_tc_packer import TcQueueT, PusTelecommand @@ -15,7 +14,7 @@ class Service23WriteToFile: """ This class generates the telecommand packet for the custom PUS service [23, 128] :param - objectID(bytearray): The objectID of the filesystem handler (e.g. SDCardHandler, PLOCHandler) + objectID(bytearray): The objectID of the filesystem handler (e.g. SD_CARD_HANDLER_ID, PLOCHandler) repositoryPath(str): The directory of the file filename(str): The name of the file (e.g. boot.bin) fileData(bytearray): The data to write to the file @@ -243,30 +242,30 @@ def generateService23Subservice129Packet(repositoryPath, filename, objectID=byte def pack_service23_test_into(tcQueue: TcQueueT) -> TcQueueT: - SDCardHandler = [0x4D, 0x00, 0x73, 0xAD] + sd_handler_id = g.SD_CARD_HANDLER_ID tcQueue.appendleft(("print", "Testing Service 23")) tcQueue.append(("print", "Create directory 'test'")) - command = generateService23Subservice9Packet(directoryName="test", objectID=SDCardHandler) + command = generateService23Subservice9Packet(directoryName="test", objectID=sd_handler_id) tcQueue.appendleft(command.pack_command_tuple()) tcQueue.append(("print", "Create subdirectory 'subdir' in 'test'")) command = generateService23Subservice9Packet(repositoryPath="test", directoryName="subdir", - objectID=SDCardHandler) + objectID=sd_handler_id) tcQueue.appendleft(command.pack_command_tuple()) tcQueue.appendleft(("print", "Create and write in test.bin")) - command = generateService23Subservice128Packet("test/subdir", "test.bin", SDCardHandler, - fileData=bytearray([0x01, 0x00, 0x01, 0x00])) + command = generateService23Subservice128Packet( + "test/subdir", "test.bin", sd_handler_id, fileData=bytearray([0x01, 0x00, 0x01, 0x00])) tcQueue.appendleft(command[0].pack_command_tuple()) tcQueue.appendleft(("print", "Read data of test.bin")) - command = generateService23Subservice129Packet("test/subdir", "test.bin", SDCardHandler) + command = generateService23Subservice129Packet("test/subdir", "test.bin", sd_handler_id) tcQueue.appendleft(command.pack_command_tuple()) tcQueue.appendleft(("print", "Delete 'test.bin'")) - command = generateService23Subservice2Packet("test.bin", "test/subdir", objectID=SDCardHandler) + command = generateService23Subservice2Packet("test.bin", "test/subdir", objectID=sd_handler_id) tcQueue.appendleft(command.pack_command_tuple()) tcQueue.appendleft(("print", "Delete 'subdir' directory")) - command = generateService23Subservice10Packet("subdir", "test", objectID=SDCardHandler) + command = generateService23Subservice10Packet("subdir", "test", objectID=sd_handler_id) tcQueue.appendleft(command.pack_command_tuple()) tcQueue.appendleft(("print", "Delete 'test' directory")) - command = generateService23Subservice10Packet(dirname="test", objectID=SDCardHandler) + command = generateService23Subservice10Packet(dirname="test", objectID=sd_handler_id) tcQueue.appendleft(command.pack_command_tuple()) tcQueue.appendleft(("print", "\r")) return tcQueue \ No newline at end of file -- GitLab