eive-tmtc/pus_tc/devs/acu.py

160 lines
6.7 KiB
Python
Raw Normal View History

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
"""
import struct
from tmtccmd.tc.packer import TcQueueT
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 *
2022-03-04 11:02:10 +01:00
from pus_tc.devs.p60dock import P60DockConfigTable
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.
"""
2022-01-18 14:03:56 +01:00
2020-12-29 11:29:03 +01:00
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)
class CommandId:
PRINT_CHANNEL_STATS = 51
2022-01-18 14:03:56 +01:00
def pack_acu_test_into(
object_id: bytearray, tc_queue: TcQueueT, op_code: str
) -> TcQueueT:
2021-02-03 14:14:54 +01:00
tc_queue.appendleft((QueueCommands.PRINT, "Testing ACU"))
2020-12-29 11:29:03 +01:00
if op_code == "51":
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Print channel stats"))
2022-01-18 14:03:56 +01:00
command = object_id + struct.pack("!I", CommandId.PRINT_CHANNEL_STATS)
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
return
2020-12-29 11:29:03 +01:00
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)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
if ACUTestProcedure.all or ACUTestProcedure.read_gnd_wdt:
2022-01-18 14:03:56 +01:00
tc_queue.appendleft(
(QueueCommands.PRINT, "ACU: Reading ground watchdog timer value")
)
2021-08-03 15:28:28 +02:00
command = pack_get_param_command(
2022-01-18 14:03:56 +01:00
object_id,
TableIds.hk,
ACUHkTable.wdt_gnd_left.parameter_address,
ACUHkTable.wdt_gnd_left.parameter_size,
2021-08-03 15:28:28 +02:00
)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
2020-12-29 11:29:03 +01:00
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)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
2020-12-29 11:29:03 +01:00
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)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
2020-12-29 11:29:03 +01:00
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"))
2022-01-18 14:03:56 +01:00
command = pack_get_param_command(
object_id,
TableIds.hk,
ACUHkTable.temperature3.parameter_address,
ACUHkTable.temperature3.parameter_size,
)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
2020-12-29 11:29:03 +01:00
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"))
2022-01-18 14:03:56 +01:00
command = pack_get_param_command(
object_id,
TableIds.config,
ACUConfigTable.vboost.parameter_address,
ACUConfigTable.vboost.parameter_size,
)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
2020-12-29 11:29:03 +01:00
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"))
2022-01-18 14:03:56 +01:00
command = pack_get_param_command(
object_id,
TableIds.config,
ACUConfigTable.vbat_max_hi.parameter_address,
ACUConfigTable.vbat_max_hi.parameter_size,
)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
2020-12-29 11:29:03 +01:00
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"))
2022-01-18 14:03:56 +01:00
command = pack_get_param_command(
object_id,
TableIds.config,
ACUConfigTable.vbat_max_lo.parameter_address,
ACUConfigTable.vbat_max_lo.parameter_size,
)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
2020-12-29 11:29:03 +01:00
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"))
2022-01-18 14:03:56 +01:00
command = pack_get_param_command(
object_id,
TableIds.config,
ACUConfigTable.ov_mode.parameter_address,
ACUConfigTable.ov_mode.parameter_size,
)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
2020-12-29 11:29:03 +01:00
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"))
2022-01-18 14:03:56 +01:00
command = pack_set_param_command(
p60dock_object_id,
P60DockConfigTable.out_en_0.parameter_address,
P60DockConfigTable.out_en_0.parameter_size,
Channel.off,
)
2021-09-08 13:20:22 +02:00
# command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
2020-12-29 11:29:03 +01:00
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue