diff --git a/config/tmtcc_user_mode_op.py b/config/tmtcc_user_mode_op.py index b94ee97..5998a40 100644 --- a/config/tmtcc_user_mode_op.py +++ b/config/tmtcc_user_mode_op.py @@ -6,10 +6,8 @@ import sys from config.tmtcc_definitions import ModeList -from core.tmtc_backend import TmTcHandler -from test.obsw_pus_service_test import run_selected_pus_tests +from tmtc_core.core.tmtcc_backend import TmTcHandler from tmtc_core.utility.tmtcc_logger import get_logger -from utility.tmtcc_binary_uploader import BinaryFileUploader LOGGER = get_logger() diff --git a/gomspace/__init__.py b/gomspace/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gomspace/gomspace_common.py b/gomspace/gomspace_common.py index 9d0c9f4..1b3df79 100644 --- a/gomspace/gomspace_common.py +++ b/gomspace/gomspace_common.py @@ -97,7 +97,6 @@ def pack_ping_command(object_id: bytearray, data: bytearray) -> bytearray: data are simply copied by the device and then sent back. """ action_id = GomspaceDeviceActions.PING - command = bytearray() command = object_id + action_id + data return command @@ -108,7 +107,7 @@ def pack_gnd_wdt_reset_command(object_id: bytearray) -> bytearray: """ action_id = GomspaceDeviceActions.WDT_RESET command = bytearray() - command = object_id + action_id + command += object_id + action_id return command @@ -118,7 +117,7 @@ def pack_reboot_command(object_id: bytearray) -> bytearray: """ action_id = GomspaceDeviceActions.REBOOT command = bytearray() - command = object_id + action_id + command += object_id + action_id return command diff --git a/gomspace/gomspace_pdu_definitions.py b/gomspace/gomspace_pdu_definitions.py index 8d8b408..009eb31 100644 --- a/gomspace/gomspace_pdu_definitions.py +++ b/gomspace/gomspace_pdu_definitions.py @@ -13,4 +13,4 @@ class PDUConfigTable: class PDUHkTable: temperature = TableEntry(bytearray([0x00, 0x28]), TableEntry.uint16_size) # Ground WDT value (remaining seconds until reboot) - wdt_gnd_left = TableEntry(bytearray([0x00, 0x80]), TableEntry.uint32_size) \ No newline at end of file + wdt_gnd_left = TableEntry(bytearray([0x00, 0x80]), TableEntry.uint32_size) diff --git a/pus_tc/tmtcc_tc_acu.py b/pus_tc/tmtcc_tc_acu.py index 18e803e..e143e2a 100644 --- a/pus_tc/tmtcc_tc_acu.py +++ b/pus_tc/tmtcc_tc_acu.py @@ -8,6 +8,7 @@ from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand +from tmtc_core.core.tmtc_core_definitions import QueueCommands from gomspace.gomspace_common import * from pus_tc.tmtcc_tc_p60dock import P60DockConfigTable from config.tmtcc_object_ids import ObjectIds @@ -53,9 +54,9 @@ class ACUHkTable: def pack_acu_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing ACU")) + tc_queue.appendleft((QueueCommands.PRINT, "Testing ACU")) - tc_queue.appendleft(("print", "P60 Dock: Enabling ACU connected to X1 slot (channel 0)")) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Enabling ACU connected to X1 slot (channel 0)")) p60dock_object_id = get_object_id(ObjectIds.P60DOCK_HANDLER_ID) command = pack_set_param_command(p60dock_object_id, P60DockConfigTable.out_en_0.parameter_address, P60DockConfigTable.out_en_0.parameter_size, Channel.on) @@ -63,59 +64,59 @@ def pack_acu_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.reboot: - tc_queue.appendleft(("print", "ACU: Reboot")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reboot")) command = pack_reboot_command(object_id) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.read_gnd_wdt: - tc_queue.appendleft(("print", "ACU: Reading ground watchdog timer value")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading ground watchdog timer value")) command = pack_get_param_command(object_id, TableIds.hk, ACUHkTable.wdt_gnd_left.parameter_address, ACUHkTable.wdt_gnd_left.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.gnd_wdt_reset: - tc_queue.appendleft(("print", "ACU: Testing ground watchdog reset")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Testing ground watchdog reset")) command = pack_gnd_wdt_reset_command(object_id) command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.ping: - tc_queue.appendleft(("print", "ACU: Ping Test")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Ping Test")) ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) command = pack_ping_command(object_id, ping_data) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.read_temperature3: - tc_queue.appendleft(("print", "ACU: Reading temperature 3")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading temperature 3")) command = pack_get_param_command(object_id, TableIds.hk, ACUHkTable.temperature3.parameter_address, ACUHkTable.temperature3.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.read_vboost: - tc_queue.appendleft(("print", "ACU: Reading vboost value")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vboost value")) command = pack_get_param_command(object_id, TableIds.config, ACUConfigTable.vboost.parameter_address, ACUConfigTable.vboost.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.read_vbat_max_hi: - tc_queue.appendleft(("print", "ACU: Reading vbat_max_hi")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vbat_max_hi")) command = pack_get_param_command(object_id, TableIds.config, ACUConfigTable.vbat_max_hi.parameter_address, ACUConfigTable.vbat_max_hi.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.read_vbat_max_lo: - tc_queue.appendleft(("print", "ACU: Reading vbat_max_lo")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vbat_max_lo")) command = pack_get_param_command(object_id, TableIds.config, ACUConfigTable.vbat_max_lo.parameter_address, ACUConfigTable.vbat_max_lo.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if ACUTestProcedure.all or ACUTestProcedure.read_ov_mode: - tc_queue.appendleft(("print", "ACU: Reading ov_mode")) + tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading ov_mode")) command = pack_get_param_command(object_id, TableIds.config, ACUConfigTable.ov_mode.parameter_address, ACUConfigTable.ov_mode.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("print", "P60 Dock: Turning off ACU")) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning off ACU")) command = pack_set_param_command(p60dock_object_id, P60DockConfigTable.out_en_0.parameter_address, P60DockConfigTable.out_en_0.parameter_size, Channel.off) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) diff --git a/pus_tc/tmtcc_tc_p60dock.py b/pus_tc/tmtcc_tc_p60dock.py index 3b6293e..450f177 100644 --- a/pus_tc/tmtcc_tc_p60dock.py +++ b/pus_tc/tmtcc_tc_p60dock.py @@ -5,7 +5,7 @@ @author J. Meier @date 13.12.2020 """ - +from tmtc_core.core.tmtc_core_definitions import QueueCommands from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand from gomspace.gomspace_common import * @@ -50,74 +50,86 @@ class P60DockHkTable: def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: if P60DockTestProcedure.all or P60DockTestProcedure.reboot: - tc_queue.appendleft(("print", "P60 Dock: Reboot")) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Reboot")) command = pack_reboot_command(object_id) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.read_gnd_wdt: - tc_queue.appendleft(("print", "P60 Dock: Reading ground watchdog timer value")) - command = pack_get_param_command(object_id, TableIds.hk, P60DockHkTable.wdt_gnd_left.parameter_address, - P60DockHkTable.wdt_gnd_left.parameter_size) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Reading ground watchdog timer value")) + command = pack_get_param_command( + object_id, TableIds.hk, P60DockHkTable.wdt_gnd_left.parameter_address, + P60DockHkTable.wdt_gnd_left.parameter_size + ) command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.gnd_wdt_reset: - tc_queue.appendleft(("print", "P60 Dock: Testing ground watchdog reset")) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing ground watchdog reset")) command = pack_gnd_wdt_reset_command(object_id) command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.ping: - tc_queue.appendleft(("print", "P60 Dock: Ping")) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Ping")) ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) command = pack_ping_command(object_id, ping_data) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_off: - tc_queue.appendleft(("print", "P60 Dock: Testing setting output channel 3 off")) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing setting output channel 3 off")) parameter = 0 # set channel off command = pack_set_param_command(object_id, P60DockConfigTable.out_en_3.parameter_address, P60DockConfigTable.out_en_3.parameter_size, parameter) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.read_temperature1: - tc_queue.appendleft(("print", "P60 Dock: Testing temperature reading")) - command = pack_get_param_command(object_id, TableIds.hk, P60DockHkTable.temperature1.parameter_address, - P60DockHkTable.temperature1.parameter_size) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing temperature reading")) + command = pack_get_param_command( + object_id, TableIds.hk, P60DockHkTable.temperature1.parameter_address, + P60DockHkTable.temperature1.parameter_size + ) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on: - tc_queue.appendleft(("print", "P60 Dock: Testing Output Channel 3 state (PDU2)")) + tc_queue.appendleft((QueueCommands.PRINT, + "P60 Dock: Testing Output Channel 3 state (PDU2)")) command = pack_get_param_command(object_id, TableIds.config, P60DockConfigTable.out_en_3.parameter_address, P60DockConfigTable.out_en_3.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.read_cur_lu_lim_0: - tc_queue.appendleft(("print", "P60 Dock: Reading current limit value of output channel 0")) - command = pack_get_param_command(object_id, TableIds.config, P60DockConfigTable.cur_lu_lim_0.parameter_address, - P60DockConfigTable.cur_lu_lim_0.parameter_size) + tc_queue.appendleft((QueueCommands.PRINT, + "P60 Dock: Reading current limit value of output channel 0")) + command = pack_get_param_command( + object_id, TableIds.config, P60DockConfigTable.cur_lu_lim_0.parameter_address, + P60DockConfigTable.cur_lu_lim_0.parameter_size + ) command = PusTelecommand(service=8, subservice=128, ssc=26, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on: - tc_queue.appendleft(("print", "P60 Dock: Testing setting output channel 3 on")) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing setting output channel 3 on")) parameter = 1 # set channel on command = pack_set_param_command(object_id, P60DockConfigTable.out_en_3.parameter_address, P60DockConfigTable.out_en_3.parameter_size, parameter) command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.invalid_table_id_test: - tc_queue.appendleft(("print", "P60 Dock: Testing invalid table id handling")) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Testing invalid table id handling")) table_id_invalid = 5 - command = pack_get_param_command(object_id, table_id_invalid, P60DockHkTable.temperature1.parameter_address, - P60DockHkTable.temperature1.parameter_size) + command = pack_get_param_command( + object_id, table_id_invalid, P60DockHkTable.temperature1.parameter_address, + P60DockHkTable.temperature1.parameter_size + ) command = PusTelecommand(service=8, subservice=128, ssc=28, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.invalid_address_test: - tc_queue.appendleft(("print", "P60 Dock: Testing invalid address handling in get param command")) + tc_queue.appendleft((QueueCommands.PRINT, + "P60 Dock: Testing invalid address handling in get param command")) invalid_address = bytearray([0x01, 0xF4]) command = pack_get_param_command(object_id, TableIds.hk, invalid_address, P60DockHkTable.temperature1.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=29, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("print", "P60 Dock: Testing invalid address handling in set param command")) + tc_queue.appendleft((QueueCommands.PRINT, + "P60 Dock: Testing invalid address handling in set param command")) invalid_address = bytearray([0x01, 0xF4]) parameter_size = 2 parameter = 1 @@ -125,16 +137,24 @@ def pack_p60dock_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if P60DockTestProcedure.all or P60DockTestProcedure.invalid_parameter_size_test: - tc_queue.appendleft(("print", "P60 Dock: Testing handling of invalid parameter sizes in get-param command")) + tc_queue.appendleft( + (QueueCommands.PRINT, + "P60 Dock: Testing handling of invalid parameter sizes in get-param command") + ) invalid_size = 5 - command = pack_get_param_command(object_id, TableIds.hk, P60DockHkTable.temperature1.parameter_address, - invalid_size) + command = pack_get_param_command( + object_id, TableIds.hk, P60DockHkTable.temperature1.parameter_address, invalid_size + ) command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("print", "P60 Dock: Testing handling of invalid parameter size in set-param command")) + tc_queue.appendleft( + (QueueCommands.PRINT, + "P60 Dock: Testing handling of invalid parameter size in set-param command") + ) parameter = 1 - command = pack_set_param_command(object_id, P60DockConfigTable.out_en_3.parameter_address, invalid_size, - parameter) + command = pack_set_param_command( + object_id, P60DockConfigTable.out_en_3.parameter_address, invalid_size, parameter + ) command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) diff --git a/pus_tc/tmtcc_tc_packer_hook.py b/pus_tc/tmtcc_tc_packer_hook.py index 001e7fa..fc38260 100644 --- a/pus_tc/tmtcc_tc_packer_hook.py +++ b/pus_tc/tmtcc_tc_packer_hook.py @@ -6,13 +6,12 @@ import os from collections import deque -from typing import Union from config.tmtcc_definitions import ServiceList from tmtc_core.utility.tmtcc_logger import get_logger from tmtc_core.pus_tc.tmtcc_pus_tc_base import TcQueueT -from tmtc_core.pus_tc.tmtcc_tc_service5_event import pack_service5_test_into -from tmtc_core.pus_tc.tmtcc_tc_service17_test import pack_service17_ping_command +from tmtc_core.pus_tc.tmtcc_tc_service_5_event import pack_generic_service5_test_into +from tmtc_core.pus_tc.tmtcc_tc_service_17_test import pack_service17_ping_command from pus_tc.tmtcc_tc_p60dock import pack_p60dock_test_into from pus_tc.tmtcc_tc_pdu2 import pack_pdu2_test_into from pus_tc.tmtcc_tc_pdu1 import pack_pdu1_test_into @@ -25,9 +24,9 @@ from pus_tc.tmtcc_tc_heater import pack_heater_test_into LOGGER = get_logger() -def pack_service_queue_user(service: Union[int, str], op_code: int, service_queue: TcQueueT): +def pack_service_queue_user(service: ServiceList, op_code: str, service_queue: TcQueueT): if service == ServiceList.SERVICE_5: - return pack_service5_test_into(service_queue) + return pack_generic_service5_test_into(service_queue) if service == ServiceList.SERVICE_17: return service_queue.appendleft(pack_service17_ping_command(ssc=1700).pack_command_tuple()) if service == ServiceList.P60DOCK: @@ -60,6 +59,6 @@ def create_total_tc_queue_user() -> TcQueueT: if not os.path.exists("log"): os.mkdir("log") tc_queue = deque() - pack_service5_test_into(tc_queue) + pack_generic_service5_test_into(tc_queue) tc_queue.appendleft(pack_service17_ping_command(ssc=1700).pack_command_tuple()) return tc_queue diff --git a/pus_tc/tmtcc_tc_service200_mode.py b/pus_tc/tmtcc_tc_service200_mode.py index 2f0641a..11d81fe 100644 --- a/pus_tc/tmtcc_tc_service200_mode.py +++ b/pus_tc/tmtcc_tc_service200_mode.py @@ -5,6 +5,7 @@ @author R. Mueller @date 02.05.2020 """ +from tmtc_core.core.tmtc_core_definitions import QueueCommands from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT from tmtc_core.core.tmtcc_object_id_manager import get_object_id @@ -15,30 +16,30 @@ TEST_DEVICE_ID = get_object_id(ObjectIds.TEST_DEVICE) def pack_service200_test_into(tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing Service 200")) + tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200")) # Object ID: Dummy Device object_id = TEST_DEVICE_ID # Set On Mode - tc_queue.appendleft(("print", "Testing Service 200: Set Mode On")) + tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200: Set Mode On")) mode_data = pack_mode_data(object_id, 1, 0) command = PusTelecommand(service=200, subservice=1, ssc=2000, app_data=mode_data) tc_queue.appendleft(command.pack_command_tuple()) # Set Normal mode - tc_queue.appendleft(("print", "Testing Service 200: Set Mode Normal")) + tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200: Set Mode Normal")) mode_data = pack_mode_data(object_id, 2, 0) command = PusTelecommand(service=200, subservice=1, ssc=2010, app_data=mode_data) tc_queue.appendleft(command.pack_command_tuple()) # Set Raw Mode - tc_queue.appendleft(("print", "Testing Service 200: Set Mode Raw")) + tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200: Set Mode Raw")) mode_data = pack_mode_data(object_id, 3, 0) command = PusTelecommand(service=200, subservice=1, ssc=2020, app_data=mode_data) tc_queue.appendleft(command.pack_command_tuple()) # Set Off Mode - tc_queue.appendleft(("print", "Testing Service 200: Set Mode Off")) + tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200: Set Mode Off")) mode_data = pack_mode_data(object_id, 0, 0) command = PusTelecommand(service=200, subservice=1, ssc=2030, app_data=mode_data) tc_queue.appendleft(command.pack_command_tuple()) - tc_queue.appendleft(("export", "log/tmtc_log_service200.txt")) + tc_queue.appendleft((QueueCommands.EXPORT_LOG, "log/tmtc_log_service200.txt")) return tc_queue diff --git a/pus_tm/tmtcc_pus_hk_handling.py b/pus_tm/tmtcc_pus_hk_handling.py index 4128375..73eede3 100644 --- a/pus_tm/tmtcc_pus_hk_handling.py +++ b/pus_tm/tmtcc_pus_hk_handling.py @@ -6,7 +6,7 @@ """ from typing import Tuple -from tmtc_core.pus_tm.obsw_tm_service_3 import Service3Base +from tmtc_core.pus_tm.tmtcc_pus_service_3 import Service3Base from tmtc_core.utility.tmtcc_logger import get_logger LOGGER = get_logger()