fsfw-example-tmtc-common/pus_tc/service_8_func_cmd.py

50 lines
1.9 KiB
Python
Raw Normal View History

2021-10-13 12:08:50 +02:00
from spacepackets.ecss.tc import PusTelecommand
2022-07-03 20:58:32 +02:00
from tmtccmd.tc import QueueHelper
2022-05-18 23:40:13 +02:00
from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes
2021-07-14 00:28:33 +02:00
2021-10-13 12:08:50 +02:00
import common_tmtc.pus_tc.command_data as cmd_data
2021-07-14 01:27:38 +02:00
2021-07-14 00:28:33 +02:00
from common_tmtc.config.object_ids import TEST_DEVICE_0_ID
2022-07-03 20:58:32 +02:00
def pack_service_8_commands_into(q: QueueHelper, op_code: str):
2021-07-14 00:28:33 +02:00
if op_code == "0":
2022-07-03 20:58:32 +02:00
pack_generic_service_8_test_into(q=q)
2021-07-14 00:28:33 +02:00
else:
print(f"pack_service_8_test: Operation code {op_code} unknown!")
2022-07-03 20:58:32 +02:00
def pack_generic_service_8_test_into(q: QueueHelper):
q.add_log_cmd("Testing Service 8")
2021-07-14 00:28:33 +02:00
object_id = TEST_DEVICE_0_ID
# set mode on
2022-07-03 20:58:32 +02:00
q.add_log_cmd("Testing Service 8: Set On Mode")
2021-10-13 12:08:50 +02:00
mode_data = pack_mode_data(object_id, Modes.ON, 0)
2022-07-03 20:58:32 +02:00
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
2021-07-14 00:28:33 +02:00
# set mode normal
2022-07-03 20:58:32 +02:00
q.add_log_cmd("Testing Service 8: Set Normal Mode")
2021-10-13 12:08:50 +02:00
mode_data = pack_mode_data(object_id, Modes.NORMAL, 0)
2022-07-03 20:58:32 +02:00
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))
2021-07-14 00:28:33 +02:00
# Direct command which triggers completion reply
2022-07-03 20:58:32 +02:00
q.add_log_cmd("Testing Service 8: Trigger Step and Completion Reply")
2021-07-14 00:28:33 +02:00
action_id = cmd_data.TEST_COMMAND_0
direct_command = object_id + action_id
2022-07-03 20:58:32 +02:00
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=direct_command))
2021-07-14 00:28:33 +02:00
# Direct command which triggers _tm_data reply
2022-07-03 20:58:32 +02:00
q.add_log_cmd("Testing Service 8: Trigger Data Reply")
2021-07-14 00:28:33 +02:00
action_id = cmd_data.TEST_COMMAND_1
command_param1 = cmd_data.TEST_COMMAND_1_PARAM_1
command_param2 = cmd_data.TEST_COMMAND_1_PARAM_2
direct_command = object_id + action_id + command_param1 + command_param2
2022-07-03 20:58:32 +02:00
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=direct_command))
2021-07-14 00:28:33 +02:00
# Set mode off
2022-07-03 20:58:32 +02:00
q.add_log_cmd("Testing Service 8: Set Off Mode")
2022-05-18 23:40:13 +02:00
mode_data = pack_mode_data(object_id, Modes.OFF, 0)
2022-07-03 20:58:32 +02:00
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data))