86 lines
4.0 KiB
Python
86 lines
4.0 KiB
Python
# -*- 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 spacepackets.ecss.tc import PusTelecommand
|
|
|
|
|
|
class StarTrackerActionIds:
|
|
PING = 0
|
|
BOOT = 1
|
|
REQ_VERSION = 2
|
|
REQ_INTERFACE = 3
|
|
REQ_TIME = 4
|
|
REQ_POWER = 11
|
|
REBOOT = 7
|
|
SUBSCRIBE_TO_TM = 18
|
|
REQ_SOLUTION = 24
|
|
REQ_TEMPERATURE = 25
|
|
|
|
|
|
def pack_star_tracker_commands(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 = object_id + struct.pack('!I', StarTrackerActionIds.PING)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "1":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Reboot star tracker"))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.REBOOT)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "2":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Temperature request"))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_TEMPERATURE)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "3":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request version"))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_VERSION)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=33, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "4":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request interface"))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_INTERFACE)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=34, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "5":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request power"))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_POWER)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=35, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "6":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Subscribe to telemetry"))
|
|
tm_id = int(input("Specify Id of tm: "))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.SUBSCRIBE_TO_TM) + struct.pack('B', tm_id)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=36, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "7":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Boot"))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.BOOT)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=37, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "8":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request time"))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_TIME)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=38, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
if op_code == "9":
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request solution"))
|
|
command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_SOLUTION)
|
|
command = PusTelecommand(service=8, subservice=128, ssc=39, app_data=command)
|
|
tc_queue.appendleft(command.pack_command_tuple())
|