2020-12-29 11:29:03 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
@file tmtcc_tc_acu.py
|
|
|
|
@brief ACU tests
|
|
|
|
@author J. Meier
|
|
|
|
@date 21.12.2020
|
|
|
|
"""
|
|
|
|
|
2021-03-19 17:39:52 +01:00
|
|
|
from tmtccmd.pus_tc.packer import TcQueueT
|
2021-04-10 22:59:51 +02:00
|
|
|
from tmtccmd.ecss.tc import PusTelecommand
|
2021-05-17 17:42:04 +02:00
|
|
|
from tmtccmd.config.definitions import QueueCommands
|
2020-12-29 11:29:03 +01:00
|
|
|
from gomspace.gomspace_common import *
|
2021-03-19 17:39:52 +01:00
|
|
|
from pus_tc.p60dock import P60DockConfigTable
|
2021-05-17 17:42:04 +02:00
|
|
|
|
|
|
|
from config.object_ids import P60_DOCK_HANDLER
|
2020-12-29 11:29:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ACUTestProcedure:
|
|
|
|
"""
|
|
|
|
@brief Use this class to define the tests to perform for the ACU.
|
|
|
|
@details Setting all to True will run all tests.
|
|
|
|
Setting all to False will only run the tests set to True.
|
|
|
|
"""
|
|
|
|
all = False
|
|
|
|
reboot = False
|
|
|
|
read_gnd_wdt = False
|
|
|
|
gnd_wdt_reset = False
|
|
|
|
ping = False
|
|
|
|
read_temperature1 = False
|
|
|
|
read_temperature2 = False
|
|
|
|
read_temperature3 = True
|
|
|
|
read_mppt_mode = True
|
|
|
|
read_vboost = True
|
|
|
|
read_vbat_max_hi = True
|
|
|
|
read_vbat_max_lo = True
|
|
|
|
read_ov_mode = True
|
|
|
|
|
|
|
|
|
|
|
|
class ACUConfigTable:
|
|
|
|
mppt_mode = TableEntry(bytearray([0x00, 0x00]), TableEntry.uint8_size)
|
|
|
|
mppt_d_mode = TableEntry(bytearray([0x00, 0x01]), TableEntry.uint8_size)
|
|
|
|
vboost = TableEntry(bytearray([0x00, 0x02]), TableEntry.uint16_size)
|
|
|
|
vbat_max_hi = TableEntry(bytearray([0x00, 0x10]), TableEntry.uint16_size)
|
|
|
|
vbat_max_lo = TableEntry(bytearray([0x00, 0x12]), TableEntry.uint16_size)
|
|
|
|
ov_mode = TableEntry(bytearray([0x00, 0x1A]), TableEntry.uint8_size)
|
|
|
|
|
|
|
|
|
|
|
|
class ACUHkTable:
|
|
|
|
temperature1 = TableEntry(bytearray([0x00, 0x1C]), TableEntry.uint16_size)
|
|
|
|
temperature2 = TableEntry(bytearray([0x00, 0x1D]), TableEntry.uint16_size)
|
|
|
|
temperature3 = TableEntry(bytearray([0x00, 0x1E]), TableEntry.uint16_size)
|
|
|
|
# Ground WDT value (remaining seconds until reboot)
|
|
|
|
wdt_gnd_left = TableEntry(bytearray([0x00, 0x74]), TableEntry.uint32_size)
|
|
|
|
|
|
|
|
|
|
|
|
def pack_acu_test_into(object_id: bytearray, tc_queue: TcQueueT) -> TcQueueT:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Testing ACU"))
|
2020-12-29 11:29:03 +01:00
|
|
|
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Enabling ACU connected to X1 slot (channel 0)"))
|
2021-05-17 17:42:04 +02:00
|
|
|
p60dock_object_id = P60_DOCK_HANDLER
|
2021-01-10 11:42:06 +01:00
|
|
|
command = pack_set_param_command(p60dock_object_id, P60DockConfigTable.out_en_0.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
P60DockConfigTable.out_en_0.parameter_size, Channel.on)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.reboot:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reboot"))
|
2020-12-29 11:29:03 +01:00
|
|
|
command = pack_reboot_command(object_id)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.read_gnd_wdt:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading ground watchdog timer value"))
|
2020-12-29 11:29:03 +01:00
|
|
|
command = pack_get_param_command(object_id, TableIds.hk, ACUHkTable.wdt_gnd_left.parameter_address,
|
|
|
|
ACUHkTable.wdt_gnd_left.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.gnd_wdt_reset:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Testing ground watchdog reset"))
|
2020-12-29 11:29:03 +01:00
|
|
|
command = pack_gnd_wdt_reset_command(object_id)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.ping:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Ping Test"))
|
2020-12-29 11:29:03 +01:00
|
|
|
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
|
|
|
command = pack_ping_command(object_id, ping_data)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.read_temperature3:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading temperature 3"))
|
2020-12-29 11:29:03 +01:00
|
|
|
command = pack_get_param_command(object_id, TableIds.hk, ACUHkTable.temperature3.parameter_address,
|
|
|
|
ACUHkTable.temperature3.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.read_vboost:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vboost value"))
|
2020-12-29 11:29:03 +01:00
|
|
|
command = pack_get_param_command(object_id, TableIds.config, ACUConfigTable.vboost.parameter_address,
|
|
|
|
ACUConfigTable.vboost.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.read_vbat_max_hi:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vbat_max_hi"))
|
2020-12-29 11:29:03 +01:00
|
|
|
command = pack_get_param_command(object_id, TableIds.config, ACUConfigTable.vbat_max_hi.parameter_address,
|
|
|
|
ACUConfigTable.vbat_max_hi.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.read_vbat_max_lo:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vbat_max_lo"))
|
2020-12-29 11:29:03 +01:00
|
|
|
command = pack_get_param_command(object_id, TableIds.config, ACUConfigTable.vbat_max_lo.parameter_address,
|
|
|
|
ACUConfigTable.vbat_max_lo.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if ACUTestProcedure.all or ACUTestProcedure.read_ov_mode:
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading ov_mode"))
|
2020-12-29 11:29:03 +01:00
|
|
|
command = pack_get_param_command(object_id, TableIds.config, ACUConfigTable.ov_mode.parameter_address,
|
|
|
|
ACUConfigTable.ov_mode.parameter_size)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
|
2021-02-03 14:14:54 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning off ACU"))
|
2021-01-10 11:42:06 +01:00
|
|
|
command = pack_set_param_command(p60dock_object_id, P60DockConfigTable.out_en_0.parameter_address,
|
2020-12-29 11:29:03 +01:00
|
|
|
P60DockConfigTable.out_en_0.parameter_size, Channel.off)
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
|
|
|
|
return tc_queue
|