diff --git a/config/tmtcc_definitions.py b/config/tmtcc_definitions.py index 2f7c6f8..62a3b77 100644 --- a/config/tmtcc_definitions.py +++ b/config/tmtcc_definitions.py @@ -34,6 +34,7 @@ class ServiceList(enum.Enum): ACU = auto() TMP1075_1 = auto() TMP1075_2 = auto() + HEATER = auto() class SerialConfig(enum.Enum): diff --git a/config/tmtcc_globals.py b/config/tmtcc_globals.py index a09c423..28119d7 100644 --- a/config/tmtcc_globals.py +++ b/config/tmtcc_globals.py @@ -158,6 +158,8 @@ def add_globals_post_args_parsing(args: argparse.Namespace): service = ServiceList.TMP1075_1 elif service == "tmp1075_2": service = ServiceList.TMP1075_2 + elif service == "heater": + service = ServiceList.HEATER 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 2185b6a..9592852 100644 --- a/config/tmtcc_object_ids.py +++ b/config/tmtcc_object_ids.py @@ -18,6 +18,7 @@ class ObjectIds(enum.Enum): ACU_HANDLER_ID = auto() TMP1075_1_HANDLER_ID = auto() TMP1075_2_HANDLER_ID = auto() + HEATER = auto() def set_object_ids(object_id_dict: Dict[ObjectIds, bytearray]): @@ -31,5 +32,6 @@ def set_object_ids(object_id_dict: Dict[ObjectIds, bytearray]): 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]), + o_ids.HEATER: bytearray([0x54, 0x00, 0x00, 0x1]), } ) diff --git a/gomspace/gomspace_common.py b/gomspace/gomspace_common.py index 7115c46..9d0c9f4 100644 --- a/gomspace/gomspace_common.py +++ b/gomspace/gomspace_common.py @@ -14,6 +14,7 @@ class GomspaceDeviceActions: PARAM_GET = bytearray([0x0, 0x0, 0x0, 0x00]) PARAM_SET = bytearray([0x0, 0x0, 0x0, 0xFF]) WDT_RESET = bytearray([0x0, 0x0, 0x0, 0x9]) + REQUEST_HK_TABLE = bytearray([0x0, 0x0, 0x0, 0x10]) class TableIds: @@ -119,3 +120,14 @@ def pack_reboot_command(object_id: bytearray) -> bytearray: command = bytearray() command = object_id + action_id return command + + +def pack_request_full_hk_table_command(object_id: bytearray) -> bytearray: + """ Function to generate the command to request the full housekeeping table from a gomspace + device. + @param object_id The object id of the gomspace device handler. + """ + action_id = GomspaceDeviceActions.REQUEST_HK_TABLE + command = bytearray() + command = object_id + action_id + return command diff --git a/pus_tc/tmtcc_tc_heater.py b/pus_tc/tmtcc_tc_heater.py new file mode 100644 index 0000000..db181f8 --- /dev/null +++ b/pus_tc/tmtcc_tc_heater.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +""" +@file tmtcc_tc_heater.py +@brief Command sequence to test the HeaterHandler +@author J. Meier +@date 30.01.2021 +""" + +from tmtc_core.pus_tc.tmtcc_pus_tc_packer import TcQueueT +from tmtc_core.pus_tc.tmtcc_pus_tc_base import PusTelecommand + + +class TestProcedure: + """ + @brief The variables in this class can be used to configure the heater test procedure. + """ + on = True # All heaters will be turned on + off = False # All heaters will be turned off + + +class SwitchNumbers: + PAYLOAD_CAMERA_HEATER = 0 + + +class SwitchActions: + OFF = 0 + ON = 1 + + +class ActionIds: + SWITCH_HEATER = bytearray([0x0, 0x0, 0x0, 0x0]) + + +def pack_heater_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: + tc_queue.appendleft(("print", "Testing Heater Switching")) + + if TestProcedure.on: + tc_queue.appendleft(("print", "Switching on heater of payload camera")) + command = pack_switch_heater_command(object_id, SwitchNumbers.PAYLOAD_CAMERA_HEATER, SwitchActions.ON) + command = PusTelecommand(service=8, subservice=128, ssc=300, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if TestProcedure.off: + tc_queue.appendleft(("print", "Switching off heater of payload camera")) + command = pack_switch_heater_command(object_id, SwitchNumbers.PAYLOAD_CAMERA_HEATER, SwitchActions.OFF) + command = PusTelecommand(service=8, subservice=128, ssc=301, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + + +def pack_switch_heater_command(object_id: bytearray, switch_nr: int, switch_action: int) -> bytearray: + """ Function to generate the command switch a heater + @param object_id The object id of the HeaterHandler object. + @param switch_nr The switch number identifying the heater to switch + @param switch_action Action to perform. 0 - Sets switch off, 1 - Sets switch on. + """ + action_id = ActionIds.SWITCH_HEATER + command = object_id + action_id + command.append(switch_nr) + command.append(switch_action) + return command diff --git a/pus_tc/tmtcc_tc_packer_hook.py b/pus_tc/tmtcc_tc_packer_hook.py index 06c6318..001e7fa 100644 --- a/pus_tc/tmtcc_tc_packer_hook.py +++ b/pus_tc/tmtcc_tc_packer_hook.py @@ -20,6 +20,7 @@ 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 +from pus_tc.tmtcc_tc_heater import pack_heater_test_into LOGGER = get_logger() @@ -33,11 +34,13 @@ def pack_service_queue_user(service: Union[int, str], op_code: int, service_queu object_id = get_object_id(ObjectIds.P60DOCK_HANDLER_ID) return pack_p60dock_test_into(object_id, service_queue) if service == ServiceList.PDU1: - object_id = get_object_id(ObjectIds.PDU1_HANDLER_ID) - return pack_pdu1_test_into(object_id, service_queue) + pdu1_object_id = get_object_id(ObjectIds.PDU1_HANDLER_ID) + p60dock_object_id = get_object_id(ObjectIds.P60DOCK_HANDLER_ID) + return pack_pdu1_test_into(pdu1_object_id, p60dock_object_id, service_queue) if service == ServiceList.PDU2: - object_id = get_object_id(ObjectIds.PDU2_HANDLER_ID) - return pack_pdu2_test_into(object_id, service_queue) + pdu2_object_id = get_object_id(ObjectIds.PDU2_HANDLER_ID) + p60dock_object_id = get_object_id(ObjectIds.P60DOCK_HANDLER_ID) + return pack_pdu2_test_into(pdu2_object_id, p60dock_object_id, service_queue) if service == ServiceList.ACU: object_id = get_object_id(ObjectIds.ACU_HANDLER_ID) return pack_acu_test_into(object_id, service_queue) @@ -47,6 +50,9 @@ def pack_service_queue_user(service: Union[int, str], op_code: int, service_queu if service == ServiceList.TMP1075_2: object_id = get_object_id(ObjectIds.TMP1075_2_HANDLER_ID) return pack_tmp1075_test_into(object_id, service_queue) + if service == ServiceList.HEATER: + object_id = get_object_id(ObjectIds.HEATER) + return pack_heater_test_into(object_id, service_queue) LOGGER.warning("Invalid Service !") diff --git a/pus_tc/tmtcc_tc_pdu1.py b/pus_tc/tmtcc_tc_pdu1.py index 47ee8d7..f546d3a 100644 --- a/pus_tc/tmtcc_tc_pdu1.py +++ b/pus_tc/tmtcc_tc_pdu1.py @@ -25,11 +25,11 @@ class PDU1TestProcedure: read_temperature = False -def pack_pdu1_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: +def pack_pdu1_test_into(pdu1_object_id: bytearray, p60dock_object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: tc_queue.appendleft(("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, + command = pack_set_param_command(p60dock_object_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()) @@ -37,12 +37,12 @@ def pack_pdu1_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: if PDU1TestProcedure.all or PDU1TestProcedure.ping: tc_queue.appendleft(("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 = pack_ping_command(pdu1_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")) - command = pack_get_param_command(object_id, TableIds.hk, PDUHkTable.temperature.parameter_address, + command = pack_get_param_command(pdu1_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()) diff --git a/pus_tc/tmtcc_tc_pdu2.py b/pus_tc/tmtcc_tc_pdu2.py index 2243bf4..8ea6d98 100644 --- a/pus_tc/tmtcc_tc_pdu2.py +++ b/pus_tc/tmtcc_tc_pdu2.py @@ -19,7 +19,7 @@ class PDU2TestProcedure: @details Setting all to True will run all tests. Setting all to False will only run the tests set to True. """ - all = True + all = False reboot = False read_gnd_wdt = False gnd_wdt_reset = False @@ -31,68 +31,74 @@ class PDU2TestProcedure: 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 - invalid_parameter_size_test = True + invalid_parameter_size_test = False + request_hk_table = True -def pack_pdu2_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: +def pack_pdu2_test_into(pdu2_object_id: bytearray, p60dock_object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: tc_queue.appendleft(("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, + command = pack_set_param_command(p60dock_object_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")) - command = pack_reboot_command(object_id) + command = pack_reboot_command(pdu2_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")) - command = pack_get_param_command(object_id, TableIds.hk, PDUHkTable.wdt_gnd_left.parameter_address, + command = pack_get_param_command(pdu2_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")) - command = pack_gnd_wdt_reset_command(object_id) + command = pack_gnd_wdt_reset_command(pdu2_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")) ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - command = pack_ping_command(object_id, ping_data) + command = pack_ping_command(pdu2_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)")) - command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address, + command = pack_set_param_command(pdu2_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: + if PDU2TestProcedure.all or PDU2TestProcedure.read_temperature: tc_queue.appendleft(("print", "PDU2: Testing temperature reading")) - command = pack_get_param_command(object_id, TableIds.hk, PDUHkTable.temperature.parameter_address, + command = pack_get_param_command(pdu2_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)")) - command = pack_get_param_command(object_id, TableIds.config, PDUConfigTable.out_en_2.parameter_address, + command = pack_get_param_command(pdu2_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, + command = pack_get_param_command(pdu2_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")) - command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address, + command = pack_set_param_command(pdu2_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) tc_queue.appendleft(command.pack_command_tuple()) + if PDU2TestProcedure.all or PDU2TestProcedure.request_hk_table: + tc_queue.appendleft(("print", "PDU2: Requesting housekeeping table")) + command = pack_request_full_hk_table_command(pdu2_object_id) + command = PusTelecommand(service=8, subservice=128, ssc=28, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) return tc_queue diff --git a/tmtc_core b/tmtc_core index bdb8d55..bd46c5a 160000 --- a/tmtc_core +++ b/tmtc_core @@ -1 +1 @@ -Subproject commit bdb8d5533a40c8396dedafc1844fe3645bcf8de3 +Subproject commit bd46c5a85262140ab097b2704926745e1a0687d1