starting changing code to new API

This commit is contained in:
Robin Müller 2022-07-04 15:22:53 +02:00
parent fd5b946810
commit 27edcbd71d
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
34 changed files with 1472 additions and 1737 deletions

View File

@ -1,17 +1,16 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Unittests in tmtccmd" type="tests" factoryName="Unittests">
<configuration default="false" name="Python tests in tmtccmd" type="tests" factoryName="Autodetect">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tmtccmd/src/tests" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/deps/tmtccmd/tests" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="_new_pattern" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/tmtccmd/src/tests&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/deps/tmtccmd/tests&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>

View File

@ -1,18 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Unittests in spacepackets" type="tests" factoryName="Unittests">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/spacepackets/tests" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="_new_pattern" value="&quot;&quot;" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;$PROJECT_DIR$/spacepackets/tests&quot;" />
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
</component>

View File

@ -39,7 +39,7 @@ class EiveHookObject(TmTcHookBase):
custom_mode_operation(mode=mode, tmtc_backend=tmtc_backend)
def pack_service_queue(self, service: int, op_code: str, service_queue: TcQueueT):
from pus_tc.tc_packer_hook import pack_service_queue_user
from pus_tc.procedure_packer import pack_service_queue_user
pack_service_queue_user(
service=service, op_code=op_code, service_queue=service_queue

2
deps/tmtccmd vendored

@ -1 +1 @@
Subproject commit 82962b95ebda8fc5200fe999319abb3bdb7fcd90
Subproject commit e5d12ca4c0da06338e575701972aaf4180b49635

View File

@ -8,6 +8,7 @@
"""
import enum
import struct
from typing import Union
from tmtccmd.tc.pus_8_funccmd import generate_action_command
from tmtccmd.tc.definitions import PusTelecommand
@ -74,7 +75,10 @@ class Channel:
def pack_get_param_command(
object_id: bytes, table_id: int, memory_address: bytearray, parameter_size: int
object_id: bytes,
table_id: int,
memory_address: Union[int, bytes],
parameter_size: int,
) -> PusTelecommand:
"""Function to generate a command to retrieve parameters like the temperature from a gomspace device.
@param object_id: The object id of the gomspace device handler.
@ -83,9 +87,12 @@ def pack_get_param_command(
@param parameter_size: Size of the value to read. E.g. temperature is uint16_t and thus parameter_size is 2
@return: The command as bytearray.
"""
app_data = struct.pack('!B', table_id)
app_data += struct.pack('!H', memory_address)
app_data += struct.pack('!B', parameter_size)
app_data = struct.pack("!B", table_id)
if isinstance(memory_address, int):
app_data += struct.pack("!H", memory_address)
else:
app_data += memory_address
app_data += struct.pack("!B", parameter_size)
return generate_action_command(
object_id=object_id,
action_id=GomspaceDeviceActionIds.PARAM_GET,
@ -95,7 +102,7 @@ def pack_get_param_command(
def pack_set_param_command(
object_id: bytes,
memory_address: bytearray,
memory_address: bytes,
parameter_size: int,
parameter: int,
ssc: int = 0,
@ -116,7 +123,7 @@ def pack_set_param_command(
if parameter_size == 1:
app_data.append(parameter)
elif parameter_size == 2:
app_data += struct.pack('!H', parameter)
app_data += struct.pack("!H", parameter)
elif parameter_size == 4:
byte_one = 0xFF000000 & parameter >> 24
byte_two = 0xFF0000 & parameter >> 16

View File

@ -6,9 +6,8 @@
import struct
from config.definitions import CustomServiceList
from tmtccmd.config import add_op_code_entry, add_service_op_code_entry
from tmtccmd.tc.packer import TcQueueT
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT
from tmtccmd.tc import QueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid,
generate_one_diag_command,
@ -84,53 +83,48 @@ def add_acu_cmds(cmd_dict: ServiceOpCodeDictT):
)
def pack_acu_commands(
object_id: ObjectId, tc_queue: TcQueueT, op_code: str
) -> TcQueueT:
tc_queue.appendleft((QueueCommands.PRINT, "Handling ACU command"))
def pack_acu_commands(object_id: ObjectId, q: QueueHelper, op_code: str) -> TcQueueT:
q.add_log_cmd("Handling ACU command")
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Print channel stats"))
command = generate_action_command(
object_id=object_id.as_bytes,
action_id=gs.GomspaceDeviceActionIds.PRINT_SWITCH_V_I,
q.add_log_cmd("ACU: Print channel stats")
q.add_pus_tc(
generate_action_command(
object_id=object_id.as_bytes,
action_id=gs.GomspaceDeviceActionIds.PRINT_SWITCH_V_I,
)
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
tc_queue.appendleft(
(QueueCommands.PRINT, f"PDU1: {GsInfo.REQUEST_CORE_HK_ONCE}")
)
q.add_log_cmd(f"PDU1: {GsInfo.REQUEST_CORE_HK_ONCE}")
hk_sid = make_sid(object_id=object_id.as_bytes, set_id=gs.SetIds.ACU_CORE)
command = generate_one_diag_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
q.add_pus_tc(generate_one_diag_command(sid=hk_sid))
if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE:
tc_queue.appendleft(
(QueueCommands.PRINT, f"PDU1: {GsInfo.REQUEST_AUX_HK_ONCE}")
)
q.add_log_cmd(f"PDU1: {GsInfo.REQUEST_AUX_HK_ONCE}")
hk_sid = make_sid(object_id=object_id.as_bytes, set_id=gs.SetIds.ACU_AUX)
command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
if op_code in GomspaceOpCodes.GET_PARAM:
tc_queue.appendleft(
(QueueCommands.PRINT, f"PDU1: {GsInfo.GET_PARAMETER}")
)
q.add_log_cmd(f"PDU1: {GsInfo.GET_PARAMETER}")
table_id = int(input("Specify table ID: "))
memory_address = int(input("Specify memory address: 0x"), 16)
parameter_size = int(input("Specify parameter size: "))
command = gs.pack_get_param_command(object_id.as_bytes, table_id, memory_address, parameter_size)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.SET_PARAM:
tc_queue.appendleft(
(QueueCommands.PRINT, f"PDU1: {GsInfo.SET_PARAMETER}")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes, table_id, memory_address, parameter_size
)
)
if op_code in GomspaceOpCodes.SET_PARAM:
q.add_log_cmd(f"PDU1: {GsInfo.SET_PARAMETER}")
memory_address = int(input("Specify memory address: 0x"), 16)
memory_address = struct.pack('!H', memory_address)
memory_address = struct.pack("!H", memory_address)
parameter_size = int(input("Specify parameter size: "))
parameter = int(input("Specify parameter: "))
command = gs.pack_set_param_command(object_id.as_bytes, memory_address, parameter_size, parameter)
tc_queue.appendleft(command.pack_command_tuple())
pack_test_cmds(object_id=object_id, tc_queue=tc_queue)
q.add_pus_tc(
gs.pack_set_param_command(
object_id.as_bytes, memory_address, parameter_size, parameter
)
)
pack_test_cmds(object_id=object_id, q=q)
return tc_queue
return q
class ACUTestProcedure:
@ -156,91 +150,84 @@ class ACUTestProcedure:
off = False
def pack_test_cmds(object_id: ObjectId, tc_queue: TcQueueT):
def pack_test_cmds(object_id: ObjectId, q: QueueHelper):
if ACUTestProcedure.all or ACUTestProcedure.reboot:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reboot"))
command = gs.pack_reboot_command(object_id)
# command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("ACU: Reboot")
q.add_pus_tc(gs.pack_reboot_command(object_id))
if ACUTestProcedure.all or ACUTestProcedure.read_gnd_wdt:
tc_queue.appendleft(
(QueueCommands.PRINT, "ACU: Reading ground watchdog timer value")
q.add_log_cmd("ACU: Reading ground watchdog timer value")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.hk,
ACUHkTable.wdt_gnd_left.parameter_address,
ACUHkTable.wdt_gnd_left.parameter_size,
)
)
command = gs.pack_get_param_command(
object_id.as_bytes,
gs.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:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Testing ground watchdog reset"))
command = gs.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())
q.add_log_cmd("ACU: Testing ground watchdog reset")
q.add_pus_tc(gs.pack_gnd_wdt_reset_command(object_id))
if ACUTestProcedure.all or ACUTestProcedure.ping:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Ping Test"))
q.add_log_cmd("ACU: Ping Test")
ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
command = gs.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())
q.add_pus_tc(gs.pack_ping_command(object_id, ping_data))
if ACUTestProcedure.all or ACUTestProcedure.read_temperature3:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading temperature 3"))
command = gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.hk,
ACUHkTable.temperature3.parameter_address,
ACUHkTable.temperature3.parameter_size,
q.add_log_cmd("ACU: Reading temperature 3")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.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:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vboost value"))
command = gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
ACUConfigTable.vboost.parameter_address,
ACUConfigTable.vboost.parameter_size,
q.add_log_cmd("ACU: Reading vboost value")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.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:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vbat_max_hi"))
command = gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
ACUConfigTable.vbat_max_hi.parameter_address,
ACUConfigTable.vbat_max_hi.parameter_size,
q.add_log_cmd("ACU: Reading vbat_max_hi")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.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:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading vbat_max_lo"))
command = gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
ACUConfigTable.vbat_max_lo.parameter_address,
ACUConfigTable.vbat_max_lo.parameter_size,
q.add_log_cmd("ACU: Reading vbat_max_lo")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.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:
tc_queue.appendleft((QueueCommands.PRINT, "ACU: Reading ov_mode"))
command = gs.pack_get_param_command(
object_id.as_bytes,
gs.TableIds.config,
ACUConfigTable.ov_mode.parameter_address,
ACUConfigTable.ov_mode.parameter_size,
q.add_log_cmd("ACU: Reading ov_mode")
q.add_pus_tc(
gs.pack_get_param_command(
object_id.as_bytes,
gs.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())
if ACUTestProcedure.all or ACUTestProcedure.off:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Turning off ACU"))
command = gs.pack_set_param_command(
ACU_HANDLER_ID,
P60DockConfigTable.out_en_0.parameter_address,
P60DockConfigTable.out_en_0.parameter_size,
gs.Channel.off,
q.add_log_cmd("P60 Dock: Turning off ACU")
q.add_pus_tc(
gs.pack_set_param_command(
ACU_HANDLER_ID,
P60DockConfigTable.out_en_0.parameter_address,
P60DockConfigTable.out_en_0.parameter_size,
gs.Channel.off,
)
)
tc_queue.appendleft(command.pack_command_tuple())

View File

@ -1,5 +1,5 @@
from tmtccmd.tc.definitions import TcQueueT, QueueCommands
from config.object_ids import BPX_HANDLER_ID
from tmtccmd.tc import QueueHelper
from tmtccmd.tc.pus_8_funccmd import generate_action_command
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
@ -24,33 +24,33 @@ class BpxOpCodes:
REBOOT = ["4", "reboot"]
def pack_bpx_commands(tc_queue: TcQueueT, op_code: str):
def pack_bpx_commands(q: QueueHelper, op_code: str):
if op_code in BpxOpCodes.HK:
tc_queue.appendleft((QueueCommands.PRINT, "Requesting BPX battery HK set"))
q.add_log_cmd("Requesting BPX battery HK set")
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_HK_SET)
cmd = generate_one_hk_command(sid=sid, ssc=0)
tc_queue.appendleft(cmd.pack_command_tuple())
q.add_pus_tc(generate_one_hk_command(sid=sid))
if op_code in BpxOpCodes.RST_BOOT_CNT:
tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters"))
cmd = generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS
q.add_log_cmd("Resetting reboot counters")
q.add_pus_tc(
generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS
)
)
tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in BpxOpCodes.REQUEST_CFG:
tc_queue.appendleft((QueueCommands.PRINT, "Requesting configuration struct"))
cmd = generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.GET_CFG
q.add_log_cmd("Requesting configuration struct")
q.add_pus_tc(
generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.GET_CFG
)
)
tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in BpxOpCodes.REQUEST_CFG_HK:
tc_queue.appendleft((QueueCommands.PRINT, "Requesting configuration struct HK"))
q.add_log_cmd("Requesting configuration struct HK")
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_CFG_SET)
cmd = generate_one_hk_command(sid=sid, ssc=0)
tc_queue.appendleft(cmd.pack_command_tuple())
q.add_pus_tc(generate_one_hk_command(sid=sid))
if op_code in BpxOpCodes.REBOOT:
tc_queue.appendleft((QueueCommands.PRINT, "Rebooting BPX battery"))
cmd = generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.REBOOT
q.add_log_cmd("Rebooting BPX battery")
q.add_pus_tc(
generate_action_command(
object_id=BPX_HANDLER_ID, action_id=BpxActionIds.REBOOT
)
)
tc_queue.appendleft(cmd.pack_command_tuple())
pass

View File

@ -7,16 +7,14 @@ import enum
from config.definitions import CustomServiceList
from config.object_ids import get_object_ids
from tmtccmd.tc import QueueHelper
from tmtccmd.utility.obj_id import ObjectId
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT
from tmtccmd.tc.pus_201_fsfw_health import (
pack_set_health_cmd_data,
FsfwHealth,
Subservices,
)
from tmtccmd.tc.pus_8_funccmd import generate_action_command
from tmtccmd.config.globals import add_service_op_code_entry, add_op_code_entry
from tmtccmd.tc.packer import TcQueueT
from spacepackets.ecss.tc import PusTelecommand
@ -82,9 +80,9 @@ def add_heater_cmds(cmd_dict: ServiceOpCodeDictT):
)
def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
def pack_heater_cmds(object_id: bytearray, op_code: str, q: QueueHelper):
if op_code in OpCodes.HEATER_CMD:
tc_queue.appendleft((QueueCommands.PRINT, "Heater Switching"))
q.add_log_cmd("Heater Switching")
heater_number = prompt_heater()
while True:
action = input("Turn switch on or off? (0 - off, 1 - on): ")
@ -101,14 +99,13 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
else:
act_str = "off"
debug_string = f"Switching heater {heater_number} {act_str}"
tc_queue.appendleft((QueueCommands.PRINT, debug_string))
command = pack_switch_heater_command(object_id, heater_number, action)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd(debug_string)
q.add_pus_tc(pack_switch_heater_command(object_id, heater_number, action))
if op_code in OpCodes.HEATER_EXT_CTRL:
heater_number = prompt_heater()
obj_id = heater_idx_to_obj(heater_number)
health_cmd(
tc_queue=tc_queue,
q=q,
object_id=obj_id,
health=FsfwHealth.EXTERNAL_CTRL,
health_str="External Control",
@ -118,7 +115,7 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
heater_number = prompt_heater()
obj_id = heater_idx_to_obj(heater_number)
health_cmd(
tc_queue=tc_queue,
q=q,
object_id=obj_id,
health=FsfwHealth.FAULTY,
health_str="Faulty",
@ -128,7 +125,7 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, tc_queue: TcQueueT):
heater_number = prompt_heater()
obj_id = heater_idx_to_obj(heater_number)
health_cmd(
tc_queue=tc_queue,
q=q,
object_id=obj_id,
health=FsfwHealth.HEALTHY,
health_str="Healthy",
@ -188,23 +185,19 @@ def prompt_heater() -> int:
def health_cmd(
tc_queue: TcQueueT,
q: QueueHelper,
heater_idx: int,
object_id: ObjectId,
health: FsfwHealth,
health_str: str,
):
tc_queue.appendleft(
(
QueueCommands.PRINT,
f"Setting Heater {heater_idx} {object_id} to {health_str}",
q.add_log_cmd(f"Setting Heater {heater_idx} {object_id} to {health_str}")
app_data = pack_set_health_cmd_data(object_id=object_id.as_bytes, health=health)
q.add_pus_tc(
PusTelecommand(
service=201, subservice=Subservices.TC_SET_HEALTH, app_data=app_data
)
)
app_data = pack_set_health_cmd_data(object_id=object_id.as_bytes, health=health)
cmd = PusTelecommand(
service=201, subservice=Subservices.TC_SET_HEALTH, app_data=app_data
)
tc_queue.appendleft(cmd.pack_command_tuple())
def pack_switch_heater_command(

View File

@ -7,16 +7,15 @@
"""
import struct
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.packer import TcQueueT
from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc import QueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
make_sid,
generate_one_diag_command,
generate_one_hk_command,
)
from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes
from tmtccmd.utility import ObjectId
class ImtqSetIds:
@ -40,233 +39,149 @@ class ImtqActionIds:
perform_negative_y_test = bytearray([0x0, 0x0, 0x0, 0x0A])
perform_positive_z_test = bytearray([0x0, 0x0, 0x0, 0x0B])
perform_negative_z_test = bytearray([0x0, 0x0, 0x0, 0x0C])
# Initiates the reading of the last performed self test. After sending this command the results can be downlinked
# via the housekeeping service by using the appropriate set ids listed above.
# Initiates the reading of the last performed self test. After sending this command the results
# can be downlinked via the housekeeping service by using the appropriate set ids listed above.
read_self_test_results = bytearray([0x0, 0x0, 0x0, 0x0D])
def pack_imtq_test_into(
object_id: bytearray, tc_queue: TcQueueT, op_code: str
) -> TcQueueT:
tc_queue.appendleft(
(
QueueCommands.PRINT,
"Testing ISIS IMTQ handler with object id: 0x" + object_id.hex(),
)
def pack_imtq_test_into(object_id: ObjectId, q: QueueHelper, op_code: str):
q.add_log_cmd(
f"Testing ISIS IMTQ handler with object id: {object_id.as_hex_string}"
)
if op_code == "0":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Set mode off"))
command = pack_mode_data(object_id, Modes.OFF, 0)
command = PusTelecommand(service=200, subservice=1, ssc=9, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Set mode off")
command = pack_mode_data(object_id.as_bytes, Modes.OFF, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command))
if op_code == "1":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Set mode on"))
command = pack_mode_data(object_id, Modes.ON, 0)
command = PusTelecommand(service=200, subservice=1, ssc=10, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Set mode on")
command = pack_mode_data(object_id.as_bytes, Modes.ON, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command))
if op_code == "2":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Mode Normal"))
command = pack_mode_data(object_id, Modes.NORMAL, 0)
command = PusTelecommand(service=200, subservice=1, ssc=11, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Mode Normal")
command = pack_mode_data(object_id.as_bytes, Modes.NORMAL, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command))
if op_code == "3":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Perform positive x self test"))
command = object_id + ImtqActionIds.perform_positive_x_test
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Perform positive x self test")
command = object_id.as_bytes + ImtqActionIds.perform_positive_x_test
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Initiate reading of positive x self test results",
)
)
command = object_id + ImtqActionIds.read_self_test_results
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Initiate reading of positive x self test results")
command = object_id.as_bytes + ImtqActionIds.read_self_test_results
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Request dataset with positive x self test results",
)
)
sid = make_sid(object_id, ImtqSetIds.POSITIVE_X_TEST)
command = generate_one_hk_command(sid, 24)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Request dataset with positive x self test results")
sid = make_sid(object_id.as_bytes, ImtqSetIds.POSITIVE_X_TEST)
q.add_pus_tc(generate_one_hk_command(sid))
if op_code == "4":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Perform negative x self test"))
command = object_id + ImtqActionIds.perform_negative_x_test
command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Initiate reading of negative x self test results",
)
)
command = object_id + ImtqActionIds.read_self_test_results
command = PusTelecommand(service=8, subservice=128, ssc=26, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Request dataset with negative x self test results",
)
)
sid = make_sid(object_id, ImtqSetIds.NEGATIVE_X_TEST)
command = generate_one_hk_command(sid, 27)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Perform negative x self test")
command = object_id.as_bytes + ImtqActionIds.perform_negative_x_test
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
q.add_log_cmd("IMTQ: Initiate reading of negative x self test results")
command = object_id.as_bytes + ImtqActionIds.read_self_test_results
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
q.add_log_cmd("IMTQ: Request dataset with negative x self test results")
sid = make_sid(object_id.as_bytes, ImtqSetIds.NEGATIVE_X_TEST)
q.add_pus_tc(generate_one_hk_command(sid))
if op_code == "5":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Perform positive y self test"))
command = object_id + ImtqActionIds.perform_positive_y_test
command = PusTelecommand(service=8, subservice=128, ssc=28, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Perform positive y self test")
command = object_id.as_bytes + ImtqActionIds.perform_positive_y_test
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
q.add_log_cmd("IMTQ: Initiate reading of positive y self test results")
command = object_id.as_bytes + ImtqActionIds.read_self_test_results
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Initiate reading of positive y self test results",
)
)
command = object_id + ImtqActionIds.read_self_test_results
command = PusTelecommand(service=8, subservice=128, ssc=29, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Request dataset with positive y self test results",
)
)
sid = make_sid(object_id, ImtqSetIds.POSITIVE_Y_TEST)
command = generate_one_hk_command(sid, 30)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Request dataset with positive y self test results")
sid = make_sid(object_id.as_bytes, ImtqSetIds.POSITIVE_Y_TEST)
q.add_pus_tc(generate_one_hk_command(sid))
if op_code == "6":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Perform negative y self test"))
command = object_id + ImtqActionIds.perform_negative_y_test
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Perform negative y self test")
command = object_id.as_bytes + ImtqActionIds.perform_negative_y_test
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Initiate reading of negative y self test results",
)
)
command = object_id + ImtqActionIds.read_self_test_results
command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Initiate reading of negative y self test results")
command = object_id.as_bytes + ImtqActionIds.read_self_test_results
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Request dataset with negative y self test results",
)
)
sid = make_sid(object_id, ImtqSetIds.NEGATIVE_Y_TEST)
command = generate_one_hk_command(sid, 33)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Request dataset with negative y self test results")
sid = make_sid(object_id.as_bytes, ImtqSetIds.NEGATIVE_Y_TEST)
q.add_pus_tc(generate_one_hk_command(sid))
if op_code == "7":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Perform positive z self test"))
command = object_id + ImtqActionIds.perform_positive_z_test
command = PusTelecommand(service=8, subservice=128, ssc=34, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Perform positive z self test")
command = object_id.as_bytes + ImtqActionIds.perform_positive_z_test
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Initiate reading of positive z self test results",
)
)
command = object_id + ImtqActionIds.read_self_test_results
command = PusTelecommand(service=8, subservice=128, ssc=35, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Initiate reading of positive z self test results")
command = object_id.as_bytes + ImtqActionIds.read_self_test_results
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Request dataset with positive z self test results",
)
)
sid = make_sid(object_id, ImtqSetIds.POSITIVE_Y_TEST)
command = generate_one_hk_command(sid, 36)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Request dataset with positive z self test results")
sid = make_sid(object_id.as_bytes, ImtqSetIds.POSITIVE_Y_TEST)
q.add_pus_tc(generate_one_hk_command(sid))
if op_code == "8":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Perform negative z self test"))
command = object_id + ImtqActionIds.perform_negative_z_test
command = PusTelecommand(service=8, subservice=128, ssc=35, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Initiate reading of negative z self test results",
)
)
command = object_id + ImtqActionIds.read_self_test_results
command = PusTelecommand(service=8, subservice=128, ssc=36, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
tc_queue.appendleft(
(
QueueCommands.PRINT,
"IMTQ: Request dataset with negative z self test results",
)
)
sid = make_sid(object_id, ImtqSetIds.NEGATIVE_Z_TEST)
command = generate_one_hk_command(sid, 37)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Perform negative z self test")
command = object_id.as_bytes + ImtqActionIds.perform_negative_z_test
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
q.add_log_cmd("IMTQ: Initiate reading of negative z self test results")
command = object_id.as_bytes + ImtqActionIds.read_self_test_results
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
q.add_log_cmd("IMTQ: Request dataset with negative z self test results")
sid = make_sid(object_id.as_bytes, ImtqSetIds.NEGATIVE_Z_TEST)
q.add_pus_tc(generate_one_hk_command(sid))
if op_code == "9":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Commanding dipole"))
q.add_log_cmd("IMTQ: Commanding dipole")
x_dipole = 0
y_dipole = 0
z_dipole = 0
duration = 0 # ms
command = pack_dipole_command(object_id, x_dipole, y_dipole, z_dipole, duration)
tc_queue.appendleft(command.pack_command_tuple())
q.add_pus_tc(
pack_dipole_command(
object_id.as_bytes, x_dipole, y_dipole, z_dipole, duration
)
)
if op_code == "10":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Get commanded dipole"))
command = object_id + ImtqActionIds.get_commanded_dipole
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("IMTQ: Get commanded dipole")
command = object_id.as_bytes + ImtqActionIds.get_commanded_dipole
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
if op_code == "11":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Get engineering hk set"))
command = generate_one_diag_command(
sid=make_sid(object_id=object_id, set_id=ImtqSetIds.ENG_HK_SET), ssc=0
q.add_log_cmd("IMTQ: Get engineering hk set")
q.add_pus_tc(
generate_one_diag_command(
sid=make_sid(object_id=object_id.as_bytes, set_id=ImtqSetIds.ENG_HK_SET)
)
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "12":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Get calibrated MTM hk set"))
command = generate_one_diag_command(
sid=make_sid(object_id=object_id, set_id=ImtqSetIds.CAL_MTM_SET), ssc=0
q.add_log_cmd("IMTQ: Get calibrated MTM hk set")
q.add_pus_tc(
generate_one_diag_command(
sid=make_sid(
object_id=object_id.as_bytes, set_id=ImtqSetIds.CAL_MTM_SET
)
)
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == "13":
tc_queue.appendleft((QueueCommands.PRINT, "IMTQ: Get raw MTM hk set"))
command = generate_one_diag_command(
sid=make_sid(object_id=object_id, set_id=ImtqSetIds.RAW_MTM_SET), ssc=0
q.add_log_cmd("IMTQ: Get raw MTM hk set")
q.add_pus_tc(
generate_one_diag_command(
sid=make_sid(
object_id=object_id.as_bytes, set_id=ImtqSetIds.RAW_MTM_SET
)
)
)
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue
def pack_dipole_command(
object_id: bytearray, x_dipole: int, y_dipole: int, z_dipole: int, duration: int
object_id: bytes, x_dipole: int, y_dipole: int, z_dipole: int, duration: int
) -> PusTelecommand:
"""This function packs the command causing the ISIS IMTQ to generate a dipole.
@param object_id The object id of the IMTQ handler.
@ -279,9 +194,9 @@ def pack_dipole_command(
"""
action_id = ImtqActionIds.start_actuation_dipole
command = object_id + action_id
command += struct.pack('!h', x_dipole)
command += struct.pack('!h', y_dipole)
command += struct.pack('!h', z_dipole)
command += struct.pack('!h', duration)
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
command += struct.pack("!h", x_dipole)
command += struct.pack("!h", y_dipole)
command += struct.pack("!h", z_dipole)
command += struct.pack("!h", duration)
command = PusTelecommand(service=8, subservice=128, app_data=command)
return command

View File

@ -7,6 +7,8 @@
"""
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.packer import TcQueueT
from tmtccmd.tc import QueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
make_sid,
@ -87,240 +89,193 @@ class P60DockHkTable:
wdt_gnd_left = TableEntry(bytearray([0x00, 0xA8]), TableEntry.uint32_size)
def pack_p60dock_cmds(object_id: ObjectId, tc_queue: TcQueueT, op_code: str):
def pack_p60dock_cmds(object_id: ObjectId, q: QueueHelper, op_code: str):
objb = object_id.as_bytes
if op_code in P60OpCodes.STACK_3V3_ON:
tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_3V3_ON))
command = pack_set_param_command(
objb,
P60DockConfigTable.out_en_9.parameter_address,
P60DockConfigTable.out_en_9.parameter_size,
Channel.on,
q.add_log_cmd(Info.STACK_3V3_ON)
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_9.parameter_address,
P60DockConfigTable.out_en_9.parameter_size,
Channel.on,
)
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in P60OpCodes.STACK_3V3_OFF:
tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_3V3_OFF))
command = pack_set_param_command(
objb,
P60DockConfigTable.out_en_9.parameter_address,
P60DockConfigTable.out_en_9.parameter_size,
Channel.off,
q.add_log_cmd(Info.STACK_3V3_OFF)
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_9.parameter_address,
P60DockConfigTable.out_en_9.parameter_size,
Channel.off,
)
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in P60OpCodes.STACK_5V_ON:
tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_5V_ON))
command = pack_set_param_command(
objb,
P60DockConfigTable.out_en_10.parameter_address,
P60DockConfigTable.out_en_10.parameter_size,
Channel.on,
q.add_log_cmd(Info.STACK_5V_ON)
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_10.parameter_address,
P60DockConfigTable.out_en_10.parameter_size,
Channel.on,
)
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in P60OpCodes.STACK_5V_OFF:
tc_queue.appendleft((QueueCommands.PRINT, Info.STACK_5V_OFF))
command = pack_set_param_command(
objb,
P60DockConfigTable.out_en_10.parameter_address,
P60DockConfigTable.out_en_10.parameter_size,
Channel.off,
q.add_log_cmd(Info.STACK_5V_OFF)
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_10.parameter_address,
P60DockConfigTable.out_en_10.parameter_size,
Channel.off,
)
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.REQUEST_CORE_HK_ONCE:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Requesting HK Core HK Once")
)
q.add_log_cmd("P60 Dock: Requesting HK Core HK Once")
hk_sid = make_sid(object_id=P60_DOCK_HANDLER, set_id=SetIds.P60_CORE)
command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
if op_code in GomspaceOpCodes.REQUEST_AUX_HK_ONCE:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Requesting HK Aux HK Once")
)
q.add_log_cmd("P60 Dock: Requesting HK Aux HK Once")
hk_sid = make_sid(object_id=P60_DOCK_HANDLER, set_id=SetIds.P60_AUX)
command = generate_one_hk_command(sid=hk_sid, ssc=0)
tc_queue.appendleft(command.pack_command_tuple())
q.add_pus_tc(generate_one_hk_command(sid=hk_sid))
if op_code in GomspaceOpCodes.PRINT_SWITCH_V_I:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Print Switches, Voltages, Currents")
q.add_log_cmd("P60 Dock: Print Switches, Voltages, Currents")
q.add_pus_tc(
generate_action_command(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
)
command = generate_action_command(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_SWITCH_V_I
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code in GomspaceOpCodes.PRINT_LATCHUPS:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Print Latchups"))
command = generate_action_command(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
q.add_log_cmd("P60 Dock: Print Latchups")
q.add_pus_tc(
generate_action_command(
object_id=objb, action_id=GomspaceDeviceActionIds.PRINT_LATCHUPS
)
)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.reboot:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Reboot"))
command = pack_reboot_command(object_id)
# command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_log_cmd("P60 Dock: Reboot")
q.add_pus_tc(pack_reboot_command(object_id))
if P60DockTestProcedure.all or P60DockTestProcedure.read_gnd_wdt:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Reading ground watchdog timer value")
q.add_log_cmd("P60 Dock: Reading ground watchdog timer value")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.wdt_gnd_left.parameter_address,
P60DockHkTable.wdt_gnd_left.parameter_size,
)
)
command = pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.wdt_gnd_left.parameter_address,
P60DockHkTable.wdt_gnd_left.parameter_size,
)
# command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.gnd_wdt_reset:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Testing ground watchdog reset")
)
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())
q.add_log_cmd("P60 Dock: Testing ground watchdog reset")
q.add_pus_tc(pack_gnd_wdt_reset_command(object_id))
if P60DockTestProcedure.all or P60DockTestProcedure.ping:
tc_queue.appendleft((QueueCommands.PRINT, "P60 Dock: Ping"))
q.add_log_cmd("P60 Dock: Ping")
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())
q.add_pus_tc(pack_ping_command(object_id, ping_data))
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_off:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Testing setting output channel 3 off")
)
q.add_log_cmd("P60 Dock: Testing setting output channel 3 off")
parameter = 0 # set channel off
command = pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
parameter,
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
parameter,
)
)
# command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.read_temperature1:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Testing temperature reading")
q.add_log_cmd("P60 Dock: Testing temperature reading")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.temperature1.parameter_address,
P60DockHkTable.temperature1.parameter_size,
)
)
command = pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.temperature1.parameter_address,
P60DockHkTable.temperature1.parameter_size,
)
# command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Testing Output Channel 3 state (PDU2)")
q.add_log_cmd("P60 Dock: Testing Output Channel 3 state (PDU2)")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
)
)
command = pack_get_param_command(
objb,
TableIds.config,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
)
# command = PusTelecommand(service=8, subservice=128, ssc=25, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.read_cur_lu_lim_0:
tc_queue.appendleft(
(
QueueCommands.PRINT,
"P60 Dock: Reading current limit value of output channel 0",
q.add_log_cmd("P60 Dock: Reading current limit value of output channel 0")
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.config,
P60DockConfigTable.cur_lu_lim_0.parameter_address,
P60DockConfigTable.cur_lu_lim_0.parameter_size,
)
)
command = pack_get_param_command(
objb,
TableIds.config,
P60DockConfigTable.cur_lu_lim_0.parameter_address,
P60DockConfigTable.cur_lu_lim_0.parameter_size,
)
# command = PusTelecommand(service=8, subservice=128, ssc=26, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.channel_3_on:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Testing setting output channel 3 on")
)
q.add_log_cmd("P60 Dock: Testing setting output channel 3 on")
parameter = 1 # set channel on
command = pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
parameter,
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
P60DockConfigTable.out_en_3.parameter_size,
parameter,
)
)
# command = PusTelecommand(service=8, subservice=128, ssc=27, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_table_id_test:
tc_queue.appendleft(
(QueueCommands.PRINT, "P60 Dock: Testing invalid table id handling")
)
q.add_log_cmd("P60 Dock: Testing invalid table id handling")
table_id_invalid = 5
command = pack_get_param_command(
objb,
table_id_invalid,
P60DockHkTable.temperature1.parameter_address,
P60DockHkTable.temperature1.parameter_size,
q.add_pus_tc(
pack_get_param_command(
objb,
table_id_invalid,
P60DockHkTable.temperature1.parameter_address,
P60DockHkTable.temperature1.parameter_size,
)
)
# command = PusTelecommand(service=8, subservice=128, ssc=28, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_address_test:
tc_queue.appendleft(
(
QueueCommands.PRINT,
"P60 Dock: Testing invalid address handling in get param command",
)
)
q.add_log_cmd("P60 Dock: Testing invalid address handling in get param command")
invalid_address = bytearray([0x01, 0xF4])
command = pack_get_param_command(
objb,
TableIds.hk,
invalid_address,
P60DockHkTable.temperature1.parameter_size,
)
# command = PusTelecommand(service=8, subservice=128, ssc=29, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
tc_queue.appendleft(
(
QueueCommands.PRINT,
"P60 Dock: Testing invalid address handling in set param command",
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
invalid_address,
P60DockHkTable.temperature1.parameter_size,
)
)
q.add_log_cmd("P60 Dock: Testing invalid address handling in set param command")
invalid_address = bytearray([0x01, 0xF4])
parameter_size = 2
parameter = 1
command = pack_set_param_command(
objb, invalid_address, parameter_size, parameter
q.add_pus_tc(
pack_set_param_command(objb, invalid_address, parameter_size, parameter)
)
# command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
if P60DockTestProcedure.all or P60DockTestProcedure.invalid_parameter_size_test:
tc_queue.appendleft(
(
QueueCommands.PRINT,
"P60 Dock: Testing handling of invalid parameter sizes in get-param command",
)
q.add_log_cmd(
"P60 Dock: Testing handling of invalid parameter sizes in get-param command"
)
invalid_size = 5
command = pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.temperature1.parameter_address,
invalid_size,
)
# command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
tc_queue.appendleft(
(
QueueCommands.PRINT,
"P60 Dock: Testing handling of invalid parameter size in set-param command",
q.add_pus_tc(
pack_get_param_command(
objb,
TableIds.hk,
P60DockHkTable.temperature1.parameter_address,
invalid_size,
)
)
parameter = 1
command = pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
invalid_size,
parameter,
q.add_log_cmd(
"P60 Dock: Testing handling of invalid parameter size in set-param command"
)
parameter = 1
q.add_pus_tc(
pack_set_param_command(
objb,
P60DockConfigTable.out_en_3.parameter_address,
invalid_size,
parameter,
)
)
# command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue

View File

@ -5,9 +5,8 @@
@author J. Meier
@date 22.11.2021
"""
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.packer import TcQueueT
from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc import QueueHelper
class CommandIds:
@ -17,24 +16,13 @@ class CommandIds:
PRINT_PDEC_MON = bytearray([0x0, 0x0, 0x0, 0x1])
def pack_pdec_handler_test(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
tc_queue.appendleft(
(
QueueCommands.PRINT,
"Testing PDEC handler with object id: 0x" + object_id.hex(),
)
)
def pack_pdec_handler_test(object_id: bytearray, q: QueueHelper, op_code: str):
q.add_log_cmd(f"Testing PDEC handler with object id: {object_id.hex()}")
if op_code == "0":
tc_queue.appendleft((QueueCommands.PRINT, "PDEC Handler: Print CLCW"))
q.add_log_cmd("PDEC Handler: Print CLCW")
command = object_id + CommandIds.PRINT_CLCW
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
if op_code == "1":
tc_queue.appendleft(
(QueueCommands.PRINT, "PDEC Handler: Print PDEC monitor register")
)
q.add_log_cmd("PDEC Handler: Print PDEC monitor register")
command = object_id + CommandIds.PRINT_PDEC_MON
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))

View File

@ -4,8 +4,8 @@
@date 17.12.2020
"""
import gomspace.gomspace_common as gs
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.packer import TcQueueT
from tmtccmd.tc import QueueHelper
from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
make_sid,