update for tmp1075 code

This commit is contained in:
Robin Müller 2023-02-06 14:44:37 +01:00
parent b474841d69
commit fc5e3c88ff
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 42 additions and 37 deletions

View File

@ -13,6 +13,7 @@ list yields a list of all related PRs for each release.
## Fixed ## Fixed
- TMP1075 comands: Implement proper prompt for device select. - TMP1075 comands: Implement proper prompt for device select.
- TMP1075 commands: Add OFF, ON, NORMAL, and HK command
# [v2.10.0] 2023-02-03 # [v2.10.0] 2023-02-03

View File

@ -38,8 +38,6 @@ class CustomServiceList(str, enum.Enum):
ACS = "acs" ACS = "acs"
COM_SS = "com" COM_SS = "com"
BPX_BATTERY = "bpx" BPX_BATTERY = "bpx"
TMP1075_1 = "tmp1075_1"
TMP1075_2 = "tmp1075_2"
HEATER = "heater" HEATER = "heater"
IMTQ = "imtq" IMTQ = "imtq"
PLOC_SUPV = "ploc_supv" PLOC_SUPV = "ploc_supv"

View File

@ -23,14 +23,6 @@ def get_eive_service_op_code_dict() -> TmtcDefinitionWrapper:
return def_wrapper 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 @tmtc_definitions_provider
def add_pdec_cmds(defs: TmtcDefinitionWrapper): def add_pdec_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry() oce = OpCodeEntry()

View File

@ -7,27 +7,31 @@
""" """
import enum import enum
from eive_tmtc.config.definitions import CustomServiceList
from spacepackets.ecss.tc import PusTelecommand from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.config.tmtc import (
tmtc_definitions_provider,
TmtcDefinitionWrapper,
OpCodeEntry,
)
from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import Mode, pack_mode_data 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 from tmtccmd.util import ObjectIdU32
class Tmp1075TestProcedure: class OpCode:
""" OFF = "off"
@brief Use this class to define the tests to perform for the Tmp1075. ON = "on"
@details Setting all to True will run all tests. NML = "nml"
Setting all to False will only run the tests set to True. HK = "hk"
"""
all = False
start_adc_conversion = False class Info:
get_temp = False OFF = "Off"
set_mode_normal = ( ON = "On"
True # Setting mode to normal starts continuous temperature reading NML = "Normal"
) HK = "HK"
set_mode_on = False # If mode is MODE_ON, temperature will only be read on command
class Tmp1075ActionId(enum.IntEnum): class Tmp1075ActionId(enum.IntEnum):
@ -35,6 +39,10 @@ class Tmp1075ActionId(enum.IntEnum):
START_ADC_CONV = 2 START_ADC_CONV = 2
class SetId:
TMEPERATURE = 1
def pack_tmp1075_test_into( def pack_tmp1075_test_into(
object_id: ObjectIdU32, op_code: str, q: DefaultPusQueueHelper 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}" f"Testing Tmp1075 Temperature Sensor Handler with object id: {object_id.as_hex_string}"
) )
obyt = object_id.as_bytes obyt = object_id.as_bytes
if Tmp1075TestProcedure.all or Tmp1075TestProcedure.start_adc_conversion: if op_code == OpCode.OFF:
q.add_log_cmd("TMP1075: Starting new temperature conversion") q.add_log_cmd("TMP1075: Set Normal Off")
command = obyt + make_action_id(Tmp1075ActionId.GET_TEMP) mode_data = pack_mode_data(obyt, Mode.OFF, 0)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
if Tmp1075TestProcedure.all or Tmp1075TestProcedure.get_temp: if op_code == OpCode.NML:
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:
q.add_log_cmd("TMP1075: Set Mode Normal") q.add_log_cmd("TMP1075: Set Mode Normal")
mode_data = pack_mode_data(obyt, Mode.NORMAL, 0) mode_data = pack_mode_data(obyt, Mode.NORMAL, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
if op_code == OpCode.ON:
if Tmp1075TestProcedure.set_mode_on:
q.add_log_cmd("TMP1075: Set Mode On") q.add_log_cmd("TMP1075: Set Mode On")
mode_data = pack_mode_data(obyt, Mode.ON, 0) mode_data = pack_mode_data(obyt, Mode.ON, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) 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 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)