2020-12-29 11:29:03 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
@file tmtcc_tc_p60dock.py
|
|
|
|
@brief P60 Dock tests
|
|
|
|
@author J. Meier
|
|
|
|
@date 13.12.2020
|
|
|
|
"""
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.tmtc.power.common_power import (
|
2022-10-18 10:44:32 +02:00
|
|
|
pack_common_gomspace_cmds,
|
|
|
|
req_hk_cmds,
|
|
|
|
pack_common_power_cmds,
|
2022-10-18 11:08:28 +02:00
|
|
|
SetIds,
|
2022-10-18 10:44:32 +02:00
|
|
|
)
|
2022-08-08 16:32:18 +02:00
|
|
|
from tmtccmd.tc import DefaultPusQueueHelper
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.gomspace.gomspace_common import (
|
2022-08-12 22:33:16 +02:00
|
|
|
TableEntry,
|
|
|
|
Channel,
|
|
|
|
TableIds,
|
|
|
|
pack_get_param_command,
|
|
|
|
pack_gnd_wdt_reset_command,
|
|
|
|
pack_ping_command,
|
|
|
|
pack_reboot_command,
|
2022-09-01 16:58:31 +02:00
|
|
|
pack_set_u8_param_command,
|
|
|
|
pack_set_u16_param_command,
|
2022-08-12 22:33:16 +02:00
|
|
|
)
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.config.object_ids import P60_DOCK_HANDLER
|
2022-08-12 22:33:16 +02:00
|
|
|
from tmtccmd.util import ObjectIdU32
|
2020-12-29 11:29:03 +01:00
|
|
|
|
|
|
|
|
2022-04-04 18:46:52 +02:00
|
|
|
class P60OpCodes:
|
2022-12-06 10:43:32 +01:00
|
|
|
STACK_3V3_ON = ["stack_3v3_on", "1"]
|
|
|
|
STACK_3V3_OFF = ["stack_3v3_off", "2"]
|
|
|
|
STACK_5V_ON = ["stack_5v_on", "3"]
|
|
|
|
STACK_5V_OFF = ["stack_5v_off", "4"]
|
2022-04-04 18:46:52 +02:00
|
|
|
TEST = ["test", "0"]
|
|
|
|
|
|
|
|
|
2022-08-11 18:10:15 +02:00
|
|
|
class P60Info:
|
2022-04-04 18:46:52 +02:00
|
|
|
PREFIX = "P60 Dock"
|
|
|
|
STACK_3V3_ON = f"{PREFIX}: Turn Stack 3V3 on"
|
|
|
|
STACK_3V3_OFF = f"{PREFIX}: Turn Stack 3V3 off"
|
|
|
|
STACK_5V_ON = f"{PREFIX}: Turn Stack 5V on"
|
|
|
|
STACK_5V_OFF = f"{PREFIX}: Turn Stack 5V off"
|
2021-09-20 11:47:04 +02:00
|
|
|
|
|
|
|
|
2020-12-29 11:29:03 +01:00
|
|
|
class P60DockTestProcedure:
|
|
|
|
"""
|
|
|
|
@brief Use this class to define the tests to perform for the P60Dock.
|
|
|
|
@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-02-09 12:35:10 +01:00
|
|
|
all = False
|
2020-12-29 11:29:03 +01:00
|
|
|
reboot = False
|
|
|
|
read_gnd_wdt = False
|
|
|
|
gnd_wdt_reset = False
|
|
|
|
ping = False
|
|
|
|
channel_3_off = False # pdu2
|
2022-01-27 15:59:19 +01:00
|
|
|
read_temperature1 = False
|
2020-12-29 11:29:03 +01:00
|
|
|
read_channel_3_state = False # pdu2
|
|
|
|
read_cur_lu_lim_0 = False
|
|
|
|
channel_3_on = False # pdu2
|
2022-01-18 14:03:56 +01:00
|
|
|
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
|
|
|
|
)
|
2021-02-09 12:35:10 +01:00
|
|
|
invalid_parameter_size_test = False
|
2020-12-29 11:29:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
class P60DockConfigTable:
|
2021-08-17 11:49:37 +02:00
|
|
|
out_en_0 = TableEntry(bytearray([0x00, 0x68]), TableEntry.uint8_size) # ACU VCC
|
|
|
|
out_en_1 = TableEntry(bytearray([0x00, 0x69]), TableEntry.uint8_size) # PDU1 VCC
|
|
|
|
out_en_2 = TableEntry(bytearray([0x00, 0x6A]), TableEntry.uint8_size) # unused
|
|
|
|
out_en_3 = TableEntry(bytearray([0x00, 0x6B]), TableEntry.uint8_size) # PDU2 VCC
|
|
|
|
out_en_4 = TableEntry(bytearray([0x00, 0x6C]), TableEntry.uint8_size) # ACU VBAT
|
|
|
|
out_en_5 = TableEntry(bytearray([0x00, 0x6D]), TableEntry.uint8_size) # unused
|
|
|
|
out_en_6 = TableEntry(bytearray([0x00, 0x6E]), TableEntry.uint8_size) # PDU1 VBAT
|
|
|
|
out_en_7 = TableEntry(bytearray([0x00, 0x6F]), TableEntry.uint8_size) # PDU2 VBAT
|
|
|
|
out_en_8 = TableEntry(bytearray([0x00, 0x70]), TableEntry.uint8_size) # Stack VBAT
|
|
|
|
out_en_9 = TableEntry(bytearray([0x00, 0x71]), TableEntry.uint8_size) # Stack 3V3
|
|
|
|
out_en_10 = TableEntry(bytearray([0x00, 0x72]), TableEntry.uint8_size) # Stack 5V
|
2022-01-18 14:03:56 +01:00
|
|
|
out_en_11 = TableEntry(
|
|
|
|
bytearray([0x00, 0x73]), TableEntry.uint8_size
|
|
|
|
) # GS 3V3 (unused)
|
|
|
|
out_en_12 = TableEntry(
|
|
|
|
bytearray([0x00, 0x74]), TableEntry.uint8_size
|
|
|
|
) # GS 5V (unused)
|
2020-12-29 11:29:03 +01:00
|
|
|
# When channel consumes more than cur_lu_lim, channel is turned of immediately
|
|
|
|
cur_lu_lim_0 = TableEntry(bytearray([0x00, 0xF8]), TableEntry.uint16_size)
|
|
|
|
|
|
|
|
|
|
|
|
class P60DockHkTable:
|
|
|
|
temperature1 = TableEntry(bytearray([0x00, 0x44]), TableEntry.uint16_size)
|
|
|
|
temperature2 = TableEntry(bytearray([0x00, 0x46]), TableEntry.uint16_size)
|
|
|
|
# Ground WDT value (remaining seconds until reboot)
|
|
|
|
wdt_gnd_left = TableEntry(bytearray([0x00, 0xA8]), TableEntry.uint32_size)
|
|
|
|
|
|
|
|
|
2022-08-08 16:32:18 +02:00
|
|
|
def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str):
|
2022-05-23 11:24:55 +02:00
|
|
|
objb = object_id.as_bytes
|
2022-10-18 10:44:32 +02:00
|
|
|
pack_common_power_cmds("P60 Dock", object_id, q, op_code)
|
|
|
|
pack_common_gomspace_cmds("P60 Dock", object_id, q, op_code)
|
2022-08-27 16:28:33 +02:00
|
|
|
p60_dock_req_hk_cmds(q, op_code)
|
2022-04-04 18:46:52 +02:00
|
|
|
if op_code in P60OpCodes.STACK_3V3_ON:
|
2022-08-12 22:33:16 +02:00
|
|
|
q.add_log_cmd(P60Info.STACK_3V3_ON)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
2022-09-01 16:58:31 +02:00
|
|
|
pack_set_u8_param_command(
|
2022-07-04 15:22:53 +02:00
|
|
|
objb,
|
|
|
|
P60DockConfigTable.out_en_9.parameter_address,
|
|
|
|
Channel.on,
|
|
|
|
)
|
2021-09-08 13:20:22 +02:00
|
|
|
)
|
2022-04-04 18:46:52 +02:00
|
|
|
if op_code in P60OpCodes.STACK_3V3_OFF:
|
2022-08-12 22:33:16 +02:00
|
|
|
q.add_log_cmd(P60Info.STACK_3V3_OFF)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
2022-09-01 16:58:31 +02:00
|
|
|
pack_set_u8_param_command(
|
2022-07-04 15:22:53 +02:00
|
|
|
objb,
|
|
|
|
P60DockConfigTable.out_en_9.parameter_address,
|
|
|
|
Channel.off,
|
|
|
|
)
|
2021-09-08 13:20:22 +02:00
|
|
|
)
|
2022-04-04 18:46:52 +02:00
|
|
|
if op_code in P60OpCodes.STACK_5V_ON:
|
2022-08-12 22:33:16 +02:00
|
|
|
q.add_log_cmd(P60Info.STACK_5V_ON)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
2022-09-01 16:58:31 +02:00
|
|
|
pack_set_u8_param_command(
|
2022-07-04 15:22:53 +02:00
|
|
|
objb,
|
|
|
|
P60DockConfigTable.out_en_10.parameter_address,
|
|
|
|
Channel.on,
|
|
|
|
)
|
2022-01-27 15:59:19 +01:00
|
|
|
)
|
2022-04-04 18:46:52 +02:00
|
|
|
if op_code in P60OpCodes.STACK_5V_OFF:
|
2022-08-12 22:33:16 +02:00
|
|
|
q.add_log_cmd(P60Info.STACK_5V_OFF)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
2022-09-01 16:58:31 +02:00
|
|
|
pack_set_u8_param_command(
|
2022-07-04 15:22:53 +02:00
|
|
|
objb,
|
|
|
|
P60DockConfigTable.out_en_10.parameter_address,
|
|
|
|
Channel.off,
|
|
|
|
)
|
2022-01-27 15:59:19 +01:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.reboot:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Reboot")
|
|
|
|
q.add_pus_tc(pack_reboot_command(object_id))
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.read_gnd_wdt:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Reading ground watchdog timer value")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
2022-09-01 16:58:31 +02:00
|
|
|
TableIds.HK,
|
2022-07-04 15:22:53 +02:00
|
|
|
P60DockHkTable.wdt_gnd_left.parameter_address,
|
|
|
|
P60DockHkTable.wdt_gnd_left.parameter_size,
|
|
|
|
)
|
2021-02-03 14:14:54 +01:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.gnd_wdt_reset:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Testing ground watchdog reset")
|
|
|
|
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.ping:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Ping")
|
2020-12-29 11:29:03 +01:00
|
|
|
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(pack_ping_command(object_id, ping_data))
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_off:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Testing setting output channel 3 off")
|
2020-12-29 11:29:03 +01:00
|
|
|
parameter = 0 # set channel off
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
2022-09-01 16:58:31 +02:00
|
|
|
pack_set_u8_param_command(
|
2022-07-04 15:22:53 +02:00
|
|
|
objb,
|
|
|
|
P60DockConfigTable.out_en_3.parameter_address,
|
|
|
|
parameter,
|
|
|
|
)
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.read_temperature1:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Testing temperature reading")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
2022-09-01 16:58:31 +02:00
|
|
|
TableIds.HK,
|
2022-07-04 15:22:53 +02:00
|
|
|
P60DockHkTable.temperature1.parameter_address,
|
|
|
|
P60DockHkTable.temperature1.parameter_size,
|
|
|
|
)
|
2021-02-03 14:14:54 +01:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Testing Output Channel 3 state (PDU2)")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
2022-09-01 16:58:31 +02:00
|
|
|
TableIds.CONFIG,
|
2022-07-04 15:22:53 +02:00
|
|
|
P60DockConfigTable.out_en_3.parameter_address,
|
|
|
|
P60DockConfigTable.out_en_3.parameter_size,
|
|
|
|
)
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.read_cur_lu_lim_0:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Reading current limit value of output channel 0")
|
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
2022-09-01 16:58:31 +02:00
|
|
|
TableIds.CONFIG,
|
2022-07-04 15:22:53 +02:00
|
|
|
P60DockConfigTable.cur_lu_lim_0.parameter_address,
|
|
|
|
P60DockConfigTable.cur_lu_lim_0.parameter_size,
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Testing setting output channel 3 on")
|
2020-12-29 11:29:03 +01:00
|
|
|
parameter = 1 # set channel on
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
2022-09-01 16:58:31 +02:00
|
|
|
pack_set_u8_param_command(
|
2022-07-04 15:22:53 +02:00
|
|
|
objb,
|
|
|
|
P60DockConfigTable.out_en_3.parameter_address,
|
|
|
|
parameter,
|
|
|
|
)
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
2020-12-29 11:29:03 +01:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_table_id_test:
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Testing invalid table id handling")
|
2020-12-29 11:29:03 +01:00
|
|
|
table_id_invalid = 5
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
|
|
|
table_id_invalid,
|
|
|
|
P60DockHkTable.temperature1.parameter_address,
|
|
|
|
P60DockHkTable.temperature1.parameter_size,
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
|
|
|
)
|
2022-07-04 15:22:53 +02:00
|
|
|
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_address_test:
|
|
|
|
q.add_log_cmd("P60 Dock: Testing invalid address handling in get param command")
|
2020-12-29 11:29:03 +01:00
|
|
|
invalid_address = bytearray([0x01, 0xF4])
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_pus_tc(
|
|
|
|
pack_get_param_command(
|
|
|
|
objb,
|
2022-09-01 16:58:31 +02:00
|
|
|
TableIds.HK,
|
2022-07-04 15:22:53 +02:00
|
|
|
invalid_address,
|
|
|
|
P60DockHkTable.temperature1.parameter_size,
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
|
|
|
)
|
2022-07-04 15:22:53 +02:00
|
|
|
q.add_log_cmd("P60 Dock: Testing invalid address handling in set param command")
|
2020-12-29 11:29:03 +01:00
|
|
|
invalid_address = bytearray([0x01, 0xF4])
|
|
|
|
parameter = 1
|
2022-09-01 16:58:31 +02:00
|
|
|
q.add_pus_tc(pack_set_u16_param_command(objb, invalid_address, parameter))
|
2022-08-27 16:28:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
def p60_dock_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str):
|
2022-10-18 11:08:28 +02:00
|
|
|
req_hk_cmds("P60 Dock", q, op_code, P60_DOCK_HANDLER, [SetIds.CORE, SetIds.AUX])
|