eive-tmtc/pus_tc/devs/tmp1075.py
2022-07-08 16:25:46 +02:00

61 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
"""
@file tmp1075.py
@brief TMP1075 tests
@author J. Meier
@date 06.01.2021
"""
from spacepackets.ecss.tc import PusTelecommand
from pus_tc.service_200_mode import pack_mode_data
from tmtccmd.tc import QueueHelper
from tmtccmd.tc.pus_200_fsfw_modes import Modes
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.
"""
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 Tmp1075ActionIds:
get_temp = bytearray([0x0, 0x0, 0x0, 0x01])
start_adc_conversion = bytearray([0x0, 0x0, 0x0, 0x02])
def pack_tmp1075_test_into(object_id: ObjectIdU32, op_code: str, q: QueueHelper):
q.add_log_cmd(
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 + Tmp1075ActionIds.start_adc_conversion
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 + Tmp1075ActionIds.get_temp
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")
mode_data = pack_mode_data(obyt, Modes.NORMAL, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
if Tmp1075TestProcedure.set_mode_on:
q.add_log_cmd("TMP1075: Set Mode On")
mode_data = pack_mode_data(obyt, Modes.ON, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
return q