diff --git a/config/hook_implementations.py b/config/hook_implementations.py index f88a15e..ea369ee 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -537,10 +537,24 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "47": ("Star Tracker: Unlock", {OpCodeDictKeys.TIMEOUT: 2.0}), "48": ("Star Tracker: Request camera parameter", {OpCodeDictKeys.TIMEOUT: 2.0}), "49": ("Star Tracker: Request limits", {OpCodeDictKeys.TIMEOUT: 2.0}), - "50": ("Star Tracker: Request blob parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "51": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "52": ("Star Tracker: (EGSE only) Load camera ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), - "53": ("Star Tracker: (EGSE only) Load camera flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), + "50": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "51": ("Star Tracker: (EGSE only) Load camera ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), + "52": ("Star Tracker: (EGSE only) Load camera flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), + "53": ("Star Tracker: Request log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "54": ("Star Tracker: Request mounting parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "55": ("Star Tracker: Request image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "56": ("Star Tracker: Request centroiding parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "57": ("Star Tracker: Request lisa parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "58": ("Star Tracker: Request matching parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "59": ("Star Tracker: Request tracking parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "60": ("Star Tracker: Request validation parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "61": ("Star Tracker: Request algo parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "62": ("Star Tracker: Request subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "63": ("Star Tracker: Request log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "64": ("Star Tracker: Request debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "65": ("Star Tracker: Set log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "66": ("Star Tracker: Set log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "67": ("Star Tracker: Set debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) diff --git a/pus_tc/star_tracker.py b/pus_tc/star_tracker.py index db146a0..78660c6 100644 --- a/pus_tc/star_tracker.py +++ b/pus_tc/star_tracker.py @@ -12,6 +12,9 @@ from tmtccmd.config.definitions import QueueCommands from tmtccmd.tc.packer import TcQueueT from spacepackets.ecss.tc import PusTelecommand from pus_tc.service_200_mode import pack_mode_data +from tmtccmd.utility.logger import get_console_logger + +LOGGER = get_console_logger() class StarTrackerActionIds: @@ -28,7 +31,7 @@ class StarTrackerActionIds: UPLOAD_IMAGE = 10 DOWNLOAD_CENTROID = 16 UPLOAD_CENTROID = 17 - SUBSCRIBE_TO_TM = 18 + SUBSCRIPTION = 18 IMAGE_PROCESSOR = 19 REQ_SOLUTION = 24 REQ_TEMPERATURE = 25 @@ -62,7 +65,21 @@ class StarTrackerActionIds: FPGA_ACTION = 66 REQ_CAMERA_PARAMS = 67 REQ_LIMITS = 68 - REQ_BLOB_PARAMS = 69 + REQ_LOG_LEVEL = 69 + REQ_MOUNTING = 70 + REQ_IMAGE_PROCESSOR = 71 + REQ_CENTROIDING = 72 + REQ_LISA = 73 + REQ_MATCHING = 74 + REQ_TRACKING = 75 + REQ_VALIDATION = 76 + REQ_ALGO = 77 + REQ_SUBSCRIPTION = 78 + REQ_LOG_SUBSCRIPTION = 79 + REQ_DEBUG_CAMERA = 80 + LOGLEVEL = 81 + LOG_SUBSCRIPTION = 82 + DEBUG_CAMERA = 83 class ImagePathDefs: @@ -78,6 +95,17 @@ class ImagePathDefs: uploadFpgaImageName = "/mnt/sd0/startracker/fpga-image.bin" egseGroundConfig = "/home/pi/arcsec/ground-config.json" egseFlightConfig = "/home/pi/arcsec/flight-config.json" + q7sGroundConfig = "/mnt/sd0/startracker/ground-config.json" + q7sFlightConfig = "/mnt/sd0/startracker/flight-config.json" + + +json_selection = { + "1": ["Q7S flight config", ImagePathDefs.q7sFlightConfig], + "2": ["Q7S ground config", ImagePathDefs.q7sGroundConfig], + "3": ["EGSE flight config", ImagePathDefs.egseFlightConfig], + "4": ["EGSE ground config", ImagePathDefs.egseGroundConfig] +} + class Region: # Definition according to datasheet (which turned out to be partially faulty) @@ -95,7 +123,7 @@ class PartitionSize: def pack_star_tracker_commands( - object_id: bytearray, tc_queue: TcQueueT, op_code: str + object_id: bytearray, tc_queue: TcQueueT, op_code: str ) -> TcQueueT: tc_queue.appendleft( ( @@ -160,13 +188,13 @@ def pack_star_tracker_commands( tc_queue.appendleft(command.pack_command_tuple()) if op_code == "10": tc_queue.appendleft( - (QueueCommands.PRINT, "Star tracker: Subscribe to telemetry") + (QueueCommands.PRINT, "Star tracker: Set subscription parameters") ) - tm_id = int(input("Specify Id of tm: ")) + jsonfile = get_config_file() command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.SUBSCRIBE_TO_TM) - + struct.pack("B", tm_id) + object_id + + struct.pack("!I", StarTrackerActionIds.SUBSCRIPTION) + + bytearray(jsonfile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=36, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -188,9 +216,9 @@ def pack_star_tracker_commands( if op_code == "14": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload image")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.UPLOAD_IMAGE) - + bytearray(ImagePathDefs.uploadFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.UPLOAD_IMAGE) + + bytearray(ImagePathDefs.uploadFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -200,18 +228,18 @@ def pack_star_tracker_commands( if not path: path = ImagePathDefs.downloadPath command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_IMAGE) - + bytearray(path, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_IMAGE) + + bytearray(path, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=53, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "16": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set limits")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.LIMITS) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.LIMITS) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=42, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -220,81 +248,82 @@ def pack_star_tracker_commands( (QueueCommands.PRINT, "Star tracker: Set tracking parameters") ) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.TRACKING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.TRACKING) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=43, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "18": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mounting")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.MOUNTING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.MOUNTING) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=44, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "19": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Camera")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CAMERA) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.CAMERA) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "20": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Blob")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.BLOB) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.BLOB) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=46, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "21": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Centroiding")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CENTROIDING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.CENTROIDING) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=47, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "22": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: LISA")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.LISA) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.LISA) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=48, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "23": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Matching")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.MATCHING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.MATCHING) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=49, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "24": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Validation")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.VALIDATION) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.VALIDATION) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=50, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "25": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Algo")) + jsonfile = get_config_file() command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.ALGO) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.ALGO) + + bytearray(jsonfile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=51, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -302,9 +331,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Take image")) actionid = int(input("Specify parameter ID (nominal - 4): ")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.TAKE_IMAGE) - + struct.pack("!B", actionid) + object_id + + struct.pack("!I", StarTrackerActionIds.TAKE_IMAGE) + + struct.pack("!B", actionid) ) command = PusTelecommand(service=8, subservice=128, ssc=52, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -324,9 +353,9 @@ def pack_star_tracker_commands( ) filename = input("Specify download image name: ") command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CHANGE_DOWNLOAD_IMAGE) - + bytearray(filename, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.CHANGE_DOWNLOAD_IMAGE) + + bytearray(filename, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=54, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -343,9 +372,9 @@ def pack_star_tracker_commands( if op_code == "32": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set json filename")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.SET_JSON_FILE_NAME) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.SET_JSON_FILE_NAME) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=57, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -363,9 +392,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set read filename")) filename = input("Specify filename: ") command = ( - object_id - + StarTrackerActionIds.SET_READ_FILENAME - + bytearray(filename, "utf-8") + object_id + + StarTrackerActionIds.SET_READ_FILENAME + + bytearray(filename, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=60, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -378,9 +407,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set time")) unix_time = 1640783543 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.SET_TIME) - + struct.pack("!Q", unix_time) + object_id + + struct.pack("!I", StarTrackerActionIds.SET_TIME) + + struct.pack("!Q", unix_time) ) command = PusTelecommand(service=8, subservice=128, ssc=61, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -388,18 +417,18 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download Centroid")) id = 0 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_CENTROID) - + struct.pack("!B", id) + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_CENTROID) + + struct.pack("!B", id) ) command = PusTelecommand(service=8, subservice=128, ssc=62, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "39": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload Centroid")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.UPLOAD_CENTROID) - + bytearray(ImagePathDefs.uploadCentroidJson, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.UPLOAD_CENTROID) + + bytearray(ImagePathDefs.uploadCentroidJson, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=63, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -409,9 +438,9 @@ def pack_star_tracker_commands( ) id = 0 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_MATCHED_STAR) - + struct.pack("!B", id) + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_MATCHED_STAR) + + struct.pack("!B", id) ) command = PusTelecommand(service=8, subservice=128, ssc=64, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -419,9 +448,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download DB Image")) id = 0 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_DBIMAGE) - + struct.pack("!B", id) + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_DBIMAGE) + + struct.pack("!B", id) ) command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -430,10 +459,10 @@ def pack_star_tracker_commands( id = 0 type = 1 # 0 - normal, 1 - fast command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_BLOBPIXEL) - + struct.pack("!B", id) - + struct.pack("!B", type) + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_BLOBPIXEL) + + struct.pack("!B", id) + + struct.pack("!B", type) ) command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -442,11 +471,11 @@ def pack_star_tracker_commands( position = int(input("Start position: ")) length = int(input("Size to download: ")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_FPGA_IMAGE) - + struct.pack("!I", position) - + struct.pack("!I", length) - + bytearray(ImagePathDefs.downloadFpgaImagePath, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_FPGA_IMAGE) + + struct.pack("!I", position) + + struct.pack("!I", length) + + bytearray(ImagePathDefs.downloadFpgaImagePath, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=66, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -455,18 +484,18 @@ def pack_star_tracker_commands( (QueueCommands.PRINT, "Star tracker: Change donwload FPGA image file name") ) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CHANGE_FPGA_DOWNLOAD_FILE) - + bytearray(ImagePathDefs.downloadFpgaImageName, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.CHANGE_FPGA_DOWNLOAD_FILE) + + bytearray(ImagePathDefs.downloadFpgaImageName, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=67, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "45": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload FPGA image")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.UPLOAD_FPGA_IMAGE) - + bytearray(ImagePathDefs.uploadFpgaImageName, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.UPLOAD_FPGA_IMAGE) + + bytearray(ImagePathDefs.uploadFpgaImageName, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=68, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -474,9 +503,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: FPGA action")) id = 3 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.FPGA_ACTION) - + struct.pack("!B", id) + object_id + + struct.pack("!I", StarTrackerActionIds.FPGA_ACTION) + + struct.pack("!B", id) ) command = PusTelecommand(service=8, subservice=128, ssc=69, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -498,41 +527,112 @@ def pack_star_tracker_commands( command = PusTelecommand(service=8, subservice=128, ssc=72, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "50": - tc_queue.appendleft( - (QueueCommands.PRINT, "Star tracker: Request blob parameters") - ) - command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_BLOB_PARAMS) - command = PusTelecommand(service=8, subservice=128, ssc=73, app_data=command) - tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "51": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set image processor parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.IMAGE_PROCESSOR) + \ bytearray(ImagePathDefs.jsonFile, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "52": + if op_code == "51": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load ground config camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ bytearray(ImagePathDefs.egseGroundConfig, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=71, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "53": + if op_code == "52": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load flight config camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ bytearray(ImagePathDefs.egseFlightConfig, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=72, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "53": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request log level parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LOG_LEVEL) + command = PusTelecommand(service=8, subservice=128, ssc=74, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "54": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request mounting parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_MOUNTING) + command = PusTelecommand(service=8, subservice=128, ssc=75, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "55": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request image processor parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_IMAGE_PROCESSOR) + command = PusTelecommand(service=8, subservice=128, ssc=76, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "56": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request centroiding parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_CENTROIDING) + command = PusTelecommand(service=8, subservice=128, ssc=75, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "57": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request lisa parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LISA) + command = PusTelecommand(service=8, subservice=128, ssc=76, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "58": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request matching parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_MATCHING) + command = PusTelecommand(service=8, subservice=128, ssc=77, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "59": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request tracking parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_TRACKING) + command = PusTelecommand(service=8, subservice=128, ssc=78, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "60": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request validation parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_VALIDATION) + command = PusTelecommand(service=8, subservice=128, ssc=79, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "61": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request algo parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_ALGO) + command = PusTelecommand(service=8, subservice=128, ssc=80, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "62": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request subscription parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_SUBSCRIPTION) + command = PusTelecommand(service=8, subservice=128, ssc=81, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "63": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request log subscription parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LOG_SUBSCRIPTION) + command = PusTelecommand(service=8, subservice=128, ssc=82, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "64": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request debug camera parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_DEBUG_CAMERA) + command = PusTelecommand(service=8, subservice=128, ssc=83, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "65": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set log level parameters")) + jsonfile = get_config_file() + command = object_id + struct.pack('!I', StarTrackerActionIds.LOGLEVEL) + bytearray(jsonfile, "utf-8") + command = PusTelecommand(service=8, subservice=128, ssc=84, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "66": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set log subscription parameters")) + jsonfile = get_config_file() + command = object_id + struct.pack('!I', StarTrackerActionIds.LOG_SUBSCRIPTION) + bytearray(jsonfile, "utf-8") + command = PusTelecommand(service=8, subservice=128, ssc=85, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "67": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set debug camera parameters")) + jsonfile = get_config_file() + command = object_id + struct.pack('!I', StarTrackerActionIds.DEBUG_CAMERA) + bytearray(jsonfile, "utf-8") + command = PusTelecommand(service=8, subservice=128, ssc=85, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) def pack_write_command(object_id: bytearray) -> bytearray: region = Region.FREE_1 address = 0 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.WRITE) - + struct.pack("!B", region) - + struct.pack("!I", address) - + bytearray(ImagePathDefs.flashFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.WRITE) + + struct.pack("!B", region) + + struct.pack("!I", address) + + bytearray(ImagePathDefs.flashFile, "utf-8") ) return command @@ -542,12 +642,12 @@ def pack_read_command(object_id: bytearray) -> bytearray: address = 0 size = PartitionSize.STAR_TRACKER_FIRMWARE command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.READ) - + struct.pack("!B", region) - + struct.pack("!I", address) - + struct.pack("!I", size) - + bytearray(ImagePathDefs.flashReadPath, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.READ) + + struct.pack("!B", region) + + struct.pack("!I", address) + + struct.pack("!I", size) + + bytearray(ImagePathDefs.flashReadPath, "utf-8") ) return command @@ -557,10 +657,37 @@ def pack_checksum_command(object_id: bytearray) -> bytearray: address = 0 size = PartitionSize.STAR_TRACKER_FIRMWARE command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CHECKSUM) - + struct.pack("!B", region) - + struct.pack("!I", address) - + struct.pack("!I", size) + object_id + + struct.pack("!I", StarTrackerActionIds.CHECKSUM) + + struct.pack("!B", region) + + struct.pack("!I", address) + + struct.pack("!I", size) ) return command + + +def get_config_file() -> str: + LOGGER.info("Specify json file to use") + key = get_json_file_key() + while key not in json_selection: + LOGGER.info("Invalid key specified, try again.") + key = get_json_file_key() + jsonfile = json_selection[key][1] + return jsonfile + + +def get_json_file_key(): + key_column_width = 10 + description_column_width = 50 + separator_width = key_column_width + description_column_width + 3 + separator_string = separator_width * "-" + key_string = "Key".ljust(key_column_width) + description_string = "Description".ljust(description_column_width) + LOGGER.info(f"{key_string} | {description_string}") + LOGGER.info(separator_string) + for key in json_selection: + key_string = key.ljust(key_column_width) + description_string = json_selection[key][0].ljust(description_column_width) + LOGGER.info(f"{key_string} | {description_string}") + key = input("Specify key: ") + return key