From 39e8ff713431ed1a6484f6980b518aecd0d8288b Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Sat, 30 Jan 2021 11:20:34 +0100 Subject: [PATCH 1/6] tmp1075 temperature sensor --- config/tmtcc_definitions.py | 3 ++- config/tmtcc_globals.py | 6 ++++-- pus_tc/tmtcc_tc_packer_hook.py | 5 ++++- pus_tc/tmtcc_tc_tmp1075.py | 9 +++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/config/tmtcc_definitions.py b/config/tmtcc_definitions.py index 6ce43ca..2f7c6f8 100644 --- a/config/tmtcc_definitions.py +++ b/config/tmtcc_definitions.py @@ -32,7 +32,8 @@ class ServiceList(enum.Enum): PDU1 = auto() PDU2 = auto() ACU = auto() - TMP1075 = auto() + TMP1075_1 = auto() + TMP1075_2 = auto() class SerialConfig(enum.Enum): diff --git a/config/tmtcc_globals.py b/config/tmtcc_globals.py index ae272ed..a09c423 100644 --- a/config/tmtcc_globals.py +++ b/config/tmtcc_globals.py @@ -154,8 +154,10 @@ def add_globals_post_args_parsing(args: argparse.Namespace): service = ServiceList.PDU2 elif service == "acu": service = ServiceList.ACU - elif service == "tmp1075": - service = ServiceList.TMP1075 + elif service == "tmp1075_1": + service = ServiceList.TMP1075_1 + elif service == "tmp1075_2": + service = ServiceList.TMP1075_2 else: logger.warning("Service not known! Setting standard service 17") service = ServiceList.SERVICE_17 diff --git a/pus_tc/tmtcc_tc_packer_hook.py b/pus_tc/tmtcc_tc_packer_hook.py index 2fced67..06c6318 100644 --- a/pus_tc/tmtcc_tc_packer_hook.py +++ b/pus_tc/tmtcc_tc_packer_hook.py @@ -41,9 +41,12 @@ 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: + if service == ServiceList.TMP1075_1: object_id = get_object_id(ObjectIds.TMP1075_1_HANDLER_ID) return pack_tmp1075_test_into(object_id, service_queue) + if service == ServiceList.TMP1075_2: + object_id = get_object_id(ObjectIds.TMP1075_2_HANDLER_ID) + return pack_tmp1075_test_into(object_id, service_queue) LOGGER.warning("Invalid Service !") diff --git a/pus_tc/tmtcc_tc_tmp1075.py b/pus_tc/tmtcc_tc_tmp1075.py index 53d1c1b..ef20410 100644 --- a/pus_tc/tmtcc_tc_tmp1075.py +++ b/pus_tc/tmtcc_tc_tmp1075.py @@ -17,10 +17,10 @@ class Tmp1075TestProcedure: @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 start_adc_conversion = False get_temp = False - set_mode_normal = False # Setting mode to normal starts continuous temperature reading + set_mode_normal = True # Setting mode to normal starts continuous temperature reading set_mode_on = False # If mode is MODE_ON, temperature will only be read on command @@ -30,7 +30,8 @@ class Tmp1075ActionIds: def pack_tmp1075_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT: - tc_queue.appendleft(("print", "Testing Tmp1075 Temperature Sensor Handler")) + tc_queue.appendleft(("print", "Testing Tmp1075 Temperature Sensor Handler with object id: 0x" + + object_id.hex())) if Tmp1075TestProcedure.all or Tmp1075TestProcedure.start_adc_conversion: tc_queue.appendleft(("print", "TMP1075: Starting new temperature conversion")) @@ -45,7 +46,7 @@ def pack_tmp1075_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT tc_queue.appendleft(command.pack_command_tuple()) if Tmp1075TestProcedure.set_mode_normal: - tc_queue.appendleft(("print", "TMP1075:: Set Mode Normal")) + tc_queue.appendleft(("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()) From 8a071954af87487be78899c3bb5378626cfde72c Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Sat, 6 Feb 2021 16:35:53 +0100 Subject: [PATCH 2/6] heater wip --- config/tmtcc_definitions.py | 1 + config/tmtcc_globals.py | 2 ++ config/tmtcc_object_ids.py | 2 ++ gomspace/gomspace_common.py | 12 +++++++ pus_tc/tmtcc_tc_heater.py | 59 ++++++++++++++++++++++++++++++++++ pus_tc/tmtcc_tc_packer_hook.py | 14 +++++--- pus_tc/tmtcc_tc_pdu1.py | 8 ++--- pus_tc/tmtcc_tc_pdu2.py | 34 ++++++++++++-------- tmtc_core | 2 +- 9 files changed, 111 insertions(+), 23 deletions(-) create mode 100644 pus_tc/tmtcc_tc_heater.py 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 From cf5ca54fbe9a3d42b1bdcbdcb9322061db76cc5a Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Tue, 9 Feb 2021 12:35:10 +0100 Subject: [PATCH 3/6] service 8 reply interpretation --- .../tmtcclient_PDU2_Test_UDP.xml | 2 +- config/tmtcc_object_ids.py | 2 ++ pus_tc/tmtcc_tc_p60dock.py | 6 ++-- pus_tc/tmtcc_tc_pdu1.py | 2 +- pus_tc/tmtcc_tc_pdu2.py | 26 ++++++++-------- pus_tm/tmtcc_pus_service_8_hook.py | 31 +++++++++++++++++++ pus_tm/tmtcc_pus_tm_factory_hook.py | 6 +++- 7 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 pus_tm/tmtcc_pus_service_8_hook.py diff --git a/.idea/runConfigurations/tmtcclient_PDU2_Test_UDP.xml b/.idea/runConfigurations/tmtcclient_PDU2_Test_UDP.xml index a69a933..0c202a0 100644 --- a/.idea/runConfigurations/tmtcclient_PDU2_Test_UDP.xml +++ b/.idea/runConfigurations/tmtcclient_PDU2_Test_UDP.xml @@ -13,7 +13,7 @@