diff --git a/config/tmtcc_definitions.py b/config/tmtcc_definitions.py index d5a4f24..6ce43ca 100644 --- a/config/tmtcc_definitions.py +++ b/config/tmtcc_definitions.py @@ -32,6 +32,7 @@ class ServiceList(enum.Enum): PDU1 = auto() PDU2 = auto() ACU = auto() + TMP1075 = auto() class SerialConfig(enum.Enum): diff --git a/config/tmtcc_globals.py b/config/tmtcc_globals.py index 6595b01..ae272ed 100644 --- a/config/tmtcc_globals.py +++ b/config/tmtcc_globals.py @@ -154,6 +154,8 @@ def add_globals_post_args_parsing(args: argparse.Namespace): service = ServiceList.PDU2 elif service == "acu": service = ServiceList.ACU + elif service == "tmp1075": + service = ServiceList.TMP1075 else: logger.warning("Service not known! Setting standard service 17") service = ServiceList.SERVICE_17 diff --git a/config/tmtcc_object_ids.py b/config/tmtcc_object_ids.py index 434d5e4..2185b6a 100644 --- a/config/tmtcc_object_ids.py +++ b/config/tmtcc_object_ids.py @@ -16,6 +16,8 @@ class ObjectIds(enum.Enum): PDU1_HANDLER_ID = auto() PDU2_HANDLER_ID = auto() ACU_HANDLER_ID = auto() + TMP1075_1_HANDLER_ID = auto() + TMP1075_2_HANDLER_ID = auto() def set_object_ids(object_id_dict: Dict[ObjectIds, bytearray]): @@ -27,5 +29,7 @@ def set_object_ids(object_id_dict: Dict[ObjectIds, bytearray]): o_ids.PDU1_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x2]), o_ids.PDU2_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x3]), o_ids.ACU_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x4]), + o_ids.TMP1075_1_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x5]), + o_ids.TMP1075_2_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x6]), } ) 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/config/tmtcc_version.py b/config/tmtcc_version.py index 1a221ce..02f0eac 100644 --- a/config/tmtcc_version.py +++ b/config/tmtcc_version.py @@ -3,8 +3,6 @@ @details Template configuration file. Copy this folder to the TMTC commander root and adapt it to your needs. """ -import tmtc_core.core.tmtcc_version as core - -SW_NAME = core.SW_NAME -SW_VERSION = core.SW_VERSION -SW_SUBVERSION = core.SW_SUBVERSION +SW_NAME = "eive" +SW_VERSION = 1 +SW_SUBVERSION = 1 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 7115c46..8aff120 100644 --- a/gomspace/gomspace_common.py +++ b/gomspace/gomspace_common.py @@ -96,7 +96,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 @@ -107,7 +106,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 @@ -117,5 +116,5 @@ 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 cf38750..e143e2a 100644 --- a/pus_tc/tmtcc_tc_acu.py +++ b/pus_tc/tmtcc_tc_acu.py @@ -8,8 +8,11 @@ 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 +from tmtc_core.core.tmtcc_object_id_manager import get_object_id class ACUTestProcedure: @@ -51,69 +54,70 @@ 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)")) - command = pack_set_param_command(g.P60DOCK_HANDLER_ID, P60DockConfigTable.out_en_0.parameter_address, + 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) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) 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")) - command = pack_set_param_command(g.P60DOCK_HANDLER_ID, P60DockConfigTable.out_en_0.parameter_address, + 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) tc_queue.appendleft(command.pack_command_tuple()) 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 5500572..86f63d6 100644 --- a/pus_tc/tmtcc_tc_packer_hook.py +++ b/pus_tc/tmtcc_tc_packer_hook.py @@ -6,26 +6,26 @@ 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 from pus_tc.tmtcc_tc_acu import pack_acu_test_into from tmtc_core.core.tmtcc_object_id_manager import get_object_id from config.tmtcc_object_ids import ObjectIds +from pus_tc.tmtcc_tc_tmp1075 import pack_tmp1075_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: @@ -40,6 +40,9 @@ def pack_service_queue_user(service: Union[int, str], op_code: int, service_queu if service == ServiceList.ACU: object_id = get_object_id(ObjectIds.ACU_HANDLER_ID) return pack_acu_test_into(object_id, service_queue) + if service == ServiceList.TMP1075: + object_id = get_object_id(ObjectIds.TMP1075_1_HANDLER_ID) + return pack_tmp1075_test_into(object_id, service_queue) LOGGER.warning("Invalid Service !") @@ -47,6 +50,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_pdu1.py b/pus_tc/tmtcc_tc_pdu1.py index 47ee8d7..da0afc4 100644 --- a/pus_tc/tmtcc_tc_pdu1.py +++ b/pus_tc/tmtcc_tc_pdu1.py @@ -8,11 +8,18 @@ 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 * +from tmtc_core.core.tmtcc_object_id_manager import get_object_id +from tmtc_core.core.tmtc_core_definitions import QueueCommands + from pus_tc.tmtcc_tc_p60dock import P60DockConfigTable +from config.tmtcc_object_ids import ObjectIds +from gomspace.gomspace_common import * from gomspace.gomspace_pdu_definitions import * +P60DOCK_HANDLER_ID = get_object_id(ObjectIds.P60DOCK_HANDLER_ID) + + class PDU1TestProcedure: """ @brief Use this class to define the tests to perform for the PDU2. @@ -25,23 +32,25 @@ class PDU1TestProcedure: read_temperature = False -def pack_pdu1_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing PDU1")) +def pack_pdu1_test_into(object_id: bytearray, tc_queue: TcQueueT): + tc_queue.appendleft((QueueCommands.PRINT, "Testing PDU1")) - tc_queue.appendleft(("print", "P60 Dock: Enabling PDU1")) - command = pack_set_param_command(g.P60DOCK_HANDLER_ID, P60DockConfigTable.out_en_1.parameter_address, - P60DockConfigTable.out_en_1.parameter_size, Channel.on) + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Enabling PDU1")) + command = pack_set_param_command( + P60DOCK_HANDLER_ID, P60DockConfigTable.out_en_1.parameter_address, + P60DockConfigTable.out_en_1.parameter_size, Channel.on + ) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if PDU1TestProcedure.all or PDU1TestProcedure.ping: - tc_queue.appendleft(("print", "PDU1: Ping Test")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU1: 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 PDU1TestProcedure.all or PDU1TestProcedure.read_temperature: - tc_queue.appendleft(("print", "PDU1: Testing temperature reading")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Testing temperature reading")) command = pack_get_param_command(object_id, TableIds.hk, PDUHkTable.temperature.parameter_address, PDUHkTable.temperature.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) diff --git a/pus_tc/tmtcc_tc_pdu2.py b/pus_tc/tmtcc_tc_pdu2.py index 2243bf4..1f84f9a 100644 --- a/pus_tc/tmtcc_tc_pdu2.py +++ b/pus_tc/tmtcc_tc_pdu2.py @@ -8,10 +8,15 @@ 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.tmtcc_object_id_manager import get_object_id +from tmtc_core.core.tmtc_core_definitions import QueueCommands +from config.tmtcc_object_ids import ObjectIds from gomspace.gomspace_common import * from gomspace.gomspace_pdu_definitions import * from pus_tc.tmtcc_tc_p60dock import P60DockConfigTable +P60DOCK_HANDLER_ID = get_object_id(ObjectIds.P60DOCK_HANDLER_ID) + class PDU2TestProcedure: """ @@ -26,8 +31,9 @@ class PDU2TestProcedure: ping = False channel_2_off = False # TCS Heater read_temperature = False + read_temperature1 = False read_channel_2_state = False # TCS Heater - read_cur_lu_lim_0 = False # OBC + read_cur_lu_lim_0 = False # OBC channel_2_on = False # TCS Heater invalid_table_id_test = False # Test to check if software properly handles invalid table ids invalid_address_test = False # Test to check if software properly handles invalid addresses @@ -35,62 +41,65 @@ class PDU2TestProcedure: def pack_pdu2_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing PDU2")) + tc_queue.appendleft((QueueCommands.PRINT, "Testing PDU2")) - tc_queue.appendleft(("print", "P60 Dock: Enabling PDU2")) - command = pack_set_param_command(g.P60DOCK_HANDLER_ID, P60DockConfigTable.out_en_3.parameter_address, + tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Enabling PDU2")) + command = pack_set_param_command(P60DOCK_HANDLER_ID, P60DockConfigTable.out_en_3.parameter_address, P60DockConfigTable.out_en_3.parameter_size, Channel.on) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if PDU2TestProcedure.all or PDU2TestProcedure.reboot: - tc_queue.appendleft(("print", "PDU2: Reboot")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: 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 PDU2TestProcedure.all or PDU2TestProcedure.read_gnd_wdt: - tc_queue.appendleft(("print", "PDU2: Reading ground watchdog timer value")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Reading ground watchdog timer value")) command = pack_get_param_command(object_id, TableIds.hk, PDUHkTable.wdt_gnd_left.parameter_address, PDUHkTable.wdt_gnd_left.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset: - tc_queue.appendleft(("print", "PDU2: Testing ground watchdog reset")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: 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 PDU2TestProcedure.all or PDU2TestProcedure.ping: - tc_queue.appendleft(("print", "PDU2: Ping Test")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: 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 PDU2TestProcedure.all or PDU2TestProcedure.channel_2_on: - tc_queue.appendleft(("print", "PDU2: Testing setting output channel 2 on (TCS Heater)")) + tc_queue.appendleft((QueueCommands.PRINT, + "PDU2: Testing setting output channel 2 on (TCS Heater)")) command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address, PDUConfigTable.out_en_2.parameter_size, Channel.on) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if PDU2TestProcedure.all or PDU2TestProcedure.read_temperature1: - tc_queue.appendleft(("print", "PDU2: Testing temperature reading")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Testing temperature reading")) command = pack_get_param_command(object_id, TableIds.hk, PDUHkTable.temperature.parameter_address, PDUHkTable.temperature.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state: - tc_queue.appendleft(("print", "PDU2: Reading output channel 2 state (TCS Heater)")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Reading output channel 2 state (TCS Heater)")) command = pack_get_param_command(object_id, TableIds.config, PDUConfigTable.out_en_2.parameter_address, PDUConfigTable.out_en_2.parameter_size) command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0: - tc_queue.appendleft(("print", "PDU2: Reading current limit value of output channel 0 (OBC)")) - command = pack_get_param_command(object_id, TableIds.config, PDUConfigTable.cur_lu_lim_0.parameter_address, + tc_queue.appendleft((QueueCommands.PRINT, + "PDU2: Reading current limit value of output channel 0 (OBC)")) + command = pack_get_param_command(object_id, TableIds.config, + PDUConfigTable.cur_lu_lim_0.parameter_address, PDUConfigTable.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 PDU2TestProcedure.all or PDU2TestProcedure.channel_2_off: - tc_queue.appendleft(("print", "PDU2: Testing setting output channel 2 off")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU2: Testing setting output channel 2 off")) command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address, PDUConfigTable.out_en_2.parameter_size, Channel.off) command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command) diff --git a/pus_tc/tmtcc_tc_service200_mode.py b/pus_tc/tmtcc_tc_service200_mode.py new file mode 100644 index 0000000..11d81fe --- /dev/null +++ b/pus_tc/tmtcc_tc_service200_mode.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +""" +@file tmtcc_tc_service200_mode.py +@brief PUS Service 200: PUS custom service 200: Mode commanding +@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 +from config.tmtcc_object_ids import ObjectIds +import struct + +TEST_DEVICE_ID = get_object_id(ObjectIds.TEST_DEVICE) + + +def pack_service200_test_into(tc_queue: TcQueueT) -> TcQueueT: + tc_queue.appendleft((QueueCommands.PRINT, "Testing Service 200")) + # Object ID: Dummy Device + object_id = TEST_DEVICE_ID + # Set On Mode + 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((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((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((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((QueueCommands.EXPORT_LOG, "log/tmtc_log_service200.txt")) + return tc_queue + + +# Mode 0: Off, Mode 1: Mode On, Mode 2: Mode Normal, Mode 3: Mode Raw +def pack_mode_data(object_id: bytearray, mode_: int, submode_: int) -> bytearray: + # Normal mode + mode = struct.pack(">I", mode_) + # Submode default + submode = struct.pack('B', submode_) + mode_data = object_id + mode + submode + return mode_data diff --git a/pus_tc/tmtcc_tc_tmp1075.py b/pus_tc/tmtcc_tc_tmp1075.py new file mode 100644 index 0000000..6ce4131 --- /dev/null +++ b/pus_tc/tmtcc_tc_tmp1075.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +""" +@file tmtcc_tc_tmp1075.py +@brief TMP1075 tests +@author J. Meier +@date 06.01.2021 +""" +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 pus_tc.tmtcc_tc_service200_mode import pack_mode_data + + +class Tmp1075TestProcedure: + """ + @brief Use this class to define the tests to perform for the Tmp1075. + @details Setting all to True will run all tests. + Setting all to False will only run the tests set to True. + """ + all = True + start_adc_conversion = False + get_temp = False + set_mode_normal = False # Setting mode to normal starts continuous temperature reading + set_mode_on = False # If mode is MODE_ON, temperature will only be read on command + + +class Tmp1075ActionIds: + get_temp = bytearray([0x0, 0x0, 0x0, 0x01]) + start_adc_conversion = bytearray([0x0, 0x0, 0x0, 0x02]) + + +def pack_tmp1075_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: + tc_queue.appendleft((QueueCommands.PRINT, "Testing Tmp1075 Temperature Sensor Handler")) + + if Tmp1075TestProcedure.all or Tmp1075TestProcedure.start_adc_conversion: + tc_queue.appendleft((QueueCommands.PRINT, "TMP1075: Starting new temperature conversion")) + command = object_id + Tmp1075ActionIds.start_adc_conversion + command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + + if Tmp1075TestProcedure.all or Tmp1075TestProcedure.get_temp: + tc_queue.appendleft((QueueCommands.PRINT, "TMP1075: Read temperature")) + command = object_id + Tmp1075ActionIds.get_temp + command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + + if Tmp1075TestProcedure.set_mode_normal: + tc_queue.appendleft((QueueCommands.PRINT, "TMP1075:: Set Mode Normal")) + mode_data = pack_mode_data(object_id, 2, 0) + command = PusTelecommand(service=200, subservice=1, ssc=220, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + + if Tmp1075TestProcedure.set_mode_on: + tc_queue.appendleft((QueueCommands.PRINT, "TMP1075: Set Mode On")) + mode_data = pack_mode_data(object_id, 1, 0) + command = PusTelecommand(service=200, subservice=1, ssc=221, app_data=mode_data) + tc_queue.appendleft(command.pack_command_tuple()) + + 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() diff --git a/tmtc_core b/tmtc_core index ed4b25a..4b41bf4 160000 --- a/tmtc_core +++ b/tmtc_core @@ -1 +1 @@ -Subproject commit ed4b25ab449cae31ac720f52ad43d13b9d7ce4c5 +Subproject commit 4b41bf458e9e724ad395afac537cad98adcba187