From 95c5aa46d979328fd13244d042dfc440c400d924 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Mon, 16 Aug 2021 10:03:40 +0200 Subject: [PATCH] star tracker ping command --- config/definitions.py | 1 + config/hook_implementations.py | 6 ++++++ config/object_ids.py | 2 +- pus_tc/pdu1.py | 2 +- pus_tc/star_tracker.py | 39 ++++++++++++++++++++++++++++++++++ pus_tc/tc_packer_hook.py | 6 +++++- 6 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 pus_tc/star_tracker.py diff --git a/config/definitions.py b/config/definitions.py index 4e9809f..16884fc 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -31,3 +31,4 @@ class CustomServiceList(enum.Enum): PLOC_SUPV = "ploc_supv" PLOC_UPDATER = "ploc_updater" CORE = 'core' + STAR_TRACKER = 'star_tracker' diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 30043e7..7747761 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -154,6 +154,11 @@ class EiveHookObject(TmTcHookBase): } service_ploc_updater_tuple = ("Ploc Updater", op_code_dict_srv_ploc_updater) + op_code_dict_srv_star_tracker = { + "0": ("Star Tracker: Ping", {OpCodeDictKeys.TIMEOUT: 2.0}), + } + service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) + service_op_code_dict[CustomServiceList.P60DOCK.value] = service_p60_tuple service_op_code_dict[CustomServiceList.PDU1.value] = service_pdu1_tuple service_op_code_dict[CustomServiceList.PDU2.value] = service_pdu2_tuple @@ -166,6 +171,7 @@ class EiveHookObject(TmTcHookBase): service_op_code_dict[CustomServiceList.RAD_SENSOR.value] = service_rad_sensor_tuple service_op_code_dict[CustomServiceList.PLOC_SUPV.value] = service_ploc_supv_tuple service_op_code_dict[CustomServiceList.PLOC_UPDATER.value] = service_ploc_updater_tuple + service_op_code_dict[CustomServiceList.STAR_TRACKER.value] = service_star_tracker_tuple return service_op_code_dict def get_json_config_file_path(self) -> str: diff --git a/config/object_ids.py b/config/object_ids.py index 33ee78c..932dc50 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -23,7 +23,7 @@ RW1_ID = bytes([0x44, 0x12, 0x00, 0x1]) RW2_ID = bytes([0x44, 0x12, 0x00, 0x2]) RW3_ID = bytes([0x44, 0x12, 0x00, 0x3]) RW4_ID = bytes([0x44, 0x12, 0x00, 0x4]) -START_TRACKER_ID = bytes([0x44, 0x13, 0x00, 0x1]) +STAR_TRACKER_ID = bytes([0x44, 0x13, 0x00, 0x1]) RAD_SENSOR_ID = bytes([0x44, 0x32, 0x00, 0xA5]) PLOC_SUPV_ID = bytes([0x44, 0x33, 0x00, 0x16]) PLOC_UPDATER_ID = bytes([0x44, 0x33, 0x00, 0x00]) diff --git a/pus_tc/pdu1.py b/pus_tc/pdu1.py index be2ba43..8497fe2 100644 --- a/pus_tc/pdu1.py +++ b/pus_tc/pdu1.py @@ -46,7 +46,7 @@ def pack_pdu1_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str) command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "4": - tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn star racker off")) + tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn star tracker off")) command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address, PDUConfigTable.out_en_2.parameter_size, Channel.off) command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command) diff --git a/pus_tc/star_tracker.py b/pus_tc/star_tracker.py new file mode 100644 index 0000000..8edb2ed --- /dev/null +++ b/pus_tc/star_tracker.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +""" +@file star_tracker.py +@brief Star tracker commanding +@author J. Meier +@date 14.08.2021 +""" +import struct + +from tmtccmd.config.definitions import QueueCommands + +from tmtccmd.tc.packer import TcQueueT +from tmtccmd.ecss.tc import PusTelecommand + + +class StarTrackerActionIds: + PING = 0 + REQ_TEMPERATURE = 25 + + +def pack_star_tracker_commands_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT: + tc_queue.appendleft( + (QueueCommands.PRINT, + "Generate command for star tracker with object id: 0x" + object_id.hex()) + ) + + if op_code == "0": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Ping")) + command = pack_ping_command(object_id) + command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + + +def pack_ping_command(object_id: bytearray) -> bytearray: + data = int(input("Specify ping data: ")) + command = bytearray() + command = object_id + struct.pack('!I', StarTrackerActionIds.PING) + command = command + struct.pack('!I', data) + return command diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index 3ef0797..ffe5cb8 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -28,10 +28,11 @@ from pus_tc.reaction_wheels import pack_single_rw_test_into from pus_tc.rad_sensor import pack_rad_sensor_test_into from pus_tc.ploc_upater import pack_ploc_updater_test_into from pus_tc.core import pack_core_commands +from pus_tc.star_tracker import pack_star_tracker_commands_into from config.definitions import CustomServiceList from config.object_ids import P60_DOCK_HANDLER, PDU_1_HANDLER_ID, PDU_2_HANDLER_ID, ACU_HANDLER_ID, \ TMP_1075_1_HANDLER_ID, TMP_1075_2_HANDLER_ID, HEATER_ID, IMTQ_HANDLER_ID, PLOC_MPSOC_ID, RW1_ID, RW2_ID, RW3_ID, RW4_ID, \ - RAD_SENSOR_ID, PLOC_SUPV_ID, PLOC_UPDATER_ID + RAD_SENSOR_ID, PLOC_SUPV_ID, PLOC_UPDATER_ID, STAR_TRACKER_ID LOGGER = get_console_logger() @@ -95,6 +96,9 @@ def pack_service_queue_user(service: Union[str, int], op_code: str, service_queu if service == CustomServiceList.PLOC_UPDATER.value: object_id = PLOC_UPDATER_ID return pack_ploc_updater_test_into(object_id=object_id, tc_queue=service_queue, op_code=op_code) + if service == CustomServiceList.STAR_TRACKER.value: + object_id = STAR_TRACKER_ID + return pack_star_tracker_commands_into(object_id=object_id, tc_queue=service_queue, op_code=op_code) if service == CustomServiceList.CORE.value: return pack_core_commands(tc_queue=service_queue, op_code=op_code) LOGGER.warning("Invalid Service !")