2021-01-10 11:42:06 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
2021-04-11 11:08:52 +02:00
|
|
|
@file tmp1075.py
|
2021-01-10 11:42:06 +01:00
|
|
|
@brief TMP1075 tests
|
|
|
|
@author J. Meier
|
|
|
|
@date 06.01.2021
|
|
|
|
"""
|
2023-01-16 17:11:20 +01:00
|
|
|
import enum
|
|
|
|
|
2021-10-01 10:55:56 +02:00
|
|
|
from spacepackets.ecss.tc import PusTelecommand
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.pus_tc.service_200_mode import pack_mode_data
|
2022-08-08 16:32:18 +02:00
|
|
|
from tmtccmd.tc import DefaultPusQueueHelper
|
2023-01-16 15:05:33 +01:00
|
|
|
from tmtccmd.tc.pus_200_fsfw_modes import Mode
|
2023-01-16 17:11:20 +01:00
|
|
|
from tmtccmd.tc.pus_8_funccmd import make_action_id
|
2022-07-08 16:25:46 +02:00
|
|
|
from tmtccmd.util import ObjectIdU32
|
2021-01-10 11:42:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
2022-01-18 14:03:56 +01:00
|
|
|
|
2021-01-30 11:20:34 +01:00
|
|
|
all = False
|
2021-01-10 11:42:06 +01:00
|
|
|
start_adc_conversion = False
|
|
|
|
get_temp = False
|
2022-01-18 14:03:56 +01:00
|
|
|
set_mode_normal = (
|
|
|
|
True # Setting mode to normal starts continuous temperature reading
|
|
|
|
)
|
2021-01-10 11:42:06 +01:00
|
|
|
set_mode_on = False # If mode is MODE_ON, temperature will only be read on command
|
|
|
|
|
|
|
|
|
2023-01-16 17:11:20 +01:00
|
|
|
class Tmp1075ActionId(enum.IntEnum):
|
|
|
|
GET_TEMP = 1
|
|
|
|
START_ADC_CONV = 2
|
2021-01-10 11:42:06 +01:00
|
|
|
|
|
|
|
|
2022-08-08 16:32:18 +02:00
|
|
|
def pack_tmp1075_test_into(
|
|
|
|
object_id: ObjectIdU32, op_code: str, q: DefaultPusQueueHelper
|
|
|
|
):
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd(
|
|
|
|
f"Testing Tmp1075 Temperature Sensor Handler with object id: {object_id.as_hex_string}"
|
2021-03-19 17:50:09 +01:00
|
|
|
)
|
2022-07-04 15:22:53 +02:00
|
|
|
obyt = object_id.as_bytes
|
2021-01-10 11:42:06 +01:00
|
|
|
if Tmp1075TestProcedure.all or Tmp1075TestProcedure.start_adc_conversion:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("TMP1075: Starting new temperature conversion")
|
2023-01-16 17:11:20 +01:00
|
|
|
command = obyt + make_action_id(Tmp1075ActionId.GET_TEMP)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2021-01-10 11:42:06 +01:00
|
|
|
if Tmp1075TestProcedure.all or Tmp1075TestProcedure.get_temp:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("TMP1075: Read temperature")
|
2023-01-16 17:11:20 +01:00
|
|
|
command = obyt + make_action_id(Tmp1075ActionId.START_ADC_CONV)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2021-01-10 11:42:06 +01:00
|
|
|
|
|
|
|
if Tmp1075TestProcedure.set_mode_normal:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("TMP1075: Set Mode Normal")
|
2023-01-16 15:05:33 +01:00
|
|
|
mode_data = pack_mode_data(obyt, Mode.NORMAL, 0)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
|
2021-01-10 11:42:06 +01:00
|
|
|
|
|
|
|
if Tmp1075TestProcedure.set_mode_on:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("TMP1075: Set Mode On")
|
2023-01-16 15:05:33 +01:00
|
|
|
mode_data = pack_mode_data(obyt, Mode.ON, 0)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
|
2021-01-10 11:42:06 +01:00
|
|
|
|
2022-07-04 15:22:53 +02:00
|
|
|
return q
|