heater wip

This commit is contained in:
Jakob Meier 2021-02-06 16:35:53 +01:00
parent 39e8ff7134
commit 8a071954af
9 changed files with 111 additions and 23 deletions

View File

@ -34,6 +34,7 @@ class ServiceList(enum.Enum):
ACU = auto() ACU = auto()
TMP1075_1 = auto() TMP1075_1 = auto()
TMP1075_2 = auto() TMP1075_2 = auto()
HEATER = auto()
class SerialConfig(enum.Enum): class SerialConfig(enum.Enum):

View File

@ -158,6 +158,8 @@ def add_globals_post_args_parsing(args: argparse.Namespace):
service = ServiceList.TMP1075_1 service = ServiceList.TMP1075_1
elif service == "tmp1075_2": elif service == "tmp1075_2":
service = ServiceList.TMP1075_2 service = ServiceList.TMP1075_2
elif service == "heater":
service = ServiceList.HEATER
else: else:
logger.warning("Service not known! Setting standard service 17") logger.warning("Service not known! Setting standard service 17")
service = ServiceList.SERVICE_17 service = ServiceList.SERVICE_17

View File

@ -18,6 +18,7 @@ class ObjectIds(enum.Enum):
ACU_HANDLER_ID = auto() ACU_HANDLER_ID = auto()
TMP1075_1_HANDLER_ID = auto() TMP1075_1_HANDLER_ID = auto()
TMP1075_2_HANDLER_ID = auto() TMP1075_2_HANDLER_ID = auto()
HEATER = auto()
def set_object_ids(object_id_dict: Dict[ObjectIds, bytearray]): 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.ACU_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x4]),
o_ids.TMP1075_1_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x5]), o_ids.TMP1075_1_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x5]),
o_ids.TMP1075_2_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x6]), o_ids.TMP1075_2_HANDLER_ID: bytearray([0x44, 0x00, 0x00, 0x6]),
o_ids.HEATER: bytearray([0x54, 0x00, 0x00, 0x1]),
} }
) )

View File

@ -14,6 +14,7 @@ class GomspaceDeviceActions:
PARAM_GET = bytearray([0x0, 0x0, 0x0, 0x00]) PARAM_GET = bytearray([0x0, 0x0, 0x0, 0x00])
PARAM_SET = bytearray([0x0, 0x0, 0x0, 0xFF]) PARAM_SET = bytearray([0x0, 0x0, 0x0, 0xFF])
WDT_RESET = bytearray([0x0, 0x0, 0x0, 0x9]) WDT_RESET = bytearray([0x0, 0x0, 0x0, 0x9])
REQUEST_HK_TABLE = bytearray([0x0, 0x0, 0x0, 0x10])
class TableIds: class TableIds:
@ -119,3 +120,14 @@ def pack_reboot_command(object_id: bytearray) -> bytearray:
command = bytearray() command = bytearray()
command = object_id + action_id command = object_id + action_id
return command 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

59
pus_tc/tmtcc_tc_heater.py Normal file
View File

@ -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

View File

@ -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 tmtc_core.core.tmtcc_object_id_manager import get_object_id
from config.tmtcc_object_ids import ObjectIds from config.tmtcc_object_ids import ObjectIds
from pus_tc.tmtcc_tc_tmp1075 import pack_tmp1075_test_into 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() 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) object_id = get_object_id(ObjectIds.P60DOCK_HANDLER_ID)
return pack_p60dock_test_into(object_id, service_queue) return pack_p60dock_test_into(object_id, service_queue)
if service == ServiceList.PDU1: if service == ServiceList.PDU1:
object_id = get_object_id(ObjectIds.PDU1_HANDLER_ID) pdu1_object_id = get_object_id(ObjectIds.PDU1_HANDLER_ID)
return pack_pdu1_test_into(object_id, service_queue) 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: if service == ServiceList.PDU2:
object_id = get_object_id(ObjectIds.PDU2_HANDLER_ID) pdu2_object_id = get_object_id(ObjectIds.PDU2_HANDLER_ID)
return pack_pdu2_test_into(object_id, service_queue) 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: if service == ServiceList.ACU:
object_id = get_object_id(ObjectIds.ACU_HANDLER_ID) object_id = get_object_id(ObjectIds.ACU_HANDLER_ID)
return pack_acu_test_into(object_id, service_queue) 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: if service == ServiceList.TMP1075_2:
object_id = get_object_id(ObjectIds.TMP1075_2_HANDLER_ID) object_id = get_object_id(ObjectIds.TMP1075_2_HANDLER_ID)
return pack_tmp1075_test_into(object_id, service_queue) 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 !") LOGGER.warning("Invalid Service !")

View File

@ -25,11 +25,11 @@ class PDU1TestProcedure:
read_temperature = False 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", "Testing PDU1"))
tc_queue.appendleft(("print", "P60 Dock: Enabling 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) P60DockConfigTable.out_en_1.parameter_size, Channel.on)
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) 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: if PDU1TestProcedure.all or PDU1TestProcedure.ping:
tc_queue.appendleft(("print", "PDU1: Ping Test")) tc_queue.appendleft(("print", "PDU1: Ping Test"))
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) 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) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU1TestProcedure.all or PDU1TestProcedure.read_temperature: if PDU1TestProcedure.all or PDU1TestProcedure.read_temperature:
tc_queue.appendleft(("print", "PDU1: Testing temperature reading")) 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) PDUHkTable.temperature.parameter_size)
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())

View File

@ -19,7 +19,7 @@ class PDU2TestProcedure:
@details Setting all to True will run all tests. @details Setting all to True will run all tests.
Setting all to False will only run the tests set to True. Setting all to False will only run the tests set to True.
""" """
all = True all = False
reboot = False reboot = False
read_gnd_wdt = False read_gnd_wdt = False
gnd_wdt_reset = False gnd_wdt_reset = False
@ -31,68 +31,74 @@ class PDU2TestProcedure:
channel_2_on = False # TCS Heater channel_2_on = False # TCS Heater
invalid_table_id_test = False # Test to check if software properly handles invalid table ids 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_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", "Testing PDU2"))
tc_queue.appendleft(("print", "P60 Dock: Enabling 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) P60DockConfigTable.out_en_3.parameter_size, Channel.on)
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.reboot: if PDU2TestProcedure.all or PDU2TestProcedure.reboot:
tc_queue.appendleft(("print", "PDU2: 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) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.read_gnd_wdt: if PDU2TestProcedure.all or PDU2TestProcedure.read_gnd_wdt:
tc_queue.appendleft(("print", "PDU2: Reading ground watchdog timer value")) 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) PDUHkTable.wdt_gnd_left.parameter_size)
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset: if PDU2TestProcedure.all or PDU2TestProcedure.gnd_wdt_reset:
tc_queue.appendleft(("print", "PDU2: Testing ground watchdog 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) command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.ping: if PDU2TestProcedure.all or PDU2TestProcedure.ping:
tc_queue.appendleft(("print", "PDU2: Ping Test")) tc_queue.appendleft(("print", "PDU2: Ping Test"))
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) 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) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_on: if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_on:
tc_queue.appendleft(("print", "PDU2: Testing setting output channel 2 on (TCS Heater)")) 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) PDUConfigTable.out_en_2.parameter_size, Channel.on)
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) 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")) 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) PDUHkTable.temperature.parameter_size)
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state: if PDU2TestProcedure.all or PDU2TestProcedure.read_channel_2_state:
tc_queue.appendleft(("print", "PDU2: Reading output channel 2 state (TCS Heater)")) 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) PDUConfigTable.out_en_2.parameter_size)
command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0: if PDU2TestProcedure.all or PDU2TestProcedure.read_cur_lu_lim_0:
tc_queue.appendleft(("print", "PDU2: Reading current limit value of output channel 0 (OBC)")) 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) PDUConfigTable.cur_lu_lim_0.parameter_size)
command = PusTelecommand(service=8, subservice=128, ssc=26, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=26, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_off: if PDU2TestProcedure.all or PDU2TestProcedure.channel_2_off:
tc_queue.appendleft(("print", "PDU2: Testing setting output 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) PDUConfigTable.out_en_2.parameter_size, Channel.off)
command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) 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 return tc_queue

@ -1 +1 @@
Subproject commit bdb8d5533a40c8396dedafc1844fe3645bcf8de3 Subproject commit bd46c5a85262140ab097b2704926745e1a0687d1