From fc5e3c88fffa2f87a3d948d9e5110e62850b59bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 6 Feb 2023 14:44:37 +0100 Subject: [PATCH] update for tmp1075 code --- CHANGELOG.md | 1 + eive_tmtc/config/definitions.py | 2 - eive_tmtc/pus_tc/cmd_definitions.py | 8 ---- eive_tmtc/tmtc/tcs/tmp1075.py | 68 +++++++++++++++++------------ 4 files changed, 42 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c783a96..7d9dc38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ list yields a list of all related PRs for each release. ## Fixed - TMP1075 comands: Implement proper prompt for device select. +- TMP1075 commands: Add OFF, ON, NORMAL, and HK command # [v2.10.0] 2023-02-03 diff --git a/eive_tmtc/config/definitions.py b/eive_tmtc/config/definitions.py index 6cb9764..6b2fc6c 100644 --- a/eive_tmtc/config/definitions.py +++ b/eive_tmtc/config/definitions.py @@ -38,8 +38,6 @@ class CustomServiceList(str, enum.Enum): ACS = "acs" COM_SS = "com" BPX_BATTERY = "bpx" - TMP1075_1 = "tmp1075_1" - TMP1075_2 = "tmp1075_2" HEATER = "heater" IMTQ = "imtq" PLOC_SUPV = "ploc_supv" diff --git a/eive_tmtc/pus_tc/cmd_definitions.py b/eive_tmtc/pus_tc/cmd_definitions.py index a42d18a..aa98a9e 100644 --- a/eive_tmtc/pus_tc/cmd_definitions.py +++ b/eive_tmtc/pus_tc/cmd_definitions.py @@ -23,14 +23,6 @@ def get_eive_service_op_code_dict() -> TmtcDefinitionWrapper: return def_wrapper -@tmtc_definitions_provider -def add_tmp_sens_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add("0", "TMP1075 Tests") - defs.add_service(CustomServiceList.TMP1075_1.value, "TMP1075 1", oce) - defs.add_service(CustomServiceList.TMP1075_2.value, "TMP1075 2", oce) - - @tmtc_definitions_provider def add_pdec_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/tcs/tmp1075.py b/eive_tmtc/tmtc/tcs/tmp1075.py index f73629a..57170d5 100644 --- a/eive_tmtc/tmtc/tcs/tmp1075.py +++ b/eive_tmtc/tmtc/tcs/tmp1075.py @@ -7,27 +7,31 @@ """ import enum +from eive_tmtc.config.definitions import CustomServiceList from spacepackets.ecss.tc import PusTelecommand +from tmtccmd.config.tmtc import ( + tmtc_definitions_provider, + TmtcDefinitionWrapper, + OpCodeEntry, +) from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data -from tmtccmd.pus.s8_fsfw_funccmd import make_action_id +from tmtccmd.tc.pus_3_fsfw_hk import create_request_one_hk_command, make_sid from tmtccmd.util import ObjectIdU32 -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. - """ +class OpCode: + OFF = "off" + ON = "on" + NML = "nml" + HK = "hk" - all = False - start_adc_conversion = False - get_temp = False - 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 + +class Info: + OFF = "Off" + ON = "On" + NML = "Normal" + HK = "HK" class Tmp1075ActionId(enum.IntEnum): @@ -35,6 +39,10 @@ class Tmp1075ActionId(enum.IntEnum): START_ADC_CONV = 2 +class SetId: + TMEPERATURE = 1 + + def pack_tmp1075_test_into( object_id: ObjectIdU32, op_code: str, q: DefaultPusQueueHelper ): @@ -42,23 +50,29 @@ def pack_tmp1075_test_into( f"Testing Tmp1075 Temperature Sensor Handler with object id: {object_id.as_hex_string}" ) obyt = object_id.as_bytes - if Tmp1075TestProcedure.all or Tmp1075TestProcedure.start_adc_conversion: - q.add_log_cmd("TMP1075: Starting new temperature conversion") - command = obyt + make_action_id(Tmp1075ActionId.GET_TEMP) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if Tmp1075TestProcedure.all or Tmp1075TestProcedure.get_temp: - q.add_log_cmd("TMP1075: Read temperature") - command = obyt + make_action_id(Tmp1075ActionId.START_ADC_CONV) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - - if Tmp1075TestProcedure.set_mode_normal: + if op_code == OpCode.OFF: + q.add_log_cmd("TMP1075: Set Normal Off") + mode_data = pack_mode_data(obyt, Mode.OFF, 0) + q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) + if op_code == OpCode.NML: q.add_log_cmd("TMP1075: Set Mode Normal") mode_data = pack_mode_data(obyt, Mode.NORMAL, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) - - if Tmp1075TestProcedure.set_mode_on: + if op_code == OpCode.ON: q.add_log_cmd("TMP1075: Set Mode On") mode_data = pack_mode_data(obyt, Mode.ON, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) - + if op_code == OpCode.HK: + q.add_log_cmd("TMP1075: Request One-Shot HK") + q.add_pus_tc(create_request_one_hk_command(make_sid(obyt, SetId.TMEPERATURE))) return q + + +@tmtc_definitions_provider +def add_tmp_sens_cmds(defs: TmtcDefinitionWrapper): + oce = OpCodeEntry() + oce.add(OpCode.OFF, Info.OFF) + oce.add(OpCode.ON, Info.ON) + oce.add(OpCode.NML, Info.NML) + oce.add(OpCode.HK, Info.HK) + defs.add_service(CustomServiceList.TMP1075.value, "TMP1075 Temperature Sensor", oce)