str image helpercommands

This commit is contained in:
Jakob Meier 2021-12-02 08:01:18 +01:00
parent 1d374230b3
commit dedb28497f
8 changed files with 127 additions and 27 deletions

View File

@ -38,3 +38,4 @@ class CustomServiceList(enum.Enum):
STAR_TRACKER = 'star_tracker' STAR_TRACKER = 'star_tracker'
CCSDS_HANDLER = 'ccsds_handler' CCSDS_HANDLER = 'ccsds_handler'
PDEC_HANDLER = 'pdec_handler' PDEC_HANDLER = 'pdec_handler'
STR_IMG_HELPER = 'str_img_helper'

View File

@ -279,6 +279,15 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT):
op_code_dict_srv_star_tracker = { op_code_dict_srv_star_tracker = {
"0": ("Star Tracker: Ping", {OpCodeDictKeys.TIMEOUT: 2.0}), "0": ("Star Tracker: Ping", {OpCodeDictKeys.TIMEOUT: 2.0}),
"1": ("Star Tracker: Reboot", {OpCodeDictKeys.TIMEOUT: 2.0}),
"2": ("Star Tracker: Request temperature", {OpCodeDictKeys.TIMEOUT: 2.0}),
"3": ("Star Tracker: Request version", {OpCodeDictKeys.TIMEOUT: 2.0}),
"4": ("Star Tracker: Request interface", {OpCodeDictKeys.TIMEOUT: 2.0}),
"5": ("Star Tracker: Request power", {OpCodeDictKeys.TIMEOUT: 2.0}),
"6": ("Star Tracker: Subscribe to telemetry", {OpCodeDictKeys.TIMEOUT: 2.0}),
"7": ("Star Tracker: Boot image (requires bootloader mode)", {OpCodeDictKeys.TIMEOUT: 2.0}),
"8": ("Star Tracker: Request time", {OpCodeDictKeys.TIMEOUT: 2.0}),
"9": ("Star Tracker: Request solution", {OpCodeDictKeys.TIMEOUT: 2.0})
} }
service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker)
@ -295,6 +304,11 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT):
} }
service_pdec_handler_tuple = ("PDEC Handler", op_code_dict_srv_pdec_handler) service_pdec_handler_tuple = ("PDEC Handler", op_code_dict_srv_pdec_handler)
op_code_dict_srv_str_img_helper = {
"0": ("Star Tracker Image Helper: Upload image", {OpCodeDictKeys.TIMEOUT: 2.0}),
}
service_str_img_helper_tuple = ("PDEC Handler", op_code_dict_srv_str_img_helper)
service_op_code_dict[CustomServiceList.P60DOCK.value] = service_p60_tuple 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.PDU1.value] = service_pdu1_tuple
service_op_code_dict[CustomServiceList.PDU2.value] = service_pdu2_tuple service_op_code_dict[CustomServiceList.PDU2.value] = service_pdu2_tuple
@ -311,3 +325,4 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT):
service_op_code_dict[CustomServiceList.PLOC_MEMORY_DUMPER.value] = service_ploc_memory_dumper_tuple service_op_code_dict[CustomServiceList.PLOC_MEMORY_DUMPER.value] = service_ploc_memory_dumper_tuple
service_op_code_dict[CustomServiceList.CCSDS_HANDLER.value] = service_ccsds_handler_tuple service_op_code_dict[CustomServiceList.CCSDS_HANDLER.value] = service_ccsds_handler_tuple
service_op_code_dict[CustomServiceList.PDEC_HANDLER.value] = service_pdec_handler_tuple service_op_code_dict[CustomServiceList.PDEC_HANDLER.value] = service_pdec_handler_tuple
service_op_code_dict[CustomServiceList.STR_IMG_HELPER.value] = service_str_img_helper_tuple

View File

@ -53,6 +53,7 @@ RAD_SENSOR_ID = bytes([0x44, 0x32, 0x00, 0xA5])
PLOC_SUPV_ID = bytes([0x44, 0x33, 0x00, 0x16]) PLOC_SUPV_ID = bytes([0x44, 0x33, 0x00, 0x16])
PLOC_UPDATER_ID = bytes([0x44, 0x33, 0x00, 0x00]) PLOC_UPDATER_ID = bytes([0x44, 0x33, 0x00, 0x00])
PLOC_MEMORY_DUMPER_ID = bytes([0x44, 0x33, 0x00, 0x01]) PLOC_MEMORY_DUMPER_ID = bytes([0x44, 0x33, 0x00, 0x01])
STR_IMG_HELPER_ID = bytes([0x44, 0x33, 0x00, 0x02])
PLOC_MPSOC_ID = bytes([0x44, 0x33, 0x00, 0x15]) PLOC_MPSOC_ID = bytes([0x44, 0x33, 0x00, 0x15])

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""PDU2 is mounted on the X4 slot of the P60 dock """PDU2 is mounted on the X2 slot of the P60 dock
@author J. Meier @author J. Meier
@date 17.12.2020 @date 17.12.2020
""" """
@ -65,16 +65,16 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
PDUConfigTable.out_en_2.parameter_size, Channel.on PDUConfigTable.out_en_2.parameter_size, Channel.on
) )
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SUS_NOMINAL_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal on"))
command = pack_set_param_command(object_id, PDUConfigTable.out_en_4.parameter_address,
PDUConfigTable.out_en_4.parameter_size, Channel.on)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.STAR_TRACKER_OFF.value: if op_code == Pdu1OpCodes.STAR_TRACKER_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn star tracker off")) tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn star tracker off"))
command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address, command = pack_set_param_command(object_id, PDUConfigTable.out_en_2.parameter_address,
PDUConfigTable.out_en_2.parameter_size, Channel.off) PDUConfigTable.out_en_2.parameter_size, Channel.off)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SUS_NOMINAL_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal on"))
command = pack_set_param_command(object_id, PDUConfigTable.out_en_4.parameter_address,
PDUConfigTable.out_en_4.parameter_size, Channel.on)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SUS_NOMINAL_OFF.value: if op_code == Pdu1OpCodes.SUS_NOMINAL_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal off")) tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal off"))
command = pack_set_param_command( command = pack_set_param_command(
@ -96,13 +96,6 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str):
PDUConfigTable.out_en_7.parameter_size, Channel.off PDUConfigTable.out_en_7.parameter_size, Channel.off
) )
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SUS_NOMINAL_ON.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal on"))
command = pack_set_param_command(
object_id, PDUConfigTable.out_en_4.parameter_address,
PDUConfigTable.out_en_4.parameter_size, Channel.on
)
tc_queue.appendleft(command.pack_command_tuple())
if op_code == Pdu1OpCodes.SUS_NOMINAL_OFF.value: if op_code == Pdu1OpCodes.SUS_NOMINAL_OFF.value:
tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal off")) tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn SUS nominal off"))
command = pack_set_param_command( command = pack_set_param_command(

View File

@ -2,7 +2,7 @@
""" """
@file tmtcc_tc_pdu2.py @file tmtcc_tc_pdu2.py
@brief PDU2 tests @brief PDU2 tests
@details PDU2 is mounted on the X2 slot of the P60 dock @details PDU2 is mounted on the X4 slot of the P60 dock
@author J. Meier @author J. Meier
@date 17.12.2020 @date 17.12.2020
""" """

View File

@ -15,10 +15,18 @@ from spacepackets.ecss.tc import PusTelecommand
class StarTrackerActionIds: class StarTrackerActionIds:
PING = 0 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 REQ_TEMPERATURE = 25
def pack_star_tracker_commands_into(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT: def pack_star_tracker_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT:
tc_queue.appendleft( tc_queue.appendleft(
(QueueCommands.PRINT, (QueueCommands.PRINT,
"Generate command for star tracker with object id: 0x" + object_id.hex()) "Generate command for star tracker with object id: 0x" + object_id.hex())
@ -26,14 +34,52 @@ def pack_star_tracker_commands_into(object_id: bytearray, tc_queue: TcQueueT, op
if op_code == "0": if op_code == "0":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Ping")) tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Ping"))
command = pack_ping_command(object_id) command = object_id + struct.pack('!I', StarTrackerActionIds.PING)
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command) command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code == "1":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Reboot star tracker"))
def pack_ping_command(object_id: bytearray) -> bytearray: command = object_id + struct.pack('!I', StarTrackerActionIds.REBOOT)
data = int(input("Specify ping data: ")) command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
command = bytearray() tc_queue.appendleft(command.pack_command_tuple())
command = object_id + struct.pack('!I', StarTrackerActionIds.PING) if op_code == "2":
command = command + struct.pack('!I', data) tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Temperature request"))
return command 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())

38
pus_tc/str_img_helper.py Normal file
View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
"""
@file str_img_helper.py
@brief Commanding of the star tracker image helper object which is responsible for uploading
and downloading images to/from the star tracker.
@details Images to uplaod must be previously transferred to the OBC with the CFDP protocol.
Also downloaded images will be stored on the filesystem of the OBC and can be transferred via CFDP.
@author J. Meier
@date 29.11.2021
"""
import struct
from tmtccmd.config.definitions import QueueCommands
from tmtccmd.tc.packer import TcQueueT
from spacepackets.ecss.tc import PusTelecommand
class Commands:
UPLOAD_IMAGE = 0
DOWNLOAD_IMAGE = 1
class ImagePathDefs:
uploadFile = "/mnt/sd0/startracker/gemma.bin"
def pack_str_img_helper_command(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT:
tc_queue.appendleft(
(QueueCommands.PRINT,
"Testing star tracker image helper object id: 0x" + object_id.hex())
)
if op_code == "0":
tc_queue.appendleft((QueueCommands.PRINT, "Star tracker image helper: Upload image"))
command = object_id + struct.pack('!I', Commands.UPLOAD_IMAGE) + bytearray(ImagePathDefs.uploadFile, 'utf-8')
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())

View File

@ -26,15 +26,16 @@ from pus_tc.ploc_upater import pack_ploc_updater_test_into
from pus_tc.ploc_memory_dumper import pack_ploc_memory_dumper_cmd from pus_tc.ploc_memory_dumper import pack_ploc_memory_dumper_cmd
from pus_tc.ccsds_handler import pack_ccsds_handler_test from pus_tc.ccsds_handler import pack_ccsds_handler_test
from pus_tc.core import pack_core_commands from pus_tc.core import pack_core_commands
from pus_tc.star_tracker import pack_star_tracker_commands_into from pus_tc.star_tracker import pack_star_tracker_commands
from pus_tc.gps import pack_gps_command from pus_tc.gps import pack_gps_command
from pus_tc.acs import pack_acs_command from pus_tc.acs import pack_acs_command
from pus_tc.str_img_helper import pack_str_img_helper_command
from config.definitions import CustomServiceList from config.definitions import CustomServiceList
from config.object_ids import P60_DOCK_HANDLER, PDU_1_HANDLER_ID, PDU_2_HANDLER_ID, \ 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, \ 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, \ PLOC_MPSOC_ID, RW1_ID, RW2_ID, RW3_ID, RW4_ID, RAD_SENSOR_ID, PLOC_SUPV_ID, PLOC_UPDATER_ID, \
STAR_TRACKER_ID, PLOC_MEMORY_DUMPER_ID, GPS_HANDLER_0_ID, GPS_HANDLER_1_ID, CCSDS_HANDLER_ID, \ STAR_TRACKER_ID, PLOC_MEMORY_DUMPER_ID, GPS_HANDLER_0_ID, GPS_HANDLER_1_ID, CCSDS_HANDLER_ID, \
PDEC_HANDLER_ID PDEC_HANDLER_ID, STR_IMG_HELPER_ID
LOGGER = get_console_logger() LOGGER = get_console_logger()
@ -103,7 +104,12 @@ def pack_service_queue_user(service: Union[str, int], op_code: str, service_queu
) )
if service == CustomServiceList.STAR_TRACKER.value: if service == CustomServiceList.STAR_TRACKER.value:
object_id = STAR_TRACKER_ID object_id = STAR_TRACKER_ID
return pack_star_tracker_commands_into( return pack_star_tracker_commands(
object_id=object_id, tc_queue=service_queue, op_code=op_code
)
if service == CustomServiceList.STR_IMG_HELPER.value:
object_id = STR_IMG_HELPER_ID
return pack_str_img_helper_command(
object_id=object_id, tc_queue=service_queue, op_code=op_code object_id=object_id, tc_queue=service_queue, op_code=op_code
) )
if service == CustomServiceList.CORE.value: if service == CustomServiceList.CORE.value: