From a5cc03d8a02362edb024e0c392d7e5491fa16d6e Mon Sep 17 00:00:00 2001 From: Julia Zink Date: Fri, 10 Mar 2023 13:16:14 +0100 Subject: [PATCH 1/5] added missing str parameters --- eive_tmtc/tmtc/acs/star_tracker.py | 239 +++++++++++++++-------------- 1 file changed, 120 insertions(+), 119 deletions(-) diff --git a/eive_tmtc/tmtc/acs/star_tracker.py b/eive_tmtc/tmtc/acs/star_tracker.py index cafa2e2..5b26110 100644 --- a/eive_tmtc/tmtc/acs/star_tracker.py +++ b/eive_tmtc/tmtc/acs/star_tracker.py @@ -12,14 +12,13 @@ import struct from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.pus_tm.defs import PrintWrapper +from eive_tmtc.utility.input_helper import InputHelper from spacepackets.ecss.tc import PusTelecommand from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider -from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode - from tmtccmd.tc import DefaultPusQueueHelper +from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode from tmtccmd.util import ObjectIdU32 -from eive_tmtc.utility.input_helper import InputHelper from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter _LOGGER = logging.getLogger(__name__) @@ -175,7 +174,7 @@ class Submode: def pack_star_tracker_commands( - object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str + object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str ): q.add_log_cmd( f"Generate command for star tracker with object id: {object_id.as_hex_string}" @@ -231,9 +230,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set subscription parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.SUBSCRIPTION) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.SUBSCRIPTION) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "12": @@ -252,9 +251,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Upload image") image = get_upload_image() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.UPLOAD_IMAGE) - + bytearray(image, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.UPLOAD_IMAGE) + + bytearray(image, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "16": @@ -263,99 +262,99 @@ def pack_star_tracker_commands( if not path: path = FileDefs.download_path data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_IMAGE) - + bytearray(path, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_IMAGE) + + bytearray(path, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "17": q.add_log_cmd("Star tracker: Set limits") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.LIMITS) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.LIMITS) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "18": q.add_log_cmd("Star tracker: Set tracking parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.TRACKING) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.TRACKING) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "19": q.add_log_cmd("Star tracker: Mounting") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.MOUNTING) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.MOUNTING) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "20": q.add_log_cmd("Star tracker: Camera") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CAMERA) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CAMERA) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "22": q.add_log_cmd("Star tracker: Centroiding") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CENTROIDING) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CENTROIDING) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "23": q.add_log_cmd("Star tracker: LISA") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.LISA) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.LISA) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "24": q.add_log_cmd("Star tracker: Matching") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.MATCHING) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.MATCHING) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "25": q.add_log_cmd("Star tracker: Validation") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.VALIDATION) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.VALIDATION) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "26": q.add_log_cmd("Star tracker: Algo") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.ALGO) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.ALGO) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "27": q.add_log_cmd("Star tracker: Take image") actionid = int(input("Specify parameter ID (take image - 4): ")) data = ( - obyt - + struct.pack("!I", StarTrackerActionId.TAKE_IMAGE) - + struct.pack("!B", actionid) + obyt + + struct.pack("!I", StarTrackerActionId.TAKE_IMAGE) + + struct.pack("!B", actionid) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "28": @@ -366,9 +365,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set name of download image") filename = input("Specify download image name: ") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CHANGE_DOWNLOAD_IMAGE) - + bytearray(filename, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CHANGE_DOWNLOAD_IMAGE) + + bytearray(filename, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "31": @@ -383,9 +382,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set json filename") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.SET_JSON_FILE_NAME) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.SET_JSON_FILE_NAME) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "35": @@ -396,9 +395,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set flash read filename") filename = input("Specify filename: ") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.SET_FLASH_READ_FILENAME) - + bytearray(filename, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.SET_FLASH_READ_FILENAME) + + bytearray(filename, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "37": @@ -409,36 +408,36 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set time") unix_time = 1640783543 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.SET_TIME) - + struct.pack("!Q", unix_time) + obyt + + struct.pack("!I", StarTrackerActionId.SET_TIME) + + struct.pack("!Q", unix_time) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "39": q.add_log_cmd("Star tracker: Download Centroid") id = 0 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_CENTROID) - + struct.pack("!B", id) + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_CENTROID) + + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "41": q.add_log_cmd("Star tracker: Download matched star") id = 0 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_MATCHED_STAR) - + struct.pack("!B", id) + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_MATCHED_STAR) + + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "42": q.add_log_cmd("Star tracker: Download DB Image") id = 0 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_DBIMAGE) - + struct.pack("!B", id) + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_DBIMAGE) + + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "43": @@ -446,10 +445,10 @@ def pack_star_tracker_commands( id = 0 type = 1 # 0 - normal, 1 - fast data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_BLOBPIXEL) - + struct.pack("!B", id) - + struct.pack("!B", type) + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_BLOBPIXEL) + + struct.pack("!B", id) + + struct.pack("!B", type) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "44": @@ -457,36 +456,36 @@ def pack_star_tracker_commands( position = int(input("Start position: ")) length = int(input("Size to download: ")) data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_FPGA_IMAGE) - + struct.pack("!I", position) - + struct.pack("!I", length) - + bytearray(FileDefs.downloadFpgaImagePath, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_FPGA_IMAGE) + + struct.pack("!I", position) + + struct.pack("!I", length) + + bytearray(FileDefs.downloadFpgaImagePath, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "45": q.add_log_cmd("Star tracker: Change donwload FPGA image file name") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CHANGE_FPGA_DOWNLOAD_FILE) - + bytearray(FileDefs.downloadFpgaImageName, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CHANGE_FPGA_DOWNLOAD_FILE) + + bytearray(FileDefs.downloadFpgaImageName, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "46": q.add_log_cmd("Star tracker: Upload FPGA image") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.UPLOAD_FPGA_IMAGE) - + bytearray(FileDefs.uploadFpgaImageName, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.UPLOAD_FPGA_IMAGE) + + bytearray(FileDefs.uploadFpgaImageName, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "47": q.add_log_cmd("Star tracker: FPGA action") id = 3 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.FPGA_ACTION) - + struct.pack("!B", id) + obyt + + struct.pack("!I", StarTrackerActionId.FPGA_ACTION) + + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "48": @@ -505,25 +504,25 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set image processor parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.IMAGE_PROCESSOR) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.IMAGE_PROCESSOR) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "52": q.add_log_cmd("Star tracker: EGSE load ground config camera parameters") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CAMERA) - + bytearray(FileDefs.egse_ground_config, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CAMERA) + + bytearray(FileDefs.egse_ground_config, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "53": q.add_log_cmd("Star tracker: EGSE load flight config camera parameters") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CAMERA) - + bytearray(FileDefs.egse_flight_config, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CAMERA) + + bytearray(FileDefs.egse_flight_config, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "54": @@ -578,9 +577,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set log level parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.LOGLEVEL) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.LOGLEVEL) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "67": @@ -588,27 +587,27 @@ def pack_star_tracker_commands( json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.LOG_SUBSCRIPTION) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.LOG_SUBSCRIPTION) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "68": q.add_log_cmd("Star tracker: Set debug camera parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DEBUG_CAMERA) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.DEBUG_CAMERA) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "69": q.add_log_cmd("Star tracker: Firmware update") firmware = get_firmware() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.FIRMWARE_UPDATE) - + bytearray(firmware, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.FIRMWARE_UPDATE) + + bytearray(firmware, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "70": @@ -632,11 +631,11 @@ def pack_read_command(object_id: bytes) -> bytearray: if not path: path = FileDefs.download_path data = ( - object_id - + struct.pack("!I", StarTrackerActionId.FLASH_READ) - + struct.pack("!B", start_region) - + struct.pack("!I", size) - + bytearray(path, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionId.FLASH_READ) + + struct.pack("!B", start_region) + + struct.pack("!I", size) + + bytearray(path, "utf-8") ) return bytearray(data) @@ -646,11 +645,11 @@ def pack_checksum_command(object_id: bytes) -> bytearray: address = 0 size = PartitionSize.STAR_TRACKER_FIRMWARE data = ( - object_id - + struct.pack("!I", StarTrackerActionId.CHECKSUM) - + struct.pack("!B", start_region) - + struct.pack("!I", address) - + struct.pack("!I", size) + object_id + + struct.pack("!I", StarTrackerActionId.CHECKSUM) + + struct.pack("!B", start_region) + + struct.pack("!I", address) + + struct.pack("!I", size) ) return bytearray(data) @@ -694,7 +693,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper): current_idx = 0 fmt_len = struct.calcsize(ticks_time_fmt) (ticks, unix_time) = struct.unpack( - ticks_time_fmt, hk_data[current_idx : current_idx + fmt_len] + ticks_time_fmt, hk_data[current_idx: current_idx + fmt_len] ) unix_as_dt = datetime.datetime.fromtimestamp(unix_time, tz=datetime.timezone.utc) pw.dlog(f"Ticks: {ticks} | UNIX time: {unix_time}") @@ -703,7 +702,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper): calib_quaternions_fmt = "!ffff" fmt_len = struct.calcsize(calib_quaternions_fmt) (calib_q_w, calib_q_x, calib_q_y, calib_q_z) = struct.unpack( - calib_quaternions_fmt, hk_data[current_idx : current_idx + fmt_len] + calib_quaternions_fmt, hk_data[current_idx: current_idx + fmt_len] ) pw.dlog("Calibrated Quaternions") pw.dlog(f"Quaternion w: {calib_q_w}") @@ -714,7 +713,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper): track_fmt = "!fffff" fmt_len = struct.calcsize(track_fmt) (track_confidence, track_q_w, track_q_x, track_q_y, track_q_z) = struct.unpack( - track_fmt, hk_data[current_idx : current_idx + fmt_len] + track_fmt, hk_data[current_idx: current_idx + fmt_len] ) pw.dlog(f"Track Confidence: {track_confidence}") pw.dlog(f"Track QW: {track_q_w}") @@ -734,18 +733,20 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper): # Result of LISA: Lost in space algorithm lisa_fmt = "!fffffB" fmt_len = struct.calcsize(track_fmt) - (lisa_q_w, lisa_q_x, lisa_q_y, lisa_q_z) = struct.unpack( - lisa_fmt, hk_data[current_idx : current_idx + fmt_len] + (lisa_q_w, lisa_q_x, lisa_q_y, lisa_q_z, lisa_percentage_close_stars, lisa_number_close_stars) = struct.unpack( + lisa_fmt, hk_data[current_idx: current_idx + fmt_len] ) pw.dlog(f"LISA QW: {lisa_q_w}") pw.dlog(f"LISA QX: {lisa_q_x}") pw.dlog(f"LISA QY: {lisa_q_y}") pw.dlog(f"LISA QZ: {lisa_q_z}") + pw.dlog(f"Percentage of close stars in LISA solution: {lisa_percentage_close_stars}") + pw.dlog(f"Number of close stars in LISA solution: {lisa_number_close_stars}") current_idx += fmt_len is_trusworthy = hk_data[current_idx] pw.dlog(f"Trustworthy solution: {is_trusworthy}") current_idx += 1 - stable_count = struct.unpack("!I", hk_data[current_idx : current_idx + 4]) + stable_count = struct.unpack("!I", hk_data[current_idx: current_idx + 4]) pw.dlog(f"Stable count: {stable_count}") current_idx += 4 solution_strategy = hk_data[current_idx] From a249d7184011e2c739b5145f4dff74dccaa7020d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 10 Mar 2023 13:37:17 +0100 Subject: [PATCH 2/5] changelog --- CHANGELOG.md | 4 +++ eive_tmtc/tmtc/acs/acs_ctrl.py | 54 ++++++++++++++------------------- eive_tmtc/tmtc/acs/defs.py | 16 ++++++++++ eive_tmtc/tmtc/acs/subsystem.py | 34 ++++++++------------- 4 files changed, 54 insertions(+), 54 deletions(-) create mode 100644 eive_tmtc/tmtc/acs/defs.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 4050bc5..d027013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ list yields a list of all related PRs for each release. # [unreleased] +## Changed + +- ACS mode changes: The ACS CTRL submodes are now modes. DETUBMLE is now submode of SAFE mode. + # [v2.17.3] 2023-03-09 ## Fixed diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index a97a3e8..f588520 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -8,6 +8,7 @@ from typing import Tuple from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import ACS_CONTROLLER from eive_tmtc.pus_tm.defs import PrintWrapper +from eive_tmtc.tmtc.acs.defs import AcsMode, SafeSubmode from tmtccmd.config.tmtc import ( tmtc_definitions_provider, TmtcDefinitionWrapper, @@ -55,17 +56,6 @@ class SetId(enum.IntEnum): ACTUATOR_CMD_DATA = 9 -class Submode(enum.IntEnum): - OFF = 0 - SAFE = 10 - DETUMBLE = 11 - IDLE = 12 - PTG_NADIR = 13 - PTG_TARGET = 14 - PTG_TARGET_GS = 15 - PTG_INERTIAL = 16 - - class ActionId(enum.IntEnum): SOLAR_ARRAY_DEPLOYMENT_SUCCESSFUL = 0 RESET_MEKF = 1 @@ -73,13 +63,13 @@ class ActionId(enum.IntEnum): class OpCodes: OFF = ["off"] - SAFE = ["normal_safe"] - DTBL = ["normal_detumble"] - IDLE = ["normal_idle"] - NADIR = ["normal_nadir"] - TARGET = ["normal_target"] - GS = ["normal_gs"] - INERTIAL = ["normal_inertial"] + SAFE = ["safe"] + DTBL = ["safe_detumble"] + IDLE = ["ptg_idle"] + NADIR = ["ptg_nadir"] + TARGET = ["ptg_target"] + GS = ["ptg_target_gs"] + INERTIAL = ["ptg_inertial"] SAFE_PTG = ["confirm_deployment"] RESET_MEKF = ["reset_mekf"] SET_PARAMETER_SCALAR = ["set_scalar_param"] @@ -119,9 +109,9 @@ class OpCodes: class Info: OFF = "Switch ACS CTRL off" - SAFE = "Switch ACS CTRL normal - safe" - DTBL = "Switch ACS CTRL normal - detumble" - IDLE = "Switch ACS CTRL normal - idle" + SAFE = "Switch ACS CTRL - safe" + DTBL = "Switch ACS CTRL - safe with detumble submode" + IDLE = "Switch ACS CTRL - pointing idle" NADIR = "Switch ACS CTRL normal - pointing nadir" TARGET = "Switch ACS CTRL normal - pointing target" GS = "Switch ACS CTRL normal - pointing target groundstation" @@ -235,29 +225,29 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.OFF, 0)) elif op_code in OpCodes.SAFE: q.add_log_cmd(f"{Info.SAFE}") - q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.SAFE)) + q.add_pus_tc( + pack_mode_command(ACS_CONTROLLER, AcsMode.SAFE, SafeSubmode.DEFAULT) + ) elif op_code in OpCodes.DTBL: q.add_log_cmd(f"{Info.DTBL}") - q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.DETUMBLE)) + q.add_pus_tc( + pack_mode_command(ACS_CONTROLLER, AcsMode.SAFE, SafeSubmode.DETUMBLE) + ) elif op_code in OpCodes.IDLE: q.add_log_cmd(f"{Info.IDLE}") - q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.IDLE)) + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.IDLE, 0)) elif op_code in OpCodes.NADIR: q.add_log_cmd(f"{Info.NADIR}") - q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_NADIR)) + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_NADIR, 0)) elif op_code in OpCodes.TARGET: q.add_log_cmd(f"{Info.TARGET}") - q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_TARGET)) + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_TARGET, 0)) elif op_code in OpCodes.GS: q.add_log_cmd(f"{Info.GS}") - q.add_pus_tc( - pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_TARGET_GS) - ) + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_TARGET_GS, 0)) elif op_code in OpCodes.INERTIAL: q.add_log_cmd(f"{Info.INERTIAL}") - q.add_pus_tc( - pack_mode_command(ACS_CONTROLLER, Mode.NORMAL, Submode.PTG_INERTIAL) - ) + q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_INERTIAL, 0)) elif op_code in OpCodes.SAFE_PTG: q.add_log_cmd(f"{Info.SAFE_PTG}") q.add_pus_tc( diff --git a/eive_tmtc/tmtc/acs/defs.py b/eive_tmtc/tmtc/acs/defs.py new file mode 100644 index 0000000..b8a435f --- /dev/null +++ b/eive_tmtc/tmtc/acs/defs.py @@ -0,0 +1,16 @@ +import enum + + +class AcsMode(enum.IntEnum): + OFF = 0 + SAFE = 10 + IDLE = 11 + PTG_NADIR = 12 + PTG_TARGET = 13 + PTG_TARGET_GS = 14 + PTG_INERTIAL = 15 + + +class SafeSubmode(enum.IntEnum): + DEFAULT = 0 + DETUMBLE = 1 diff --git a/eive_tmtc/tmtc/acs/subsystem.py b/eive_tmtc/tmtc/acs/subsystem.py index f42d701..e2c3d50 100644 --- a/eive_tmtc/tmtc/acs/subsystem.py +++ b/eive_tmtc/tmtc/acs/subsystem.py @@ -1,6 +1,7 @@ import enum from typing import Tuple, Dict +from eive_tmtc.tmtc.acs.defs import AcsMode, SafeSubmode from spacepackets.ecss import PusTelecommand from eive_tmtc.tmtc.common import pack_mode_cmd_with_info from eive_tmtc.config.object_ids import ACS_SUBSYSTEM_ID @@ -27,17 +28,6 @@ class OpCode(str, enum.Enum): REPORT_ALL_MODES = "all_modes" -class AcsMode(enum.IntEnum): - OFF = 0 - SAFE = 10 - DETUMBLE = 11 - IDLE = 12 - PTG_TARGET_NADIR = 13 - PTG_TARGET = 14 - PTG_TARGET_GS = 15 - PTG_TARGET_INERTIAL = 16 - - class Info(str, enum.Enum): OFF = "Off Command" SAFE = "Safe Mode Command" @@ -50,15 +40,15 @@ class Info(str, enum.Enum): REPORT_ALL_MODES = "Report All Modes Recursively" -HANDLER_LIST: Dict[str, Tuple[int, str]] = { - OpCode.OFF: (AcsMode.OFF, Info.OFF), - OpCode.SAFE: (AcsMode.SAFE, Info.SAFE), - OpCode.DETUMBLE: (AcsMode.DETUMBLE, Info.DETUMBLE), - OpCode.IDLE: (AcsMode.IDLE, Info.IDLE), - OpCode.PTG_TARGET: (AcsMode.PTG_TARGET, Info.PTG_TARGET), - OpCode.PTG_TARGET_GS: (AcsMode.PTG_TARGET_GS, Info.PTG_TARGET_GS), - OpCode.PTG_TARGET_NADIR: (AcsMode.PTG_TARGET_NADIR, Info.PTG_TARGET_NADIR), - OpCode.PTG_TARGET_INERTIAL: (AcsMode.PTG_TARGET_INERTIAL, Info.PTG_TARGET_INERTIAL), +HANDLER_LIST: Dict[str, Tuple[int, int, str]] = { + OpCode.OFF: (AcsMode.OFF, 0, Info.OFF), + OpCode.SAFE: (AcsMode.SAFE, SafeSubmode.DEFAULT, Info.SAFE), + OpCode.DETUMBLE: (AcsMode.SAFE, SafeSubmode.DETUMBLE, Info.DETUMBLE), + OpCode.IDLE: (AcsMode.IDLE, 0, Info.IDLE), + OpCode.PTG_TARGET: (AcsMode.PTG_TARGET, 0, Info.PTG_TARGET), + OpCode.PTG_TARGET_GS: (AcsMode.PTG_TARGET_GS, 0, Info.PTG_TARGET_GS), + OpCode.PTG_TARGET_NADIR: (AcsMode.PTG_NADIR, 0, Info.PTG_TARGET_NADIR), + OpCode.PTG_TARGET_INERTIAL: (AcsMode.PTG_INERTIAL, 0, Info.PTG_TARGET_INERTIAL), } @@ -81,9 +71,9 @@ def build_acs_subsystem_cmd(p: ServiceProviderParams): return pack_mode_cmd_with_info( object_id=ACS_SUBSYSTEM_ID, - info=f"{info_prefix}: {mode_info_tup[1]}", - submode=0, + info=f"{info_prefix}: {mode_info_tup[2]}", mode=mode_info_tup[0], + submode=mode_info_tup[1], q=q, ) From 05429d2048af6b41d523595d4880574176f136b6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 10 Mar 2023 13:38:21 +0100 Subject: [PATCH 3/5] run black --- eive_tmtc/tmtc/acs/star_tracker.py | 243 +++++++++++++++-------------- 1 file changed, 125 insertions(+), 118 deletions(-) diff --git a/eive_tmtc/tmtc/acs/star_tracker.py b/eive_tmtc/tmtc/acs/star_tracker.py index 5b26110..162bd05 100644 --- a/eive_tmtc/tmtc/acs/star_tracker.py +++ b/eive_tmtc/tmtc/acs/star_tracker.py @@ -174,7 +174,7 @@ class Submode: def pack_star_tracker_commands( - object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str + object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str ): q.add_log_cmd( f"Generate command for star tracker with object id: {object_id.as_hex_string}" @@ -230,9 +230,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set subscription parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.SUBSCRIPTION) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.SUBSCRIPTION) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "12": @@ -251,9 +251,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Upload image") image = get_upload_image() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.UPLOAD_IMAGE) - + bytearray(image, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.UPLOAD_IMAGE) + + bytearray(image, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "16": @@ -262,99 +262,99 @@ def pack_star_tracker_commands( if not path: path = FileDefs.download_path data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_IMAGE) - + bytearray(path, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_IMAGE) + + bytearray(path, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "17": q.add_log_cmd("Star tracker: Set limits") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.LIMITS) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.LIMITS) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "18": q.add_log_cmd("Star tracker: Set tracking parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.TRACKING) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.TRACKING) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "19": q.add_log_cmd("Star tracker: Mounting") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.MOUNTING) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.MOUNTING) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "20": q.add_log_cmd("Star tracker: Camera") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CAMERA) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CAMERA) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "22": q.add_log_cmd("Star tracker: Centroiding") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CENTROIDING) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CENTROIDING) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "23": q.add_log_cmd("Star tracker: LISA") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.LISA) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.LISA) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "24": q.add_log_cmd("Star tracker: Matching") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.MATCHING) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.MATCHING) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "25": q.add_log_cmd("Star tracker: Validation") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.VALIDATION) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.VALIDATION) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "26": q.add_log_cmd("Star tracker: Algo") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.ALGO) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.ALGO) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "27": q.add_log_cmd("Star tracker: Take image") actionid = int(input("Specify parameter ID (take image - 4): ")) data = ( - obyt - + struct.pack("!I", StarTrackerActionId.TAKE_IMAGE) - + struct.pack("!B", actionid) + obyt + + struct.pack("!I", StarTrackerActionId.TAKE_IMAGE) + + struct.pack("!B", actionid) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "28": @@ -365,9 +365,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set name of download image") filename = input("Specify download image name: ") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CHANGE_DOWNLOAD_IMAGE) - + bytearray(filename, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CHANGE_DOWNLOAD_IMAGE) + + bytearray(filename, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "31": @@ -382,9 +382,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set json filename") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.SET_JSON_FILE_NAME) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.SET_JSON_FILE_NAME) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "35": @@ -395,9 +395,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set flash read filename") filename = input("Specify filename: ") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.SET_FLASH_READ_FILENAME) - + bytearray(filename, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.SET_FLASH_READ_FILENAME) + + bytearray(filename, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "37": @@ -408,36 +408,36 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set time") unix_time = 1640783543 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.SET_TIME) - + struct.pack("!Q", unix_time) + obyt + + struct.pack("!I", StarTrackerActionId.SET_TIME) + + struct.pack("!Q", unix_time) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "39": q.add_log_cmd("Star tracker: Download Centroid") id = 0 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_CENTROID) - + struct.pack("!B", id) + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_CENTROID) + + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "41": q.add_log_cmd("Star tracker: Download matched star") id = 0 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_MATCHED_STAR) - + struct.pack("!B", id) + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_MATCHED_STAR) + + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "42": q.add_log_cmd("Star tracker: Download DB Image") id = 0 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_DBIMAGE) - + struct.pack("!B", id) + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_DBIMAGE) + + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "43": @@ -445,10 +445,10 @@ def pack_star_tracker_commands( id = 0 type = 1 # 0 - normal, 1 - fast data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_BLOBPIXEL) - + struct.pack("!B", id) - + struct.pack("!B", type) + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_BLOBPIXEL) + + struct.pack("!B", id) + + struct.pack("!B", type) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "44": @@ -456,36 +456,36 @@ def pack_star_tracker_commands( position = int(input("Start position: ")) length = int(input("Size to download: ")) data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DOWNLOAD_FPGA_IMAGE) - + struct.pack("!I", position) - + struct.pack("!I", length) - + bytearray(FileDefs.downloadFpgaImagePath, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.DOWNLOAD_FPGA_IMAGE) + + struct.pack("!I", position) + + struct.pack("!I", length) + + bytearray(FileDefs.downloadFpgaImagePath, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "45": q.add_log_cmd("Star tracker: Change donwload FPGA image file name") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CHANGE_FPGA_DOWNLOAD_FILE) - + bytearray(FileDefs.downloadFpgaImageName, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CHANGE_FPGA_DOWNLOAD_FILE) + + bytearray(FileDefs.downloadFpgaImageName, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "46": q.add_log_cmd("Star tracker: Upload FPGA image") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.UPLOAD_FPGA_IMAGE) - + bytearray(FileDefs.uploadFpgaImageName, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.UPLOAD_FPGA_IMAGE) + + bytearray(FileDefs.uploadFpgaImageName, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "47": q.add_log_cmd("Star tracker: FPGA action") id = 3 data = ( - obyt - + struct.pack("!I", StarTrackerActionId.FPGA_ACTION) - + struct.pack("!B", id) + obyt + + struct.pack("!I", StarTrackerActionId.FPGA_ACTION) + + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "48": @@ -504,25 +504,25 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set image processor parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.IMAGE_PROCESSOR) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.IMAGE_PROCESSOR) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "52": q.add_log_cmd("Star tracker: EGSE load ground config camera parameters") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CAMERA) - + bytearray(FileDefs.egse_ground_config, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CAMERA) + + bytearray(FileDefs.egse_ground_config, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "53": q.add_log_cmd("Star tracker: EGSE load flight config camera parameters") data = ( - obyt - + struct.pack("!I", StarTrackerActionId.CAMERA) - + bytearray(FileDefs.egse_flight_config, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.CAMERA) + + bytearray(FileDefs.egse_flight_config, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "54": @@ -577,9 +577,9 @@ def pack_star_tracker_commands( q.add_log_cmd("Star tracker: Set log level parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.LOGLEVEL) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.LOGLEVEL) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "67": @@ -587,27 +587,27 @@ def pack_star_tracker_commands( json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.LOG_SUBSCRIPTION) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.LOG_SUBSCRIPTION) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "68": q.add_log_cmd("Star tracker: Set debug camera parameters") json_file = get_config_file() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.DEBUG_CAMERA) - + bytearray(json_file, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.DEBUG_CAMERA) + + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "69": q.add_log_cmd("Star tracker: Firmware update") firmware = get_firmware() data = ( - obyt - + struct.pack("!I", StarTrackerActionId.FIRMWARE_UPDATE) - + bytearray(firmware, "utf-8") + obyt + + struct.pack("!I", StarTrackerActionId.FIRMWARE_UPDATE) + + bytearray(firmware, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) if op_code == "70": @@ -631,11 +631,11 @@ def pack_read_command(object_id: bytes) -> bytearray: if not path: path = FileDefs.download_path data = ( - object_id - + struct.pack("!I", StarTrackerActionId.FLASH_READ) - + struct.pack("!B", start_region) - + struct.pack("!I", size) - + bytearray(path, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionId.FLASH_READ) + + struct.pack("!B", start_region) + + struct.pack("!I", size) + + bytearray(path, "utf-8") ) return bytearray(data) @@ -645,11 +645,11 @@ def pack_checksum_command(object_id: bytes) -> bytearray: address = 0 size = PartitionSize.STAR_TRACKER_FIRMWARE data = ( - object_id - + struct.pack("!I", StarTrackerActionId.CHECKSUM) - + struct.pack("!B", start_region) - + struct.pack("!I", address) - + struct.pack("!I", size) + object_id + + struct.pack("!I", StarTrackerActionId.CHECKSUM) + + struct.pack("!B", start_region) + + struct.pack("!I", address) + + struct.pack("!I", size) ) return bytearray(data) @@ -693,7 +693,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper): current_idx = 0 fmt_len = struct.calcsize(ticks_time_fmt) (ticks, unix_time) = struct.unpack( - ticks_time_fmt, hk_data[current_idx: current_idx + fmt_len] + ticks_time_fmt, hk_data[current_idx : current_idx + fmt_len] ) unix_as_dt = datetime.datetime.fromtimestamp(unix_time, tz=datetime.timezone.utc) pw.dlog(f"Ticks: {ticks} | UNIX time: {unix_time}") @@ -702,7 +702,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper): calib_quaternions_fmt = "!ffff" fmt_len = struct.calcsize(calib_quaternions_fmt) (calib_q_w, calib_q_x, calib_q_y, calib_q_z) = struct.unpack( - calib_quaternions_fmt, hk_data[current_idx: current_idx + fmt_len] + calib_quaternions_fmt, hk_data[current_idx : current_idx + fmt_len] ) pw.dlog("Calibrated Quaternions") pw.dlog(f"Quaternion w: {calib_q_w}") @@ -713,7 +713,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper): track_fmt = "!fffff" fmt_len = struct.calcsize(track_fmt) (track_confidence, track_q_w, track_q_x, track_q_y, track_q_z) = struct.unpack( - track_fmt, hk_data[current_idx: current_idx + fmt_len] + track_fmt, hk_data[current_idx : current_idx + fmt_len] ) pw.dlog(f"Track Confidence: {track_confidence}") pw.dlog(f"Track QW: {track_q_w}") @@ -733,20 +733,27 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper): # Result of LISA: Lost in space algorithm lisa_fmt = "!fffffB" fmt_len = struct.calcsize(track_fmt) - (lisa_q_w, lisa_q_x, lisa_q_y, lisa_q_z, lisa_percentage_close_stars, lisa_number_close_stars) = struct.unpack( - lisa_fmt, hk_data[current_idx: current_idx + fmt_len] - ) + ( + lisa_q_w, + lisa_q_x, + lisa_q_y, + lisa_q_z, + lisa_percentage_close_stars, + lisa_number_close_stars, + ) = struct.unpack(lisa_fmt, hk_data[current_idx : current_idx + fmt_len]) pw.dlog(f"LISA QW: {lisa_q_w}") pw.dlog(f"LISA QX: {lisa_q_x}") pw.dlog(f"LISA QY: {lisa_q_y}") pw.dlog(f"LISA QZ: {lisa_q_z}") - pw.dlog(f"Percentage of close stars in LISA solution: {lisa_percentage_close_stars}") + pw.dlog( + f"Percentage of close stars in LISA solution: {lisa_percentage_close_stars}" + ) pw.dlog(f"Number of close stars in LISA solution: {lisa_number_close_stars}") current_idx += fmt_len is_trusworthy = hk_data[current_idx] pw.dlog(f"Trustworthy solution: {is_trusworthy}") current_idx += 1 - stable_count = struct.unpack("!I", hk_data[current_idx: current_idx + 4]) + stable_count = struct.unpack("!I", hk_data[current_idx : current_idx + 4]) pw.dlog(f"Stable count: {stable_count}") current_idx += 4 solution_strategy = hk_data[current_idx] From 9f905524b6f2b10b1e8bcd9139c21a206cdf8aa3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 10 Mar 2023 14:08:31 +0100 Subject: [PATCH 4/5] small fix --- eive_tmtc/tmtc/acs/subsystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eive_tmtc/tmtc/acs/subsystem.py b/eive_tmtc/tmtc/acs/subsystem.py index e2c3d50..223c558 100644 --- a/eive_tmtc/tmtc/acs/subsystem.py +++ b/eive_tmtc/tmtc/acs/subsystem.py @@ -81,7 +81,7 @@ def build_acs_subsystem_cmd(p: ServiceProviderParams): @tmtc_definitions_provider def add_acs_subsystem_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() - for op_code, (_, info) in HANDLER_LIST.items(): + for op_code, (_, _, info) in HANDLER_LIST.items(): oce.add(op_code, info) oce.add(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES) defs.add_service(CustomServiceList.ACS_SS, "ACS Subsystem", oce) From e32a6ded6661d450dbc75a7ab0194e8048af3d5c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 10 Mar 2023 15:36:15 +0100 Subject: [PATCH 5/5] object stirng update --- eive_tmtc/config/objects.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eive_tmtc/config/objects.csv b/eive_tmtc/config/objects.csv index c1171c1..cc893ed 100644 --- a/eive_tmtc/config/objects.csv +++ b/eive_tmtc/config/objects.csv @@ -135,7 +135,7 @@ 0x60000004;HEATER_4_CAMERA 0x60000005;HEATER_5_STR 0x60000006;HEATER_6_DRO -0x60000007;HEATER_7_HPA +0x60000007;HEATER_7_SYRLINKS 0x73000001;ACS_BOARD_ASS 0x73000002;SUS_BOARD_ASS 0x73000003;TCS_BOARD_ASS