From 3fe51b08a679bbf2646be4bef8db3af6a7ca465b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Nov 2023 08:50:51 +0100 Subject: [PATCH 01/42] let's try a DB --- eive_tmtc/config/__init__.py | 1 + eive_tmtc/config/definitions.py | 1 + eive_tmtc/pus_tm/hk_handler.py | 31 +++++++++++++---- eive_tmtc/tmtc/power/tm.py | 35 +++++++++++++++++-- tmtcc.py | 61 +++++++++++++++++---------------- 5 files changed, 92 insertions(+), 37 deletions(-) diff --git a/eive_tmtc/config/__init__.py b/eive_tmtc/config/__init__.py index e69de29..1fb3fce 100644 --- a/eive_tmtc/config/__init__.py +++ b/eive_tmtc/config/__init__.py @@ -0,0 +1 @@ +from .definitions import * # noqa diff --git a/eive_tmtc/config/definitions.py b/eive_tmtc/config/definitions.py index 16e4046..83064f1 100644 --- a/eive_tmtc/config/definitions.py +++ b/eive_tmtc/config/definitions.py @@ -11,6 +11,7 @@ from spacepackets.ccsds import PacketId from spacepackets.util import UnsignedByteField +DB_PATH = "tm.db" PUS_APID = 0x65 CFDP_APID = 0x66 PUS_PACKET_ID = PacketId(PacketType.TM, True, PUS_APID) diff --git a/eive_tmtc/pus_tm/hk_handler.py b/eive_tmtc/pus_tm/hk_handler.py index ac40d80..943cafe 100644 --- a/eive_tmtc/pus_tm/hk_handler.py +++ b/eive_tmtc/pus_tm/hk_handler.py @@ -1,7 +1,8 @@ """HK Handling for EIVE OBSW""" import dataclasses import logging -from typing import List +import sqlite3 +from typing import List, Optional, cast from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_hk_data from eive_tmtc.tmtc.internal_err_reporter import handle_ier_hk_data @@ -18,7 +19,6 @@ from eive_tmtc.tmtc.tcs import handle_thermal_controller_hk_data from eive_tmtc.tmtc.tcs.tmp1075 import handle_tmp_1075_hk_data from spacepackets.ecss import PusTelemetry from tmtccmd.tm.pus_3_fsfw_hk import ( - Service3Base, HkContentType, Service3FsfwTm, ) @@ -60,9 +60,10 @@ def handle_hk_packet( printer: FsfwTmTcPrinter, hk_filter: HkFilter, hk_level: int, + db: Optional[sqlite3.Connection], ): tm_packet = Service3FsfwTm.unpack(raw_telemetry=raw_tm, custom_hk_handling=False) - named_obj_id = obj_id_dict.get(tm_packet.object_id.as_bytes) + named_obj_id = cast(ObjectIdU32, obj_id_dict.get(tm_packet.object_id.as_bytes)) if named_obj_id is None: named_obj_id = tm_packet.object_id if tm_packet.subservice == 25 or tm_packet.subservice == 26: @@ -75,6 +76,7 @@ def handle_hk_packet( hk_packet=tm_packet, tm=tm_packet.pus_tm, hk_data=hk_data, + db=db, ) return try: @@ -89,6 +91,7 @@ def handle_hk_packet( hk_packet=tm_packet, tm=tm_packet.pus_tm, hk_data=hk_data, + db=db, ) except ValueError as e: _LOGGER.exception( @@ -101,12 +104,14 @@ def handle_hk_packet( def handle_regular_hk_print( # noqa C901: Complexity okay here printer: FsfwTmTcPrinter, object_id: ObjectIdU32, - hk_packet: Service3Base, + hk_packet: Service3FsfwTm, tm: PusTelemetry, hk_data: bytes, + db: Optional[sqlite3.Connection], ): objb = object_id.as_bytes set_id = hk_packet.set_id + assert tm.time_provider is not None packet_dt = tm.time_provider.as_date_time() pw = PrintWrapper(printer.file_logger) """This function is called when a Service 3 Housekeeping packet is received.""" @@ -127,9 +132,23 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here elif objb == obj_ids.CORE_CONTROLLER_ID: return handle_core_hk_data(pw=pw, hk_data=hk_data, set_id=set_id) elif objb == obj_ids.PDU_1_HANDLER_ID: - return handle_pdu_data(pw=pw, pdu_idx=1, set_id=set_id, hk_data=hk_data) + return handle_pdu_data( + hk_packet=hk_packet, + con=db, + pw=pw, + pdu_idx=1, + set_id=set_id, + hk_data=hk_data, + ) elif objb == obj_ids.PDU_2_HANDLER_ID: - return handle_pdu_data(pw=pw, pdu_idx=2, set_id=set_id, hk_data=hk_data) + return handle_pdu_data( + hk_packet=hk_packet, + con=db, + pw=pw, + pdu_idx=2, + set_id=set_id, + hk_data=hk_data, + ) elif objb == obj_ids.PLOC_MPSOC_ID: return handle_ploc_mpsoc_hk_data(pw=pw, hk_data=hk_data, set_id=set_id) elif objb == obj_ids.ACU_HANDLER_ID: diff --git a/eive_tmtc/tmtc/power/tm.py b/eive_tmtc/tmtc/power/tm.py index 76f8a21..9bdb8c5 100644 --- a/eive_tmtc/tmtc/power/tm.py +++ b/eive_tmtc/tmtc/power/tm.py @@ -1,5 +1,6 @@ import struct -from typing import List, Tuple +import sqlite3 +from typing import List, Optional, Tuple from eive_tmtc.tmtc.power.acu import acu_config_table_handler from eive_tmtc.tmtc.power.common_power import ( @@ -8,6 +9,7 @@ from eive_tmtc.tmtc.power.common_power import ( OBC_ENDIANNESS, ) from eive_tmtc.tmtc.power.power import PcduSetIds +from tmtccmd.tm.pus_3_fsfw_hk import Service3FsfwTm from tmtccmd.util import ObjectIdBase from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from eive_tmtc.pus_tm.defs import PrintWrapper @@ -146,7 +148,14 @@ class DevicesInfoParser: return "Unknown Type" -def handle_pdu_data(pw: PrintWrapper, pdu_idx: int, set_id: int, hk_data: bytes): +def handle_pdu_data( + hk_packet: Service3FsfwTm, + con: Optional[sqlite3.Connection], + pw: PrintWrapper, + pdu_idx: int, + set_id: int, + hk_data: bytes, +): current_idx = 0 priv_idx = pdu_idx - 1 if set_id == SetId.AUX or set_id == SetId.AUX: @@ -219,6 +228,28 @@ def handle_pdu_data(pw: PrintWrapper, pdu_idx: int, set_id: int, hk_data: bytes) f"Boot Count {boot_count} | Battery Mode {batt_mode} | " f"Temperature {temperature} | VCC {vcc} | VBAT {vbat}" ) + if con is not None: + cursor = con.cursor() + if pdu_idx == 1: + tbl_name = "Pdu1" + channel_list = PDU1_CHANNELS_NAMES + else: + tbl_name = "Pdu2" + channel_list = PDU2_CHANNELS_NAMES + for idx, name in enumerate(channel_list): + cursor.execute( + f"CREATE TABLE {tbl_name}{name} IF NOT EXISTS " + f"(GenerationTime, OutEnable, Voltage, Current)" + ) + value_list = [ + hk_packet.pus_tm.time_provider.as_datetime(), # type: ignore + output_enb_list[idx], + voltage_list[idx], + current_list[idx], + ] + cursor.execute( + f"INSERT INTO {tbl_name}{name} VALUES(?, ?, ?, ?)", value_list + ) pw.dlog(info) diff --git a/tmtcc.py b/tmtcc.py index a4721d7..785d455 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -1,60 +1,62 @@ #!/usr/bin/env python3 +import sqlite3 import logging import sys import time +from importlib.metadata import version from pathlib import Path +from typing import Tuple import tmtccmd -from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler -from eive_tmtc.cfdp.tm import CfdpInCcsdsWrapper -from eive_tmtc.cfdp.user import EiveCfdpUser -from spacepackets.ecss import PusVerificator -from spacepackets.version import get_version as get_sp_version from spacepackets.cfdp import ( ChecksumType, TransmissionMode, ) - -from eive_tmtc.pus_tc.tc_handler import TcHandler -from eive_tmtc.pus_tm.hk_handler import HkFilter -from tmtccmd.logging import add_colorlog_console_logger +from spacepackets.ecss import PusVerificator +from spacepackets.version import get_version as get_sp_version +from tmtccmd import BackendBase from tmtccmd.cfdp.handler import CfdpInCcsdsHandler from tmtccmd.cfdp.mib import ( - LocalEntityCfg, IndicationCfg, + LocalEntityCfg, RemoteEntityCfg, ) -from tmtccmd import BackendBase -from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider +from tmtccmd.config import ( + SetupWrapper, + default_json_path, + params_to_procedure_conversion, +) +from tmtccmd.config.args import ( + PreArgsParsingWrapper, + ProcedureParamsWrapper, + SetupParams, +) +from tmtccmd.core import BackendRequest from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter - +from tmtccmd.logging import add_colorlog_console_logger from tmtccmd.logging.pus import ( RawTmtcTimedLogWrapper, RegularTmtcLogWrapper, TimedLogWhen, ) from tmtccmd.pus import VerificationWrapper -from tmtccmd.tm import SpecificApidHandlerBase, GenericApidHandlerBase, CcsdsTmHandler -from tmtccmd.core import BackendRequest -from tmtccmd.config import ( - default_json_path, - SetupWrapper, - params_to_procedure_conversion, -) -from tmtccmd.config.args import ( - SetupParams, - PreArgsParsingWrapper, - ProcedureParamsWrapper, -) +from tmtccmd.tm import CcsdsTmHandler, GenericApidHandlerBase, SpecificApidHandlerBase +from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider + from eive_tmtc import APP_LOGGER -from importlib.metadata import version +from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler +from eive_tmtc.cfdp.tm import CfdpInCcsdsWrapper +from eive_tmtc.cfdp.user import EiveCfdpUser from eive_tmtc.config.definitions import ( - PUS_APID, CFDP_APID, CFDP_LOCAL_ENTITY_ID, CFDP_REMOTE_ENTITY_ID, + PUS_APID, + DB_PATH, ) from eive_tmtc.config.hook import EiveHookObject +from eive_tmtc.pus_tc.tc_handler import TcHandler +from eive_tmtc.pus_tm.hk_handler import HkFilter from eive_tmtc.pus_tm.pus_demux import pus_factory_hook _LOGGER = APP_LOGGER @@ -80,6 +82,7 @@ class PusHandler(SpecificApidHandlerBase): self.hk_level = hk_level self.these_objs_hk_only = [] self.hk_filter = HkFilter(object_ids=self.these_objs_hk_only, set_ids=[]) + self.tm_db = sqlite3.connect(DB_PATH) def handle_tm(self, packet: bytes, _user_args: any): # with open("tc.bin", "wb") as of: @@ -106,7 +109,7 @@ class CustomCcsdsTmHandler(CcsdsTmHandler): _LOGGER.debug(f"Received packet {packet.hex(sep=',')} with APID {apid}") -def setup_params() -> (SetupWrapper, int): +def setup_params() -> Tuple[SetupWrapper, int]: hook_obj = EiveHookObject(default_json_path()) params = SetupParams() parser_wrapper = PreArgsParsingWrapper() @@ -190,7 +193,7 @@ def setup_tmtc_handlers( raw_logger: RawTmtcTimedLogWrapper, gui: bool, hk_level: int, -) -> (CcsdsTmHandler, TcHandler): +) -> Tuple[CcsdsTmHandler, TcHandler]: cfdp_in_ccsds_wrapper = setup_cfdp_handler() verification_wrapper = VerificationWrapper( verificator, _LOGGER, printer.file_logger -- 2.43.0 From ce363e378592012297fc3f9db7d52bf026fe85fe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Nov 2023 11:12:18 +0100 Subject: [PATCH 02/42] this seems to work well --- eive_tmtc/pus_tm/hk_handler.py | 29 +++--- eive_tmtc/pus_tm/pus_demux.py | 130 ------------------------ eive_tmtc/pus_tm/pus_handler.py | 171 ++++++++++++++++++++++++++++++++ eive_tmtc/tmtc/power/tm.py | 49 +++++++-- tmtcc.py | 46 +-------- 5 files changed, 229 insertions(+), 196 deletions(-) delete mode 100644 eive_tmtc/pus_tm/pus_demux.py create mode 100644 eive_tmtc/pus_tm/pus_handler.py diff --git a/eive_tmtc/pus_tm/hk_handler.py b/eive_tmtc/pus_tm/hk_handler.py index e474ccd..2a479a0 100644 --- a/eive_tmtc/pus_tm/hk_handler.py +++ b/eive_tmtc/pus_tm/hk_handler.py @@ -2,7 +2,8 @@ import dataclasses import logging import sqlite3 -from typing import List, Optional, cast +from typing import List, cast +from uuid import UUID from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_hk_data from eive_tmtc.tmtc.internal_err_reporter import handle_ier_hk_data @@ -17,7 +18,6 @@ from eive_tmtc.tmtc.acs.reaction_wheels import handle_rw_hk_data from eive_tmtc.tmtc.com.syrlinks_handler import handle_syrlinks_hk_data from eive_tmtc.tmtc.tcs import handle_thermal_controller_hk_data from eive_tmtc.tmtc.tcs.tmp1075 import handle_tmp_1075_hk_data -from spacepackets.ecss import PusTelemetry from tmtccmd.pus.tm.s3_fsfw_hk import ( HkContentType, Service3FsfwTm, @@ -56,11 +56,12 @@ class HkFilter: def handle_hk_packet( raw_tm: bytes, + packet_uuid: UUID, obj_id_dict: ObjectIdDictT, printer: FsfwTmTcPrinter, hk_filter: HkFilter, hk_level: int, - db: Optional[sqlite3.Connection], + db_con: sqlite3.Connection, ): tm_packet = Service3FsfwTm.unpack(raw_telemetry=raw_tm, custom_hk_handling=False) named_obj_id = cast(ObjectIdU32, obj_id_dict.get(tm_packet.object_id.as_bytes)) @@ -74,9 +75,9 @@ def handle_hk_packet( printer=printer, object_id=named_obj_id, hk_packet=tm_packet, - tm=tm_packet.pus_tm, + tm_packet=tm_packet.pus_tm, hk_data=hk_data, - db=db, + db=db_con, ) return try: @@ -87,11 +88,11 @@ def handle_hk_packet( if hk_level >= 1: handle_regular_hk_print( printer=printer, + packet_uuid=packet_uuid, object_id=named_obj_id, hk_packet=tm_packet, - tm=tm_packet.pus_tm, hk_data=hk_data, - db=db, + db=db_con, ) except ValueError as e: _LOGGER.exception( @@ -102,17 +103,17 @@ def handle_hk_packet( def handle_regular_hk_print( # noqa C901: Complexity okay here - printer: FsfwTmTcPrinter, - object_id: ObjectIdU32, hk_packet: Service3FsfwTm, - tm: PusTelemetry, + packet_uuid: UUID, hk_data: bytes, - db: Optional[sqlite3.Connection], + db: sqlite3.Connection, + object_id: ObjectIdU32, + printer: FsfwTmTcPrinter, ): objb = object_id.as_bytes set_id = hk_packet.set_id - assert tm.time_provider is not None - packet_dt = tm.time_provider.as_date_time() + assert hk_packet.pus_tm.time_provider is not None + packet_dt = hk_packet.pus_tm.time_provider.as_date_time() pw = PrintWrapper(printer.file_logger) """This function is called when a Service 3 Housekeeping packet is received.""" if objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]: @@ -133,6 +134,7 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here return handle_core_hk_data(pw=pw, hk_data=hk_data, set_id=set_id) elif objb == obj_ids.PDU_1_HANDLER_ID: return handle_pdu_data( + packet_uuid=packet_uuid, hk_packet=hk_packet, con=db, pw=pw, @@ -142,6 +144,7 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here ) elif objb == obj_ids.PDU_2_HANDLER_ID: return handle_pdu_data( + packet_uuid=packet_uuid, hk_packet=hk_packet, con=db, pw=pw, diff --git a/eive_tmtc/pus_tm/pus_demux.py b/eive_tmtc/pus_tm/pus_demux.py deleted file mode 100644 index bc5b274..0000000 --- a/eive_tmtc/pus_tm/pus_demux.py +++ /dev/null @@ -1,130 +0,0 @@ -"""Core EIVE TM handler module -""" -import logging -import sqlite3 -from typing import Optional - -from spacepackets.ccsds.time import CdsShortTimestamp -from spacepackets.ecss import PusTelemetry -from spacepackets.ecss.pus_17_test import Service17Tm -from spacepackets.util import PrintFormats -from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter -from tmtccmd.logging.pus import RawTmtcTimedLogWrapper -from tmtccmd.pus import VerificationWrapper -from tmtccmd.pus.s20_fsfw_param import Service20FsfwTm, Service20ParamDumpWrapper -from tmtccmd.pus.s20_fsfw_param_defs import CustomSubservice as ParamSubservice -from tmtccmd.pus.s200_fsfw_mode import Service200FsfwTm -from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice - -from eive_tmtc.config.object_ids import get_object_ids - -from .action_reply_handler import handle_action_reply -from .defs import PrintWrapper -from .event_handler import handle_event_packet -from .hk_handler import HkFilter, handle_hk_packet -from .verification_handler import generic_retval_printout, handle_service_1_fsfw_packet - -_LOGGER = logging.getLogger(__name__) - - -def pus_factory_hook( # noqa C901 : Complexity okay here - packet: bytes, - verif_wrapper: VerificationWrapper, - printer: FsfwTmTcPrinter, - raw_logger: RawTmtcTimedLogWrapper, - hk_level: int, - hk_filter: HkFilter, - db: Optional[sqlite3.Connection], -): - if len(packet) < 8: - _LOGGER.warning("Detected packet shorter than 8 bytes!") - return - try: - tm_packet = PusTelemetry.unpack(packet, CdsShortTimestamp.empty()) - # _LOGGER.info(f"Sequence count: {tm_packet.seq_count}") - except ValueError as value_error: - _LOGGER.warning(f"{value_error}") - _LOGGER.warning("Could not generate PUS TM object from raw data") - _LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}") - return - service = tm_packet.service - obj_id_dict = get_object_ids() - pw = PrintWrapper(printer.file_logger) - dedicated_handler = True - if service == 1: - handle_service_1_fsfw_packet(wrapper=verif_wrapper, raw_tm=packet) - elif service == 3: - handle_hk_packet( - db=db, - printer=printer, - raw_tm=packet, - obj_id_dict=obj_id_dict, - hk_level=hk_level, - hk_filter=hk_filter, - ) - elif service == 5: - handle_event_packet(raw_tm=packet, pw=pw) - elif service == 8: - handle_action_reply(raw_tm=packet, printer=printer, obj_id_dict=obj_id_dict) - elif service == 17: - tm_packet = Service17Tm.unpack( - data=packet, time_reader=CdsShortTimestamp.empty() - ) - if tm_packet.subservice == 2: - verif_wrapper.dlog("Received Ping Reply TM[17,2]") - dedicated_handler = True - elif service == 20: - param_packet = Service20FsfwTm.unpack( - raw_telemetry=packet, time_reader=CdsShortTimestamp.empty() - ) - if tm_packet.subservice == ParamSubservice.TM_DUMP_REPLY: - param_wrapper = Service20ParamDumpWrapper(param_tm=param_packet) - try: - param = param_wrapper.get_param() - obj = obj_id_dict.get(param_wrapper.param_tm.object_id) - pw.dlog(f"Received parameter dump TM from {obj}") - pw.dlog(f"Parameter: {param}") - if param.rows == 1 and param.columns == 1: - try: - scalar_param = param.parse_scalar_param() - if isinstance(scalar_param, int): - pw.dlog(f"Scalar integer parameter: {scalar_param}") - elif isinstance(scalar_param, float): - pw.dlog(f"Scalar floating point parameter: {scalar_param}") - except ValueError as e: - pw.dlog(f"received {e} trying to parse scalar parameter") - else: - # TODO: Could improve display further by actually displaying a matrix as a - # matrix using row and column information - pw.dlog( - "Received vector or matrix data:" - f" {param.param_raw.hex(sep=',')}" - ) - except ValueError as e: - pw.dlog(f"received {e} when trying to parse parameters") - except NotImplementedError as e: - pw.dlog(f"received {e} when trying to parse parameters") - else: - pw.dlog(f"unknown subservice {tm_packet.subservice} for parameter service") - elif service == 200: - tm_packet = Service200FsfwTm.unpack( - raw_telemetry=packet, time_reader=CdsShortTimestamp.empty() - ) - if tm_packet.subservice == ModeSubservice.TM_CANT_REACH_MODE: - obj_id = tm_packet.object_id - obj_id_obj = obj_id_dict.get(obj_id) - retval = tm_packet.return_value - string_list = generic_retval_printout(retval) - pw.dlog(f"Received Mode Reply from {obj_id_obj}: Can't reach mode.") - for string in string_list: - pw.dlog(f"Reason: {string}") - dedicated_handler = True - else: - dedicated_handler = False - else: - _LOGGER.info(f"The service {service} is not implemented in Telemetry Factory") - tm_packet.print_source_data(PrintFormats.HEX) - dedicated_handler = True - if not dedicated_handler and tm_packet is not None: - printer.handle_long_tm_print(packet_if=tm_packet, info_if=tm_packet) - raw_logger.log_tm(tm_packet) diff --git a/eive_tmtc/pus_tm/pus_handler.py b/eive_tmtc/pus_tm/pus_handler.py new file mode 100644 index 0000000..d02dda0 --- /dev/null +++ b/eive_tmtc/pus_tm/pus_handler.py @@ -0,0 +1,171 @@ +"""Core EIVE TM handler module +""" +import logging +import sqlite3 +import uuid +from typing import Any + +from spacepackets.ccsds.time import CdsShortTimestamp +from spacepackets.ecss import PusTelemetry +from spacepackets.ecss.pus_17_test import Service17Tm +from spacepackets.util import PrintFormats +from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter +from tmtccmd.logging.pus import RawTmtcTimedLogWrapper +from tmtccmd.pus import VerificationWrapper +from tmtccmd.pus.s20_fsfw_param import Service20FsfwTm, Service20ParamDumpWrapper +from tmtccmd.pus.s20_fsfw_param_defs import CustomSubservice as ParamSubservice +from tmtccmd.pus.s200_fsfw_mode import Service200FsfwTm +from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice +from tmtccmd.tmtc import GenericApidHandlerBase, SpecificApidHandlerBase +from eive_tmtc.config.definitions import DB_PATH, PUS_APID + +from eive_tmtc.config.object_ids import get_object_ids + +from .action_reply_handler import handle_action_reply +from .defs import PrintWrapper +from .event_handler import handle_event_packet +from .hk_handler import HkFilter, handle_hk_packet +from .verification_handler import generic_retval_printout, handle_service_1_fsfw_packet + +_LOGGER = logging.getLogger(__name__) + + +class PusHandler(SpecificApidHandlerBase): + def __init__( + self, + wrapper: VerificationWrapper, + printer: FsfwTmTcPrinter, + raw_logger: RawTmtcTimedLogWrapper, + hk_level: int, + ): + super().__init__(PUS_APID, None) + self.printer = printer + self.verif_wrapper = wrapper + self.raw_logger = raw_logger + self.hk_level = hk_level + self.these_objs_hk_only = [] + self.hk_filter = HkFilter(object_ids=self.these_objs_hk_only, set_ids=[]) + self.obj_id_dict = get_object_ids() + self.pw = PrintWrapper(printer.file_logger) + + def handle_tm(self, packet: bytes, _user_args: Any): + self.pus_handler( + packet, + ) + + def pus_handler( # noqa C901 : Complexity okay here + self, + packet: bytes, + ): + packet_uuid = uuid.uuid4() + if len(packet) < 8: + _LOGGER.warning("Detected packet shorter than 8 bytes!") + return + try: + tm_packet = PusTelemetry.unpack(packet, CdsShortTimestamp.empty()) + # _LOGGER.info(f"Sequence count: {tm_packet.seq_count}") + except ValueError as value_error: + _LOGGER.warning(f"{value_error}") + _LOGGER.warning("Could not generate PUS TM object from raw data") + _LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}") + return + service = tm_packet.service + dedicated_handler = True + if service == 1: + handle_service_1_fsfw_packet(wrapper=self.verif_wrapper, raw_tm=packet) + elif service == 3: + handle_hk_packet( + db_con=sqlite3.connect(DB_PATH), + packet_uuid=packet_uuid, + printer=self.printer, + raw_tm=packet, + obj_id_dict=self.obj_id_dict, + hk_level=self.hk_level, + hk_filter=self.hk_filter, + ) + elif service == 5: + handle_event_packet(raw_tm=packet, pw=self.pw) + elif service == 8: + handle_action_reply( + raw_tm=packet, printer=self.printer, obj_id_dict=self.obj_id_dict + ) + elif service == 17: + pus17_tm = Service17Tm.unpack( + data=packet, time_reader=CdsShortTimestamp.empty() + ) + if pus17_tm.subservice == 2: + self.verif_wrapper.dlog("Received Ping Reply TM[17,2]") + dedicated_handler = True + elif service == 20: + self._handle_param_packet(packet, tm_packet) + elif service == 200: + dedicated_handler = self._handle_mode_packet(packet, tm_packet) + else: + _LOGGER.info( + f"The service {service} is not implemented in Telemetry Factory" + ) + tm_packet.print_source_data(PrintFormats.HEX) + dedicated_handler = True + if not dedicated_handler and tm_packet is not None: + self.printer.handle_long_tm_print(packet_if=tm_packet, info_if=tm_packet) + self.raw_logger.log_tm(tm_packet) + + def _handle_param_packet(self, raw_data: bytes, tm_packet: PusTelemetry): + param_packet = Service20FsfwTm.unpack( + raw_telemetry=raw_data, time_reader=CdsShortTimestamp.empty() + ) + if tm_packet.subservice == ParamSubservice.TM_DUMP_REPLY: + param_wrapper = Service20ParamDumpWrapper(param_tm=param_packet) + try: + param = param_wrapper.get_param() + obj = self.obj_id_dict.get(param_wrapper.param_tm.object_id) + self.pw.dlog(f"Received parameter dump TM from {obj}") + self.pw.dlog(f"Parameter: {param}") + if param.rows == 1 and param.columns == 1: + try: + scalar_param = param.parse_scalar_param() + if isinstance(scalar_param, int): + self.pw.dlog(f"Scalar integer parameter: {scalar_param}") + elif isinstance(scalar_param, float): + self.pw.dlog( + f"Scalar floating point parameter: {scalar_param}" + ) + except ValueError as e: + self.pw.dlog(f"received {e} trying to parse scalar parameter") + else: + # TODO: Could improve display further by actually displaying a matrix as a + # matrix using row and column information + self.pw.dlog( + "Received vector or matrix data:" + f" {param.param_raw.hex(sep=',')}" + ) + except ValueError as e: + self.pw.dlog(f"received {e} when trying to parse parameters") + except NotImplementedError as e: + self.pw.dlog(f"received {e} when trying to parse parameters") + else: + self.pw.dlog( + f"unknown subservice {tm_packet.subservice} for parameter service" + ) + + def _handle_mode_packet(self, raw_data: bytes, _: PusTelemetry) -> bool: + tm_packet = Service200FsfwTm.unpack( + raw_telemetry=raw_data, time_reader=CdsShortTimestamp.empty() + ) + if tm_packet.subservice == ModeSubservice.TM_CANT_REACH_MODE: + obj_id = tm_packet.object_id + obj_id_obj = self.obj_id_dict.get(obj_id) + retval = tm_packet.return_value + string_list = generic_retval_printout(retval) + self.pw.dlog(f"Received Mode Reply from {obj_id_obj}: Can't reach mode.") + for string in string_list: + self.pw.dlog(f"Reason: {string}") + return True + return False + + +class UnknownApidHandler(GenericApidHandlerBase): + def handle_tm(self, apid: int, packet: bytes, _user_args: Any): + _LOGGER.warning( + f"Packet with unknown APID {apid} detected: {packet.hex(sep=',')}" + ) diff --git a/eive_tmtc/tmtc/power/tm.py b/eive_tmtc/tmtc/power/tm.py index 2fd6fce..650bea1 100644 --- a/eive_tmtc/tmtc/power/tm.py +++ b/eive_tmtc/tmtc/power/tm.py @@ -1,6 +1,7 @@ import struct import sqlite3 from typing import List, Optional, Tuple +from uuid import UUID from eive_tmtc.tmtc.power.acu import acu_config_table_handler from eive_tmtc.tmtc.power.common_power import ( @@ -149,12 +150,13 @@ class DevicesInfoParser: def handle_pdu_data( + hk_data: bytes, hk_packet: Service3FsfwTm, + packet_uuid: UUID, con: Optional[sqlite3.Connection], pw: PrintWrapper, pdu_idx: int, set_id: int, - hk_data: bytes, ): current_idx = 0 priv_idx = pdu_idx - 1 @@ -229,27 +231,54 @@ def handle_pdu_data( f"Temperature {temperature} | VCC {vcc} | VBAT {vbat}" ) if con is not None: + packet_dt = hk_packet.pus_tm.time_provider.as_datetime() # type: ignore cursor = con.cursor() if pdu_idx == 1: - tbl_name = "Pdu1" + tbl_base_name = "Pdu1_" channel_list = PDU1_CHANNELS_NAMES else: - tbl_name = "Pdu2" + tbl_base_name = "Pdu2_" channel_list = PDU2_CHANNELS_NAMES + cursor.execute( + f""" + CREATE TABLE IF NOT EXISTS {tbl_base_name}BootCount( + packet_uuid TEXT PRIMARY KEY, + generation_time TEXT, + Count NUM + )""" + ) + cursor.execute( + f"INSERT INTO {tbl_base_name}BootCount VALUES(?, ?, ?)", + (str(packet_uuid), packet_dt, boot_count), + ) + for idx, name in enumerate(channel_list): + words = name.split() + camel_case_name = "".join(word.capitalize() for word in words) + tbl_name = f"{tbl_base_name}{camel_case_name}" + print(f"creating table {tbl_name}") cursor.execute( - f"CREATE TABLE {tbl_name}{name} IF NOT EXISTS " - f"(GenerationTime, OutEnable, Voltage, Current)" + f""" + CREATE TABLE IF NOT EXISTS {tbl_name}( + packet_uuid TEXT PRIMARY KEY, + generation_time TEXT, + out_enable NUM, + voltage NUM, + current NUM + )""" ) - value_list = [ - hk_packet.pus_tm.time_provider.as_datetime(), # type: ignore + value_tuple = ( + str(packet_uuid), + packet_dt, output_enb_list[idx], voltage_list[idx], current_list[idx], - ] - cursor.execute( - f"INSERT INTO {tbl_name}{name} VALUES(?, ?, ?, ?)", value_list ) + print(value_tuple) + cursor.execute( + f"INSERT INTO {tbl_name} VALUES(?, ?, ?, ?, ?)", value_tuple + ) + con.commit() pw.dlog(info) diff --git a/tmtcc.py b/tmtcc.py index e6e4188..a4fc4b0 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -import sqlite3 import logging import sys import time @@ -16,7 +15,6 @@ from spacepackets.ecss import PusVerificator from spacepackets.version import get_version as get_sp_version from tmtccmd import BackendBase from tmtccmd.cfdp.handler import RemoteEntityCfgTable -from eive_tmtc.cfdp.handler import CfdpInCcsdsHandler from tmtccmd.cfdp.mib import ( IndicationCfg, LocalEntityCfg, @@ -41,11 +39,13 @@ from tmtccmd.logging.pus import ( TimedLogWhen, ) from tmtccmd.pus import VerificationWrapper -from tmtccmd.tmtc import CcsdsTmHandler, GenericApidHandlerBase, SpecificApidHandlerBase +from tmtccmd.tmtc import CcsdsTmHandler from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider from eive_tmtc import APP_LOGGER +from eive_tmtc.pus_tm.pus_handler import PusHandler, UnknownApidHandler from eive_tmtc.cfdp.fault_handler import EiveCfdpFaultHandler +from eive_tmtc.cfdp.handler import CfdpInCcsdsHandler from eive_tmtc.cfdp.tm import CfdpInCcsdsWrapper from eive_tmtc.cfdp.user import EiveCfdpUser, EiveCheckTimerProvider from eive_tmtc.config.definitions import ( @@ -53,12 +53,9 @@ from eive_tmtc.config.definitions import ( CFDP_LOCAL_ENTITY_ID, CFDP_REMOTE_ENTITY_ID, PUS_APID, - DB_PATH, ) from eive_tmtc.config.hook import EiveHookObject from eive_tmtc.pus_tc.tc_handler import TcHandler -from eive_tmtc.pus_tm.hk_handler import HkFilter -from eive_tmtc.pus_tm.pus_demux import pus_factory_hook _LOGGER = APP_LOGGER _LOG_LEVEL = logging.INFO @@ -68,43 +65,6 @@ ROTATING_TIMED_LOGGER_INTERVAL_WHEN = TimedLogWhen.PER_MINUTE ROTATING_TIMED_LOGGER_INTERVAL = 30 -class PusHandler(SpecificApidHandlerBase): - def __init__( - self, - wrapper: VerificationWrapper, - printer: FsfwTmTcPrinter, - raw_logger: RawTmtcTimedLogWrapper, - hk_level: int, - ): - super().__init__(PUS_APID, None) - self.printer = printer - self.verif_wrapper = wrapper - self.raw_logger = raw_logger - self.hk_level = hk_level - self.these_objs_hk_only = [] - self.hk_filter = HkFilter(object_ids=self.these_objs_hk_only, set_ids=[]) - self.tm_db = sqlite3.connect(DB_PATH) - - def handle_tm(self, packet: bytes, _user_args: any): - # with open("tc.bin", "wb") as of: - # of.write(packet) - pus_factory_hook( - packet, - self.verif_wrapper, - self.printer, - self.raw_logger, - self.hk_level, - self.hk_filter, - ) - - -class UnknownApidHandler(GenericApidHandlerBase): - def handle_tm(self, apid: int, packet: bytes, _user_args: any): - _LOGGER.warning( - f"Packet with unknown APID {apid} detected: {packet.hex(sep=',')}" - ) - - class CustomCcsdsTmHandler(CcsdsTmHandler): def user_hook(self, apid: int, packet: bytes): _LOGGER.debug(f"Received packet {packet.hex(sep=',')} with APID {apid}") -- 2.43.0 From 57a225f926d7f7812cc12e02fde3ec2bd21c0c59 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Nov 2023 11:37:57 +0100 Subject: [PATCH 03/42] start adding raw TM DB --- eive_tmtc/config/definitions.py | 4 +++- eive_tmtc/pus_tm/pus_handler.py | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/eive_tmtc/config/definitions.py b/eive_tmtc/config/definitions.py index 83064f1..e88874c 100644 --- a/eive_tmtc/config/definitions.py +++ b/eive_tmtc/config/definitions.py @@ -11,7 +11,9 @@ from spacepackets.ccsds import PacketId from spacepackets.util import UnsignedByteField -DB_PATH = "tm.db" +TM_DB_PATH = "tm.db" +RAW_TM_PATH = "raw_tm.db" + PUS_APID = 0x65 CFDP_APID = 0x66 PUS_PACKET_ID = PacketId(PacketType.TM, True, PUS_APID) diff --git a/eive_tmtc/pus_tm/pus_handler.py b/eive_tmtc/pus_tm/pus_handler.py index d02dda0..d37638e 100644 --- a/eive_tmtc/pus_tm/pus_handler.py +++ b/eive_tmtc/pus_tm/pus_handler.py @@ -17,7 +17,7 @@ from tmtccmd.pus.s20_fsfw_param_defs import CustomSubservice as ParamSubservice from tmtccmd.pus.s200_fsfw_mode import Service200FsfwTm from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice from tmtccmd.tmtc import GenericApidHandlerBase, SpecificApidHandlerBase -from eive_tmtc.config.definitions import DB_PATH, PUS_APID +from eive_tmtc.config.definitions import TM_DB_PATH, PUS_APID, RAW_TM_PATH from eive_tmtc.config.object_ids import get_object_ids @@ -58,6 +58,9 @@ class PusHandler(SpecificApidHandlerBase): packet: bytes, ): packet_uuid = uuid.uuid4() + db_con = sqlite3.connect(TM_DB_PATH) + raw_tm_db_con = sqlite3.connect(RAW_TM_PATH) + raw_tm_db_con.execute("INSERT ") if len(packet) < 8: _LOGGER.warning("Detected packet shorter than 8 bytes!") return @@ -75,7 +78,7 @@ class PusHandler(SpecificApidHandlerBase): handle_service_1_fsfw_packet(wrapper=self.verif_wrapper, raw_tm=packet) elif service == 3: handle_hk_packet( - db_con=sqlite3.connect(DB_PATH), + db_con=db_con, packet_uuid=packet_uuid, printer=self.printer, raw_tm=packet, -- 2.43.0 From 2259d269dde518f9d6ea23b90d0839dd4120192c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Nov 2023 13:19:42 +0100 Subject: [PATCH 04/42] separate function for raw TM insertion --- eive_tmtc/config/definitions.py | 3 ++- eive_tmtc/pus_tm/pus_handler.py | 40 +++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/eive_tmtc/config/definitions.py b/eive_tmtc/config/definitions.py index e88874c..e5bf6b8 100644 --- a/eive_tmtc/config/definitions.py +++ b/eive_tmtc/config/definitions.py @@ -12,7 +12,8 @@ from spacepackets.util import UnsignedByteField TM_DB_PATH = "tm.db" -RAW_TM_PATH = "raw_tm.db" +# Separate DB or not? Not sure.. +# RAW_TM_PATH = "raw_tm.db" PUS_APID = 0x65 CFDP_APID = 0x66 diff --git a/eive_tmtc/pus_tm/pus_handler.py b/eive_tmtc/pus_tm/pus_handler.py index d37638e..b50e836 100644 --- a/eive_tmtc/pus_tm/pus_handler.py +++ b/eive_tmtc/pus_tm/pus_handler.py @@ -17,7 +17,7 @@ from tmtccmd.pus.s20_fsfw_param_defs import CustomSubservice as ParamSubservice from tmtccmd.pus.s200_fsfw_mode import Service200FsfwTm from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice from tmtccmd.tmtc import GenericApidHandlerBase, SpecificApidHandlerBase -from eive_tmtc.config.definitions import TM_DB_PATH, PUS_APID, RAW_TM_PATH +from eive_tmtc.config.definitions import TM_DB_PATH, PUS_APID from eive_tmtc.config.object_ids import get_object_ids @@ -58,9 +58,6 @@ class PusHandler(SpecificApidHandlerBase): packet: bytes, ): packet_uuid = uuid.uuid4() - db_con = sqlite3.connect(TM_DB_PATH) - raw_tm_db_con = sqlite3.connect(RAW_TM_PATH) - raw_tm_db_con.execute("INSERT ") if len(packet) < 8: _LOGGER.warning("Detected packet shorter than 8 bytes!") return @@ -72,6 +69,8 @@ class PusHandler(SpecificApidHandlerBase): _LOGGER.warning("Could not generate PUS TM object from raw data") _LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}") return + db_con = sqlite3.connect(TM_DB_PATH) + self._store_packet_in_db(db_con, packet, tm_packet, packet_uuid) service = tm_packet.service dedicated_handler = True if service == 1: @@ -113,6 +112,39 @@ class PusHandler(SpecificApidHandlerBase): self.printer.handle_long_tm_print(packet_if=tm_packet, info_if=tm_packet) self.raw_logger.log_tm(tm_packet) + def _store_packet_in_db( + self, + db_con: sqlite3.Connection, + packet: bytes, + tm_packet: PusTelemetry, + packet_uuid: uuid.UUID, + ): + cursor = db_con.cursor() + assert tm_packet.time_provider is not None + cursor.execute( + """ + CREATE TABLE IF NOT EXISTS pus_tm( + packet_uuid TEXT PRIMARY KEY, + generation_time TEXT, + service NUM, + subservice NUM, + data_len NUM, + raw_data BLOB + )""" + ) + cursor.execute( + "INSERT INTO pus_tm VALUES(?, ?, ?, ?, ?, ?)", + ( + str(packet_uuid), + tm_packet.time_provider.as_datetime(), + tm_packet.service, + tm_packet.subservice, + len(packet), + packet, + ), + ) + db_con.commit() + def _handle_param_packet(self, raw_data: bytes, tm_packet: PusTelemetry): param_packet = Service20FsfwTm.unpack( raw_telemetry=raw_data, time_reader=CdsShortTimestamp.empty() -- 2.43.0 From c0ab3351c9f30257016f6291502fd208b698753c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Nov 2023 13:48:08 +0100 Subject: [PATCH 05/42] that's a lot of work.. --- eive_tmtc/tmtc/power/tm.py | 151 +++++++++++++++++++++++++------------ 1 file changed, 101 insertions(+), 50 deletions(-) diff --git a/eive_tmtc/tmtc/power/tm.py b/eive_tmtc/tmtc/power/tm.py index 650bea1..7226e8b 100644 --- a/eive_tmtc/tmtc/power/tm.py +++ b/eive_tmtc/tmtc/power/tm.py @@ -1,6 +1,9 @@ +import dataclasses +from datetime import datetime import struct +import logging import sqlite3 -from typing import List, Optional, Tuple +from typing import List, Tuple from uuid import UUID from eive_tmtc.tmtc.power.acu import acu_config_table_handler @@ -22,6 +25,8 @@ from eive_tmtc.config.object_ids import ( ACU_HANDLER_ID, ) +_LOGGER = logging.getLogger(__name__) + P60_INDEX_LIST = [ "ACU VCC", "PDU1 VCC", @@ -149,11 +154,23 @@ class DevicesInfoParser: return "Unknown Type" +@dataclasses.dataclass +class PduData: + boot_count: int + batt_mode: int + temperature: float + vcc: int + vbat: int + out_enables: List[bool] + voltages: List[int] + currents: List[int] + + def handle_pdu_data( hk_data: bytes, hk_packet: Service3FsfwTm, packet_uuid: UUID, - con: Optional[sqlite3.Connection], + con: sqlite3.Connection, pw: PrintWrapper, pdu_idx: int, set_id: int, @@ -230,58 +247,92 @@ def handle_pdu_data( f"Boot Count {boot_count} | Battery Mode {batt_mode} | " f"Temperature {temperature} | VCC {vcc} | VBAT {vbat}" ) - if con is not None: - packet_dt = hk_packet.pus_tm.time_provider.as_datetime() # type: ignore - cursor = con.cursor() - if pdu_idx == 1: - tbl_base_name = "Pdu1_" - channel_list = PDU1_CHANNELS_NAMES - else: - tbl_base_name = "Pdu2_" - channel_list = PDU2_CHANNELS_NAMES - cursor.execute( - f""" - CREATE TABLE IF NOT EXISTS {tbl_base_name}BootCount( - packet_uuid TEXT PRIMARY KEY, - generation_time TEXT, - Count NUM - )""" + try: + handle_pdu_db_insertion( + con, + packet_uuid, + hk_packet.pus_tm.time_provider.as_datetime(), # type: ignore + pdu_idx, + PduData( + boot_count, + batt_mode, + temperature, + vcc, + vbat, + output_enb_list, + voltage_list, + current_list, + ), ) - cursor.execute( - f"INSERT INTO {tbl_base_name}BootCount VALUES(?, ?, ?)", - (str(packet_uuid), packet_dt, boot_count), - ) - - for idx, name in enumerate(channel_list): - words = name.split() - camel_case_name = "".join(word.capitalize() for word in words) - tbl_name = f"{tbl_base_name}{camel_case_name}" - print(f"creating table {tbl_name}") - cursor.execute( - f""" - CREATE TABLE IF NOT EXISTS {tbl_name}( - packet_uuid TEXT PRIMARY KEY, - generation_time TEXT, - out_enable NUM, - voltage NUM, - current NUM - )""" - ) - value_tuple = ( - str(packet_uuid), - packet_dt, - output_enb_list[idx], - voltage_list[idx], - current_list[idx], - ) - print(value_tuple) - cursor.execute( - f"INSERT INTO {tbl_name} VALUES(?, ?, ?, ?, ?)", value_tuple - ) - con.commit() + except sqlite3.OperationalError as e: + _LOGGER.warning(f"SQLite error {e}") pw.dlog(info) +def handle_pdu_db_insertion( + con: sqlite3.Connection, + packet_uuid: UUID, + packet_dt: datetime, + pdu_idx: int, + pdu_data: PduData, +): + cursor = con.cursor() + if pdu_idx == 1: + tbl_base_name = "pdu1" + channel_list = PDU1_CHANNELS_NAMES + else: + tbl_base_name = "pdu2" + channel_list = PDU2_CHANNELS_NAMES + cursor.execute( + f""" + CREATE TABLE IF NOT EXISTS {tbl_base_name}( + packet_uuid TEXT PRIMARY KEY, + generation_time TEXT, + boot_count NUM, + bat_mode NUM, + temp REAL, + vcc NUM, + vbat NUM + )""" + ) + cursor.execute( + f"INSERT INTO {tbl_base_name} VALUES(?, ?, ?, ?, ?, ?, ?)", + ( + str(packet_uuid), + packet_dt, + pdu_data.boot_count, + pdu_data.batt_mode, + pdu_data.temperature, + pdu_data.vcc, + pdu_data.vbat, + ), + ) + + for idx, name in enumerate(channel_list): + words = name.split() + camel_case_name = "_".join(word.lower() for word in words) + tbl_name = f"{tbl_base_name}_{camel_case_name}" + cursor.execute( + f""" + CREATE TABLE IF NOT EXISTS {tbl_name}( + packet_uuid TEXT PRIMARY KEY, + generation_time TEXT, + out_enable NUM, + voltage NUM, + current NUM + )""" + ) + value_tuple = ( + str(packet_uuid), + packet_dt, + pdu_data.out_enables[idx], + pdu_data.voltages[idx], + pdu_data.currents[idx], + ) + cursor.execute(f"INSERT INTO {tbl_name} VALUES(?, ?, ?, ?, ?)", value_tuple) + con.commit() + + def handle_p60_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): if set_id == SetId.CORE: pw.dlog("Received P60 Core HK. Voltages in mV, currents in mA") -- 2.43.0 From 6e87a0249ce28531062ee5048ea0630fbf196e6f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Nov 2023 13:51:53 +0100 Subject: [PATCH 06/42] no need for file logging here anymore --- eive_tmtc/tmtc/power/tm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eive_tmtc/tmtc/power/tm.py b/eive_tmtc/tmtc/power/tm.py index 7226e8b..04bc618 100644 --- a/eive_tmtc/tmtc/power/tm.py +++ b/eive_tmtc/tmtc/power/tm.py @@ -266,7 +266,7 @@ def handle_pdu_data( ) except sqlite3.OperationalError as e: _LOGGER.warning(f"SQLite error {e}") - pw.dlog(info) + _LOGGER.info(info) def handle_pdu_db_insertion( -- 2.43.0 From 7cb5766a7ade4f3febb214a6ed93dedae0f4285e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Nov 2023 14:50:49 +0100 Subject: [PATCH 07/42] added another helper/wrapper type --- eive_tmtc/pus_tm/hk.py | 21 +++ eive_tmtc/pus_tm/hk_handler.py | 22 +-- eive_tmtc/tmtc/com/syrlinks_handler.py | 185 ++++++++++++++++++------- eive_tmtc/tmtc/power/tm.py | 28 ++-- 4 files changed, 178 insertions(+), 78 deletions(-) create mode 100644 eive_tmtc/pus_tm/hk.py diff --git a/eive_tmtc/pus_tm/hk.py b/eive_tmtc/pus_tm/hk.py new file mode 100644 index 0000000..ce585ff --- /dev/null +++ b/eive_tmtc/pus_tm/hk.py @@ -0,0 +1,21 @@ +import uuid +import dataclasses +import datetime +import sqlite3 +from tmtccmd.pus.tm.s3_fsfw_hk import Service3FsfwTm + + +@dataclasses.dataclass +class HkTmInfo: + packet_uuid: uuid.UUID + hk_packet: Service3FsfwTm + db_con: sqlite3.Connection + hk_data: bytes + + @property + def packet_datetime(self) -> datetime.datetime: + return self.hk_packet.pus_tm.time_provider.as_datetime() + + @property + def set_id(self) -> int: + return self.hk_packet.set_id diff --git a/eive_tmtc/pus_tm/hk_handler.py b/eive_tmtc/pus_tm/hk_handler.py index 2a479a0..e896cd0 100644 --- a/eive_tmtc/pus_tm/hk_handler.py +++ b/eive_tmtc/pus_tm/hk_handler.py @@ -4,6 +4,7 @@ import logging import sqlite3 from typing import List, cast from uuid import UUID +from eive_tmtc.pus_tm.hk import HkTmInfo from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_hk_data from eive_tmtc.tmtc.internal_err_reporter import handle_ier_hk_data @@ -112,6 +113,9 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here ): objb = object_id.as_bytes set_id = hk_packet.set_id + hk_info = HkTmInfo( + packet_uuid=packet_uuid, hk_packet=hk_packet, db_con=db, hk_data=hk_data + ) assert hk_packet.pus_tm.time_provider is not None packet_dt = hk_packet.pus_tm.time_provider.as_date_time() pw = PrintWrapper(printer.file_logger) @@ -119,12 +123,18 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here if objb in [obj_ids.RW1_ID, obj_ids.RW2_ID, obj_ids.RW3_ID, obj_ids.RW4_ID]: return handle_rw_hk_data(pw, object_id, set_id, hk_data) elif objb == obj_ids.SYRLINKS_HANDLER_ID: - return handle_syrlinks_hk_data(pw=pw, hk_data=hk_data, set_id=set_id) + return handle_syrlinks_hk_data( + hk_info=hk_info, + pw=pw, + ) elif objb == obj_ids.IMTQ_HANDLER_ID: return handle_imtq_hk(pw=pw, hk_data=hk_data, set_id=set_id) elif objb == obj_ids.GPS_CONTROLLER: return handle_gps_data( - pw=pw, set_id=set_id, hk_data=hk_data, packet_time=packet_dt + pw=pw, + set_id=set_id, + hk_data=hk_data, + packet_time=packet_dt, ) elif objb == obj_ids.PCDU_HANDLER_ID: return handle_pcdu_hk(pw=pw, set_id=set_id, hk_data=hk_data) @@ -134,9 +144,7 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here return handle_core_hk_data(pw=pw, hk_data=hk_data, set_id=set_id) elif objb == obj_ids.PDU_1_HANDLER_ID: return handle_pdu_data( - packet_uuid=packet_uuid, - hk_packet=hk_packet, - con=db, + hk_info=hk_info, pw=pw, pdu_idx=1, set_id=set_id, @@ -144,9 +152,7 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here ) elif objb == obj_ids.PDU_2_HANDLER_ID: return handle_pdu_data( - packet_uuid=packet_uuid, - hk_packet=hk_packet, - con=db, + hk_info=hk_info, pw=pw, pdu_idx=2, set_id=set_id, diff --git a/eive_tmtc/tmtc/com/syrlinks_handler.py b/eive_tmtc/tmtc/com/syrlinks_handler.py index 608d101..6981662 100644 --- a/eive_tmtc/tmtc/com/syrlinks_handler.py +++ b/eive_tmtc/tmtc/com/syrlinks_handler.py @@ -8,30 +8,34 @@ import enum import logging import math - -from eive_tmtc.pus_tm.defs import PrintWrapper -from eive_tmtc.tmtc.com.defs import Mode as ComMode -from eive_tmtc.config.definitions import CustomServiceList -from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, -) -from tmtccmd.tmtc import DefaultPusQueueHelper -from tmtccmd.pus.tc.s3_fsfw_hk import ( - make_sid, - create_request_one_diag_command, - create_request_one_hk_command, - create_enable_periodic_hk_command_with_interval_with_diag, - create_disable_periodic_hk_command_with_diag, -) -from spacepackets.ecss.tc import PusTelecommand -from tmtccmd.pus.s200_fsfw_mode import Mode, create_mode_command -from eive_tmtc.config.object_ids import SYRLINKS_HANDLER_ID import struct -from tmtccmd.util import ObjectIdU32 +from spacepackets.ecss.tc import PusTelecommand +from tmtccmd.config.tmtc import ( + OpCodeEntry, + TmtcDefinitionWrapper, + tmtc_definitions_provider, +) +from eive_tmtc.pus_tm.hk import HkTmInfo from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter +from tmtccmd.pus.s200_fsfw_mode import Mode, create_mode_command +from tmtccmd.pus.tc.s3_fsfw_hk import ( + create_disable_periodic_hk_command_with_diag, + create_enable_periodic_hk_command_with_interval_with_diag, + create_request_one_diag_command, + create_request_one_hk_command, + make_sid, +) +from tmtccmd.tmtc import DefaultPusQueueHelper +from tmtccmd.util import ObjectIdU32 + +from eive_tmtc.config.definitions import CustomServiceList +from eive_tmtc.config.object_ids import SYRLINKS_HANDLER_ID +from eive_tmtc.pus_tm.defs import PrintWrapper +from eive_tmtc.tmtc.com.defs import Mode as ComMode + + +_LOGGER = logging.getLogger(__name__) class SetId(enum.IntEnum): @@ -258,18 +262,24 @@ def pack_syrlinks_command( # noqa C901: Complexity okay here. q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) -def handle_syrlinks_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): - if set_id == SetId.RX_REGISTERS_DATASET: - return handle_syrlinks_rx_registers_dataset(pw, hk_data) - elif set_id == SetId.TX_REGISTERS_DATASET: - return handle_syrlinks_tx_registers_dataset(pw, hk_data) - elif set_id == SetId.TEMPERATURE_SET_ID: - return handle_syrlinks_temp_dataset(pw, hk_data) +def handle_syrlinks_hk_data( + hk_info: HkTmInfo, + pw: PrintWrapper, +): + if hk_info.set_id == SetId.RX_REGISTERS_DATASET: + return handle_syrlinks_rx_registers_dataset(hk_info, pw) + elif hk_info.set_id == SetId.TX_REGISTERS_DATASET: + return handle_syrlinks_tx_registers_dataset(hk_info, pw) + elif hk_info.set_id == SetId.TEMPERATURE_SET_ID: + return handle_syrlinks_temp_dataset(hk_info, pw) else: - pw.dlog(f"Service 3 TM: Syrlinks handler reply with unknown set ID {set_id}") + pw.dlog( + f"Service 3 TM: Syrlinks handler reply with unknown set ID {hk_info.set_id}" + ) -def handle_syrlinks_temp_dataset(pw: PrintWrapper, hk_data: bytes): +def handle_syrlinks_temp_dataset(hk_info: HkTmInfo, pw: PrintWrapper): + hk_data = hk_info.hk_data if len(hk_data) < 8: raise ValueError("expected at least 8 bytes of HK data") temp_power_amplifier = struct.unpack("!f", hk_data[0:4])[0] @@ -279,7 +289,11 @@ def handle_syrlinks_temp_dataset(pw: PrintWrapper, hk_data: bytes): pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[8:], 2)) -def handle_syrlinks_rx_registers_dataset(pw: PrintWrapper, hk_data: bytes): +def handle_syrlinks_rx_registers_dataset( + hk_info: HkTmInfo, + pw: PrintWrapper, +): + hk_data = hk_info.hk_data header_list = [ "RX Status", "RX Sensitivity", @@ -342,14 +356,44 @@ def handle_syrlinks_rx_registers_dataset(pw: PrintWrapper, hk_data: bytes): pw.dlog( FsfwTmTcPrinter.get_validity_buffer(validity_buffer=validity_buffer, num_vars=8) ) - pw.dlog(f"Carrier Detect: {carrier_detect}") - pw.dlog(f"Carrier Lock: {carrier_lock}") - pw.dlog(f"Data Lock (data clock recovery loop lock status): {data_lock}") - pw.dlog(f"Data Valid (valid if TEB < 10e-5): {data_valid}") - pw.dlog(f"Data Lock (data clock recovery loop lock status): {data_lock}") - pw.dlog(f"RX AGC Inhibit: {rx_agc_inhibit}") - pw.dlog(f"RX AGC: {rx_agc}") - pw.dlog(f"Eb / E0RX [dB]: {eb_to_n0}") + print(f"Carrier Detect: {carrier_detect}") + print(f"Carrier Lock: {carrier_lock}") + print(f"Data Lock (data clock recovery loop lock status): {data_lock}") + print(f"Data Valid (valid if TEB < 10e-5): {data_valid}") + print(f"Data Lock (data clock recovery loop lock status): {data_lock}") + print(f"RX AGC Inhibit: {rx_agc_inhibit}") + print(f"RX AGC: {rx_agc}") + print(f"Eb / E0RX [dB]: {eb_to_n0}") + cursor = hk_info.db_con.cursor() + cursor.execute( + """ + CREATE TABLE IF NOT EXISTS syrlinks_rx_regs( + packet_uuid TEXT PRIMARY KEY, + generation_time TEXT, + carrier_detect NUM, + carrier_lock NUM, + data_lock NUM, + data_valid NUM, + rx_agc_inhibit NUM, + rx_agc NUM, + eb_to_e0_rx NUM + )""" + ) + cursor.execute( + "INSERT INTO syrlinks_rx_regs VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", + ( + str(hk_info.packet_uuid), + hk_info.hk_packet.pus_tm.time_provider.as_datetime(), # type: ignore + carrier_detect, + carrier_lock, + data_lock, + data_valid, + rx_agc_inhibit, + rx_agc, + eb_to_n0, + ), + ) + hk_info.db_con.commit() class TxConv(enum.IntEnum): @@ -375,11 +419,11 @@ WAVEFORM_STRINGS = ["OFF", "CW", "QPSK", "0QPSK", "PCM/PM", "PSK/PM", "BPSK"] def handle_syrlinks_tx_registers_dataset( + hk_info: HkTmInfo, pw: PrintWrapper, - hk_data: bytes, ): header_list = ["TX Status Raw", "TX Waveform", "TX AGC value"] - tx_status = hk_data[0] + tx_status = hk_info.hk_data[0] """ try: tx_conv = TxConv(tx_status & 0b111) @@ -397,9 +441,10 @@ def handle_syrlinks_tx_registers_dataset( logging.getLogger(__name__).warning( f"invalid TX conf set {(tx_status >> 2) & 0b11}" ) - tx_conf_set = -1 + # Hack to make DB insertion work. + tx_conf_set = TxCfgSet.START_WITH_CURRENT_CFG tx_clock_detect = (tx_status >> 4) & 0b1 - tx_waveform = hk_data[1] + tx_waveform = hk_info.hk_data[1] waveform = tx_waveform & 0b1111 try: waveform_str = WAVEFORM_STRINGS[waveform] @@ -407,11 +452,11 @@ def handle_syrlinks_tx_registers_dataset( logging.getLogger(__name__).warning(f"Unknown waveform value {waveform}") waveform_str = "Unknown" pcm_mode = (tx_waveform >> 4) & 0b1 - tx_agc_value = struct.unpack("!H", hk_data[2:4])[0] + tx_agc_value = struct.unpack("!H", hk_info.hk_data[2:4])[0] tx_agc_inhibit = (tx_agc_value >> 15) & 0b1 tx_agc = tx_agc_value & 0xFFF content_list = [tx_status, tx_waveform, tx_agc_value] - validity_buffer = hk_data[4:] + validity_buffer = hk_info.hk_data[4:] for header, content in zip(header_list, content_list): pw.dlog(f"{header}: {content}") pw.dlog( @@ -419,10 +464,46 @@ def handle_syrlinks_tx_registers_dataset( ) # pw.dlog(f"TX CONV: {tx_conv!r}") # pw.dlog(f"TX DIFF (differential encoder enable): {tx_diff_encoder_enable}") - pw.dlog(f"TX Status: {tx_status_status!r}") - pw.dlog(f"TX Config Set: {tx_conf_set!r}") - pw.dlog(f"TX Clock Detect: {tx_clock_detect}") - pw.dlog(f"Waveform: {waveform_str}") - pw.dlog(f"PCM Mode: {pcm_mode}") - pw.dlog(f"TX AGC Inhibit: {tx_agc_inhibit}") - pw.dlog(f"TX AGC: {tx_agc}") + print(f"TX Status: {tx_status_status!r}") + print(f"TX Config Set: {tx_conf_set!r}") + print(f"TX Clock Detect: {tx_clock_detect}") + print(f"Waveform: {waveform_str}") + print(f"PCM Mode: {pcm_mode}") + print(f"TX AGC Inhibit: {tx_agc_inhibit}") + print(f"TX AGC: {tx_agc}") + cursor = hk_info.db_con.cursor() + cursor.execute( + """ + CREATE TABLE IF NOT EXISTS syrlinks_tx_regs( + packet_uuid TEXT PRIMARY KEY, + generation_time TEXT, + tx_status NUM, + tx_status_str TEXT, + tx_cfg_set NUM, + tx_cfg_set_str TEXT, + tx_clock_detect NUM, + waveform NUM, + waveform_str TEXT, + pcm_mode NUM, + tx_agc_inhibut NUM, + tx_agc NUM + )""" + ) + cursor.execute( + "INSERT INTO syrlinks_tx_regs VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + ( + str(hk_info.packet_uuid), + hk_info.hk_packet.pus_tm.time_provider.as_datetime(), # type: ignore + tx_status_status, + tx_status_status.name, + tx_conf_set, + tx_conf_set.name, + tx_clock_detect, + waveform, + waveform_str, + pcm_mode, + tx_agc_inhibit, + tx_agc, + ), + ) + hk_info.db_con.commit() diff --git a/eive_tmtc/tmtc/power/tm.py b/eive_tmtc/tmtc/power/tm.py index 04bc618..455ccf3 100644 --- a/eive_tmtc/tmtc/power/tm.py +++ b/eive_tmtc/tmtc/power/tm.py @@ -1,10 +1,9 @@ import dataclasses -from datetime import datetime import struct import logging import sqlite3 from typing import List, Tuple -from uuid import UUID +from eive_tmtc.pus_tm.hk import HkTmInfo from eive_tmtc.tmtc.power.acu import acu_config_table_handler from eive_tmtc.tmtc.power.common_power import ( @@ -13,7 +12,6 @@ from eive_tmtc.tmtc.power.common_power import ( OBC_ENDIANNESS, ) from eive_tmtc.tmtc.power.power import PcduSetIds -from tmtccmd.pus.tm.s3_fsfw_hk import Service3FsfwTm from tmtccmd.util import ObjectIdBase from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from eive_tmtc.pus_tm.defs import PrintWrapper @@ -168,9 +166,7 @@ class PduData: def handle_pdu_data( hk_data: bytes, - hk_packet: Service3FsfwTm, - packet_uuid: UUID, - con: sqlite3.Connection, + hk_info: HkTmInfo, pw: PrintWrapper, pdu_idx: int, set_id: int, @@ -249,9 +245,7 @@ def handle_pdu_data( ) try: handle_pdu_db_insertion( - con, - packet_uuid, - hk_packet.pus_tm.time_provider.as_datetime(), # type: ignore + hk_info, pdu_idx, PduData( boot_count, @@ -270,13 +264,11 @@ def handle_pdu_data( def handle_pdu_db_insertion( - con: sqlite3.Connection, - packet_uuid: UUID, - packet_dt: datetime, + hk_info: HkTmInfo, pdu_idx: int, pdu_data: PduData, ): - cursor = con.cursor() + cursor = hk_info.db_con.cursor() if pdu_idx == 1: tbl_base_name = "pdu1" channel_list = PDU1_CHANNELS_NAMES @@ -298,8 +290,8 @@ def handle_pdu_db_insertion( cursor.execute( f"INSERT INTO {tbl_base_name} VALUES(?, ?, ?, ?, ?, ?, ?)", ( - str(packet_uuid), - packet_dt, + str(hk_info.packet_uuid), + hk_info.packet_datetime, pdu_data.boot_count, pdu_data.batt_mode, pdu_data.temperature, @@ -323,14 +315,14 @@ def handle_pdu_db_insertion( )""" ) value_tuple = ( - str(packet_uuid), - packet_dt, + str(hk_info.packet_uuid), + hk_info.packet_datetime, pdu_data.out_enables[idx], pdu_data.voltages[idx], pdu_data.currents[idx], ) cursor.execute(f"INSERT INTO {tbl_name} VALUES(?, ?, ?, ?, ?)", value_tuple) - con.commit() + hk_info.db_con.commit() def handle_p60_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): -- 2.43.0 From b3920524ab61f997ecdf40dd350dc4cd2e05558b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 10:17:05 +0100 Subject: [PATCH 08/42] OOF --- eive_tmtc/cfdp/tm.py | 2 +- eive_tmtc/config/hook.py | 124 ++++++++++++- eive_tmtc/pus_tc/procedure_packer.py | 240 ++++++++++++++----------- eive_tmtc/pus_tc/system/proc.py | 50 +++--- eive_tmtc/pus_tc/tc_handler.py | 2 +- eive_tmtc/tmtc/acs/acs_board.py | 16 +- eive_tmtc/tmtc/acs/acs_ctrl.py | 103 ++++++----- eive_tmtc/tmtc/acs/gps.py | 20 +-- eive_tmtc/tmtc/acs/gyros.py | 14 +- eive_tmtc/tmtc/acs/imtq.py | 52 +++--- eive_tmtc/tmtc/acs/mgms.py | 6 +- eive_tmtc/tmtc/acs/reaction_wheels.py | 34 ++-- eive_tmtc/tmtc/acs/star_tracker.py | 138 +++++++------- eive_tmtc/tmtc/com/ccsds_handler.py | 22 +-- eive_tmtc/tmtc/com/pdec_handler.py | 16 +- eive_tmtc/tmtc/com/syrlinks_handler.py | 54 +++--- eive_tmtc/tmtc/core.py | 80 ++++----- eive_tmtc/tmtc/payload/plpcdu.py | 34 ++-- eive_tmtc/tmtc/payload/rad_sensor.py | 16 +- eive_tmtc/tmtc/payload/scex.py | 27 ++- eive_tmtc/tmtc/power/acu.py | 8 +- eive_tmtc/tmtc/power/p60dock.py | 38 ++-- eive_tmtc/tmtc/power/pdu1.py | 44 ++--- eive_tmtc/tmtc/power/pdu2.py | 10 +- eive_tmtc/tmtc/power/power.py | 30 ++-- eive_tmtc/tmtc/tcs/ctrl.py | 42 ++--- eive_tmtc/tmtc/tcs/heater.py | 10 +- eive_tmtc/tmtc/tcs/rtd.py | 30 ++-- eive_tmtc/tmtc/tcs/subsystem.py | 10 +- eive_tmtc/tmtc/tcs/tmp1075.py | 22 +-- eive_tmtc/tmtc/time.py | 43 ++--- eive_tmtc/tmtc/wdt.py | 6 +- pyproject.toml | 4 +- 33 files changed, 731 insertions(+), 616 deletions(-) diff --git a/eive_tmtc/cfdp/tm.py b/eive_tmtc/cfdp/tm.py index 5072553..65239b7 100644 --- a/eive_tmtc/cfdp/tm.py +++ b/eive_tmtc/cfdp/tm.py @@ -4,7 +4,7 @@ from typing import Any from eive_tmtc.config.definitions import CFDP_APID from spacepackets.ccsds import SPACE_PACKET_HEADER_SIZE from spacepackets.cfdp import PduFactory, PduType -from tmtccmd.cfdp.handler import CfdpInCcsdsHandler +from eive_tmtc.cfdp.handler import CfdpInCcsdsHandler from tmtccmd.tmtc import SpecificApidHandlerBase _LOGGER = logging.getLogger(__name__) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index 6019fb7..222fdd7 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -1,12 +1,12 @@ from typing import Optional from eive_tmtc.config.definitions import SPACE_PACKET_IDS +from eive_tmtc.tmtc.time import create_time_node from tmtccmd import HookBase, CcsdsTmtcBackend from tmtccmd.com import ComInterface -from tmtccmd.config import TmtcDefinitionWrapper +from tmtccmd.config import CmdTreeNode from eive_tmtc.config.retvals import get_retval_dict -from eive_tmtc.pus_tc.cmd_definitions import get_eive_service_op_code_dict from tmtccmd.util import ObjectIdDictT, RetvalDictT @@ -14,20 +14,134 @@ class EiveHookObject(HookBase): def __init__(self, json_cfg_path: str): super().__init__(json_cfg_path=json_cfg_path) - def get_tmtc_definitions(self) -> TmtcDefinitionWrapper: - return get_eive_service_op_code_dict() + def get_command_definitions(self) -> CmdTreeNode: + root_node = CmdTreeNode.root_node() + mode_node = CmdTreeNode("mode", "Mode Commands") + hk_node = CmdTreeNode("hk", "HK Commands") + action_node = CmdTreeNode("action", "Action Commands") + param_node = CmdTreeNode("params", "Parameter Commands") + health_node = CmdTreeNode("health", "Health Commands") + dev_node = CmdTreeNode("dev", "Device Commands") + dev_node.add_child(hk_node) + dev_node.add_child(mode_node) + dev_node.add_child(health_node) + dev_node.add_child(param_node) + # Not strictly necessary, but I do not know a single device which does not have actions.. + dev_node.add_child(action_node) + assy_node = CmdTreeNode("assy", "Assembly Commands") + assy_node.add_child(mode_node) - def assign_communication_interface(self, com_if_key: str) -> Optional[ComInterface]: + system_node = CmdTreeNode("sys", "EIVE System") + + acs_node = CmdTreeNode("acs", "ACS Subsystem") + acs_brd_assy_node = CmdTreeNode("acs_brd_assy", "ACS Board Assembly") + acs_brd_assy_node.add_child(mode_node) + mgm_devs = CmdTreeNode("mgm_devs", "MGM Devices") + gyro_devs = CmdTreeNode("gyro_devs", "Gyro Devices") + acs_brd_assy_node.add_child(mgm_devs) + acs_brd_assy_node.add_child(gyro_devs) + acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller") + acs_ctrl.add_child(mode_node) + acs_ctrl.add_child(action_node) + acs_ctrl.add_child(param_node) + rws = CmdTreeNode("rws", "Reaction Wheel Devices") + rw_assy = CmdTreeNode("rw_assy", "Reaction Wheel Assembly") + rw_1 = CmdTreeNode("rw_1", "Reaction Wheel 1") + rw_2 = CmdTreeNode("rw_2", "Reaction Wheel 2") + rw_3 = CmdTreeNode("rw_3", "Reaction Wheel 3") + rw_4 = CmdTreeNode("rw_4", "Reaction Wheel 4") + rws.add_child(rw_assy) + rws.add_child(rw_1) + rws.add_child(rw_2) + rws.add_child(rw_3) + rws.add_child(rw_4) + mgt = CmdTreeNode("mgt", "ISIS MGT") + mgt.add_child(dev_node) + mgt.add_child(assy_node) + star_tracker = CmdTreeNode("str", "Star Tracker") + star_tracker_img_helper = CmdTreeNode( + "str_img_helper", "Star Tracker Image Helper" + ) + star_tracker.add_child(star_tracker_img_helper) + gnss_devs = CmdTreeNode("gnss", "GNSS Devices") + + acs_node.add_child(acs_brd_assy_node) + acs_node.add_child(acs_ctrl) + acs_node.add_child(mode_node) + acs_node.add_child(rws) + acs_node.add_child(mgt) + acs_node.add_child(star_tracker) + acs_node.add_child(gnss_devs) + + tcs_node = CmdTreeNode("tcs", "TCS Subsystem") + tmp_1075_node = CmdTreeNode("tmp1075_devs", "TMP1075 Devices") + rtds_node = CmdTreeNode("rtd_devs", "RTD Devices") + heaters_node = CmdTreeNode("heaters", "Heater Devices") + tcs_ctrl = CmdTreeNode("tcs_ctrl", "TCS Controller") + tcs_node.add_child(rtds_node) + tcs_node.add_child(tmp_1075_node) + tcs_node.add_child(tcs_ctrl) + tcs_node.add_child(heaters_node) + tcs_brd_assy = CmdTreeNode("tcs_brd_assy", "TCS Board Assembly") + tcs_node.add_child(tcs_brd_assy) + + com_node = CmdTreeNode("com", "COM Subsystem") + syrlinks_node = CmdTreeNode("syrlinks", "Syrlinks") + syrlinks_node.add_child(dev_node) + syrlinks_node.add_child(assy_node) + syrlinks_node.add_child(action_node) + ccsds_node = CmdTreeNode("ccsds", "CCSDS Handler") + ccsds_node.add_child(action_node) + com_node.add_child(syrlinks_node) + + eps_node = CmdTreeNode("eps", "EPS Subsystem") + acu_node = CmdTreeNode("acu", "PCDU ACU component") + pdu_1_node = CmdTreeNode("pdu1", "PCDU PDU 1 component") + pdu_2_node = CmdTreeNode("pdu2", "PCDU PDU 2 component") + p60_dock_node = CmdTreeNode("p60_dock", "PCDU P60 Dock component") + bat_node = CmdTreeNode("bat", "Battery Component") + eps_node.add_child(acu_node) + eps_node.add_child(pdu_1_node) + eps_node.add_child(pdu_2_node) + eps_node.add_child(p60_dock_node) + eps_node.add_child(bat_node) + + payload_node = CmdTreeNode("payload", "Payload Subsystem") + scex_node = CmdTreeNode("scex", "SCEX devices") + scex_node.add_child(dev_node) + pl_pcdu = CmdTreeNode("pl_pcdu", "Payload PCDU") + payload_node.add_child(pl_pcdu) + + obdh_node = CmdTreeNode("obdh", "OBDH Subsystem") + xiphos_wdt = CmdTreeNode("wdt", "Xiphos WDT") + core_ctrl = CmdTreeNode("core", "Core Controller") + obdh_node.add_child(xiphos_wdt) + obdh_node.add_child(core_ctrl) + obdh_node.add_child(create_time_node()) + + root_node.add_child(system_node) + root_node.add_child(acs_node) + root_node.add_child(tcs_node) + root_node.add_child(com_node) + root_node.add_child(eps_node) + root_node.add_child(payload_node) + root_node.add_child(obdh_node) + return root_node + + def get_communication_interface(self, com_if_key: str) -> Optional[ComInterface]: from tmtccmd.config.com import ( create_com_interface_default, create_com_interface_cfg_default, ) + assert self.cfg_path is not None + cfg = create_com_interface_cfg_default( com_if_key=com_if_key, json_cfg_path=self.cfg_path, space_packet_ids=SPACE_PACKET_IDS, ) + assert cfg is not None return create_com_interface_default(cfg) def perform_mode_operation(self, tmtc_backend: CcsdsTmtcBackend, mode: int): diff --git a/eive_tmtc/pus_tc/procedure_packer.py b/eive_tmtc/pus_tc/procedure_packer.py index 60937c7..8ba9dd2 100644 --- a/eive_tmtc/pus_tc/procedure_packer.py +++ b/eive_tmtc/pus_tc/procedure_packer.py @@ -2,6 +2,7 @@ """ import logging from typing import cast +from build.lib.build.lib.eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd @@ -10,34 +11,27 @@ from eive_tmtc.tmtc.tcs.ctrl import pack_tcs_ctrl_commands from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands from eive_tmtc.tmtc.payload.scex import pack_scex_cmds from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands +from eive_tmtc.tmtc.time import pack_time_management_cmd from tmtccmd import DefaultProcedureInfo, TcHandlerBase -from tmtccmd.config import CoreServiceList from tmtccmd.tmtc import DefaultPusQueueHelper -from tmtccmd.tmtc.decorator import ( - route_to_registered_service_handlers, - ServiceProviderParams, -) -from eive_tmtc.tmtc.misc.s200_test import pack_service_200_test_into from eive_tmtc.tmtc.power.p60dock import pack_p60dock_cmds from eive_tmtc.tmtc.power.pdu2 import pack_pdu2_commands from eive_tmtc.tmtc.power.pdu1 import pack_pdu1_commands from eive_tmtc.tmtc.power.acu import pack_acu_commands -from eive_tmtc.tmtc.acs.imtq import pack_imtq_test_into +from eive_tmtc.tmtc.acs.imtq import create_imtq_command from eive_tmtc.tmtc.tcs.heater import pack_heater_cmds from eive_tmtc.tmtc.acs.reaction_wheels import ( - pack_single_rw_test_into, + create_single_rw_cmd, pack_rw_ass_cmds, ) -from eive_tmtc.tmtc.payload.ploc_memory_dumper import pack_ploc_memory_dumper_cmd from eive_tmtc.tmtc.com.ccsds_handler import pack_ccsds_handler_command from eive_tmtc.tmtc.core import pack_core_commands from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands from eive_tmtc.tmtc.com.syrlinks_handler import pack_syrlinks_command -from eive_tmtc.tmtc.com.pdec_handler import pack_pdec_handler_test +from eive_tmtc.tmtc.com.pdec_handler import pack_pdec_handler_commands from eive_tmtc.tmtc.wdt import pack_wdt_commands from eive_tmtc.tmtc.acs.acs_board import pack_acs_command -from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import ( P60_DOCK_HANDLER, PDU_1_HANDLER_ID, @@ -55,7 +49,6 @@ from eive_tmtc.config.object_ids import ( RW4_ID, RAD_SENSOR_ID, STAR_TRACKER_ID, - PLOC_MEMORY_DUMPER_ID, CCSDS_HANDLER_ID, PDEC_HANDLER_ID, STR_IMG_HELPER_ID, @@ -66,10 +59,9 @@ from eive_tmtc.config.object_ids import ( from eive_tmtc.tmtc.tcs.tmp1075 import pack_tmp1075_test_into from eive_tmtc.tmtc.acs.gps import pack_gps_command -from eive_tmtc.tmtc.payload.rad_sensor import pack_rad_sensor_test_into +from eive_tmtc.tmtc.payload.rad_sensor import create_rad_sensor_cmd from eive_tmtc.tmtc.payload.plpcdu import pack_pl_pcdu_commands from eive_tmtc.tmtc.acs.str_img_helper import pack_str_img_helper_command -from eive_tmtc.pus_tc.system.proc import pack_proc_commands import eive_tmtc.config.object_ids as oids from tmtccmd.util import ObjectIdU32 @@ -82,30 +74,49 @@ def handle_default_procedure( # noqa C901: Complexity okay here. info: DefaultProcedureInfo, queue_helper: DefaultPusQueueHelper, ): - service = info.service - op_code = info.op_code + cmd_path = info.cmd_path + assert cmd_path is not None + cmd_path_list = cmd_path.split("/") + if cmd_path_list[0] == "/": + cmd_path_list = cmd_path_list[1:] + if len(cmd_path_list) == 0: + raise ValueError( + "command path list empty. Full command path {cmd_path} might have invalid format" + ) obj_id_man = get_object_ids() - if service == CoreServiceList.SERVICE_200.value: - return pack_service_200_test_into(q=queue_helper) - if service == CustomServiceList.P60DOCK.value: + if cmd_path_list == ["eps", "p60_dock"]: object_id = cast(ObjectIdU32, obj_id_man.get(P60_DOCK_HANDLER)) - return pack_p60dock_cmds(object_id=object_id, q=queue_helper, op_code=op_code) - if service == CustomServiceList.RTD.value: - return pack_rtd_commands(object_id=None, q=queue_helper, op_code=op_code) - if service == CustomServiceList.PDU1.value: + assert len(cmd_path_list) >= 2 + return pack_p60dock_cmds( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list == ["tcs", "rtd_devs"]: + assert len(cmd_path_list) >= 2 + return pack_rtd_commands( + object_id=None, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list == ["eps", "pdu1"]: object_id = cast(ObjectIdU32, obj_id_man.get(PDU_1_HANDLER_ID)) - return pack_pdu1_commands(object_id=object_id, q=queue_helper, op_code=op_code) - if service == CustomServiceList.PDU2.value: + return pack_pdu1_commands( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list == ["eps", "pdu2"]: object_id = cast(ObjectIdU32, obj_id_man.get(PDU_2_HANDLER_ID)) - return pack_pdu2_commands(object_id=object_id, q=queue_helper, op_code=op_code) - if service == CustomServiceList.ACU.value: + return pack_pdu2_commands( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list == ["eps", "acu"]: object_id = cast(ObjectIdU32, obj_id_man.get(ACU_HANDLER_ID)) - return pack_acu_commands(object_id=object_id, q=queue_helper, op_code=op_code) - if service == CustomServiceList.TCS_SS.value: - return pack_tcs_sys_commands(q=queue_helper, op_code=op_code) - if service == CustomServiceList.TCS_CTRL.value: - return pack_tcs_ctrl_commands(q=queue_helper, op_code=op_code) - if service == CustomServiceList.TMP1075.value: + return pack_acu_commands( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list == ["tcs"]: + assert len(cmd_path_list) >= 1 + return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[1]) + if cmd_path_list == ["tcs", "tcs_ctrl"]: + assert len(cmd_path_list) >= 2 + return pack_tcs_ctrl_commands(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list == ["tcs", "tmp1075_devs"]: menu_dict = { "0": ("TMP1075 TCS Board 0", TMP1075_HANDLER_TCS_BRD_0_ID), "1": ("TMP1075 TCS Board 1", TMP1075_HANDLER_TCS_BRD_1_ID), @@ -115,106 +126,119 @@ def handle_default_procedure( # noqa C901: Complexity okay here. } input_helper = InputHelper(menu_dict) tmp_select = input_helper.get_key() + assert len(cmd_path_list) >= 2 object_id = obj_id_man.get(menu_dict[tmp_select][1]) + assert object_id is not None return pack_tmp1075_test_into( - object_id=object_id, q=queue_helper, op_code=op_code + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if service == CustomServiceList.HEATER.value: + if cmd_path_list == ["tcs", "heaters"]: object_id = HEATER_CONTROLLER_ID - return pack_heater_cmds(object_id=object_id, q=queue_helper, op_code=op_code) - if service == CustomServiceList.IMTQ.value: + return pack_heater_cmds( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list == ["acs", "mgt"]: object_id = cast(ObjectIdU32, obj_id_man.get(IMTQ_HANDLER_ID)) - return pack_imtq_test_into(object_id=object_id, q=queue_helper, op_code=op_code) - if service == CustomServiceList.REACTION_WHEEL_1.value: - return pack_single_rw_test_into( - object_id=RW1_ID, rw_idx=1, q=queue_helper, op_code=op_code + return create_imtq_command( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if service == CustomServiceList.REACTION_WHEEL_2.value: - return pack_single_rw_test_into( - object_id=RW2_ID, rw_idx=2, q=queue_helper, op_code=op_code + if cmd_path_list == ["acs", "rw_assy", "rw_1"]: + assert len(cmd_path_list) >= 4 + return create_single_rw_cmd( + object_id=RW1_ID, rw_idx=1, q=queue_helper, cmd_str=cmd_path_list[3] ) - if service == CustomServiceList.REACTION_WHEEL_3.value: - return pack_single_rw_test_into( - object_id=RW3_ID, rw_idx=3, q=queue_helper, op_code=op_code + if cmd_path_list == ["acs", "rw_assy", "rw_2"]: + assert len(cmd_path_list) >= 4 + return create_single_rw_cmd( + object_id=RW2_ID, rw_idx=2, q=queue_helper, cmd_str=cmd_path_list[3] ) - if service == CustomServiceList.REACTION_WHEEL_4.value: - return pack_single_rw_test_into( - object_id=RW4_ID, rw_idx=4, q=queue_helper, op_code=op_code + if cmd_path_list == ["acs", "rw_assy", "rw_3"]: + return create_single_rw_cmd( + object_id=RW3_ID, rw_idx=3, q=queue_helper, cmd_str=cmd_path_list[3] ) - if service == CustomServiceList.MGMS.value: - return handle_mgm_cmd(q=queue_helper, op_code=op_code) - if service == CustomServiceList.RAD_SENSOR.value: + if cmd_path_list == ["acs", "rw_assy", "rw_4"]: + return create_single_rw_cmd( + object_id=RW4_ID, rw_idx=4, q=queue_helper, cmd_str=cmd_path_list[3] + ) + if cmd_path_list == ["acs", "acs_brd_assy", "mgm_devs"]: + assert len(cmd_path_list) >= 4 + return handle_mgm_cmd(q=queue_helper, cmd_str=cmd_path_list[3]) + if cmd_path_list == ["payload", "rad_sensor"]: + assert len(cmd_path_list) >= 3 object_id = cast(ObjectIdU32, obj_id_man.get(RAD_SENSOR_ID)) - return pack_rad_sensor_test_into( - object_id=object_id, q=queue_helper, op_code=op_code + return create_rad_sensor_cmd( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if service == CustomServiceList.STAR_TRACKER.value: + if cmd_path_list == ["acs", "str"]: object_id = cast(ObjectIdU32, obj_id_man.get(STAR_TRACKER_ID)) + assert len(cmd_path_list) >= 3 return pack_star_tracker_commands( - object_id=object_id, q=queue_helper, op_code=op_code + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if service == CustomServiceList.STR_IMG_HELPER.value: + if cmd_path_list == ["acs", "str_img_helper"]: + assert len(cmd_path_list) >= 3 object_id = cast(ObjectIdU32, obj_id_man.get(STR_IMG_HELPER_ID)) return pack_str_img_helper_command( - object_id=object_id, q=queue_helper, op_code=op_code + object_id=object_id, q=queue_helper, op_code=cmd_path_list[2] ) - if service == CustomServiceList.CORE.value: - return pack_core_commands(q=queue_helper, op_code=op_code) - if service == CustomServiceList.PLOC_MEMORY_DUMPER.value: - object_id = cast(ObjectIdU32, obj_id_man.get(PLOC_MEMORY_DUMPER_ID)) - return pack_ploc_memory_dumper_cmd( - object_id=object_id, q=queue_helper, op_code=op_code - ) - if service == CustomServiceList.POWER.value: - return pack_power_commands(queue_helper, op_code) - if service == CustomServiceList.ACS.value: - return pack_acs_command(q=queue_helper, op_code=op_code) - if service == CustomServiceList.GPS_CTRL.value: + if cmd_path_list == ["acs", "acs_ctrl"]: + assert len(cmd_path_list) >= 3 + return pack_acs_ctrl_command(queue_helper, cmd_path_list[2]) + if cmd_path_list == ["obdh", "core"]: + assert len(cmd_path_list) >= 3 + return pack_core_commands(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list == ["eps"]: + assert len(cmd_path_list) >= 2 + return pack_power_commands(queue_helper, cmd_path_list[2]) + if cmd_path_list == ["acs"]: + assert len(cmd_path_list) >= 2 + return pack_acs_command(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list == ["acs", "gnss_devs"]: + assert len(cmd_path_list) >= 3 return pack_gps_command( - object_id=oids.GPS_CONTROLLER, q=queue_helper, op_code=op_code + object_id=oids.GPS_CONTROLLER, q=queue_helper, cmd_str=cmd_path_list[2] ) - if service == CustomServiceList.CCSDS_HANDLER.value: + if cmd_path_list == ["com", "ccsds"]: object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID)) + assert len(cmd_path_list) >= 3 return pack_ccsds_handler_command( - object_id=object_id, q=queue_helper, op_code=op_code + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if service == CustomServiceList.PDEC_HANDLER.value: - return pack_pdec_handler_test( - object_id=PDEC_HANDLER_ID, q=queue_helper, op_code=op_code + if cmd_path_list == ["com", "pdec"]: + assert len(cmd_path_list) >= 3 + return pack_pdec_handler_commands( + object_id=PDEC_HANDLER_ID, q=queue_helper, cmd_str=cmd_path_list[2] ) - if service == CustomServiceList.SYRLINKS.value: + if cmd_path_list == ["com", "syrlinks"]: object_id = cast(ObjectIdU32, obj_id_man.get(SYRLINKS_HANDLER_ID)) + assert len(cmd_path_list) >= 3 return pack_syrlinks_command( - object_id=object_id, q=queue_helper, op_code=op_code + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if service == CustomServiceList.GYRO.value: - return handle_gyr_cmd(q=queue_helper, op_code=op_code) - if service == CustomServiceList.PROCEDURE.value: - return pack_proc_commands(q=queue_helper, op_code=op_code) - if service == CustomServiceList.PL_PCDU.value: - return pack_pl_pcdu_commands(q=queue_helper, op_code=op_code) - if service == CustomServiceList.TCS_ASS.value: - return pack_tcs_sys_commands(q=queue_helper, op_code=op_code) - if service == CustomServiceList.RW_ASSEMBLY.value: - return pack_rw_ass_cmds(q=queue_helper, object_id=RW_ASSEMBLY, op_code=op_code) - if service == CustomServiceList.SCEX.value: + if cmd_path_list == ["acs", "gyro_devs"]: + assert len(cmd_path_list) >= 3 + return handle_gyr_cmd(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list == ["payload", "pl_pcdu"]: + assert len(cmd_path_list) >= 3 + return pack_pl_pcdu_commands(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list == ["tcs", "tcs_brd_assy"]: + assert len(cmd_path_list) >= 3 + return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list == ["acs", "rws", "rw_assy"]: + assert len(cmd_path_list) >= 4 + return pack_rw_ass_cmds( + q=queue_helper, object_id=RW_ASSEMBLY, cmd_str=cmd_path_list[3] + ) + if cmd_path_list == ["payload", "scex"]: + assert len(cmd_path_list) >= 3 return pack_scex_cmds( - ServiceProviderParams( - handler_base=tc_base, - op_code=op_code, - info=info, - queue_helper=queue_helper, - ) + cmd_str=cmd_path_list[2], + q=queue_helper, ) - if service == CustomServiceList.XIPHOS_WDT.value: - return pack_wdt_commands(queue_helper, op_code) - if not route_to_registered_service_handlers( - service, - ServiceProviderParams( - handler_base=tc_base, - op_code=op_code, - info=info, - queue_helper=queue_helper, - ), - ): - logging.getLogger(__name__).warning(f"Invalid Service {service}") + if cmd_path_list == ["core", "xiphos_wdt"]: + return pack_wdt_commands(queue_helper, cmd_path_list[2]) + if "time" in cmd_path_list: + return pack_time_management_cmd(queue_helper, cmd_path_list[1]) + logging.getLogger(__name__).warning( + f"invalid or unimplemented command path {cmd_path}" + ) diff --git a/eive_tmtc/pus_tc/system/proc.py b/eive_tmtc/pus_tc/system/proc.py index 5656b3c..ed189fb 100644 --- a/eive_tmtc/pus_tc/system/proc.py +++ b/eive_tmtc/pus_tc/system/proc.py @@ -36,7 +36,7 @@ from eive_tmtc.pus_tc.system.controllers import ( ) from eive_tmtc.tmtc.acs.acs_board import pack_acs_command from eive_tmtc.tmtc.acs.sus_board import pack_sus_cmds -from eive_tmtc.tmtc.acs.imtq import pack_imtq_test_into, pack_dipole_command +from eive_tmtc.tmtc.acs.imtq import create_imtq_command, pack_dipole_command from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands from eive_tmtc.tmtc.acs.reaction_wheels import pack_rw_ass_cmds, pack_set_speed_command @@ -312,7 +312,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. # Enable scheduling q.add_pus_tc(create_enable_tc_sched_cmd()) # check whether tcs_assembly also has to be commanded to NORMAL Mode - pack_tcs_sys_commands(q=q, op_code=TcsOpCodes.TCS_BOARD_ASS_NORMAL[0]) + pack_tcs_sys_commands(q=q, cmd_str=TcsOpCodes.TCS_BOARD_ASS_NORMAL[0]) pack_cmd_ctrl_to_nml(q=q, object_id=obj_id_dict.get(oids.THERMAL_CONTROLLER_ID)) if op_code in OpCode.TV_TEARDOWN_TCS_FT_OFF: @@ -337,7 +337,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. ] d_side_pairs = a_side_pairs + b_side_pairs diag_list = [False, False, True, False, False] - pack_acs_command(q=q, op_code="acs-a") + pack_acs_command(q=q, cmd_str="acs-a") for a_side_dev in a_side_pairs: oid = a_side_dev[0] @@ -351,9 +351,9 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg.default(), ) - pack_acs_command(q=q, op_code="acs-off") + pack_acs_command(q=q, cmd_str="acs-off") q.add_wait_seconds(5.0) - pack_acs_command(q=q, op_code="acs-b") + pack_acs_command(q=q, cmd_str="acs-b") sid_list.clear() diag_list = [False, False, True, False, False] @@ -370,9 +370,9 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg.default(), ) - pack_acs_command(q=q, op_code="acs-off") + pack_acs_command(q=q, cmd_str="acs-off") q.add_wait_seconds(5.0) - pack_acs_command(q=q, op_code="acs-d") + pack_acs_command(q=q, cmd_str="acs-d") sid_list.clear() @@ -400,7 +400,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg.default(), ) - pack_acs_command(q=q, op_code="acs-off") + pack_acs_command(q=q, cmd_str="acs-off") if op_code in OpCode.MGT_FT: key = KAI.MGT_FT[0] @@ -416,10 +416,10 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. ] # Command MGT to mode on - pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="1") + create_imtq_command(oids.IMTQ_HANDLER_ID, q=q, cmd_str="1") q.add_wait_seconds(5.0) # Command MGT to normal mode - pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="2") + create_imtq_command(oids.IMTQ_HANDLER_ID, q=q, cmd_str="2") for imtq_dev in imtq_pairs: oid = imtq_dev[0] @@ -433,7 +433,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg.default(), ) - pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="0") + create_imtq_command(oids.IMTQ_HANDLER_ID, q=q, cmd_str="0") if op_code in OpCode.MGT_FT_DP: key = KAI.MGT_FT_DP[0] @@ -472,12 +472,12 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. True, True, ] - pack_acs_command(q=q, op_code="acs-d") + pack_acs_command(q=q, cmd_str="acs-d") # Command MGT to mode on - pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="1") + create_imtq_command(oids.IMTQ_HANDLER_ID, q=q, cmd_str="1") q.add_wait_seconds(20.0) # Command MGT to normal mode - pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="2") + create_imtq_command(oids.IMTQ_HANDLER_ID, q=q, cmd_str="2") for d_side_and_imtq_dev in d_side_and_imtq_pairs: oid = d_side_and_imtq_dev[0] @@ -494,8 +494,8 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=cfg, ) - pack_imtq_test_into(oids.IMTQ_HANDLER_ID, q=q, op_code="0") - pack_acs_command(q=q, op_code="acs-off") + create_imtq_command(oids.IMTQ_HANDLER_ID, q=q, cmd_str="0") + pack_acs_command(q=q, cmd_str="acs-off") if op_code in OpCode.SUS_FT: key = KAI.SUS_FT[0] @@ -538,7 +538,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg.default(), ) - pack_acs_command(q=q, op_code="sus-off") + pack_acs_command(q=q, cmd_str="sus-off") q.add_wait_seconds(5.0) pack_sus_cmds(q=q, op_code="sus-red") @@ -562,7 +562,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg.default(), ) - pack_acs_command(q=q, op_code="sus-off") + pack_acs_command(q=q, cmd_str="sus-off") q.add_wait_seconds(5.0) pack_sus_cmds(q=q, op_code="sus-d") @@ -593,7 +593,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg.default(), ) - pack_acs_command(q=q, op_code="sus-off") + pack_acs_command(q=q, cmd_str="sus-off") if op_code in OpCode.SYRLINKS_FT: key = KAI.SYRLINKS_FT[0] @@ -612,7 +612,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. if op_code in OpCode.STR_FT: key = KAI.STR_FT[0] - pack_star_tracker_commands(object_id=oids.STAR_TRACKER_ID, q=q, op_code="2") + pack_star_tracker_commands(object_id=oids.STAR_TRACKER_ID, q=q, cmd_str="2") # STR sid_list.append(make_sid(oids.STAR_TRACKER_ID, StrSetIds.TEMPERATURE)) @@ -625,7 +625,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg.default(), ) - pack_star_tracker_commands(object_id=oids.STAR_TRACKER_ID, q=q, op_code="3") + pack_star_tracker_commands(object_id=oids.STAR_TRACKER_ID, q=q, cmd_str="3") if op_code in OpCode.RW_FT_ONE_RW: key = KAI.RW_FT_ONE_RW[0] @@ -658,7 +658,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. False, ] # RW NORMAL - pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, op_code="nml") + pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, cmd_str="nml") # RW HK für alle RWs nur einzeln for rw_dev in rw_pairs: @@ -673,7 +673,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg(mgt=False, one_rw=True, two_rws=False), ) # RW OFF - pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, op_code="off") + pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, cmd_str="off") # ass command with 2 rws to speed if op_code in OpCode.RW_FT_TWO_RWS: @@ -715,7 +715,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. False, ] # RW NORMAL - pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, op_code="nml") + pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, cmd_str="nml") # RW for rw_dev in rw_pairs: @@ -730,7 +730,7 @@ def pack_proc_commands( # noqa C901: Complexity is okay here. cfg=GenericHkListeningCfg(mgt=False, one_rw=False, two_rws=True), ) # RW OFF - pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, op_code="off") + pack_rw_ass_cmds(object_id=oids.RW_ASSEMBLY, q=q, cmd_str="off") def enable_listen_to_hk_for_x_seconds( diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index 3ff9778..85dbf42 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -7,9 +7,9 @@ from eive_tmtc.config.definitions import ( CFDP_LOCAL_ENTITY_ID, ) from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure +from eive_tmtc.cfdp.handler import CfdpInCcsdsHandler from tmtccmd import TcHandlerBase, ProcedureWrapper from tmtccmd.cfdp.defs import CfdpRequestType -from tmtccmd.cfdp.handler import CfdpInCcsdsHandler from tmtccmd.logging import get_current_time_string from tmtccmd.logging.pus import RawTmtcTimedLogWrapper from tmtccmd.tmtc import ( diff --git a/eive_tmtc/tmtc/acs/acs_board.py b/eive_tmtc/tmtc/acs/acs_board.py index c3a4988..5d1d41b 100644 --- a/eive_tmtc/tmtc/acs/acs_board.py +++ b/eive_tmtc/tmtc/acs/acs_board.py @@ -30,8 +30,8 @@ class DualSideSubmode(enum.IntEnum): DUAL_SIDE = 2 -def pack_acs_command(q: DefaultPusQueueHelper, op_code: str): - if op_code in AcsOpCodes.ACS_ASS_A_SIDE: +def pack_acs_command(q: DefaultPusQueueHelper, cmd_str: str): + if cmd_str in AcsOpCodes.ACS_ASS_A_SIDE: pack_mode_cmd_with_info( object_id=ACS_BOARD_ASS_ID, mode=Mode.NORMAL, @@ -39,7 +39,7 @@ def pack_acs_command(q: DefaultPusQueueHelper, op_code: str): q=q, info="Switching to ACS board assembly A side", ) - if op_code in AcsOpCodes.ACS_ASS_B_SIDE: + if cmd_str in AcsOpCodes.ACS_ASS_B_SIDE: pack_mode_cmd_with_info( object_id=ACS_BOARD_ASS_ID, mode=Mode.NORMAL, @@ -47,7 +47,7 @@ def pack_acs_command(q: DefaultPusQueueHelper, op_code: str): q=q, info="Switching to ACS board assembly B side", ) - if op_code in AcsOpCodes.ACS_ASS_DUAL_MODE: + if cmd_str in AcsOpCodes.ACS_ASS_DUAL_MODE: pack_mode_cmd_with_info( object_id=ACS_BOARD_ASS_ID, mode=Mode.NORMAL, @@ -55,7 +55,7 @@ def pack_acs_command(q: DefaultPusQueueHelper, op_code: str): q=q, info="Switching to ACS board assembly dual mode", ) - if op_code in AcsOpCodes.ACS_ASS_A_ON: + if cmd_str in AcsOpCodes.ACS_ASS_A_ON: pack_mode_cmd_with_info( object_id=ACS_BOARD_ASS_ID, mode=Mode.ON, @@ -63,7 +63,7 @@ def pack_acs_command(q: DefaultPusQueueHelper, op_code: str): q=q, info="Switching ACS board assembly A side on", ) - if op_code in AcsOpCodes.ACS_ASS_B_ON: + if cmd_str in AcsOpCodes.ACS_ASS_B_ON: pack_mode_cmd_with_info( object_id=ACS_BOARD_ASS_ID, mode=Mode.ON, @@ -71,7 +71,7 @@ def pack_acs_command(q: DefaultPusQueueHelper, op_code: str): q=q, info="Switching ACS board assembly B side on", ) - if op_code in AcsOpCodes.ACS_ASS_DUAL_ON: + if cmd_str in AcsOpCodes.ACS_ASS_DUAL_ON: pack_mode_cmd_with_info( object_id=ACS_BOARD_ASS_ID, mode=Mode.ON, @@ -79,7 +79,7 @@ def pack_acs_command(q: DefaultPusQueueHelper, op_code: str): q=q, info="Switching ACS board assembly dual side on", ) - if op_code in AcsOpCodes.ACS_ASS_OFF: + if cmd_str in AcsOpCodes.ACS_ASS_OFF: pack_mode_cmd_with_info( object_id=ACS_BOARD_ASS_ID, mode=Mode.OFF, diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index dcd74e9..46275fe 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -270,54 +270,51 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): ) -@service_provider(CustomServiceList.ACS_CTRL.value) -def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 - op_code = p.op_code - q = p.queue_helper - if op_code in OpCodes.OFF: +def pack_acs_ctrl_command(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 + if cmd_str in OpCodes.OFF: q.add_log_cmd(f"{Info.OFF}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.OFF, 0)) - elif op_code in OpCodes.SAFE: + elif cmd_str in OpCodes.SAFE: q.add_log_cmd(f"{Info.SAFE}") q.add_pus_tc( pack_mode_command(ACS_CONTROLLER, AcsMode.SAFE, SafeSubmode.DEFAULT) ) - elif op_code in OpCodes.DTBL: + elif cmd_str in OpCodes.DTBL: q.add_log_cmd(f"{Info.DTBL}") q.add_pus_tc( pack_mode_command(ACS_CONTROLLER, AcsMode.SAFE, SafeSubmode.DETUMBLE) ) - elif op_code in OpCodes.IDLE: + elif cmd_str in OpCodes.IDLE: q.add_log_cmd(f"{Info.IDLE}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.IDLE, 0)) - elif op_code in OpCodes.NADIR: + elif cmd_str in OpCodes.NADIR: q.add_log_cmd(f"{Info.NADIR}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_NADIR, 0)) - elif op_code in OpCodes.TARGET: + elif cmd_str in OpCodes.TARGET: q.add_log_cmd(f"{Info.TARGET}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_TARGET, 0)) - elif op_code in OpCodes.GS: + elif cmd_str in OpCodes.GS: q.add_log_cmd(f"{Info.GS}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_TARGET_GS, 0)) - elif op_code in OpCodes.INERTIAL: + elif cmd_str in OpCodes.INERTIAL: q.add_log_cmd(f"{Info.INERTIAL}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_INERTIAL, 0)) - elif op_code in OpCodes.SAFE_PTG: + elif cmd_str in OpCodes.SAFE_PTG: q.add_log_cmd(f"{Info.SAFE_PTG}") q.add_pus_tc( create_action_cmd( ACS_CONTROLLER, ActionId.SOLAR_ARRAY_DEPLOYMENT_SUCCESSFUL ) ) - elif op_code in OpCodes.RESET_MEKF: + elif cmd_str in OpCodes.RESET_MEKF: q.add_log_cmd(f"{Info.RESET_MEKF}") q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.RESET_MEKF)) - elif op_code in OpCodes.RESTORE_MEKF_NONFINITE_RECOVERY: + elif cmd_str in OpCodes.RESTORE_MEKF_NONFINITE_RECOVERY: q.add_log_cmd(f"{Info.RESTORE_MEKF_NONFINITE_RECOVERY}") q.add_pus_tc( create_action_cmd(ACS_CONTROLLER, ActionId.RESTORE_MEKF_NONFINITE_RECOVERY) ) - elif op_code in OpCodes.UPDATE_TLE: + elif cmd_str in OpCodes.UPDATE_TLE: q.add_log_cmd(f"{Info.UPDATE_TLE}") while True: line1 = input("Please input the first line of the TLE: ") @@ -333,21 +330,21 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 print("The line does not have the required length of 69 characters") tle = line1.encode() + line2.encode() q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.UPDATE_TLE, tle)) - elif op_code in OpCodes.SET_PARAMETER_SCALAR: + elif cmd_str in OpCodes.SET_PARAMETER_SCALAR: q.add_log_cmd(f"{Info.SET_PARAMETER_SCALAR}") set_acs_ctrl_param_scalar(q) - elif op_code in OpCodes.SET_PARAMETER_VECTOR: + elif cmd_str in OpCodes.SET_PARAMETER_VECTOR: q.add_log_cmd(f"{Info.SET_PARAMETER_VECTOR}") set_acs_ctrl_param_vector(q) - elif op_code in OpCodes.SET_PARAMETER_MATRIX: + elif cmd_str in OpCodes.SET_PARAMETER_MATRIX: q.add_log_cmd(f"{Info.SET_PARAMETER_MATRIX}") set_acs_ctrl_param_matrix(q) - elif op_code in OpCodes.REQUEST_RAW_MGM_HK: + elif cmd_str in OpCodes.REQUEST_RAW_MGM_HK: q.add_log_cmd(Info.REQUEST_RAW_MGM_HK) q.add_pus_tc( generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.MGM_RAW_SET)) ) - elif op_code in OpCodes.ENABLE_RAW_MGM_HK: + elif cmd_str in OpCodes.ENABLE_RAW_MGM_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_RAW_MGM_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -355,19 +352,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_RAW_MGM_HK: + elif cmd_str in OpCodes.DISABLE_RAW_MGM_HK: q.add_log_cmd(Info.DISABLE_RAW_MGM_HK) q.add_pus_tc( disable_periodic_hk_command( False, make_sid(ACS_CONTROLLER, SetId.MGM_RAW_SET) ) ) - elif op_code in OpCodes.REQUEST_PROC_MGM_HK: + elif cmd_str in OpCodes.REQUEST_PROC_MGM_HK: q.add_log_cmd(Info.REQUEST_PROC_MGM_HK) q.add_pus_tc( generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.MGM_PROC_SET)) ) - elif op_code in OpCodes.ENABLE_PROC_MGM_HK: + elif cmd_str in OpCodes.ENABLE_PROC_MGM_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_PROC_MGM_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -375,19 +372,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_PROC_MGM_HK: + elif cmd_str in OpCodes.DISABLE_PROC_MGM_HK: q.add_log_cmd(Info.DISABLE_PROC_MGM_HK) q.add_pus_tc( disable_periodic_hk_command( False, make_sid(ACS_CONTROLLER, SetId.MGM_PROC_SET) ) ) - elif op_code in OpCodes.REQUEST_RAW_SUS_HK: + elif cmd_str in OpCodes.REQUEST_RAW_SUS_HK: q.add_log_cmd(Info.REQUEST_RAW_SUS_HK) q.add_pus_tc( generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.SUS_RAW_SET)) ) - elif op_code in OpCodes.ENABLE_RAW_SUS_HK: + elif cmd_str in OpCodes.ENABLE_RAW_SUS_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_RAW_SUS_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -395,19 +392,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_RAW_SUS_HK: + elif cmd_str in OpCodes.DISABLE_RAW_SUS_HK: q.add_log_cmd(Info.DISABLE_RAW_SUS_HK) q.add_pus_tc( disable_periodic_hk_command( False, make_sid(ACS_CONTROLLER, SetId.SUS_RAW_SET) ) ) - elif op_code in OpCodes.REQUEST_PROC_SUS_HK: + elif cmd_str in OpCodes.REQUEST_PROC_SUS_HK: q.add_log_cmd(Info.REQUEST_PROC_SUS_HK) q.add_pus_tc( generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.SUS_PROC_SET)) ) - elif op_code in OpCodes.ENABLE_PROC_SUS_HK: + elif cmd_str in OpCodes.ENABLE_PROC_SUS_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_PROC_SUS_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -415,19 +412,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_PROC_SUS_HK: + elif cmd_str in OpCodes.DISABLE_PROC_SUS_HK: q.add_log_cmd(Info.DISABLE_PROC_SUS_HK) q.add_pus_tc( disable_periodic_hk_command( False, make_sid(ACS_CONTROLLER, SetId.SUS_PROC_SET) ) ) - elif op_code in OpCodes.REQUEST_RAW_GYR_HK: + elif cmd_str in OpCodes.REQUEST_RAW_GYR_HK: q.add_log_cmd(Info.REQUEST_RAW_GYR_HK) q.add_pus_tc( create_request_one_diag_command(make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET)) ) - elif op_code in OpCodes.ENABLE_RAW_GYR_HK: + elif cmd_str in OpCodes.ENABLE_RAW_GYR_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_RAW_GYR_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -435,21 +432,21 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_RAW_GYR_HK: + elif cmd_str in OpCodes.DISABLE_RAW_GYR_HK: q.add_log_cmd(Info.DISABLE_RAW_GYR_HK) q.add_pus_tc( disable_periodic_hk_command( True, make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET) ) ) - elif op_code in OpCodes.REQUEST_PROC_GYR_HK: + elif cmd_str in OpCodes.REQUEST_PROC_GYR_HK: q.add_log_cmd(Info.REQUEST_PROC_GYR_HK) q.add_pus_tc( create_request_one_diag_command( make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET) ) ) - elif op_code in OpCodes.ENABLE_PROC_GYR_HK: + elif cmd_str in OpCodes.ENABLE_PROC_GYR_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_PROC_GYR_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -457,19 +454,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_PROC_GYR_HK: + elif cmd_str in OpCodes.DISABLE_PROC_GYR_HK: q.add_log_cmd(Info.DISABLE_PROC_GYR_HK) q.add_pus_tc( disable_periodic_hk_command( True, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET) ) ) - elif op_code in OpCodes.REQUEST_PROC_GPS_HK: + elif cmd_str in OpCodes.REQUEST_PROC_GPS_HK: q.add_log_cmd(Info.REQUEST_PROC_GPS_HK) q.add_pus_tc( generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.GPS_PROC_SET)) ) - elif op_code in OpCodes.ENABLE_PROC_GPS_HK: + elif cmd_str in OpCodes.ENABLE_PROC_GPS_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_PROC_GPS_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -477,19 +474,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_PROC_GPS_HK: + elif cmd_str in OpCodes.DISABLE_PROC_GPS_HK: q.add_log_cmd(Info.DISABLE_PROC_GPS_HK) q.add_pus_tc( disable_periodic_hk_command( False, make_sid(ACS_CONTROLLER, SetId.GPS_PROC_SET) ) ) - elif op_code in OpCodes.REQUEST_MEKF_HK: + elif cmd_str in OpCodes.REQUEST_MEKF_HK: q.add_log_cmd(Info.REQUEST_MEKF_HK) q.add_pus_tc( create_request_one_diag_command(make_sid(ACS_CONTROLLER, SetId.MEKF_DATA)) ) - elif op_code in OpCodes.ENABLE_MEKF_HK: + elif cmd_str in OpCodes.ENABLE_MEKF_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_MEKF_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -497,17 +494,17 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_MEKF_HK: + elif cmd_str in OpCodes.DISABLE_MEKF_HK: q.add_log_cmd(Info.DISABLE_MEKF_HK) q.add_pus_tc( disable_periodic_hk_command(True, make_sid(ACS_CONTROLLER, SetId.MEKF_DATA)) ) - elif op_code in OpCodes.REQUEST_CTRL_VAL_HK: + elif cmd_str in OpCodes.REQUEST_CTRL_VAL_HK: q.add_log_cmd(Info.REQUEST_CTRL_VAL_HK) q.add_pus_tc( generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.CTRL_VAL_DATA)) ) - elif op_code in OpCodes.ENABLE_CTRL_VAL_HK: + elif cmd_str in OpCodes.ENABLE_CTRL_VAL_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_CTRL_VAL_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -515,19 +512,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_CTRL_VAL_HK: + elif cmd_str in OpCodes.DISABLE_CTRL_VAL_HK: q.add_log_cmd(Info.DISABLE_CTRL_VAL_HK) q.add_pus_tc( disable_periodic_hk_command( False, make_sid(ACS_CONTROLLER, SetId.CTRL_VAL_DATA) ) ) - elif op_code in OpCodes.REQUEST_ACT_CMD_HK: + elif cmd_str in OpCodes.REQUEST_ACT_CMD_HK: q.add_log_cmd(Info.REQUEST_ACT_CMD_HK) q.add_pus_tc( generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA)) ) - elif op_code in OpCodes.ENABLE_ACT_CMD_HK: + elif cmd_str in OpCodes.ENABLE_ACT_CMD_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_ACT_CMD_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -535,19 +532,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_ACT_CMD_HK: + elif cmd_str in OpCodes.DISABLE_ACT_CMD_HK: q.add_log_cmd(Info.DISABLE_ACT_CMD_HK) q.add_pus_tc( disable_periodic_hk_command( False, make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA) ) ) - elif op_code in OpCodes.REQUEST_FUSED_ROT_RATE_HK: + elif cmd_str in OpCodes.REQUEST_FUSED_ROT_RATE_HK: q.add_log_cmd(Info.REQUEST_FUSED_ROT_RATE_HK) q.add_pus_tc( generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.FUSED_ROT_RATE_DATA)) ) - elif op_code in OpCodes.ENABLE_FUSED_ROT_RATE_HK: + elif cmd_str in OpCodes.ENABLE_FUSED_ROT_RATE_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_FUSED_ROT_RATE_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -555,7 +552,7 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_FUSED_ROT_RATE_HK: + elif cmd_str in OpCodes.DISABLE_FUSED_ROT_RATE_HK: q.add_log_cmd(Info.DISABLE_FUSED_ROT_RATE_HK) q.add_pus_tc( disable_periodic_hk_command( @@ -563,7 +560,7 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 ) ) else: - logging.getLogger(__name__).info(f"Unknown op code {op_code}") + logging.getLogger(__name__).info(f"Unknown op code {cmd_str}") def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): diff --git a/eive_tmtc/tmtc/acs/gps.py b/eive_tmtc/tmtc/acs/gps.py index de5f823..8662612 100644 --- a/eive_tmtc/tmtc/acs/gps.py +++ b/eive_tmtc/tmtc/acs/gps.py @@ -73,12 +73,12 @@ def add_gps_cmds(defs: TmtcDefinitionWrapper): def pack_gps_command( # noqa: C901 - object_id: bytes, q: DefaultPusQueueHelper, op_code: str + object_id: bytes, q: DefaultPusQueueHelper, cmd_str: str ): # noqa: C901: - if op_code in OpCode.RESET_GNSS: + if cmd_str in OpCode.RESET_GNSS: # TODO: This needs to be re-implemented _LOGGER.warning("Reset pin handling needs to be re-implemented") - if op_code in OpCode.ENABLE_CORE_HK: + if cmd_str in OpCode.ENABLE_CORE_HK: interval = float(input("Please specify interval in floating point seconds: ")) if interval <= 0: raise ValueError("invalid interval") @@ -90,21 +90,21 @@ def pack_gps_command( # noqa: C901 ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code in OpCode.DISABLE_CORE_HK: + if cmd_str in OpCode.DISABLE_CORE_HK: q.add_log_cmd(f"gps: {Info.DISABLE_CORE_HK}") q.add_pus_tc( create_disable_periodic_hk_command_with_diag( diag=False, sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK) ) ) - if op_code in OpCode.REQ_CORE_HK: + if cmd_str in OpCode.REQ_CORE_HK: q.add_log_cmd(f"GPS: {Info.REQ_CORE_HK}") q.add_pus_tc( create_request_one_hk_command( sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK) ) ) - if op_code in OpCode.ENABLE_SKYVIEW_HK: + if cmd_str in OpCode.ENABLE_SKYVIEW_HK: interval = float(input("Please specify interval in floating point seconds: ")) if interval <= 0: raise ValueError("invalid interval") @@ -116,24 +116,24 @@ def pack_gps_command( # noqa: C901 ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code in OpCode.DISABLE_SKYVIEW_HK: + if cmd_str in OpCode.DISABLE_SKYVIEW_HK: q.add_log_cmd(f"gps: {Info.DISABLE_SKYVIEW_HK}") q.add_pus_tc( create_disable_periodic_hk_command_with_diag( diag=False, sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK) ) ) - if op_code in OpCode.REQ_SKYVIEW_HK: + if cmd_str in OpCode.REQ_SKYVIEW_HK: q.add_log_cmd(f"GPS: {Info.REQ_SKYVIEW_HK}") q.add_pus_tc( create_request_one_hk_command( sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK) ) ) - if op_code in OpCode.ON: + if cmd_str in OpCode.ON: q.add_log_cmd(f"GPS: {Info.ON}") q.add_pus_tc(create_mode_command(object_id, Mode.ON, 0)) - if op_code in OpCode.OFF: + if cmd_str in OpCode.OFF: q.add_log_cmd(f"GPS: {Info.OFF}") q.add_pus_tc(create_mode_command(object_id, Mode.OFF, 0)) diff --git a/eive_tmtc/tmtc/acs/gyros.py b/eive_tmtc/tmtc/acs/gyros.py index 4fe1442..11da367 100644 --- a/eive_tmtc/tmtc/acs/gyros.py +++ b/eive_tmtc/tmtc/acs/gyros.py @@ -59,7 +59,7 @@ GYR_SEL_DICT = { } -def handle_gyr_cmd(q: DefaultPusQueueHelper, op_code: str): +def handle_gyr_cmd(q: DefaultPusQueueHelper, cmd_str: str): print("Please select the Gyro Device") for k, v in GYR_SEL_DICT.items(): print(f"{k}: {v[0]}") @@ -72,23 +72,23 @@ def handle_gyr_cmd(q: DefaultPusQueueHelper, op_code: str): core_hk_id = AdisGyroSetId.CORE_HK else: core_hk_id = L3gGyroSetId.CORE_HK - if op_code == OpCode.NML: + if cmd_str == OpCode.NML: q.add_log_cmd(f"Gyro {gyr_info[0]} NORMAL mode") q.add_pus_tc(create_mode_command(gyr_obj_id, Mode.NORMAL, 0)) - if op_code == OpCode.OFF: + if cmd_str == OpCode.OFF: q.add_log_cmd(f"Gyro {gyr_info[0]} OFF mode") q.add_pus_tc(create_mode_command(gyr_obj_id, Mode.OFF, 0)) - elif op_code == OpCode.CORE_HK: + elif cmd_str == OpCode.CORE_HK: q.add_log_cmd(f"Gyro {gyr_info[0]} Core HK") q.add_pus_tc(create_request_one_hk_command(make_sid(gyr_obj_id, core_hk_id))) - elif op_code == OpCode.CFG_HK: + elif cmd_str == OpCode.CFG_HK: if not is_adis: raise ValueError("No config HK for L3 device") q.add_log_cmd(f"Gyro {gyr_info[0]} CFG HK") q.add_pus_tc( create_request_one_hk_command(make_sid(gyr_obj_id, AdisGyroSetId.CFG_HK)) ) - elif op_code == OpCode.SET_FAULTY: + elif cmd_str == OpCode.SET_FAULTY: q.add_log_cmd(f"Gyro {gyr_info[0]} set faulty") q.add_pus_tc( PusTelecommand( @@ -101,7 +101,7 @@ def handle_gyr_cmd(q: DefaultPusQueueHelper, op_code: str): ) else: logging.getLogger(__name__).warning( - f"invalid op code {op_code} for gyro command" + f"invalid op code {cmd_str} for gyro command" ) diff --git a/eive_tmtc/tmtc/acs/imtq.py b/eive_tmtc/tmtc/acs/imtq.py index a0cb0eb..919d411 100644 --- a/eive_tmtc/tmtc/acs/imtq.py +++ b/eive_tmtc/tmtc/acs/imtq.py @@ -128,26 +128,26 @@ def add_imtq_cmds(defs: TmtcDefinitionWrapper): defs.add_service(CustomServiceList.IMTQ.value, "IMQT Device", oce) -def pack_imtq_test_into( # noqa C901 - object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str +def create_imtq_command( # noqa C901 + object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str ): q.add_log_cmd( f"Testing ISIS IMTQ handler with object id: {object_id.as_hex_string}" ) - if op_code == OpCode.OFF: + if cmd_str == OpCode.OFF: q.add_log_cmd("IMTQ: Set mode off") command = pack_mode_data(object_id.as_bytes, Mode.OFF, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) - if op_code == OpCode.ON: + if cmd_str == OpCode.ON: q.add_log_cmd("IMTQ: Set mode on") command = pack_mode_data(object_id.as_bytes, Mode.ON, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) - if op_code == OpCode.NORMAL: + if cmd_str == OpCode.NORMAL: q.add_log_cmd("IMTQ: Mode Normal") command = pack_mode_data(object_id.as_bytes, Mode.NORMAL, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) - if op_code == OpCode.POS_X_SELF_TEST: + if cmd_str == OpCode.POS_X_SELF_TEST: q.add_log_cmd("IMTQ: Perform positive x self test") command = object_id.as_bytes + ImtqActionId.perform_positive_x_test q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) @@ -160,7 +160,7 @@ def pack_imtq_test_into( # noqa C901 sid = make_sid(object_id.as_bytes, ImtqSetId.POSITIVE_X_TEST) q.add_pus_tc(generate_one_hk_command(sid)) - if op_code == OpCode.NEG_X_SELF_TEST: + if cmd_str == OpCode.NEG_X_SELF_TEST: q.add_log_cmd("IMTQ: Perform negative x self test") command = object_id.as_bytes + ImtqActionId.perform_negative_x_test q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) @@ -171,7 +171,7 @@ def pack_imtq_test_into( # noqa C901 sid = make_sid(object_id.as_bytes, ImtqSetId.NEGATIVE_X_TEST) q.add_pus_tc(generate_one_hk_command(sid)) - if op_code == OpCode.POS_Y_SELF_TEST: + if cmd_str == OpCode.POS_Y_SELF_TEST: q.add_log_cmd("IMTQ: Perform positive y self test") command = object_id.as_bytes + ImtqActionId.perform_positive_y_test q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) @@ -183,7 +183,7 @@ def pack_imtq_test_into( # noqa C901 sid = make_sid(object_id.as_bytes, ImtqSetId.POSITIVE_Y_TEST) q.add_pus_tc(generate_one_hk_command(sid)) - if op_code == OpCode.NEG_Y_SELF_TEST: + if cmd_str == OpCode.NEG_Y_SELF_TEST: q.add_log_cmd("IMTQ: Perform negative y self test") command = object_id.as_bytes + ImtqActionId.perform_negative_y_test q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) @@ -196,7 +196,7 @@ def pack_imtq_test_into( # noqa C901 sid = make_sid(object_id.as_bytes, ImtqSetId.NEGATIVE_Y_TEST) q.add_pus_tc(generate_one_hk_command(sid)) - if op_code == OpCode.POS_Z_SELF_TEST: + if cmd_str == OpCode.POS_Z_SELF_TEST: q.add_log_cmd("IMTQ: Perform positive z self test") command = object_id.as_bytes + ImtqActionId.perform_positive_z_test q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) @@ -209,7 +209,7 @@ def pack_imtq_test_into( # noqa C901 sid = make_sid(object_id.as_bytes, ImtqSetId.POSITIVE_Y_TEST) q.add_pus_tc(generate_one_hk_command(sid)) - if op_code == OpCode.NEG_Z_SELF_TEST: + if cmd_str == OpCode.NEG_Z_SELF_TEST: q.add_log_cmd("IMTQ: Perform negative z self test") command = object_id.as_bytes + ImtqActionId.perform_negative_z_test q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) @@ -220,7 +220,7 @@ def pack_imtq_test_into( # noqa C901 sid = make_sid(object_id.as_bytes, ImtqSetId.NEGATIVE_Z_TEST) q.add_pus_tc(generate_one_hk_command(sid)) - if op_code in OpCode.SET_DIPOLE: + if cmd_str in OpCode.SET_DIPOLE: x_dipole = int(input("Specify X dipole [range [0, 2000] * 10^-4 * Am^2]: ")) y_dipole = int(input("Specify Y dipole [range [0, 2000] * 10^-4 * Am^2]: ")) z_dipole = int(input("Specify Z dipole [range [0, 2000] * 10^-4 * Am^2]: ")) @@ -241,12 +241,12 @@ def pack_imtq_test_into( # noqa C901 ) ) - if op_code == "10": # doesnt seem to work anymore + if cmd_str == "10": # doesnt seem to work anymore q.add_log_cmd("IMTQ: Get commanded dipole") command = object_id.as_bytes + ImtqActionId.get_commanded_dipole q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == OpCode.ENABLE_ENG_HK_NO_TORQUE: + if cmd_str == OpCode.ENABLE_ENG_HK_NO_TORQUE: q.add_log_cmd("IMTQ: Enable ENG HK") interval = float(input("Please enter collection interval in seconds: ")) cmds = create_enable_periodic_hk_command_with_interval_with_diag( @@ -256,14 +256,14 @@ def pack_imtq_test_into( # noqa C901 ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code == OpCode.DISABLE_ENG_HK_NO_TORQUE: + if cmd_str == OpCode.DISABLE_ENG_HK_NO_TORQUE: q.add_log_cmd("IMTQ: Disable ENG HK (No Torque)") q.add_pus_tc( create_disable_periodic_hk_command_with_diag( True, make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_NO_TORQUE) ) ) - if op_code == OpCode.REQUEST_ENG_HK_WITH_TORQUE: + if cmd_str == OpCode.REQUEST_ENG_HK_WITH_TORQUE: q.add_log_cmd("IMTQ: Get engineering hk set with torque") q.add_pus_tc( create_request_one_diag_command( @@ -273,7 +273,7 @@ def pack_imtq_test_into( # noqa C901 ) ) ) - if op_code == OpCode.ENABLE_ENG_HK_WITH_TORQUE: + if cmd_str == OpCode.ENABLE_ENG_HK_WITH_TORQUE: q.add_log_cmd("IMTQ: Enable ENG HK with torque") interval = float(input("Please enter collection interval in seconds: ")) cmds = create_enable_periodic_hk_command_with_interval_with_diag( @@ -283,14 +283,14 @@ def pack_imtq_test_into( # noqa C901 ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code == OpCode.DISABLE_ENG_HK_WITH_TORQUE: + if cmd_str == OpCode.DISABLE_ENG_HK_WITH_TORQUE: q.add_log_cmd("IMTQ: Disable ENG HK with Torque") q.add_pus_tc( create_disable_periodic_hk_command_with_diag( True, make_sid(object_id.as_bytes, ImtqSetId.ENG_HK_SET_WITH_TORQUE) ) ) - if op_code == OpCode.REQUEST_ENG_HK_NO_TORQUE: + if cmd_str == OpCode.REQUEST_ENG_HK_NO_TORQUE: q.add_log_cmd("IMTQ: Get engineering hk set (no torque)") q.add_pus_tc( generate_one_diag_command( @@ -300,7 +300,7 @@ def pack_imtq_test_into( # noqa C901 ) ) - if op_code == "12": + if cmd_str == "12": q.add_log_cmd("IMTQ: Get calibrated MTM hk set") q.add_pus_tc( create_request_one_diag_command( @@ -308,7 +308,7 @@ def pack_imtq_test_into( # noqa C901 ) ) - if op_code == OpCode.REQUEST_MGM_RAW_NO_TORQUE: + if cmd_str == OpCode.REQUEST_MGM_RAW_NO_TORQUE: q.add_log_cmd("IMTQ: Get raw MTM hk set") q.add_pus_tc( create_request_one_diag_command( @@ -318,14 +318,14 @@ def pack_imtq_test_into( # noqa C901 ) ) - if op_code == OpCode.DISABLE_MGM_RAW_NO_TORQUE: + if cmd_str == OpCode.DISABLE_MGM_RAW_NO_TORQUE: q.add_log_cmd("IMTQ: Disable MGM RAW HK (No Torque)") q.add_pus_tc( create_disable_periodic_hk_command_with_diag( True, make_sid(object_id.as_bytes, ImtqSetId.RAW_MTM_NO_TORQUE) ) ) - if op_code == OpCode.ENABLE_MGM_RAW_NO_TORQUE: + if cmd_str == OpCode.ENABLE_MGM_RAW_NO_TORQUE: q.add_log_cmd("IMTQ: Enable MGM RAW HK (No Torque)") interval = float(input("Please enter collection interval in seconds: ")) cmds = create_enable_periodic_hk_command_with_interval_with_diag( @@ -335,7 +335,7 @@ def pack_imtq_test_into( # noqa C901 ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code == OpCode.REQUEST_MGM_RAW_WITH_TORQUE: + if cmd_str == OpCode.REQUEST_MGM_RAW_WITH_TORQUE: q.add_log_cmd("IMTQ: Get raw MTM hk set") q.add_pus_tc( create_request_one_diag_command( @@ -344,7 +344,7 @@ def pack_imtq_test_into( # noqa C901 ) ) ) - if op_code == OpCode.ENABLE_MGM_RAW_WITH_TORQUE: + if cmd_str == OpCode.ENABLE_MGM_RAW_WITH_TORQUE: q.add_log_cmd("IMTQ: Enable MGM RAW HK (No Torque)") interval = float(input("Please enter collection interval in seconds: ")) cmds = create_enable_periodic_hk_command_with_interval_with_diag( @@ -354,7 +354,7 @@ def pack_imtq_test_into( # noqa C901 ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code == OpCode.DISABLE_MGM_RAW_WITH_TORQUE: + if cmd_str == OpCode.DISABLE_MGM_RAW_WITH_TORQUE: q.add_log_cmd("IMTQ: Disable MGM RAW HK (No Torque)") q.add_pus_tc( create_disable_periodic_hk_command_with_diag( diff --git a/eive_tmtc/tmtc/acs/mgms.py b/eive_tmtc/tmtc/acs/mgms.py index 1166d94..f6f877b 100644 --- a/eive_tmtc/tmtc/acs/mgms.py +++ b/eive_tmtc/tmtc/acs/mgms.py @@ -47,17 +47,17 @@ MGM_SEL_DICT = { } -def handle_mgm_cmd(q: DefaultPusQueueHelper, op_code: str): +def handle_mgm_cmd(q: DefaultPusQueueHelper, cmd_str: str): print("Please select the MGM Device") for k, v in MGM_SEL_DICT.items(): print(f"{k}: {v[0]}") sel_idx = int(input("Select MGM device by index: ")) mgm_info = MGM_SEL_DICT[MgmSel(sel_idx)] mgm_obj_id = mgm_info[1] - if op_code == OpCode.NORMAL: + if cmd_str == OpCode.NORMAL: q.add_log_cmd(f"Gyro {mgm_info[0]} NORMAL mode") q.add_pus_tc(create_mode_command(mgm_obj_id, Mode.NORMAL, 0)) - if op_code == OpCode.OFF: + if cmd_str == OpCode.OFF: q.add_log_cmd(f"Gyro {mgm_info[0]} OFF mode") q.add_pus_tc(create_mode_command(mgm_obj_id, Mode.OFF, 0)) diff --git a/eive_tmtc/tmtc/acs/reaction_wheels.py b/eive_tmtc/tmtc/acs/reaction_wheels.py index 7fe3b9b..5f07864 100644 --- a/eive_tmtc/tmtc/acs/reaction_wheels.py +++ b/eive_tmtc/tmtc/acs/reaction_wheels.py @@ -144,10 +144,10 @@ def add_rw_cmds(defs: TmtcDefinitionWrapper): ) -def pack_single_rw_test_into( # noqa C901: Complexity is okay here. - object_id: bytes, rw_idx: int, q: DefaultPusQueueHelper, op_code: str +def create_single_rw_cmd( # noqa C901: Complexity is okay here. + object_id: bytes, rw_idx: int, q: DefaultPusQueueHelper, cmd_str: str ): - if op_code == OpCodesDev.SPEED: + if cmd_str == OpCodesDev.SPEED: speed, ramp_time = prompt_speed_ramp_time() q.add_log_cmd( f"RW {rw_idx}: {InfoDev.SPEED} with target " @@ -155,41 +155,41 @@ def pack_single_rw_test_into( # noqa C901: Complexity is okay here. ) q.add_pus_tc(pack_set_speed_command(object_id, speed, ramp_time)) - if op_code == OpCodesDev.ON: + if cmd_str == OpCodesDev.ON: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.ON}") mode_data = pack_mode_data(object_id, Mode.ON, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) - if op_code == OpCodesDev.NML: + if cmd_str == OpCodesDev.NML: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.NML}") mode_data = pack_mode_data(object_id, Mode.NORMAL, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) - if op_code == OpCodesDev.OFF: + if cmd_str == OpCodesDev.OFF: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.OFF}") mode_data = pack_mode_data(object_id, Mode.OFF, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) - if op_code == OpCodesDev.GET_TM: + if cmd_str == OpCodesDev.GET_TM: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.GET_TM}") q.add_pus_tc( generate_one_hk_command( sid=make_sid(object_id=object_id, set_id=RwSetId.TM_SET) ) ) - if op_code == OpCodesDev.REQ_TM: + if cmd_str == OpCodesDev.REQ_TM: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.REQ_TM}") q.add_pus_tc( create_action_cmd(object_id=object_id, action_id=ActionId.REQUEST_TM) ) - if op_code in OpCodesDev.GET_STATUS: + if cmd_str in OpCodesDev.GET_STATUS: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.GET_STATUS}") q.add_pus_tc( generate_one_diag_command( sid=make_sid(object_id=object_id, set_id=RwSetId.STATUS_SET_ID) ) ) - if op_code in OpCodesDev.ENABLE_STATUS_HK: + if cmd_str in OpCodesDev.ENABLE_STATUS_HK: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.ENABLE_STATUS_HK}") interval = float(input("Please enter HK interval in floating point seconds: ")) cmds = enable_periodic_hk_command_with_interval( @@ -197,7 +197,7 @@ def pack_single_rw_test_into( # noqa C901: Complexity is okay here. ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code in OpCodesDev.DISABLE_STATUS_HK: + if cmd_str in OpCodesDev.DISABLE_STATUS_HK: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.DISABLE_STATUS_HK}") q.add_pus_tc( disable_periodic_hk_command( @@ -206,32 +206,32 @@ def pack_single_rw_test_into( # noqa C901: Complexity is okay here. ) -def pack_rw_ass_cmds(q: DefaultPusQueueHelper, object_id: bytes, op_code: str): - if op_code in OpCodesAss.OFF: +def pack_rw_ass_cmds(q: DefaultPusQueueHelper, object_id: bytes, cmd_str: str): + if cmd_str in OpCodesAss.OFF: data = pack_mode_data(object_id=object_id, mode=Mode.OFF, submode=0) q.add_pus_tc( PusTelecommand( service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=data ) ) - if op_code in OpCodesAss.ON: + if cmd_str in OpCodesAss.ON: data = pack_mode_data(object_id=object_id, mode=Mode.ON, submode=0) q.add_pus_tc( PusTelecommand( service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=data ) ) - if op_code in OpCodesAss.NML: + if cmd_str in OpCodesAss.NML: data = pack_mode_data(object_id=object_id, mode=Mode.NORMAL, submode=0) q.add_pus_tc( PusTelecommand( service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=data ) ) - if op_code in OpCodesAss.ALL_SPEED_UP: + if cmd_str in OpCodesAss.ALL_SPEED_UP: speed, ramp_time = prompt_speed_ramp_time() rw_speed_up_cmd_consec(q, [RW1_ID, RW2_ID, RW3_ID, RW4_ID], speed, ramp_time) - if op_code in OpCodesAss.ALL_SPEED_OFF: + if cmd_str in OpCodesAss.ALL_SPEED_OFF: rw_speed_down_cmd_consec( q, [RW1_ID, RW2_ID, RW3_ID, RW4_ID], prompt_ramp_time() ) diff --git a/eive_tmtc/tmtc/acs/star_tracker.py b/eive_tmtc/tmtc/acs/star_tracker.py index 17fec8b..f891b9e 100644 --- a/eive_tmtc/tmtc/acs/star_tracker.py +++ b/eive_tmtc/tmtc/acs/star_tracker.py @@ -238,68 +238,68 @@ def prompt_object_id_mode_cmd() -> bytes: def pack_star_tracker_commands( # noqa C901 - object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str + object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str ): q.add_log_cmd( f"Generate command for star tracker with object id: {object_id.as_hex_string}" ) obyt = object_id.as_bytes - if op_code == OpCodes.ON_BOOTLOADER: + if cmd_str == OpCodes.ON_BOOTLOADER: q.add_log_cmd("Star tracker: Mode On, Submode Bootloader") data = pack_mode_data(prompt_object_id_mode_cmd(), Mode.ON, Submode.BOOTLOADER) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) - if op_code == OpCodes.ON_FIRMWARE: + if cmd_str == OpCodes.ON_FIRMWARE: q.add_log_cmd("Star tracker: Mode On, Submode Firmware") data = pack_mode_data(prompt_object_id_mode_cmd(), Mode.ON, Submode.FIRMWARE) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) - if op_code == OpCodes.NORMAL: + if cmd_str == OpCodes.NORMAL: q.add_log_cmd("Star tracker: Mode Normal") data = pack_mode_data(prompt_object_id_mode_cmd(), Mode.NORMAL, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) - if op_code == OpCodes.OFF: + if cmd_str == OpCodes.OFF: q.add_log_cmd("Star tracker: Mode Off") data = pack_mode_data(prompt_object_id_mode_cmd(), Mode.OFF, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) - if op_code == OpCodes.ONE_SHOOT_HK: + if cmd_str == OpCodes.ONE_SHOOT_HK: q.add_log_cmd(Info.ONE_SHOOT_HK) request_dataset(q, DataSetRequest.ONESHOT) - if op_code == OpCodes.ENABLE_HK: + if cmd_str == OpCodes.ENABLE_HK: q.add_log_cmd(Info.ENABLE_HK) request_dataset(q, DataSetRequest.ENABLE) - if op_code == OpCodes.DISABLE_HK: + if cmd_str == OpCodes.DISABLE_HK: q.add_log_cmd(Info.DISABLE_HK) request_dataset(q, DataSetRequest.DISABLE) - if op_code == "4": + if cmd_str == "4": q.add_log_cmd("Star tracker: Mode Raw") data = pack_mode_data(obyt, Mode.RAW, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) - if op_code == OpCodes.PING: + if cmd_str == OpCodes.PING: q.add_log_cmd("Star tracker: Ping") data = obyt + struct.pack("!I", StarTrackerActionId.PING) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "6": + if cmd_str == "6": q.add_log_cmd("Star tracker: Switch to bootloader program") data = obyt + struct.pack( "!I", StarTrackerActionId.SWITCH_TO_BOOTLOADER_PROGRAM ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "7": + if cmd_str == "7": q.add_log_cmd("Star tracker: Temperature request") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_TEMPERATURE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "8": + if cmd_str == "8": q.add_log_cmd("Star tracker: Request version") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_VERSION) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "9": + if cmd_str == "9": q.add_log_cmd("Star tracker: Request interface") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_INTERFACE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "10": + if cmd_str == "10": q.add_log_cmd("Star tracker: Request power") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_POWER) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "11": + if cmd_str == "11": q.add_log_cmd("Star tracker: Set subscription parameters") json_file = get_config_file() data = ( @@ -308,15 +308,15 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "12": + if cmd_str == "12": q.add_log_cmd("Star tracker: Boot") data = obyt + struct.pack("!I", StarTrackerActionId.BOOT) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "13": + if cmd_str == "13": q.add_log_cmd("Star tracker: Request time") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_TIME) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCodes.UPLOAD_IMAGE: + if cmd_str == OpCodes.UPLOAD_IMAGE: q.add_log_cmd("Star tracker: Upload image") image = get_upload_image() data = ( @@ -325,7 +325,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(image, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCodes.DOWNLOAD_IMAGE: + if cmd_str == OpCodes.DOWNLOAD_IMAGE: q.add_log_cmd(f"STR: {Info.DOWNLOAD_IMAGE}") path = input("Specify storage location (default - /mnt/sd0/startracker): ") if not path: @@ -336,7 +336,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(path, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "17": + if cmd_str == "17": q.add_log_cmd("Star tracker: Set limits") json_file = get_config_file() data = ( @@ -345,7 +345,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "18": + if cmd_str == "18": q.add_log_cmd("Star tracker: Set tracking parameters") json_file = get_config_file() data = ( @@ -354,7 +354,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "19": + if cmd_str == "19": q.add_log_cmd("Star tracker: Mounting") json_file = get_config_file() data = ( @@ -363,7 +363,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "20": + if cmd_str == "20": q.add_log_cmd("Star tracker: Camera") json_file = get_config_file() data = ( @@ -372,7 +372,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "22": + if cmd_str == "22": q.add_log_cmd("Star tracker: Centroiding") json_file = get_config_file() data = ( @@ -381,7 +381,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "23": + if cmd_str == "23": q.add_log_cmd("Star tracker: LISA") json_file = get_config_file() data = ( @@ -390,7 +390,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "24": + if cmd_str == "24": q.add_log_cmd("Star tracker: Matching") json_file = get_config_file() data = ( @@ -399,7 +399,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "25": + if cmd_str == "25": q.add_log_cmd("Star tracker: Validation") json_file = get_config_file() data = ( @@ -408,7 +408,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "26": + if cmd_str == "26": q.add_log_cmd("Star tracker: Algo") json_file = get_config_file() data = ( @@ -417,7 +417,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCodes.TAKE_IMAGE: + if cmd_str == OpCodes.TAKE_IMAGE: q.add_log_cmd("Star tracker: Take image") actionid = int( input("Specify parameter ID (4: take image, 7: get histogram): ") @@ -428,11 +428,11 @@ def pack_star_tracker_commands( # noqa C901 + struct.pack("!B", actionid) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "28": + if cmd_str == "28": q.add_log_cmd("Star tracker: Stop str helper") data = obyt + struct.pack("!I", StarTrackerActionId.STOP_STR_HELPER) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "30": + if cmd_str == "30": q.add_log_cmd("Star tracker: Set name of download image") filename = input("Specify download image name: ") data = ( @@ -441,15 +441,15 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(filename, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "31": + if cmd_str == "31": q.add_log_cmd("Star tracker: Request histogram") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_HISTOGRAM) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "32": + if cmd_str == "32": q.add_log_cmd("Star tracker: Request contrast") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_CONTRAST) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "33": + if cmd_str == "33": q.add_log_cmd("Star tracker: Set json filename") json_file = get_config_file() data = ( @@ -458,11 +458,11 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "35": + if cmd_str == "35": q.add_log_cmd("Star tracker: Flash read") data = pack_read_command(obyt) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "36": + if cmd_str == "36": q.add_log_cmd("Star tracker: Set flash read filename") filename = input("Specify filename: ") data = ( @@ -471,15 +471,15 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(filename, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "37": + if cmd_str == "37": q.add_log_cmd("Star tracker: Get checksum") data = pack_checksum_command(obyt) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCodes.SET_TIME_FROM_SYS_TIME: + if cmd_str == OpCodes.SET_TIME_FROM_SYS_TIME: q.add_log_cmd(Info.SET_TIME_FROM_SYS_TIME) data = obyt + struct.pack("!I", StarTrackerActionId.SET_TIME_FROM_SYS_TIME) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "39": + if cmd_str == "39": q.add_log_cmd("Star tracker: Download Centroid") id = 0 data = ( @@ -488,7 +488,7 @@ def pack_star_tracker_commands( # noqa C901 + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "41": + if cmd_str == "41": q.add_log_cmd("Star tracker: Download matched star") id = 0 data = ( @@ -497,7 +497,7 @@ def pack_star_tracker_commands( # noqa C901 + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "42": + if cmd_str == "42": q.add_log_cmd("Star tracker: Download DB Image") id = 0 data = ( @@ -506,7 +506,7 @@ def pack_star_tracker_commands( # noqa C901 + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "43": + if cmd_str == "43": q.add_log_cmd("Star tracker: Download Blob Pixel") id = 0 type = 1 # 0 - normal, 1 - fast @@ -517,7 +517,7 @@ def pack_star_tracker_commands( # noqa C901 + struct.pack("!B", type) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "47": + if cmd_str == "47": q.add_log_cmd("Star tracker: FPGA action") id = 3 data = ( @@ -526,19 +526,19 @@ def pack_star_tracker_commands( # noqa C901 + struct.pack("!B", id) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "48": + if cmd_str == "48": q.add_log_cmd("Star tracker: Unlock") data = obyt + struct.pack("!I", StarTrackerActionId.UNLOCK) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "49": + if cmd_str == "49": q.add_log_cmd("Star tracker: Request camera parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_CAMERA_PARAMS) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "50": + if cmd_str == "50": q.add_log_cmd("Star tracker: Request limits") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_LIMITS) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCodes.SET_IMG_PROCESSOR_MODE: + if cmd_str == OpCodes.SET_IMG_PROCESSOR_MODE: q.add_log_cmd(Info.SET_IMG_PROCESSOR_MODE) json_file = get_config_file() data = ( @@ -547,7 +547,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "52": + if cmd_str == "52": q.add_log_cmd("Star tracker: EGSE load ground config camera parameters") data = ( obyt @@ -555,7 +555,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(FileDefs.egse_ground_config, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "53": + if cmd_str == "53": q.add_log_cmd("Star tracker: EGSE load flight config camera parameters") data = ( obyt @@ -563,55 +563,55 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(FileDefs.egse_flight_config, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "54": + if cmd_str == "54": q.add_log_cmd("Star tracker: Request log level parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_LOG_LEVEL) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "55": + if cmd_str == "55": q.add_log_cmd("Star tracker: Request mounting parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_MOUNTING) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "56": + if cmd_str == "56": q.add_log_cmd("Star tracker: Request image processor parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_IMAGE_PROCESSOR) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "57": + if cmd_str == "57": q.add_log_cmd("Star tracker: Request centroiding parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_CENTROIDING) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "58": + if cmd_str == "58": q.add_log_cmd("Star tracker: Request lisa parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_LISA) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "59": + if cmd_str == "59": q.add_log_cmd("Star tracker: Request matching parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_MATCHING) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "60": + if cmd_str == "60": q.add_log_cmd("Star tracker: Request tracking parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_TRACKING) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "61": + if cmd_str == "61": q.add_log_cmd("Star tracker: Request validation parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_VALIDATION) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "62": + if cmd_str == "62": q.add_log_cmd("Star tracker: Request algo parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_ALGO) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "63": + if cmd_str == "63": q.add_log_cmd("Star tracker: Request subscription parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_SUBSCRIPTION) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "64": + if cmd_str == "64": q.add_log_cmd("Star tracker: Request log subscription parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_LOG_SUBSCRIPTION) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "65": + if cmd_str == "65": q.add_log_cmd("Star tracker: Request debug camera parameters") data = obyt + struct.pack("!I", StarTrackerActionId.REQ_DEBUG_CAMERA) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "66": + if cmd_str == "66": q.add_log_cmd("Star tracker: Set log level parameters") json_file = get_config_file() data = ( @@ -620,7 +620,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "67": + if cmd_str == "67": q.add_log_cmd("Star tracker: Set log subscription parameters") json_file = get_config_file() @@ -630,7 +630,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "68": + if cmd_str == "68": q.add_log_cmd("Star tracker: Set debug camera parameters") json_file = get_config_file() data = ( @@ -639,7 +639,7 @@ def pack_star_tracker_commands( # noqa C901 + bytearray(json_file, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCodes.FW_UPDATE: + if cmd_str == OpCodes.FW_UPDATE: q.add_log_cmd(Info.FW_UPDATE) firmware = get_firmware() data = ( @@ -648,7 +648,7 @@ def pack_star_tracker_commands( # noqa C901 + firmware.encode() ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCodes.ADD_SECONDARY_TM_TO_NORMAL_MODE: + if cmd_str == OpCodes.ADD_SECONDARY_TM_TO_NORMAL_MODE: q.add_log_cmd(Info.ADD_SECONDARY_TM_TO_NORMAL_MODE) for val in SetId: print("{:<2}: {:<20}".format(val, val.name)) @@ -660,7 +660,7 @@ def pack_star_tracker_commands( # noqa C901 struct.pack("!I", set_id), ) ) - if op_code == OpCodes.RESET_SECONDARY_TM_SET: + if cmd_str == OpCodes.RESET_SECONDARY_TM_SET: q.add_log_cmd(Info.RESET_SECONDARY_TM_SET) q.add_pus_tc( create_action_cmd( @@ -668,7 +668,7 @@ def pack_star_tracker_commands( # noqa C901 StarTrackerActionId.RESET_SECONDARY_TM_SET, ) ) - if op_code == OpCodes.READ_SECONDARY_TM_SET: + if cmd_str == OpCodes.READ_SECONDARY_TM_SET: q.add_log_cmd(Info.READ_SECONDARY_TM_SET) q.add_pus_tc( create_action_cmd( diff --git a/eive_tmtc/tmtc/com/ccsds_handler.py b/eive_tmtc/tmtc/com/ccsds_handler.py index 4aba6ed..5ddcc97 100644 --- a/eive_tmtc/tmtc/com/ccsds_handler.py +++ b/eive_tmtc/tmtc/com/ccsds_handler.py @@ -67,29 +67,29 @@ class Info: def pack_ccsds_handler_command( # noqa C901 - object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str + object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str ): obyt = object_id.as_bytes prefix = "CCSDS Handler" q.add_log_cmd(f"Testing CCSDS handler with object id: {object_id.as_hex_string}") - if op_code in OpCode.ENABLE_WITH_LOW_DATARATE: + if cmd_str in OpCode.ENABLE_WITH_LOW_DATARATE: q.add_log_cmd(f"{prefix}: {Info.ENABLE_WITH_LOW_DATARATE}") q.add_pus_tc(create_mode_command(obyt, Mode.ON, Submode.DATARATE_LOW)) - if op_code in OpCode.ENABLE_WITH_HIGH_DATARATE: + if cmd_str in OpCode.ENABLE_WITH_HIGH_DATARATE: q.add_log_cmd(f"{prefix}: {Info.ENABLE_WITH_HIGH_DATARATE}") q.add_pus_tc(create_mode_command(obyt, Mode.ON, Submode.DATARATE_HIGH)) - if op_code in OpCode.DISABLE: + if cmd_str in OpCode.DISABLE: q.add_log_cmd(f"{prefix}: {Info.DISABLE}") q.add_pus_tc(create_mode_command(obyt, Mode.OFF, 0)) - if op_code in OpCode.ENABLE_ACTION: + if cmd_str in OpCode.ENABLE_ACTION: q.add_log_cmd(f"{prefix}: {Info.ENABLE_ACTION}") command = obyt + struct.pack("!I", ActionId.EN_TRANSMITTER) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCode.DISABLE_ACTION: + if cmd_str in OpCode.DISABLE_ACTION: q.add_log_cmd(f"{prefix}: {Info.DISABLE_ACTION}") command = obyt + struct.pack("!I", ActionId.DIS_TRANSMITTER) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "4": + if cmd_str == "4": q.add_log_cmd("CCSDS Handler: Set arbitrary bitrate") bitrate = int(input("Specify bit rate (bps): ")) command = ( @@ -98,19 +98,19 @@ def pack_ccsds_handler_command( # noqa C901 + struct.pack("!I", bitrate) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "5": + if cmd_str == "5": q.add_log_cmd("CCSDS Handler: Enable tx clock manipulator") command = obyt + struct.pack("!I", ActionId.ENABLE_TX_CLK_MANIPULATOR) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "6": + if cmd_str == "6": q.add_log_cmd("CCSDS Handler: Disable tx clock manipulator") command = obyt + struct.pack("!I", ActionId.DISABLE_TX_CLK_MANIPULATOR) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "7": + if cmd_str == "7": q.add_log_cmd("CCSDS Handler: Update tx data on rising edge of tx clock") command = obyt + struct.pack("!I", ActionId.UPDATE_ON_RISING_EDGE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "8": + if cmd_str == "8": q.add_log_cmd("CCSDS Handler: Update tx data on falling edge of tx clock") command = obyt + struct.pack("!I", ActionId.UPDATE_ON_FALLING_EDGE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) diff --git a/eive_tmtc/tmtc/com/pdec_handler.py b/eive_tmtc/tmtc/com/pdec_handler.py index 24e7a1f..5ac69b4 100644 --- a/eive_tmtc/tmtc/com/pdec_handler.py +++ b/eive_tmtc/tmtc/com/pdec_handler.py @@ -60,20 +60,20 @@ class Info: RESET_NO_INIT = "Reset with mandatory initialization" -def pack_pdec_handler_test( - object_id: bytearray, q: DefaultPusQueueHelper, op_code: str +def pack_pdec_handler_commands( + object_id: bytes, q: DefaultPusQueueHelper, cmd_str: str ): q.add_log_cmd(f"Testing PDEC handler with object id: {object_id.hex()}") prefix = "PDEC Handler " - if op_code == OpCode.PRINT_CLCW: + if cmd_str == OpCode.PRINT_CLCW: q.add_log_cmd(f"{prefix}: {Info.PRINT_CLCW}") command = object_id + CommandId.PRINT_CLCW q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == OpCode.PRINT_MON_REG: + if cmd_str == OpCode.PRINT_MON_REG: q.add_log_cmd(f"{prefix}: {Info.PRINT_MON_REG}") command = object_id + CommandId.PRINT_PDEC_MON q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == OpCode.POSITIVE_WINDOW: + if cmd_str == OpCode.POSITIVE_WINDOW: q.add_log_cmd(f"{prefix}: {Info.POSITIVE_WINDOW}") pw = int(input("Specify positive window to set: ")) q.add_pus_tc( @@ -86,7 +86,7 @@ def pack_pdec_handler_test( ) ) ) - if op_code == OpCode.NEGATIVE_WINDOW: + if cmd_str == OpCode.NEGATIVE_WINDOW: q.add_log_cmd(f"{prefix}: {Info.NEGATIVE_WINDOW}") nw = int(input("Specify negative window to set: ")) q.add_pus_tc( @@ -99,12 +99,12 @@ def pack_pdec_handler_test( ) ) ) - if op_code == OpCode.RESET_NO_INIT: + if cmd_str == OpCode.RESET_NO_INIT: q.add_log_cmd(f"{prefix}: {Info.RESET_NO_INIT}") q.add_pus_tc( create_action_cmd(object_id=object_id, action_id=ActionId.RESET_NO_INIT) ) - if op_code == OpCode.RESET_WITH_INIT: + if cmd_str == OpCode.RESET_WITH_INIT: q.add_log_cmd(f"{prefix}: {Info.RESET_WITH_INIT}") q.add_pus_tc( create_action_cmd(object_id=object_id, action_id=ActionId.RESET_WITH_INIT) diff --git a/eive_tmtc/tmtc/com/syrlinks_handler.py b/eive_tmtc/tmtc/com/syrlinks_handler.py index 608d101..8a1fada 100644 --- a/eive_tmtc/tmtc/com/syrlinks_handler.py +++ b/eive_tmtc/tmtc/com/syrlinks_handler.py @@ -143,42 +143,42 @@ def normal_mode_cmd(q: DefaultPusQueueHelper, info: str, submode: int): def pack_syrlinks_command( # noqa C901: Complexity okay here. - object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str + object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str ): obyt = object_id.as_bytes prefix = "Syrlinks" q.add_log_cmd(f"Testing Syrlinks with object id: {object_id.as_hex_string}") - if op_code == OpCode.OFF: + if cmd_str == OpCode.OFF: q.add_log_cmd(f"{prefix}: {Info.OFF}") q.add_pus_tc(create_mode_command(obyt, Mode.OFF, 0)) - if op_code == OpCode.ON: + if cmd_str == OpCode.ON: q.add_log_cmd(f"{prefix}: {Info.ON}") q.add_pus_tc(create_mode_command(obyt, Mode.ON, ComMode.RX_ONLY)) - if op_code == OpCode.NORMAL_RX_ONLY: + if cmd_str == OpCode.NORMAL_RX_ONLY: normal_mode_cmd(q, Info.NORMAL_RX_ONLY, ComMode.RX_ONLY) - if op_code == OpCode.NORMAL_RX_AND_TX_LOW_DATARATE: + if cmd_str == OpCode.NORMAL_RX_AND_TX_LOW_DATARATE: normal_mode_cmd( q, Info.NORMAL_RX_AND_TX_LOW_DATARATE, ComMode.RX_AND_TX_LOW_DATARATE ) - if op_code == OpCode.NORMAL_RX_AND_TX_DEF_DATARATE: + if cmd_str == OpCode.NORMAL_RX_AND_TX_DEF_DATARATE: normal_mode_cmd( q, Info.NORMAL_RX_AND_TX_DEF_DATARATE, ComMode.RX_AND_TX_DEF_DATARATE ) - if op_code == OpCode.NORMAL_RX_AND_TX_HIGH_DATARATE: + if cmd_str == OpCode.NORMAL_RX_AND_TX_HIGH_DATARATE: normal_mode_cmd( q, Info.NORMAL_RX_AND_TX_HIGH_DATARATE, ComMode.RX_AND_TX_HIGH_DATARATE ) - if op_code in OpCode.NORMAL_RX_AND_TX_CW: + if cmd_str in OpCode.NORMAL_RX_AND_TX_CW: normal_mode_cmd(q, Info.NORMAL_RX_AND_TX_CW, ComMode.RX_AND_TX_CARRIER_WAVE) - if op_code in OpCode.HK_RX_REGS: + if cmd_str in OpCode.HK_RX_REGS: q.add_log_cmd(f"{prefix}: {Info.HK_RX_REGS}") sid = make_sid(obyt, SetId.RX_REGISTERS_DATASET) q.add_pus_tc(create_request_one_diag_command(sid)) - if op_code in OpCode.HK_TEMPS: + if cmd_str in OpCode.HK_TEMPS: q.add_log_cmd(f"{prefix}: {Info.HK_TEMPS}") sid = make_sid(obyt, SetId.TEMPERATURE_SET_ID) q.add_pus_tc(create_request_one_hk_command(sid)) - if op_code in OpCode.ENABLE_HK_RX_REGS: + if cmd_str in OpCode.ENABLE_HK_RX_REGS: q.add_log_cmd(f"{prefix}: {Info.ENABLE_HK_RX_REGS}") sid = make_sid(obyt, SetId.RX_REGISTERS_DATASET) interval = float(input("HK interval in floating point seconds")) @@ -187,11 +187,11 @@ def pack_syrlinks_command( # noqa C901: Complexity okay here. ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code in OpCode.DISABLE_HK_RX_REGS: + if cmd_str in OpCode.DISABLE_HK_RX_REGS: q.add_log_cmd(f"{prefix}: {Info.DISABLE_HK_RX_REGS}") sid = make_sid(obyt, SetId.RX_REGISTERS_DATASET) q.add_pus_tc(create_disable_periodic_hk_command_with_diag(True, sid)) - if op_code in OpCode.ENABLE_HK_TX_REGS: + if cmd_str in OpCode.ENABLE_HK_TX_REGS: q.add_log_cmd(f"{prefix}: {Info.ENABLE_HK_TX_REGS}") sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET) interval = float(input("HK interval in floating point seconds")) @@ -200,59 +200,59 @@ def pack_syrlinks_command( # noqa C901: Complexity okay here. ) for cmd in cmds: q.add_pus_tc(cmd) - if op_code in OpCode.DISABLE_HK_TX_REGS: + if cmd_str in OpCode.DISABLE_HK_TX_REGS: q.add_log_cmd(f"{prefix}: {Info.DISABLE_HK_TX_REGS}") sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET) q.add_pus_tc(create_disable_periodic_hk_command_with_diag(True, sid)) - if op_code in OpCode.HK_TX_REGS: + if cmd_str in OpCode.HK_TX_REGS: q.add_log_cmd(f"{prefix}: {Info.HK_TX_REGS}") sid = make_sid(obyt, SetId.TX_REGISTERS_DATASET) q.add_pus_tc(create_request_one_diag_command(sid)) - if op_code in OpCode.TX_STATUS: + if cmd_str in OpCode.TX_STATUS: q.add_log_cmd(f"{prefix}: {Info.TX_STATUS}") command = obyt + struct.pack("!I", CommandId.READ_TX_STATUS) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "9": + if cmd_str == "9": q.add_log_cmd("Syrlinks: Read TX waveform") command = obyt + struct.pack("!I", CommandId.READ_TX_WAVEFORM) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "10": + if cmd_str == "10": q.add_log_cmd("Syrlinks: Read TX AGC value high byte") command = obyt + struct.pack("!I", CommandId.READ_TX_AGC_VALUE_HIGH_BYTE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "11": + if cmd_str == "11": q.add_log_cmd("Syrlinks: Read TX AGC value low byte") command = obyt + struct.pack("!I", CommandId.READ_TX_AGC_VALUE_LOW_BYTE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "12": + if cmd_str == "12": q.add_log_cmd("Syrlinks: Write LCL config") command = obyt + struct.pack("!I", CommandId.WRITE_LCL_CONFIG) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "13": + if cmd_str == "13": q.add_log_cmd("Syrlinks: Read RX status registers") command = obyt + struct.pack("!I", CommandId.READ_RX_STATUS_REGISTERS) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "14": + if cmd_str == "14": q.add_log_cmd("Syrlinks: Read LCL config register") command = obyt + struct.pack("!I", CommandId.READ_LCL_CONFIG_REGISTER) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "15": + if cmd_str == "15": q.add_log_cmd("Syrlinks: Set waveform OQPSK") command = obyt + struct.pack("!I", CommandId.SET_WAVEFORM_OQPSK) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "16": + if cmd_str == "16": q.add_log_cmd("Syrlinks: Set waveform BPSK") command = obyt + struct.pack("!I", CommandId.SET_WAVEFORM_BPSK) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "17": + if cmd_str == "17": q.add_log_cmd("Syrlinks: Set second config") command = obyt + struct.pack("!I", CommandId.SET_SECOND_CONFIG) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "18": + if cmd_str == "18": q.add_log_cmd("Syrlinks: Enable debug printout") command = obyt + struct.pack("!I", CommandId.ENABLE_DEBUG) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "19": + if cmd_str == "19": q.add_log_cmd("Syrlinks: Disable debug printout") command = obyt + struct.pack("!I", CommandId.DISABLE_DEBUG) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) diff --git a/eive_tmtc/tmtc/core.py b/eive_tmtc/tmtc/core.py index a8f5faf..d7b4170 100644 --- a/eive_tmtc/tmtc/core.py +++ b/eive_tmtc/tmtc/core.py @@ -245,22 +245,22 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper): def pack_core_commands( # noqa C901 - q: DefaultPusQueueHelper, op_code: str + q: DefaultPusQueueHelper, cmd_str: str ): # noqa: C901 , complexity okay here - if op_code == OpCode.ANNOUNCE_VERSION: + if cmd_str == OpCode.ANNOUNCE_VERSION: q.add_log_cmd(f"{Info.ANNOUNCE_VERSION}") q.add_pus_tc(create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_VERSION)) - elif op_code == OpCode.ANNOUNCE_CURRENT_IMAGE: + elif cmd_str == OpCode.ANNOUNCE_CURRENT_IMAGE: q.add_log_cmd(f"{Info.ANNOUNCE_CURRENT_IMAGE}") q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_CURRENT_IMAGE) ) - elif op_code == OpCode.ANNOUNCE_BOOT_COUNTS: + elif cmd_str == OpCode.ANNOUNCE_BOOT_COUNTS: q.add_log_cmd(f"{Info.ANNOUNCE_BOOT_COUNTS}") q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_BOOT_COUNTS) ) - elif op_code in OpCode.REBOOT_XSC: + elif cmd_str in OpCode.REBOOT_XSC: reboot_self, chip_select, copy_select = determine_reboot_params() add_xsc_reboot_cmd( q=q, @@ -268,16 +268,16 @@ def pack_core_commands( # noqa C901 chip=chip_select, copy=copy_select, ) - elif op_code in OpCode.REBOOT_FULL: + elif cmd_str in OpCode.REBOOT_FULL: q.add_log_cmd(f"Core Command: {Info.REBOOT_FULL}") q.add_pus_tc( create_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionId.FULL_REBOOT ) ) - elif op_code in OpCode.XSC_REBOOT_SELF: + elif cmd_str in OpCode.XSC_REBOOT_SELF: add_xsc_reboot_cmd(q=q, reboot_self=True) - elif op_code == OpCode.SYSTEMCTL_CMD_EXECUTOR: + elif cmd_str == OpCode.SYSTEMCTL_CMD_EXECUTOR: print("systemctl command types: ") for entry in SystemctlCmd: print(f"{entry}: {entry.name}") @@ -286,7 +286,7 @@ def pack_core_commands( # noqa C901 ) unit_name = input("Specify unit name: ") q.add_pus_tc(create_systemctl_cmd(systemctl_cmd, unit_name)) - elif op_code == OpCode.EXECUTE_SHELL_CMD_BLOCKING: + elif cmd_str == OpCode.EXECUTE_SHELL_CMD_BLOCKING: custom_cmd = input("Please specify command to execute: ") q.add_pus_tc( create_action_cmd( @@ -295,7 +295,7 @@ def pack_core_commands( # noqa C901 user_data=custom_cmd.encode(), ) ) - elif op_code == OpCode.EXECUTE_SHELL_CMD_NON_BLOCKING: + elif cmd_str == OpCode.EXECUTE_SHELL_CMD_NON_BLOCKING: custom_cmd = input("Please specify command to execute: ") q.add_pus_tc( create_action_cmd( @@ -304,29 +304,29 @@ def pack_core_commands( # noqa C901 user_data=custom_cmd.encode(), ) ) - elif op_code in OpCode.XSC_REBOOT_0_0: + elif cmd_str in OpCode.XSC_REBOOT_0_0: add_xsc_reboot_cmd( q=q, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_0_NOM ) - elif op_code in OpCode.XSC_REBOOT_0_1: + elif cmd_str in OpCode.XSC_REBOOT_0_1: add_xsc_reboot_cmd( q=q, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_1_GOLD, ) - elif op_code in OpCode.XSC_REBOOT_1_0: + elif cmd_str in OpCode.XSC_REBOOT_1_0: add_xsc_reboot_cmd( q=q, reboot_self=False, chip=Chip.CHIP_1, copy=Copy.COPY_0_NOM ) - elif op_code in OpCode.XSC_REBOOT_1_1: + elif cmd_str in OpCode.XSC_REBOOT_1_1: add_xsc_reboot_cmd( q=q, reboot_self=False, chip=Chip.CHIP_1, copy=Copy.COPY_1_GOLD, ) - elif op_code == OpCode.READ_REBOOT_MECHANISM_INFO: + elif cmd_str == OpCode.READ_REBOOT_MECHANISM_INFO: q.add_log_cmd(Info.READ_REBOOT_MECHANISM_INFO) q.add_pus_tc( create_action_cmd( @@ -334,7 +334,7 @@ def pack_core_commands( # noqa C901 action_id=ActionId.READ_REBOOT_MECHANISM_INFO, ) ) - elif op_code == OpCode.DISABLE_REBOOT_FILE_HANDLING: + elif cmd_str == OpCode.DISABLE_REBOOT_FILE_HANDLING: q.add_log_cmd("Disabling reboot file handling") user_data = bytearray([0]) q.add_pus_tc( @@ -344,7 +344,7 @@ def pack_core_commands( # noqa C901 user_data=user_data, ) ) - elif op_code == OpCode.ENABLE_REBOOT_FILE_HANDLING: + elif cmd_str == OpCode.ENABLE_REBOOT_FILE_HANDLING: q.add_log_cmd("Enabling reboot file handling") user_data = bytearray([1]) q.add_pus_tc( @@ -354,7 +354,7 @@ def pack_core_commands( # noqa C901 user_data=user_data, ) ) - elif op_code == OpCode.RESET_ALL_REBOOT_COUNTERS: + elif cmd_str == OpCode.RESET_ALL_REBOOT_COUNTERS: q.add_log_cmd("Resetting all reboot counters") q.add_pus_tc( create_action_cmd( @@ -362,15 +362,15 @@ def pack_core_commands( # noqa C901 action_id=ActionId.RESET_REBOOT_COUNTER, ) ) - elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_00: + elif cmd_str == OpCode.RWD_RESET_REBOOT_COUNTER_00: reset_specific_boot_counter(q, 0, 0) - elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_01: + elif cmd_str == OpCode.RWD_RESET_REBOOT_COUNTER_01: reset_specific_boot_counter(q, 0, 1) - elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_10: + elif cmd_str == OpCode.RWD_RESET_REBOOT_COUNTER_10: reset_specific_boot_counter(q, 1, 0) - elif op_code == OpCode.RWD_RESET_REBOOT_COUNTER_11: + elif cmd_str == OpCode.RWD_RESET_REBOOT_COUNTER_11: reset_specific_boot_counter(q, 1, 1) - elif op_code == OpCode.RWD_SET_MAX_REBOOT_CNT: + elif cmd_str == OpCode.RWD_SET_MAX_REBOOT_CNT: max_count = int(input("Set new maximum reboot threshold [1, 50]: ")) if max_count < 1 or max_count > 50: raise ValueError("Invalid value, must be in range 1 to 50") @@ -381,16 +381,16 @@ def pack_core_commands( # noqa C901 user_data=bytes([max_count]), ) ) - elif op_code in OpCode.OBSW_UPDATE_FROM_SD_0: + elif cmd_str in OpCode.OBSW_UPDATE_FROM_SD_0: q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_0) q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_SD_0)) - elif op_code in OpCode.OBSW_UPDATE_FROM_SD_1: + elif cmd_str in OpCode.OBSW_UPDATE_FROM_SD_1: q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_1) q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_SD_1)) - elif op_code in OpCode.OBSW_UPDATE_FROM_TMP: + elif cmd_str in OpCode.OBSW_UPDATE_FROM_TMP: q.add_log_cmd(Info.OBSW_UPDATE_FROM_TMP) q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_TMP)) - elif op_code in OpCode.AUTO_SWITCH_ENABLE: + elif cmd_str in OpCode.AUTO_SWITCH_ENABLE: q.add_log_cmd(Info.AUTO_SWITCH_ENABLE) chip, copy = determine_chip_and_copy() user_data = bytes([chip, copy]) @@ -399,26 +399,26 @@ def pack_core_commands( # noqa C901 CORE_CONTROLLER_ID, ActionId.AUTO_SWITCH_ENABLE, user_data ) ) - elif op_code in OpCode.AUTO_SWITCH_DISABLE: + elif cmd_str in OpCode.AUTO_SWITCH_DISABLE: q.add_log_cmd(Info.AUTO_SWITCH_DISABLE) q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.AUTO_SWITCH_DISABLE) ) - elif op_code in OpCode.SWITCH_TO_SD_0: + elif cmd_str in OpCode.SWITCH_TO_SD_0: q.add_log_cmd(Info.SWITCH_TO_SD_0) q.add_pus_tc( create_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionId.SWITCH_TO_SD_0 ) ) - elif op_code in OpCode.SWITCH_TO_SD_1: + elif cmd_str in OpCode.SWITCH_TO_SD_1: q.add_log_cmd(Info.SWITCH_TO_SD_1) q.add_pus_tc( create_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionId.SWITCH_TO_SD_1 ) ) - elif op_code in OpCode.SWITCH_TO_BOTH_SD_CARDS: + elif cmd_str in OpCode.SWITCH_TO_BOTH_SD_CARDS: while True: active_sd_card = int(input("Please specify active SD card [0/1]: ")) if active_sd_card not in [0, 1]: @@ -432,11 +432,11 @@ def pack_core_commands( # noqa C901 user_data=bytes([active_sd_card]), ) ) - elif op_code in OpCode.GET_HK: + elif cmd_str in OpCode.GET_HK: q.add_log_cmd("Requesting housekeeping set") sid = make_sid(object_id=CORE_CONTROLLER_ID, set_id=SetId.HK) q.add_pus_tc(generate_one_hk_command(sid)) - elif op_code in OpCode.SET_PREF_SD: + elif cmd_str in OpCode.SET_PREF_SD: q.add_log_cmd("Set preferred SD card") pref_sd = int( input("Specify which SD card to set as the preferred one (0/1): ") @@ -453,7 +453,7 @@ def pack_core_commands( # noqa C901 ) ) ) - elif op_code == OpCode.CP_HELPER: + elif cmd_str == OpCode.CP_HELPER: cp_recursive = int(input("Copy recursively (0/1) ?: ")) if cp_recursive not in [0, 1]: raise ValueError("Invalid value, only 0 or 1 allowed") @@ -466,13 +466,13 @@ def pack_core_commands( # noqa C901 q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.CP_HELPER, user_data) ) - elif op_code == OpCode.MV_HELPER: + elif cmd_str == OpCode.MV_HELPER: user_data = packet_source_dest_path("Move") q.add_log_cmd(Info.MV_HELPER) q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.MV_HELPER, user_data) ) - elif op_code == OpCode.RM_HELPER: + elif cmd_str == OpCode.RM_HELPER: rm_recursive = int(input("Remove with recursive (-r) option (0/1) ?: ")) if rm_recursive not in [0, 1]: raise ValueError("Invalid value, only 0 or 1 allowed") @@ -487,7 +487,7 @@ def pack_core_commands( # noqa C901 q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.RM_HELPER, user_data) ) - elif op_code == OpCode.LIST_DIR_INTO_FILE: + elif cmd_str == OpCode.LIST_DIR_INTO_FILE: q.add_log_cmd(Info.LIST_DIR_INTO_FILE) user_data = list_directory_base_user_data() dest_file_path = input("Destination file path: ") @@ -498,7 +498,7 @@ def pack_core_commands( # noqa C901 CORE_CONTROLLER_ID, ActionId.LIST_DIR_INTO_FILE, user_data ) ) - elif op_code == OpCode.LIST_DIR_DUMP_DIRECTLY: + elif cmd_str == OpCode.LIST_DIR_DUMP_DIRECTLY: q.add_log_cmd(Info.LIST_DIR_DUMP_DIRECTLY) user_data = list_directory_base_user_data() q.add_pus_tc( @@ -506,7 +506,7 @@ def pack_core_commands( # noqa C901 CORE_CONTROLLER_ID, ActionId.LIST_DIR_DUMP_DIRECTLY, user_data ) ) - elif op_code == OpCode.MKDIR_HELPER: + elif cmd_str == OpCode.MKDIR_HELPER: q.add_log_cmd(Info.MKDIR_HELPER) user_data = input("Specify absolute path of newly created directory: ") user_data = bytearray(user_data.encode()) @@ -516,7 +516,7 @@ def pack_core_commands( # noqa C901 ) else: _LOGGER.warning( - f"Unknown operation code {op_code} for core controller commands" + f"Unknown operation code {cmd_str} for core controller commands" ) diff --git a/eive_tmtc/tmtc/payload/plpcdu.py b/eive_tmtc/tmtc/payload/plpcdu.py index 53eb207..ea151bd 100644 --- a/eive_tmtc/tmtc/payload/plpcdu.py +++ b/eive_tmtc/tmtc/payload/plpcdu.py @@ -215,13 +215,13 @@ def add_pl_pcdu_cmds(defs: TmtcDefinitionWrapper): def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. - q: DefaultPusQueueHelper, op_code: str + q: DefaultPusQueueHelper, cmd_str: str ): # noqa C901: Complexity is okay here. - if op_code == OpCode.SWITCH_ON: + if cmd_str == OpCode.SWITCH_ON: pack_pl_pcdu_mode_cmd(q=q, info=Info.SWITCH_ON, mode=Mode.ON, submode=0) - if op_code == OpCode.SWITCH_OFF: + if cmd_str == OpCode.SWITCH_OFF: pack_pl_pcdu_mode_cmd(q=q, info=Info.SWITCH_OFF, mode=Mode.OFF, submode=0) - if op_code in OpCode.ENABLE_HK: + if cmd_str in OpCode.ENABLE_HK: interval = float( input("Please enter HK collection interval in floating point seconds: ") ) @@ -231,13 +231,13 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. q.add_log_cmd(f"Enable PL PCDU HK with interval of {interval} seconds") for cmd in cmds: q.add_pus_tc(cmd) - if op_code == OpCode.DISABLE_HK: + if cmd_str == OpCode.DISABLE_HK: cmd = disable_periodic_hk_command( diag=True, sid=make_sid(PL_PCDU_ID, SetId.ADC) ) q.add_log_cmd("Disabling PL PCDU HK") q.add_pus_tc(cmd) - if op_code == OpCode.NORMAL_SSR: + if cmd_str == OpCode.NORMAL_SSR: pack_pl_pcdu_mode_cmd( q=q, info=Info.NORMAL_SSR, @@ -246,49 +246,49 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. NormalSubmodesMask.SOLID_STATE_RELAYS_ADC_ON ), ) - if op_code == OpCode.NORMAL_DRO: + if cmd_str == OpCode.NORMAL_DRO: pack_pl_pcdu_mode_cmd( q=q, info=Info.NORMAL_DRO, mode=Mode.NORMAL, submode=submode_mask_to_submode(NormalSubmodesMask.DRO_ON), ) - if op_code == OpCode.NORMAL_X8: + if cmd_str == OpCode.NORMAL_X8: pack_pl_pcdu_mode_cmd( q=q, info=Info.NORMAL_X8, mode=Mode.NORMAL, submode=submode_mask_to_submode(NormalSubmodesMask.X8_ON), ) - if op_code == OpCode.NORMAL_TX: + if cmd_str == OpCode.NORMAL_TX: pack_pl_pcdu_mode_cmd( q=q, info=Info.NORMAL_TX, mode=Mode.NORMAL, submode=submode_mask_to_submode(NormalSubmodesMask.TX_ON), ) - if op_code == OpCode.NORMAL_MPA: + if cmd_str == OpCode.NORMAL_MPA: pack_pl_pcdu_mode_cmd( q=q, info=Info.NORMAL_MPA, mode=Mode.NORMAL, submode=submode_mask_to_submode(NormalSubmodesMask.MPA_ON), ) - if op_code == OpCode.NORMAL_HPA: + if cmd_str == OpCode.NORMAL_HPA: pack_pl_pcdu_mode_cmd( q=q, info=Info.NORMAL_HPA, mode=Mode.NORMAL, submode=submode_mask_to_submode(NormalSubmodesMask.HPA_ON), ) - if op_code == OpCode.REQ_OS_HK: + if cmd_str == OpCode.REQ_OS_HK: q.add_log_cmd(f"PL PCDU: {Info.REQ_OS_HK}") q.add_pus_tc( generate_one_diag_command( sid=make_sid(object_id=PL_PCDU_ID, set_id=SetId.ADC) ) ) - if op_code == OpCode.UPDATE_I_UPPER_LIMIT: + if cmd_str == OpCode.UPDATE_I_UPPER_LIMIT: q.add_log_cmd(Info.UPDATE_I_UPPER_LIMIT) print("Select device to update lower current limit for: ") param_id = dev_select_to_upper_i_update_param_id(dev_select_prompt(True)) @@ -300,7 +300,7 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. create_scalar_double_parameter(PL_PCDU_ID, 0, param_id, new_param_value) ) ) - if op_code == OpCode.UPDATE_V_LOWER_LIMIT: + if cmd_str == OpCode.UPDATE_V_LOWER_LIMIT: q.add_log_cmd(Info.UPDATE_V_LOWER_LIMIT) print("Select device to update lower voltage limit for: ") param_id = dev_select_to_lower_u_update_param_id(dev_select_prompt(False)) @@ -312,7 +312,7 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. create_scalar_double_parameter(PL_PCDU_ID, 0, param_id, new_param_value) ) ) - if op_code == OpCode.UPDATE_V_UPPER_LIMIT: + if cmd_str == OpCode.UPDATE_V_UPPER_LIMIT: q.add_log_cmd(Info.UPDATE_V_UPPER_LIMIT) print("Select device to update upper voltage limit for: ") param_id = dev_select_to_upper_u_update_param_id(dev_select_prompt(False)) @@ -324,9 +324,9 @@ def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. create_scalar_double_parameter(PL_PCDU_ID, 0, param_id, new_param_value) ) ) - if op_code == OpCode.SWITCH_HPA_ON_PROC: + if cmd_str == OpCode.SWITCH_HPA_ON_PROC: hpa_on_procedure(q) - if op_code == OpCode.INJECT_ALL_ON_FAILURE: + if cmd_str == OpCode.INJECT_ALL_ON_FAILURE: pack_failure_injection_cmd( q=q, param_id=ParamId.INJECT_ALL_ON_FAILURE, diff --git a/eive_tmtc/tmtc/payload/rad_sensor.py b/eive_tmtc/tmtc/payload/rad_sensor.py index a8a3e22..e0b5386 100644 --- a/eive_tmtc/tmtc/payload/rad_sensor.py +++ b/eive_tmtc/tmtc/payload/rad_sensor.py @@ -66,27 +66,27 @@ def add_rad_sens_cmds(defs: TmtcDefinitionWrapper): ) -def pack_rad_sensor_test_into( - object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str +def create_rad_sensor_cmd( + object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str ): q.add_log_cmd(f"Commanding Radiation sensor handler {object_id}") - if op_code in OpCode.ON: + if cmd_str in OpCode.ON: rad_sensor_mode_cmd(object_id, Mode.ON, Info.ON, q) - if op_code in OpCode.NORMAL: + if cmd_str in OpCode.NORMAL: rad_sensor_mode_cmd(object_id, Mode.NORMAL, Info.NORMAL, q) - if op_code in OpCode.OFF: + if cmd_str in OpCode.OFF: rad_sensor_mode_cmd(object_id, Mode.OFF, Info.OFF, q) - if op_code in OpCode.REQ_HK_ONCE: + if cmd_str in OpCode.REQ_HK_ONCE: q.add_log_cmd(f"Rad sensor: {Info.REQ_OS_HK}") q.add_pus_tc( generate_one_hk_command(sid=make_sid(object_id.as_bytes, set_id=SetId.HK)) ) - if op_code in OpCode.DEBUG_ON: + if cmd_str in OpCode.DEBUG_ON: q.add_log_cmd(f"Rad sensor: {Info.DEBUG_ON}") command = object_id.as_bytes + struct.pack("!I", CommandId.ENABLE_DEBUG_OUTPUT) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCode.DEBUG_OFF: + if cmd_str in OpCode.DEBUG_OFF: q.add_log_cmd(f"Rad sensor: {Info.DEBUG_OFF}") command = object_id.as_bytes + struct.pack("!I", CommandId.DISABLE_DEBUG_OUTPUT) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) diff --git a/eive_tmtc/tmtc/payload/scex.py b/eive_tmtc/tmtc/payload/scex.py index b06e09a..2b5a198 100644 --- a/eive_tmtc/tmtc/payload/scex.py +++ b/eive_tmtc/tmtc/payload/scex.py @@ -6,7 +6,7 @@ from spacepackets.ecss import PusTelecommand from eive_tmtc.config.definitions import CustomServiceList from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.pus.s200_fsfw_mode import Mode, pack_mode_data, Subservice -from tmtccmd.tmtc import service_provider +from tmtccmd.tmtc import DefaultPusQueueHelper, service_provider from tmtccmd.tmtc.decorator import ServiceProviderParams from tmtccmd.pus.s8_fsfw_action import create_action_cmd from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper @@ -79,11 +79,8 @@ def add_scex_cmds(defs: TmtcDefinitionWrapper): ) -@service_provider(CustomServiceList.SCEX.value) -def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 - op_code = p.op_code - q = p.queue_helper - if op_code == OpCode.ON: +def pack_scex_cmds(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 + if cmd_str == OpCode.ON: q.add_log_cmd(Info.SWITCH_ON) q.add_pus_tc( PusTelecommand( @@ -92,7 +89,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.ON, 0), ) ) - if op_code == OpCode.NORMAL: + if cmd_str == OpCode.NORMAL: q.add_log_cmd(Info.NORMAL) q.add_pus_tc( PusTelecommand( @@ -101,7 +98,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.NORMAL, 0), ) ) - if op_code == OpCode.OFF: + if cmd_str == OpCode.OFF: q.add_log_cmd(Info.SWITCH_OFF) q.add_pus_tc( PusTelecommand( @@ -110,20 +107,20 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.OFF, 0), ) ) - if op_code == OpCode.PING: + if cmd_str == OpCode.PING: q.add_log_cmd(Info.PING) app_data = bytes([0]) q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.PING, app_data)) - if op_code == OpCode.ION_CMD: + if cmd_str == OpCode.ION_CMD: q.add_log_cmd(Info.ION_CMD) app_data = bytes([0]) q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.ION_CMD, app_data)) - if op_code == OpCode.TEMP_CMD: + if cmd_str == OpCode.TEMP_CMD: q.add_log_cmd(Info.TEMP_CMD) app_data = bytes([0]) q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.TEMP_CMD, app_data)) - if op_code == OpCode.EXP_STATUS_CMD: + if cmd_str == OpCode.EXP_STATUS_CMD: q.add_log_cmd(Info.EXP_STATUS_CMD) app_data = bytes([0]) q.add_pus_tc( @@ -131,7 +128,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 ) # one cell - if op_code == OpCode.ONE_CELLS_CMD: + if cmd_str == OpCode.ONE_CELLS_CMD: q.add_log_cmd(Info.ONE_CELLS_CMD) app_data = bytearray([0]) @@ -178,7 +175,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 create_action_cmd(SCEX_HANDLER_ID, ActionId.ONE_CELLS_CMD, app_data) ) - if op_code == OpCode.ALL_CELLS_CMD: + if cmd_str == OpCode.ALL_CELLS_CMD: q.add_log_cmd(Info.ALL_CELLS_CMD) app_data = bytearray([0]) @@ -210,7 +207,7 @@ def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 create_action_cmd(SCEX_HANDLER_ID, ActionId.ALL_CELLS_CMD, app_data) ) - if op_code == OpCode.FRAM: + if cmd_str == OpCode.FRAM: q.add_log_cmd(Info.FRAM) app_data = bytes([0]) q.add_pus_tc(create_action_cmd(SCEX_HANDLER_ID, ActionId.FRAM, app_data)) diff --git a/eive_tmtc/tmtc/power/acu.py b/eive_tmtc/tmtc/power/acu.py index d285b4f..ecfda8c 100644 --- a/eive_tmtc/tmtc/power/acu.py +++ b/eive_tmtc/tmtc/power/acu.py @@ -63,11 +63,11 @@ def add_acu_cmds(defs: TmtcDefinitionWrapper): ) -def pack_acu_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): +def pack_acu_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str): q.add_log_cmd("Handling ACU command") - pack_common_power_cmds("ACU", object_id, q, op_code) - pack_common_gomspace_cmds("ACU", object_id, q, op_code) - acu_req_hk_cmds(q, op_code) + pack_common_power_cmds("ACU", object_id, q, cmd_str) + pack_common_gomspace_cmds("ACU", object_id, q, cmd_str) + acu_req_hk_cmds(q, cmd_str) pack_test_cmds(object_id=object_id, q=q) diff --git a/eive_tmtc/tmtc/power/p60dock.py b/eive_tmtc/tmtc/power/p60dock.py index 714221f..0fe3d3f 100644 --- a/eive_tmtc/tmtc/power/p60dock.py +++ b/eive_tmtc/tmtc/power/p60dock.py @@ -27,15 +27,15 @@ from eive_tmtc.config.object_ids import P60_DOCK_HANDLER from tmtccmd.util import ObjectIdU32 -class P60OpCode: - STACK_3V3_ON = ["stack_3v3_on", "1"] - STACK_3V3_OFF = ["stack_3v3_off", "2"] - STACK_5V_ON = ["stack_5v_on", "3"] - STACK_5V_OFF = ["stack_5v_off", "4"] - TEST = ["test", "0"] +class CmdString: + STACK_3V3_ON = "stack_3v3_on" + STACK_3V3_OFF = "stack_3v3_off" + STACK_5V_ON = "stack_5v_on" + STACK_5V_OFF = "stack_5v_off" + TEST = "test" -class P60Info: +class CmdInfo: PREFIX = "P60 Dock" STACK_3V3_ON = f"{PREFIX}: Turn Stack 3V3 on" STACK_3V3_OFF = f"{PREFIX}: Turn Stack 3V3 off" @@ -99,14 +99,14 @@ class P60DockHkTable: def pack_p60dock_cmds( # noqa C901: Complexity okay here. - object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str + object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str ): objb = object_id.as_bytes - pack_common_power_cmds("P60 Dock", object_id, q, op_code) - pack_common_gomspace_cmds("P60 Dock", object_id, q, op_code) - p60_dock_req_hk_cmds(q, op_code) - if op_code in P60OpCode.STACK_3V3_ON: - q.add_log_cmd(P60Info.STACK_3V3_ON) + pack_common_power_cmds("P60 Dock", object_id, q, cmd_str) + pack_common_gomspace_cmds("P60 Dock", object_id, q, cmd_str) + p60_dock_req_hk_cmds(q, cmd_str) + if cmd_str == CmdString.STACK_3V3_ON: + q.add_log_cmd(CmdInfo.STACK_3V3_ON) q.add_pus_tc( pack_set_u8_param_command( objb, @@ -114,8 +114,8 @@ def pack_p60dock_cmds( # noqa C901: Complexity okay here. Channel.on, ) ) - if op_code in P60OpCode.STACK_3V3_OFF: - q.add_log_cmd(P60Info.STACK_3V3_OFF) + if cmd_str == CmdString.STACK_3V3_OFF: + q.add_log_cmd(CmdInfo.STACK_3V3_OFF) q.add_pus_tc( pack_set_u8_param_command( objb, @@ -123,8 +123,8 @@ def pack_p60dock_cmds( # noqa C901: Complexity okay here. Channel.off, ) ) - if op_code in P60OpCode.STACK_5V_ON: - q.add_log_cmd(P60Info.STACK_5V_ON) + if cmd_str == CmdString.STACK_5V_ON: + q.add_log_cmd(CmdInfo.STACK_5V_ON) q.add_pus_tc( pack_set_u8_param_command( objb, @@ -132,8 +132,8 @@ def pack_p60dock_cmds( # noqa C901: Complexity okay here. Channel.on, ) ) - if op_code in P60OpCode.STACK_5V_OFF: - q.add_log_cmd(P60Info.STACK_5V_OFF) + if cmd_str == CmdString.STACK_5V_OFF: + q.add_log_cmd(CmdInfo.STACK_5V_OFF) q.add_pus_tc( pack_set_u8_param_command( objb, diff --git a/eive_tmtc/tmtc/power/pdu1.py b/eive_tmtc/tmtc/power/pdu1.py index 16bc2b3..fb3c627 100644 --- a/eive_tmtc/tmtc/power/pdu1.py +++ b/eive_tmtc/tmtc/power/pdu1.py @@ -75,13 +75,13 @@ class PDU1TestProcedure: turn_channel_3_off = False -def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): +def pack_pdu1_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str): q.add_log_cmd("Commanding PDU1") objb = object_id.as_bytes - pdu1_switch_cmds(q, op_code) - pdu1_req_hk_cmds(q, op_code) - pack_common_power_cmds("PDU1", object_id, q, op_code) - pack_common_gomspace_cmds("PDU1", object_id, q, op_code) + pdu1_switch_cmds(q, cmd_str) + pdu1_req_hk_cmds(q, cmd_str) + pack_common_power_cmds("PDU1", object_id, q, cmd_str) + pack_common_gomspace_cmds("PDU1", object_id, q, cmd_str) if PDU1TestProcedure.all or PDU1TestProcedure.ping: q.add_log_cmd("PDU1: Ping Test") ping_data = bytearray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) @@ -111,39 +111,39 @@ def info_off_pdu1(base: str) -> str: def pdu1_switch_cmds( # noqa C901: Complexity is okay here. - q: DefaultPusQueueHelper, op_code: str + q: DefaultPusQueueHelper, cmd_str: str ): # noqa C901: Complexity okay here - if op_code in PowerOpCodes.TCS_ON: + if cmd_str in PowerOpCodes.TCS_ON: tcs_on_cmd(q) - elif op_code in PowerOpCodes.TCS_OFF: + elif cmd_str in PowerOpCodes.TCS_OFF: tcs_off_cmd(q) - elif op_code in PowerOpCodes.SYRLINKS_ON: + elif cmd_str in PowerOpCodes.SYRLINKS_ON: syrlinks_on_cmd(q) - elif op_code in PowerOpCodes.SYRLINKS_OFF: + elif cmd_str in PowerOpCodes.SYRLINKS_OFF: syrlinks_off_cmd(q) - elif op_code in PowerOpCodes.STAR_TRACKER_ON: + elif cmd_str in PowerOpCodes.STAR_TRACKER_ON: startracker_on_cmd(q) - elif op_code in PowerOpCodes.STAR_TRACKER_OFF: + elif cmd_str in PowerOpCodes.STAR_TRACKER_OFF: startracker_off_cmd(q) - elif op_code in PowerOpCodes.MGT_ON: + elif cmd_str in PowerOpCodes.MGT_ON: mgt_on_cmd(q) - elif op_code in PowerOpCodes.MGT_OFF: + elif cmd_str in PowerOpCodes.MGT_OFF: mgt_off_cmd(q) - elif op_code in PowerOpCodes.SUS_N_ON: + elif cmd_str in PowerOpCodes.SUS_N_ON: sun_sensor_nominal_on_cmd(q) - elif op_code in PowerOpCodes.SUS_N_OFF: + elif cmd_str in PowerOpCodes.SUS_N_OFF: sun_sensor_nominal_off_cmd(q) - elif op_code in PowerOpCodes.SCEX_ON: + elif cmd_str in PowerOpCodes.SCEX_ON: solar_cell_experiment_on_cmd(q) - elif op_code in PowerOpCodes.SCEX_OFF: + elif cmd_str in PowerOpCodes.SCEX_OFF: solar_cell_experiment_off_cmd(q) - elif op_code in PowerOpCodes.PLOC_ON: + elif cmd_str in PowerOpCodes.PLOC_ON: ploc_on_cmd(q) - elif op_code in PowerOpCodes.PLOC_OFF: + elif cmd_str in PowerOpCodes.PLOC_OFF: ploc_off_cmd(q) - elif op_code in PowerOpCodes.ACS_A_ON: + elif cmd_str in PowerOpCodes.ACS_A_ON: acs_board_a_on_cmd(q) - elif op_code in PowerOpCodes.ACS_A_OFF: + elif cmd_str in PowerOpCodes.ACS_A_OFF: acs_board_a_off_cmd(q) diff --git a/eive_tmtc/tmtc/power/pdu2.py b/eive_tmtc/tmtc/power/pdu2.py index 69c54e2..82aa898 100644 --- a/eive_tmtc/tmtc/power/pdu2.py +++ b/eive_tmtc/tmtc/power/pdu2.py @@ -88,13 +88,13 @@ class PDU2TestProcedure: request_hk_table = False -def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): +def pack_pdu2_commands(object_id: ObjectIdU32, q: DefaultPusQueueHelper, cmd_str: str): q.add_log_cmd("Testing PDU2") objb = object_id.as_bytes - pdu2_switch_cmds(q, op_code) - pdu2_req_hk_cmds(q, op_code) - pack_common_power_cmds("PDU2", object_id, q, op_code) - pack_common_gomspace_cmds("PDU2", object_id, q, op_code) + pdu2_switch_cmds(q, cmd_str) + pdu2_req_hk_cmds(q, cmd_str) + pack_common_power_cmds("PDU2", object_id, q, cmd_str) + pack_common_gomspace_cmds("PDU2", object_id, q, cmd_str) if PDU2TestProcedure.all or PDU2TestProcedure.reboot: q.add_log_cmd("PDU2: Reboot") q.add_pus_tc(pack_reboot_command(object_id)) diff --git a/eive_tmtc/tmtc/power/power.py b/eive_tmtc/tmtc/power/power.py index 9a0643a..64ce23f 100644 --- a/eive_tmtc/tmtc/power/power.py +++ b/eive_tmtc/tmtc/power/power.py @@ -30,7 +30,7 @@ from eive_tmtc.tmtc.power.pdu2 import ( from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry from eive_tmtc.config.object_ids import PCDU_HANDLER_ID -from eive_tmtc.tmtc.power.p60dock import P60OpCode, P60Info, p60_dock_req_hk_cmds +from eive_tmtc.tmtc.power.p60dock import CmdString, CmdInfo, p60_dock_req_hk_cmds from eive_tmtc.tmtc.power.acu import add_acu_cmds, acu_req_hk_cmds from tmtccmd.pus.tc.s3_fsfw_hk import ( create_request_one_diag_command, @@ -73,29 +73,29 @@ class PcduSwitches(enum.IntEnum): P60_DOCK_3V3_STACK = 19 -def pack_power_commands(q: DefaultPusQueueHelper, op_code: str): - pdu1_switch_cmds(q, op_code) - pdu2_switch_cmds(q, op_code) - if op_code in PowerOpCodes.SWITCHER_HK: +def pack_power_commands(q: DefaultPusQueueHelper, cmd_str: str): + pdu1_switch_cmds(q, cmd_str) + pdu2_switch_cmds(q, cmd_str) + if cmd_str in PowerOpCodes.SWITCHER_HK: q.add_log_cmd("Requesting switcher state HK") q.add_pus_tc( create_request_one_diag_command( make_sid(PCDU_HANDLER_ID, PcduSetIds.SWITCHER_SET) ) ) - if op_code in PowerOpCodes.INFO_CORE: + if cmd_str in PowerOpCodes.INFO_CORE: pdu1_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0]) pdu2_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0]) p60_dock_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0]) acu_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0]) q.add_wait_seconds(8.0) - elif op_code in PowerOpCodes.INFO_AUX: + elif cmd_str in PowerOpCodes.INFO_AUX: pdu1_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0]) pdu2_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0]) p60_dock_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0]) acu_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0]) q.add_wait_seconds(8.0) - elif op_code in PowerOpCodes.INFO_ALL: + elif cmd_str in PowerOpCodes.INFO_ALL: pdu1_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0]) pdu2_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0]) pdu1_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0]) @@ -105,7 +105,7 @@ def pack_power_commands(q: DefaultPusQueueHelper, op_code: str): acu_req_hk_cmds(q, PowerOpCodes.REQUEST_CORE_HK_ONCE[0]) acu_req_hk_cmds(q, PowerOpCodes.REQUEST_AUX_HK_ONCE[0]) q.add_wait_seconds(8.0) - elif op_code in PowerOpCodes.RESET_ALL_GND_WDTS: + elif cmd_str in PowerOpCodes.RESET_ALL_GND_WDTS: oids = get_object_ids() pack_reset_gnd_wdt_cmd(q, "P60 Dock", oids[P60_DOCK_HANDLER]) pack_reset_gnd_wdt_cmd(q, "ACU", oids[ACU_HANDLER_ID]) @@ -114,19 +114,19 @@ def pack_power_commands(q: DefaultPusQueueHelper, op_code: str): q.add_wait_seconds(5.0) if q.empty(): logging.getLogger(__name__).info( - f"Queue is empty, no stack for op code {op_code}" + f"Queue is empty, no stack for op code {cmd_str}" ) @tmtc_definitions_provider def add_p60_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() - oce.add(keys=P60OpCode.STACK_3V3_ON, info=P60Info.STACK_3V3_ON) - oce.add(keys=P60OpCode.STACK_3V3_OFF, info=P60Info.STACK_3V3_OFF) - oce.add(keys=P60OpCode.STACK_5V_ON, info=P60Info.STACK_5V_ON) - oce.add(keys=P60OpCode.STACK_5V_OFF, info=P60Info.STACK_5V_OFF) + oce.add(keys=CmdString.STACK_3V3_ON, info=CmdInfo.STACK_3V3_ON) + oce.add(keys=CmdString.STACK_3V3_OFF, info=CmdInfo.STACK_3V3_OFF) + oce.add(keys=CmdString.STACK_5V_ON, info=CmdInfo.STACK_5V_ON) + oce.add(keys=CmdString.STACK_5V_OFF, info=CmdInfo.STACK_5V_OFF) add_gomspace_cmd_defs(oce) - oce.add(keys=P60OpCode.TEST, info="P60 Tests") + oce.add(keys=CmdString.TEST, info="P60 Tests") defs.add_service( name=CustomServiceList.P60DOCK.value, info="P60 Device", op_code_entry=oce ) diff --git a/eive_tmtc/tmtc/tcs/ctrl.py b/eive_tmtc/tmtc/tcs/ctrl.py index 3c3b906..4f644f8 100644 --- a/eive_tmtc/tmtc/tcs/ctrl.py +++ b/eive_tmtc/tmtc/tcs/ctrl.py @@ -17,7 +17,7 @@ from tmtccmd.pus.tc.s3_fsfw_hk import ( ) -class OpCode: +class CmdStr: REQUEST_PRIMARY_TEMP_SET = "temp" ENABLE_TEMP_SET = "enable_temp_set" REQUEST_DEVICE_TEMP_SET = "temp_devs" @@ -26,7 +26,7 @@ class OpCode: REQUEST_TCS_CTRL_INFO = "tcs_ctrl_info" -class Info: +class CmdInfo: ENABLE_TEMP_SET = "Enable Primary Temperature Set" REQUEST_PRIMARY_TEMP_SET = "Request HK set of primary sensor temperatures" REQUEST_DEVICE_TEMP_SET = "Request HK set of device sensor temperatures" @@ -35,56 +35,56 @@ class Info: REQUEST_TCS_CTRL_INFO = "Request TCS controller information" -def pack_tcs_ctrl_commands(q: DefaultPusQueueHelper, op_code: str): - if op_code == OpCode.REQUEST_PRIMARY_TEMP_SET: +def pack_tcs_ctrl_commands(q: DefaultPusQueueHelper, cmd_str: str): + if cmd_str == CmdStr.REQUEST_PRIMARY_TEMP_SET: sensor_set_sid = make_sid(TCS_CONTROLLER, CtrlSetId.PRIMARY_SENSORS) - q.add_log_cmd(Info.REQUEST_PRIMARY_TEMP_SET) + q.add_log_cmd(CmdInfo.REQUEST_PRIMARY_TEMP_SET) q.add_pus_tc(generate_one_hk_command(sensor_set_sid)) - if op_code == OpCode.REQUEST_DEVICE_TEMP_SET: - q.add_log_cmd(Info.REQUEST_DEVICE_TEMP_SET) + if cmd_str == CmdStr.REQUEST_DEVICE_TEMP_SET: + q.add_log_cmd(CmdInfo.REQUEST_DEVICE_TEMP_SET) q.add_pus_tc( generate_one_hk_command(make_sid(TCS_CONTROLLER, CtrlSetId.DEVICE_SENSORS)) ) - if op_code == OpCode.REQUEST_DEVICE_SUS_SET: - q.add_log_cmd(Info.REQUEST_DEVICE_SUS_SET) + if cmd_str == CmdStr.REQUEST_DEVICE_SUS_SET: + q.add_log_cmd(CmdInfo.REQUEST_DEVICE_SUS_SET) q.add_pus_tc( generate_one_hk_command( make_sid(TCS_CONTROLLER, CtrlSetId.SUS_TEMP_SENSORS) ) ) - if op_code == OpCode.REQUEST_HEATER_INFO: - q.add_log_cmd(Info.REQUEST_HEATER_INFO) + if cmd_str == CmdStr.REQUEST_HEATER_INFO: + q.add_log_cmd(CmdInfo.REQUEST_HEATER_INFO) q.add_pus_tc( create_request_one_diag_command( make_sid(TCS_CONTROLLER, CtrlSetId.HEATER_INFO) ) ) - if op_code == OpCode.REQUEST_TCS_CTRL_INFO: - q.add_log_cmd(Info.REQUEST_TCS_CTRL_INFO) + if cmd_str == CmdStr.REQUEST_TCS_CTRL_INFO: + q.add_log_cmd(CmdInfo.REQUEST_TCS_CTRL_INFO) q.add_pus_tc( create_request_one_hk_command( make_sid(TCS_CONTROLLER, CtrlSetId.TCS_CTRL_INFO) ) ) - if op_code == OpCode.ENABLE_TEMP_SET: + if cmd_str == CmdStr.ENABLE_TEMP_SET: interval_seconds = float(input("Please specify interval in seconds: ")) cmds = create_enable_periodic_hk_command_with_interval_with_diag( False, make_sid(TCS_CONTROLLER, CtrlSetId.PRIMARY_SENSORS), interval_seconds ) for cmd in cmds: q.add_pus_tc(cmd) - pack_tcs_ass_cmds(q, op_code) + pack_tcs_ass_cmds(q, cmd_str) @tmtc_definitions_provider def add_tcs_ctrl_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() - oce.add(keys=OpCode.ENABLE_TEMP_SET, info=Info.ENABLE_TEMP_SET) - oce.add(keys=OpCode.REQUEST_PRIMARY_TEMP_SET, info=Info.REQUEST_PRIMARY_TEMP_SET) - oce.add(keys=OpCode.REQUEST_DEVICE_TEMP_SET, info=Info.REQUEST_DEVICE_TEMP_SET) - oce.add(keys=OpCode.REQUEST_DEVICE_SUS_SET, info=Info.REQUEST_DEVICE_SUS_SET) - oce.add(keys=OpCode.REQUEST_HEATER_INFO, info=Info.REQUEST_HEATER_INFO) - oce.add(keys=OpCode.REQUEST_TCS_CTRL_INFO, info=Info.REQUEST_TCS_CTRL_INFO) + oce.add(keys=CmdStr.ENABLE_TEMP_SET, info=CmdInfo.ENABLE_TEMP_SET) + oce.add(keys=CmdStr.REQUEST_PRIMARY_TEMP_SET, info=CmdInfo.REQUEST_PRIMARY_TEMP_SET) + oce.add(keys=CmdStr.REQUEST_DEVICE_TEMP_SET, info=CmdInfo.REQUEST_DEVICE_TEMP_SET) + oce.add(keys=CmdStr.REQUEST_DEVICE_SUS_SET, info=CmdInfo.REQUEST_DEVICE_SUS_SET) + oce.add(keys=CmdStr.REQUEST_HEATER_INFO, info=CmdInfo.REQUEST_HEATER_INFO) + oce.add(keys=CmdStr.REQUEST_TCS_CTRL_INFO, info=CmdInfo.REQUEST_TCS_CTRL_INFO) defs.add_service( name=CustomServiceList.TCS_CTRL, info="TCS controller", diff --git a/eive_tmtc/tmtc/tcs/heater.py b/eive_tmtc/tmtc/tcs/heater.py index dd6352a..0ce09ae 100644 --- a/eive_tmtc/tmtc/tcs/heater.py +++ b/eive_tmtc/tmtc/tcs/heater.py @@ -69,8 +69,8 @@ def add_heater_cmds(defs: TmtcDefinitionWrapper): ) -def pack_heater_cmds(object_id: bytearray, op_code: str, q: DefaultPusQueueHelper): - if op_code in OpCode.HEATER_CMD: +def pack_heater_cmds(object_id: bytes, cmd_str: str, q: DefaultPusQueueHelper): + if cmd_str in OpCode.HEATER_CMD: q.add_log_cmd("Heater Switching") heater_number = prompt_heater() while True: @@ -90,7 +90,7 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, q: DefaultPusQueueHelpe debug_string = f"Switching heater {heater_number} {act_str}" q.add_log_cmd(debug_string) q.add_pus_tc(pack_switch_heater_command(object_id, heater_number, action)) - if op_code in OpCode.HEATER_EXT_CTRL: + if cmd_str in OpCode.HEATER_EXT_CTRL: heater_number = prompt_heater() obj_id = heater_idx_to_obj(heater_number) health_cmd( @@ -100,7 +100,7 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, q: DefaultPusQueueHelpe health_str="External Control", heater_idx=heater_number, ) - if op_code in OpCode.HEATER_FAULTY_CMD: + if cmd_str in OpCode.HEATER_FAULTY_CMD: heater_number = prompt_heater() obj_id = heater_idx_to_obj(heater_number) health_cmd( @@ -110,7 +110,7 @@ def pack_heater_cmds(object_id: bytearray, op_code: str, q: DefaultPusQueueHelpe health_str="Faulty", heater_idx=heater_number, ) - if op_code in OpCode.HEATER_HEALTHY_CMD: + if cmd_str in OpCode.HEATER_HEALTHY_CMD: heater_number = prompt_heater() obj_id = heater_idx_to_obj(heater_number) health_cmd( diff --git a/eive_tmtc/tmtc/tcs/rtd.py b/eive_tmtc/tmtc/tcs/rtd.py index fd3b727..5c24dea 100644 --- a/eive_tmtc/tmtc/tcs/rtd.py +++ b/eive_tmtc/tmtc/tcs/rtd.py @@ -81,14 +81,14 @@ class SetId(enum.IntEnum): TEMPERATURE = 1 -class OpCode: - ON = ["0", "on"] - OFF = ["1", "off"] - NORMAL = ["2", "normal"] - WRITE_CONFIG = ["3", "Write config"] +class CmdStr: + ON = "on" + OFF = "off" + NORMAL = "normal" + WRITE_CONFIG = "write_cfg" -class Info: +class CmdInfo: ON = "Switch handler on" OFF = "Switch handler off" NORMAL = "Switch handler normal" @@ -98,17 +98,17 @@ class Info: @tmtc_definitions_provider def specify_rtd_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() - oce.add(keys=OpCode.ON, info=Info.ON) - oce.add(keys=OpCode.NORMAL, info=Info.NORMAL) - oce.add(keys=OpCode.OFF, info=Info.OFF) - oce.add(keys=OpCode.WRITE_CONFIG, info=Info.WRITE_CONFIG) + oce.add(keys=CmdStr.ON, info=CmdInfo.ON) + oce.add(keys=CmdStr.NORMAL, info=CmdInfo.NORMAL) + oce.add(keys=CmdStr.OFF, info=CmdInfo.OFF) + oce.add(keys=CmdStr.WRITE_CONFIG, info=CmdInfo.WRITE_CONFIG) defs.add_service( name=CustomServiceList.RTD.value, info="RTD commands", op_code_entry=oce ) def pack_rtd_commands( - op_code: str, object_id: Optional[ObjectIdU32], q: DefaultPusQueueHelper + cmd_str: str, object_id: Optional[ObjectIdU32], q: DefaultPusQueueHelper ): if object_id is not None and object_id not in RTD_IDS: print("Specified object ID not a valid RTD ID") @@ -117,14 +117,14 @@ def pack_rtd_commands( tgt_rtd_idx = prompt_rtd_idx() object_id_dict = get_object_ids() object_id = object_id_dict.get(RTD_IDS[tgt_rtd_idx]) - if op_code in OpCode.ON: + if cmd_str == CmdStr.ON: app_data = pack_mode_data(object_id=object_id.as_bytes, mode=Mode.ON, submode=0) q.add_pus_tc( PusTelecommand( service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=app_data ) ) - if op_code in OpCode.NORMAL: + if cmd_str == CmdStr.NORMAL: app_data = pack_mode_data( object_id=object_id.as_bytes, mode=Mode.NORMAL, submode=0 ) @@ -133,7 +133,7 @@ def pack_rtd_commands( service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=app_data ) ) - if op_code in OpCode.OFF: + if cmd_str == CmdStr.OFF: app_data = pack_mode_data( object_id=object_id.as_bytes, mode=Mode.OFF, submode=0 ) @@ -142,7 +142,7 @@ def pack_rtd_commands( service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=app_data ) ) - if op_code in OpCode.WRITE_CONFIG: + if cmd_str in CmdStr.WRITE_CONFIG: command = object_id.as_bytes + struct.pack("!I", CommandId.WRITE_CONFIG) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) diff --git a/eive_tmtc/tmtc/tcs/subsystem.py b/eive_tmtc/tmtc/tcs/subsystem.py index 4ae5697..affa01d 100644 --- a/eive_tmtc/tmtc/tcs/subsystem.py +++ b/eive_tmtc/tmtc/tcs/subsystem.py @@ -23,17 +23,17 @@ class InfoSys: ANNOUNCE_MODES = "Announce Modes recursively" -def pack_tcs_sys_commands(q: DefaultPusQueueHelper, op_code: str): - if op_code == OpCode.OFF: +def pack_tcs_sys_commands(q: DefaultPusQueueHelper, cmd_str: str): + if cmd_str == OpCode.OFF: q.add_log_cmd(InfoSys.OFF) pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.OFF, 0, q, InfoSys.OFF) - if op_code == OpCode.NML: + if cmd_str == OpCode.NML: q.add_log_cmd(InfoSys.NML) pack_mode_cmd_with_info(TCS_SUBSYSTEM_ID, Mode.NORMAL, 0, q, InfoSys.OFF) - if op_code == OpCode.ANNOUNCE_MODES: + if cmd_str == OpCode.ANNOUNCE_MODES: q.add_log_cmd(InfoSys.ANNOUNCE_MODES) q.add_pus_tc(create_announce_mode_recursive_command(TCS_SUBSYSTEM_ID)) - pack_tcs_ass_cmds(q, op_code) + pack_tcs_ass_cmds(q, cmd_str) @tmtc_definitions_provider diff --git a/eive_tmtc/tmtc/tcs/tmp1075.py b/eive_tmtc/tmtc/tcs/tmp1075.py index e7905bc..5b89251 100644 --- a/eive_tmtc/tmtc/tcs/tmp1075.py +++ b/eive_tmtc/tmtc/tcs/tmp1075.py @@ -23,14 +23,14 @@ from tmtccmd.pus.tc.s3_fsfw_hk import create_request_one_hk_command, make_sid from tmtccmd.util import ObjectIdU32 -class OpCode: +class CmdStr: OFF = "off" ON = "on" NML = "nml" HK = "hk" -class Info: +class CmdInfo: OFF = "Off" ON = "On" NML = "Normal" @@ -47,25 +47,25 @@ class SetId(enum.IntEnum): def pack_tmp1075_test_into( - object_id: ObjectIdU32, op_code: str, q: DefaultPusQueueHelper + object_id: ObjectIdU32, cmd_str: str, q: DefaultPusQueueHelper ): q.add_log_cmd( f"Testing Tmp1075 Temperature Sensor Handler with object id: {object_id}" ) obyt = object_id.as_bytes - if op_code == OpCode.OFF: + if cmd_str == CmdStr.OFF: q.add_log_cmd("TMP1075: Set Normal Off") mode_data = pack_mode_data(obyt, Mode.OFF, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) - if op_code == OpCode.NML: + if cmd_str == CmdStr.NML: q.add_log_cmd("TMP1075: Set Mode Normal") mode_data = pack_mode_data(obyt, Mode.NORMAL, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) - if op_code == OpCode.ON: + if cmd_str == CmdStr.ON: q.add_log_cmd("TMP1075: Set Mode On") mode_data = pack_mode_data(obyt, Mode.ON, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=mode_data)) - if op_code == OpCode.HK: + if cmd_str == CmdStr.HK: q.add_log_cmd("TMP1075: Request One-Shot HK") q.add_pus_tc(create_request_one_hk_command(make_sid(obyt, SetId.TEMPERATURE))) return q @@ -74,10 +74,10 @@ def pack_tmp1075_test_into( @tmtc_definitions_provider def add_tmp_sens_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() - oce.add(OpCode.OFF, Info.OFF) - oce.add(OpCode.ON, Info.ON) - oce.add(OpCode.NML, Info.NML) - oce.add(OpCode.HK, Info.HK) + oce.add(CmdStr.OFF, CmdInfo.OFF) + oce.add(CmdStr.ON, CmdInfo.ON) + oce.add(CmdStr.NML, CmdInfo.NML) + oce.add(CmdStr.HK, CmdInfo.HK) defs.add_service(CustomServiceList.TMP1075.value, "TMP1075 Temperature Sensor", oce) diff --git a/eive_tmtc/tmtc/time.py b/eive_tmtc/tmtc/time.py index fcb301e..23f9b90 100644 --- a/eive_tmtc/tmtc/time.py +++ b/eive_tmtc/tmtc/time.py @@ -2,16 +2,10 @@ import enum import logging from datetime import datetime -from eive_tmtc.config.definitions import CustomServiceList from spacepackets.ecss import PusTelecommand, PusService -from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, -) -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.tmtc import DefaultPusQueueHelper +from tmtccmd.config import CmdTreeNode class Subservice(enum.IntEnum): @@ -19,9 +13,9 @@ class Subservice(enum.IntEnum): DUMP_TIME = 129 -class OpCode: - SET_CURRENT_TIME = ["set_curr_time"] - DUMP_TIME = ["dump_time"] +class CmdStr: + SET_CURRENT_TIME = "set_curr_time" + DUMP_TIME = "dump_time" class Info: @@ -29,11 +23,8 @@ class Info: DUMP_TIME = "Dump system time as event" -@service_provider(CustomServiceList.TIME.value) -def pack_set_current_time_ascii_command(p: ServiceProviderParams): - q = p.queue_helper - o = p.op_code - if o in OpCode.SET_CURRENT_TIME: +def pack_time_management_cmd(q: DefaultPusQueueHelper, cmd_str: str): + if cmd_str == CmdStr.SET_CURRENT_TIME: current_time = datetime.utcnow().isoformat() + "Z" + "\0" current_time_ascii = current_time.encode("ascii") logging.getLogger(__name__).info( @@ -47,7 +38,7 @@ def pack_set_current_time_ascii_command(p: ServiceProviderParams): app_data=current_time_ascii, ) ) - elif o in OpCode.DUMP_TIME: + elif cmd_str == CmdStr.DUMP_TIME: q.add_log_cmd(Info.DUMP_TIME) q.add_pus_tc( PusTelecommand( @@ -56,16 +47,8 @@ def pack_set_current_time_ascii_command(p: ServiceProviderParams): ) -@tmtc_definitions_provider -def add_time_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add( - keys=OpCode.SET_CURRENT_TIME, - info=Info.SET_CURRENT_TIME, - ) - oce.add(keys=OpCode.DUMP_TIME, info=Info.DUMP_TIME) - defs.add_service( - name=CustomServiceList.TIME.value, - info="Time Service", - op_code_entry=oce, - ) +def return_time_node() -> CmdTreeNode: + time_node = CmdTreeNode("time", "Time Management") + time_node.add_child(CmdTreeNode(CmdStr.SET_CURRENT_TIME, "Set current time")) + time_node.add_child(CmdTreeNode(CmdStr.DUMP_TIME, "Dumpy current time")) + return time_node diff --git a/eive_tmtc/tmtc/wdt.py b/eive_tmtc/tmtc/wdt.py index abb4ee1..ac827ab 100644 --- a/eive_tmtc/tmtc/wdt.py +++ b/eive_tmtc/tmtc/wdt.py @@ -26,10 +26,10 @@ class ActionId(enum.IntEnum): DISABLE = 1 -def pack_wdt_commands(q: DefaultPusQueueHelper, op_code: str): - if op_code == OpCode.ENABLE: +def pack_wdt_commands(q: DefaultPusQueueHelper, cmd_str: str): + if cmd_str == OpCode.ENABLE: q.add_pus_tc(create_action_cmd(XIPHOS_WDT_ID, ActionId.ENABLE)) - if op_code == OpCode.DISABLE: + if cmd_str == OpCode.DISABLE: q.add_pus_tc(create_action_cmd(XIPHOS_WDT_ID, ActionId.DISABLE)) diff --git a/pyproject.toml b/pyproject.toml index b9017d4..3bb074a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,9 +29,9 @@ classifiers = [ "Topic :: Scientific/Engineering" ] dependencies = [ - "tmtccmd ~= 7.0", + # "tmtccmd ~= 8.0.0rc0", + "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@main", "python-dateutil ~= 2.8", - # "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@main" ] [project.urls] -- 2.43.0 From ba24faefa93fc852d6622a52d9377df0502e5e45 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 10:51:26 +0100 Subject: [PATCH 09/42] this is hardcore --- eive_tmtc/config/hook.py | 19 ++++++++----------- eive_tmtc/pus_tc/procedure_packer.py | 3 ++- eive_tmtc/tmtc/__init__.py | 1 - eive_tmtc/tmtc/acs/acs_ctrl.py | 25 ++++++++++++++++++++----- eive_tmtc/tmtc/time.py | 2 +- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index 222fdd7..f088ded 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -1,14 +1,15 @@ from typing import Optional -from eive_tmtc.config.definitions import SPACE_PACKET_IDS -from eive_tmtc.tmtc.time import create_time_node -from tmtccmd import HookBase, CcsdsTmtcBackend +from tmtccmd import CcsdsTmtcBackend, HookBase from tmtccmd.com import ComInterface from tmtccmd.config import CmdTreeNode - -from eive_tmtc.config.retvals import get_retval_dict from tmtccmd.util import ObjectIdDictT, RetvalDictT +from eive_tmtc.config.definitions import SPACE_PACKET_IDS +from eive_tmtc.config.retvals import get_retval_dict +from eive_tmtc.tmtc.time import create_time_node +from eive_tmtc.tmtc.acs.acs_ctrl import create_acs_ctrl_node + class EiveHookObject(HookBase): def __init__(self, json_cfg_path: str): @@ -40,10 +41,6 @@ class EiveHookObject(HookBase): gyro_devs = CmdTreeNode("gyro_devs", "Gyro Devices") acs_brd_assy_node.add_child(mgm_devs) acs_brd_assy_node.add_child(gyro_devs) - acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller") - acs_ctrl.add_child(mode_node) - acs_ctrl.add_child(action_node) - acs_ctrl.add_child(param_node) rws = CmdTreeNode("rws", "Reaction Wheel Devices") rw_assy = CmdTreeNode("rw_assy", "Reaction Wheel Assembly") rw_1 = CmdTreeNode("rw_1", "Reaction Wheel 1") @@ -66,7 +63,7 @@ class EiveHookObject(HookBase): gnss_devs = CmdTreeNode("gnss", "GNSS Devices") acs_node.add_child(acs_brd_assy_node) - acs_node.add_child(acs_ctrl) + acs_node.add_child(create_acs_ctrl_node()) acs_node.add_child(mode_node) acs_node.add_child(rws) acs_node.add_child(mgt) @@ -130,8 +127,8 @@ class EiveHookObject(HookBase): def get_communication_interface(self, com_if_key: str) -> Optional[ComInterface]: from tmtccmd.config.com import ( - create_com_interface_default, create_com_interface_cfg_default, + create_com_interface_default, ) assert self.cfg_path is not None diff --git a/eive_tmtc/pus_tc/procedure_packer.py b/eive_tmtc/pus_tc/procedure_packer.py index 8ba9dd2..308c1bb 100644 --- a/eive_tmtc/pus_tc/procedure_packer.py +++ b/eive_tmtc/pus_tc/procedure_packer.py @@ -2,9 +2,10 @@ """ import logging from typing import cast -from build.lib.build.lib.eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd + +from eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd from eive_tmtc.tmtc.power.power import pack_power_commands from eive_tmtc.tmtc.tcs.ctrl import pack_tcs_ctrl_commands diff --git a/eive_tmtc/tmtc/__init__.py b/eive_tmtc/tmtc/__init__.py index 618cee5..2c6f4c8 100644 --- a/eive_tmtc/tmtc/__init__.py +++ b/eive_tmtc/tmtc/__init__.py @@ -1,7 +1,6 @@ from .payload.subsystem import add_payload_subsystem_cmds from .solar_array_deployment import add_sa_depl_cmds from .test import add_test_defs -from .time import add_time_cmds from .health import add_health_cmd_defs from .system import add_system_cmd_defs from .tm_store import add_persistent_tm_store_cmd_defs diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 46275fe..06e635f 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -5,9 +5,10 @@ import math import socket import struct from socket import AF_INET -from typing import Tuple +from typing import Dict, Tuple from tmtccmd.config.tmtc import ( + CmdTreeNode, OpCodeEntry, TmtcDefinitionWrapper, tmtc_definitions_provider, @@ -34,8 +35,6 @@ from tmtccmd.pus.tc.s3_fsfw_hk import ( generate_one_hk_command, make_sid, ) -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams from tmtccmd.tmtc.queue import DefaultPusQueueHelper from eive_tmtc.config.definitions import CustomServiceList @@ -211,6 +210,19 @@ if PERFORM_MGM_CALIBRATION: CALIBR_SOCKET.connect(CALIBRATION_ADDR) +def create_acs_ctrl_node() -> CmdTreeNode: + # Zip the two classes together into a dictionary + op_code_strs = [ + getattr(OpCodes, key)[0] for key in dir(OpCodes) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCodes) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller") + for op_code, info in combined_dict.items(): + acs_ctrl.add_child(CmdTreeNode(op_code, info)) + return acs_ctrl + + @tmtc_definitions_provider def acs_cmd_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() @@ -656,7 +668,7 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameters=param, - ).pack() + ) ) ) else: @@ -847,7 +859,7 @@ def handle_raw_mgm_data(pw: PrintWrapper, hk_data: bytes): pw.dlog(f"Raw Data: {hk_data.hex(sep=',')}") return - def unpack_float_tuple(idx: int) -> (tuple, int): + def unpack_float_tuple(idx: int) -> Tuple[tuple, int]: f_tuple = struct.unpack( float_tuple_fmt_str, hk_data[idx : idx + struct.calcsize(float_tuple_fmt_str)], @@ -1248,6 +1260,9 @@ def perform_mgm_calibration( # noqa C901: Complexity okay pw: PrintWrapper, mgm_tuple: Tuple ): # noqa C901: Complexity okay global CALIBR_SOCKET, CALIBRATION_ADDR + if not PERFORM_MGM_CALIBRATION: + return + assert CALIBR_SOCKET is not None try: declare_api_cmd = "declare_api_version 2" CALIBR_SOCKET.sendall(f"{declare_api_cmd}\n".encode()) diff --git a/eive_tmtc/tmtc/time.py b/eive_tmtc/tmtc/time.py index 23f9b90..1e7fdc7 100644 --- a/eive_tmtc/tmtc/time.py +++ b/eive_tmtc/tmtc/time.py @@ -47,7 +47,7 @@ def pack_time_management_cmd(q: DefaultPusQueueHelper, cmd_str: str): ) -def return_time_node() -> CmdTreeNode: +def create_time_node() -> CmdTreeNode: time_node = CmdTreeNode("time", "Time Management") time_node.add_child(CmdTreeNode(CmdStr.SET_CURRENT_TIME, "Set current time")) time_node.add_child(CmdTreeNode(CmdStr.DUMP_TIME, "Dumpy current time")) -- 2.43.0 From 02d9d6adfc093fe10dc144fb53084e843c516835 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 11:21:26 +0100 Subject: [PATCH 10/42] OOF2 --- eive_tmtc/config/hook.py | 25 ++- eive_tmtc/pus_tc/procedure_packer.py | 3 +- eive_tmtc/tmtc/acs/acs_ctrl.py | 2 +- eive_tmtc/tmtc/payload/ploc_mpsoc.py | 83 ++++----- eive_tmtc/tmtc/payload/ploc_supervisor.py | 203 +++++++++------------- eive_tmtc/tmtc/payload/scex.py | 53 +++--- tmtcc.py | 4 + 7 files changed, 168 insertions(+), 205 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index f088ded..444d032 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -1,14 +1,16 @@ from typing import Optional -from tmtccmd import CcsdsTmtcBackend, HookBase +from eive_tmtc.config.definitions import SPACE_PACKET_IDS +from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node +from eive_tmtc.tmtc.payload.scex import create_scex_node +from eive_tmtc.tmtc.time import create_time_node +from eive_tmtc.tmtc.payload.ploc_mpsoc import create_ploc_mpsoc_node +from tmtccmd import HookBase, CcsdsTmtcBackend from tmtccmd.com import ComInterface from tmtccmd.config import CmdTreeNode -from tmtccmd.util import ObjectIdDictT, RetvalDictT -from eive_tmtc.config.definitions import SPACE_PACKET_IDS from eive_tmtc.config.retvals import get_retval_dict -from eive_tmtc.tmtc.time import create_time_node -from eive_tmtc.tmtc.acs.acs_ctrl import create_acs_ctrl_node +from tmtccmd.util import ObjectIdDictT, RetvalDictT class EiveHookObject(HookBase): @@ -41,6 +43,10 @@ class EiveHookObject(HookBase): gyro_devs = CmdTreeNode("gyro_devs", "Gyro Devices") acs_brd_assy_node.add_child(mgm_devs) acs_brd_assy_node.add_child(gyro_devs) + acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller") + acs_ctrl.add_child(mode_node) + acs_ctrl.add_child(action_node) + acs_ctrl.add_child(param_node) rws = CmdTreeNode("rws", "Reaction Wheel Devices") rw_assy = CmdTreeNode("rw_assy", "Reaction Wheel Assembly") rw_1 = CmdTreeNode("rw_1", "Reaction Wheel 1") @@ -63,7 +69,7 @@ class EiveHookObject(HookBase): gnss_devs = CmdTreeNode("gnss", "GNSS Devices") acs_node.add_child(acs_brd_assy_node) - acs_node.add_child(create_acs_ctrl_node()) + acs_node.add_child(acs_ctrl) acs_node.add_child(mode_node) acs_node.add_child(rws) acs_node.add_child(mgt) @@ -104,10 +110,11 @@ class EiveHookObject(HookBase): eps_node.add_child(bat_node) payload_node = CmdTreeNode("payload", "Payload Subsystem") - scex_node = CmdTreeNode("scex", "SCEX devices") - scex_node.add_child(dev_node) pl_pcdu = CmdTreeNode("pl_pcdu", "Payload PCDU") payload_node.add_child(pl_pcdu) + payload_node.add_child(create_scex_node()) + payload_node.add_child(create_ploc_mpsoc_node()) + payload_node.add_child(create_ploc_supv_node()) obdh_node = CmdTreeNode("obdh", "OBDH Subsystem") xiphos_wdt = CmdTreeNode("wdt", "Xiphos WDT") @@ -127,8 +134,8 @@ class EiveHookObject(HookBase): def get_communication_interface(self, com_if_key: str) -> Optional[ComInterface]: from tmtccmd.config.com import ( - create_com_interface_cfg_default, create_com_interface_default, + create_com_interface_cfg_default, ) assert self.cfg_path is not None diff --git a/eive_tmtc/pus_tc/procedure_packer.py b/eive_tmtc/pus_tc/procedure_packer.py index 308c1bb..52e3daa 100644 --- a/eive_tmtc/pus_tc/procedure_packer.py +++ b/eive_tmtc/pus_tc/procedure_packer.py @@ -13,7 +13,7 @@ from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands from eive_tmtc.tmtc.payload.scex import pack_scex_cmds from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands from eive_tmtc.tmtc.time import pack_time_management_cmd -from tmtccmd import DefaultProcedureInfo, TcHandlerBase +from tmtccmd import DefaultProcedureInfo from tmtccmd.tmtc import DefaultPusQueueHelper from eive_tmtc.tmtc.power.p60dock import pack_p60dock_cmds @@ -71,7 +71,6 @@ from eive_tmtc.utility.input_helper import InputHelper def handle_default_procedure( # noqa C901: Complexity okay here. - tc_base: TcHandlerBase, info: DefaultProcedureInfo, queue_helper: DefaultPusQueueHelper, ): diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 06e635f..def521b 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -5,7 +5,7 @@ import math import socket import struct from socket import AF_INET -from typing import Dict, Tuple +from typing import Tuple from tmtccmd.config.tmtc import ( CmdTreeNode, diff --git a/eive_tmtc/tmtc/payload/ploc_mpsoc.py b/eive_tmtc/tmtc/payload/ploc_mpsoc.py index 9a8e0a5..9953b9f 100644 --- a/eive_tmtc/tmtc/payload/ploc_mpsoc.py +++ b/eive_tmtc/tmtc/payload/ploc_mpsoc.py @@ -15,13 +15,13 @@ from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import get_object_ids, PLOC_MPSOC_ID from eive_tmtc.pus_tm.defs import PrintWrapper from tmtccmd.config.tmtc import ( + CmdTreeNode, tmtc_definitions_provider, OpCodeEntry, TmtcDefinitionWrapper, ) from spacepackets.ecss.tc import PusTelecommand -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.tmtc import DefaultPusQueueHelper from eive_tmtc.utility.input_helper import InputHelper from tmtccmd.pus.s200_fsfw_mode import pack_mode_data, Mode from tmtccmd.pus.s8_fsfw_action import create_action_cmd @@ -128,6 +128,8 @@ class Info: REPLAY_WRITE_SEQ = "Replay write sequence" DOWNLINK_PWR_ON = "Downlink Power On" DOWNLINK_PWR_OFF = "Downlink Power Off" + MEM_WRITE = "Write to Memory" + MEM_READ = "Read from Memory" REPLAY_START = "Replay Start" CAM_TAKE_PIC = "Cam Take Picture" SIMPLEX_SEND_FILE = "Simplex Send File" @@ -143,6 +145,18 @@ class MemAddresses(enum.IntEnum): DEADBEEF = 0x40000004 +def create_ploc_mpsoc_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + ploc_mpsoc = CmdTreeNode("ploc_mpsoc", "PLOC MPSoC") + for op_code, info in combined_dict.items(): + ploc_mpsoc.add_child(CmdTreeNode(op_code, info)) + return ploc_mpsoc + + @tmtc_definitions_provider def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() @@ -174,31 +188,29 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper): defs.add_service(CustomServiceList.PLOC_MPSOC.value, "Ploc MPSoC", oce) -@service_provider(CustomServiceList.PLOC_MPSOC) -def pack_ploc_mpsoc_commands( # noqa C901 - p: ServiceProviderParams, +def pack_ploc_mpsoc_commands( + q: DefaultPusQueueHelper, cmd_str: str ): # noqa C901: Complexity okay here. object_id = get_object_ids().get(PLOC_MPSOC_ID) - q = p.queue_helper + assert object_id is not None prefix = "PLOC MPSoC" - op_code = p.op_code q.add_log_cmd( f"Generate command for PLOC MPSoC with object id: {object_id.as_hex_string}" ) obyt = object_id.as_bytes - if op_code == OpCode.OFF: + if cmd_str == OpCode.OFF: q.add_log_cmd(f"{prefix}: {Info.OFF}") command = pack_mode_data(obyt, Mode.OFF, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) - if op_code == OpCode.ON: + if cmd_str == OpCode.ON: q.add_log_cmd(f"{prefix}: {Info.ON}") data = pack_mode_data(obyt, Mode.ON, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) - if op_code == OpCode.NORMAL: + if cmd_str == OpCode.NORMAL: q.add_log_cmd(f"{prefix}: {Info.NORMAL}") data = pack_mode_data(object_id.as_bytes, Mode.NORMAL, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data)) - if op_code == OpCode.MEM_WRITE: + if cmd_str == OpCode.MEM_WRITE: q.add_log_cmd("PLOC MPSoC: TC mem write test") memory_address = int( input("PLOC MPSoC: Tc Mem Write: Type memory address: 0x"), 16 @@ -210,39 +222,35 @@ def pack_ploc_mpsoc_commands( # noqa C901 object_id.as_bytes, memory_address, memory_data, mem_len ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "4": - q.add_log_cmd("PLOC MPSoC: TC mem read test") - data = prepare_mem_read_command(object_id=object_id.as_bytes) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.FLASH_WRITE_FILE: + if cmd_str == OpCode.FLASH_WRITE_FILE: q.add_log_cmd(f"{prefix}: {Info.FLASH_WRITE_FILE}") data = prepare_flash_write_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.FLASH_READ_FILE: + if cmd_str == OpCode.FLASH_READ_FILE: q.add_log_cmd(f"{prefix}: {Info.FLASH_READ_FILE}") data = prepare_flash_read_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.FLASH_DELETE_FILE: + if cmd_str == OpCode.FLASH_DELETE_FILE: q.add_log_cmd("PLOC MPSoC: Flash delete") data = prepare_flash_delete_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code in OpCode.REPLAY_START: + if cmd_str in OpCode.REPLAY_START: q.add_log_cmd(f"{prefix}: {Info.REPLAY_START}") data = prepare_replay_start_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.REPLAY_STOP: + if cmd_str == OpCode.REPLAY_STOP: q.add_log_cmd("PLOC MPSoC: Replay stop") data = object_id.as_bytes + struct.pack("!I", ActionId.TC_REPLAY_STOP) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.DOWNLINK_PWR_ON: + if cmd_str == OpCode.DOWNLINK_PWR_ON: q.add_log_cmd(f"{prefix}: {OpCode.DOWNLINK_PWR_ON}") data = prepare_downlink_pwr_on_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.DOWNLINK_PWR_OFF: + if cmd_str == OpCode.DOWNLINK_PWR_OFF: q.add_log_cmd("PLOC MPSoC: Downlink pwr off") data = object_id.as_bytes + struct.pack("!I", ActionId.TC_DOWNLINK_PWR_OFF) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.FLASH_GET_DIR_CONTENT: + if cmd_str == OpCode.FLASH_GET_DIR_CONTENT: q.add_log_cmd(f"{prefix}: {Info.FLASH_GET_DIR_CONTENT}") dir_name = input("Please specify MPSoC directory name to get information for: ") dir_name = bytearray(dir_name.encode("utf-8")) @@ -254,15 +262,15 @@ def pack_ploc_mpsoc_commands( # noqa C901 user_data=dir_name, ) ) - if op_code == OpCode.REPLAY_WRITE_SEQ: + if cmd_str == OpCode.REPLAY_WRITE_SEQ: q.add_log_cmd(f"{prefix}: {Info.REPLAY_WRITE_SEQ}") data = prepare_replay_write_sequence_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "12": + if cmd_str == "12": q.add_log_cmd("PLOC MPSoC: Reset OBSW sequence count") data = object_id.as_bytes + struct.pack("!I", ActionId.OBSW_RESET_SEQ_COUNT) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.VERIFY_BOOT: + if cmd_str == OpCode.VERIFY_BOOT: num_words = 1 q.add_log_cmd(f"{prefix} {Info.VERIFY_BOOT}") data = ( @@ -272,15 +280,15 @@ def pack_ploc_mpsoc_commands( # noqa C901 + struct.pack("!H", num_words) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.MODE_REPLAY: + if cmd_str == OpCode.MODE_REPLAY: q.add_log_cmd("PLOC MPSoC: Tc mode replay") data = object_id.as_bytes + struct.pack("!I", ActionId.TC_MODE_REPLAY) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.MODE_IDLE: + if cmd_str == OpCode.MODE_IDLE: q.add_log_cmd("PLOC MPSoC: Tc mode idle") data = object_id.as_bytes + struct.pack("!I", ActionId.TC_MODE_IDLE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "16": + if cmd_str == "16": q.add_log_cmd("PLOC MPSoC: Tc cam command send") cam_cmd = input("Specify cam command string: ") data = ( @@ -289,27 +297,27 @@ def pack_ploc_mpsoc_commands( # noqa C901 + bytearray(cam_cmd, "utf-8") ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "17": + if cmd_str == "17": q.add_log_cmd("PLOC MPSoC: Set UART TX tristate") data = object_id.as_bytes + struct.pack("!I", ActionId.SET_UART_TX_TRISTATE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == "18": + if cmd_str == "18": q.add_log_cmd("PLOC MPSoC: Release UART TX") data = object_id.as_bytes + struct.pack("!I", ActionId.RELEASE_UART_TX) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.CAM_TAKE_PIC: + if cmd_str == OpCode.CAM_TAKE_PIC: q.add_log_cmd("PLOC MPSoC: Cam take picture") data = prepare_cam_take_pic_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.SIMPLEX_SEND_FILE: + if cmd_str == OpCode.SIMPLEX_SEND_FILE: q.add_log_cmd("PLOC MPSoC: Simplex send file") data = prepare_simplex_send_file_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.DOWNLINK_DATA_MODULATE: + if cmd_str == OpCode.DOWNLINK_DATA_MODULATE: q.add_log_cmd("PLOC MPSoC: Downlink data modulate") data = prepare_downlink_data_modulate_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) - if op_code == OpCode.MODE_SNAPSHOT: + if cmd_str == OpCode.MODE_SNAPSHOT: q.add_log_cmd("PLOC MPSoC: Mode snapshot") data = object_id.as_bytes + struct.pack("!I", ActionId.TC_MODE_SNAPSHOT) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) @@ -671,10 +679,7 @@ def handle_mpsoc_data_reply(action_id: int, pw: PrintWrapper, custom_data: bytea current_idx = 0 dir_name_short = custom_data[current_idx : current_idx + 12].decode("utf-8") current_idx += 12 - num_elements = struct.unpack("!I", custom_data[current_idx : current_idx + 4])[ - 0 - ] - current_idx += 4 + num_elements = struct.unpack("!I", custom_data[current_idx : current_idx + 4])[0] elem_names = [] elem_attrs = [] elem_sizes = [] diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index a48bc43..3b39969 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -11,14 +11,11 @@ import logging import struct from eive_tmtc.config.object_ids import PLOC_SUPV_ID, get_object_ids -from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.pus_tm.defs import PrintWrapper from spacepackets.ecss.tc import PusTelecommand from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid -from tmtccmd.config import TmtcDefinitionWrapper -from tmtccmd.config.tmtc import tmtc_definitions_provider, OpCodeEntry -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.config.tmtc import CmdTreeNode +from tmtccmd.tmtc import DefaultPusQueueHelper from tmtccmd.pus.s200_fsfw_mode import pack_mode_data, Mode from tmtccmd.pus.s8_fsfw_action import create_action_cmd from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter @@ -26,7 +23,7 @@ from eive_tmtc.utility.input_helper import InputHelper _LOGGER = logging.getLogger(__name__) -latchup_id_dict = { +LATCHUP_ID_DICT = { "0": "0.85V", "1": "1.8V", "2": "MISC", @@ -135,22 +132,23 @@ class SetIds(enum.IntEnum): BOOT_STATUS_REPORT = 103 -class OpCodes: - OFF = ["0", "off"] - ON = ["1", "on"] - NORMAL = ["2", "nml"] - HK_TO_OBC = ["3", "hk_to_obc"] - REQUEST_HK = ["4", "req_hk"] - START_MPSOC = ["5", "start_mpsoc"] - SHUTDOWN_MPSOC = ["6", "stop_mpsoc"] - SEL_NVM = ["7", "sel_nvm"] - SET_TIME_REF = ["set_time_ref"] - FACTORY_FLASH = ["factory_flash"] - REQ_BOOT_STATUS_REPORT = ["13", "boot_report"] - START_UPDATE = ["42", "start_update"] - PERFORM_UPDATE = ["update"] - FACTORY_RESET = ["factory_reset"] - MEM_CHECK = ["mem_check"] +class OpCode(str, enum.Enum): + value: str + OFF = "off" + ON = "on" + NML = "nml" + HK_TO_OBC = "hk_to_obc" + REQUEST_HK = "req_hk" + START_MPSOC = "start_mpsoc" + SHUTDOWN_MPSOC = "stop_mpsoc" + SEL_NVM = "sel_nvm" + SET_TIME_REF = "set_time_ref" + FACTORY_FLASH = "factory_flash" + REQ_BOOT_STATUS_REPORT = "boot_report" + START_UPDATE = "start_update" + PERFORM_UPDATE = "update" + FACTORY_RESET = "factory_reset" + MEM_CHECK = "mem_check" RESET_MPSOC = "reset_mpsoc" @@ -161,6 +159,8 @@ class Info(str, enum.Enum): NML = "Switch Normal" HK_TO_OBC = "Request HK from PLOC SUPV" REQUEST_HK = "Request HK set from PLOC Handler" + START_MPSOC = "Start MPSoC" + SHUTDOWN_MPSOC = "Shutdown MPSoC" SET_TIME_REF = "Set time reference" FACTORY_FLASH = "Factory Flash Mode" PERFORM_UPDATE = "Start or continue MPSoC SW update at starting bytes" @@ -172,95 +172,54 @@ class Info(str, enum.Enum): RESET_MPSOC = "Reset MPSoC" -@tmtc_definitions_provider -def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(OpCodes.OFF, Info.OFF) - oce.add(OpCodes.ON, Info.ON) - oce.add(OpCodes.NORMAL, Info.NML) - oce.add(OpCodes.HK_TO_OBC, Info.HK_TO_OBC) - oce.add(OpCodes.REQUEST_HK, Info.REQUEST_HK) - oce.add(OpCodes.START_MPSOC, "PLOC Supervisor: Start MPSoC") - oce.add(OpCodes.SHUTDOWN_MPSOC, "PLOC Supervisor: Shutdown MPSoC") - oce.add(OpCodes.SEL_NVM, Info.SEL_NVM) - oce.add(OpCodes.SET_TIME_REF, Info.SET_TIME_REF) - oce.add(OpCodes.FACTORY_RESET, Info.FACTORY_RESET) - oce.add(OpCodes.RESET_MPSOC, Info.RESET_MPSOC) - oce.add("8", "PLOC Supervisor: Set max restart tries") - oce.add("11", "PLOC Supervisor: Set boot timeout") - oce.add("12", "PLOC Supervisor: Disable Hk") - oce.add(OpCodes.REQ_BOOT_STATUS_REPORT, Info.REQ_BOOT_STATUS_REPORT) - oce.add("17", "PLOC Supervisor: Enable latchup alert") - oce.add("18", "PLOC Supervisor: Disable latchup alert") - oce.add("20", "PLOC Supervisor: Set alert limit") - oce.add("23", "PLOC Supervisor: Set ADC enabled channels") - oce.add("24", "PLOC Supervisor: Set ADC window and stride") - oce.add("25", "PLOC Supervisor: Set ADC threshold") - oce.add("26", "PLOC Supervisor: Request latchup status report") - oce.add("27", "PLOC Supervisor: Copy ADC data to MRAM") - oce.add("30", "PLOC Supervisor: Run auto EM tests") - oce.add("31", "PLOC Supervisor: MRAM Wipe") - oce.add("35", "PLOC Supervisor: Set GPIO") - oce.add("36", "PLOC Supervisor: Read GPIO") - oce.add("37", "PLOC Supervisor: Restart supervisor") - oce.add(OpCodes.PERFORM_UPDATE, Info.PERFORM_UPDATE) - oce.add(OpCodes.START_UPDATE, Info.START_UPDATE) - oce.add("43", "PLOC Supervisor: Terminate supervisor process") - oce.add("44", "PLOC Supervisor: Start MPSoC quiet") - oce.add("45", "PLOC Supervisor: Set shutdown timeout") - oce.add(OpCodes.FACTORY_FLASH, Info.FACTORY_FLASH) - oce.add("47", "PLOC Supervisor: Enable auto TM") - oce.add("48", "PLOC Supervisor: Disable auto TM") - oce.add("51", "PLOC Supervisor: Logging request event buffers") - oce.add("52", "PLOC Supervisor: Logging clear counters") - oce.add("53", "PLOC Supervisor: Logging set topic") - oce.add("54", "PLOC Supervisor: Logging request counters") - oce.add("55", "PLOC Supervisor: Request ADC Report") - oce.add("56", "PLOC Supervisor: Reset PL") - oce.add("57", "PLOC Supervisor: Enable NVMs") - oce.add("58", "PLOC Supervisor: Continue update") - oce.add(OpCodes.MEM_CHECK, Info.MEM_CHECK) - defs.add_service(CustomServiceList.PLOC_SUPV.value, "PLOC Supervisor", oce) +def create_ploc_supv_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("ploc_supv", "PLOC Supervisor") + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node -@service_provider(CustomServiceList.PLOC_SUPV) -def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 - q = p.queue_helper - op_code = p.op_code +def pack_ploc_supv_commands(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 object_id = get_object_ids().get(PLOC_SUPV_ID) + assert object_id is not None q.add_log_cmd(f"Testing PLOC Supervisor with object id: {object_id.as_hex_string}") obyt = object_id.as_bytes prefix = "PLOC Supervisor" - if op_code in OpCodes.OFF: + if cmd_str == OpCode.OFF: q.add_log_cmd(f"{prefix}: {Info.OFF}") command = pack_mode_data(object_id.as_bytes, Mode.OFF, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) - if op_code in OpCodes.ON: + if cmd_str == OpCode.ON: q.add_log_cmd(f"{prefix}: {Info.ON}") command = pack_mode_data(object_id.as_bytes, Mode.ON, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) - if op_code in OpCodes.NORMAL: + if cmd_str == OpCode.NML: q.add_log_cmd(f"{prefix}: {Info.NML}") command = pack_mode_data(object_id.as_bytes, Mode.NORMAL, 0) q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=command)) - if op_code in OpCodes.HK_TO_OBC: + if cmd_str == OpCode.HK_TO_OBC: q.add_log_cmd(f"{prefix}: {Info.HK_TO_OBC}") command = obyt + struct.pack("!I", SupvActionId.HK_REPORT) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.REQUEST_HK: + if cmd_str == OpCode.REQUEST_HK: q.add_log_cmd(f"{prefix}: {Info.REQUEST_HK}") sid = make_sid(object_id.as_bytes, SetIds.HK_REPORT) cmd = generate_one_hk_command(sid) q.add_pus_tc(cmd) - elif op_code in OpCodes.START_MPSOC: + elif cmd_str == OpCode.START_MPSOC: q.add_log_cmd("PLOC Supervisor: Start MPSoC") command = obyt + struct.pack("!I", SupvActionId.START_MPSOC) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.SHUTDOWN_MPSOC: + if cmd_str == OpCode.SHUTDOWN_MPSOC: q.add_log_cmd("PLOC Supervisor: Shutdown MPSoC") command = object_id.as_bytes + struct.pack("!I", SupvActionId.SHUTWOWN_MPSOC) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.SEL_NVM: + if cmd_str == OpCode.SEL_NVM: q.add_log_cmd("PLOC Supervisor: Select MPSoC boot image") mem = int(input("MEM (NVM0 - 0 or NVM1 - 1): ")) bp0 = int(input("BP0 (0 or 1): ")) @@ -268,7 +227,7 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 bp2 = int(input("BP2 (0 or 1): ")) command = pack_sel_boot_image_cmd(object_id.as_bytes, mem, bp0, bp1, bp2) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.FACTORY_RESET: + if cmd_str == OpCode.FACTORY_RESET: q.add_log_cmd(f"{prefix}: {Info.FACTORY_RESET}") while True: print("Please select the key for a factory reset operation") @@ -285,7 +244,7 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 user_data=bytes([key]), ) ) - if op_code == "8": + if cmd_str == "8": q.add_log_cmd("PLOC Supervisor: Set max restart tries") restart_tries = int(input("Specify maximum restart tries: ")) command = ( @@ -294,15 +253,15 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 + struct.pack("!B", restart_tries) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == OpCodes.RESET_MPSOC: + if cmd_str == OpCode.RESET_MPSOC: q.add_log_cmd(Info.RESET_MPSOC) command = object_id.as_bytes + struct.pack("!I", SupvActionId.RESET_MPSOC) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.SET_TIME_REF: + if cmd_str in OpCode.SET_TIME_REF: q.add_log_cmd("PLOC Supervisor: Set time reference") command = object_id.as_bytes + struct.pack("!I", SupvActionId.SET_TIME_REF) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "11": + if cmd_str == "11": q.add_log_cmd("PLOC Supervisor: Set boot timeout") boot_timeout = int(input("Specify boot timeout [ms]: ")) command = ( @@ -311,11 +270,11 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 + struct.pack("!I", boot_timeout) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "12": + if cmd_str == "12": q.add_log_cmd("PLOC Supervisor: Disable HK") command = object_id.as_bytes + struct.pack("!I", SupvActionId.DISABLE_HK) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.REQ_BOOT_STATUS_REPORT: + if cmd_str in OpCode.REQ_BOOT_STATUS_REPORT: q.add_log_cmd(f"{prefix}: {Info.REQ_BOOT_STATUS_REPORT}") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.GET_BOOT_STATUS_REPORT @@ -325,129 +284,129 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 sid = make_sid(object_id.as_bytes, SetIds.BOOT_STATUS_REPORT) req_hk = generate_one_hk_command(sid) q.add_pus_tc(req_hk) - if op_code == "17": + if cmd_str == "17": q.add_log_cmd("PLOC Supervisor: Enable latchup alert") command = pack_lachtup_alert_cmd(object_id.as_bytes, True) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "18": + if cmd_str == "18": q.add_log_cmd("PLOC Supervisor: Disable latchup alert") command = pack_lachtup_alert_cmd(object_id.as_bytes, False) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "20": + if cmd_str == "20": q.add_log_cmd("PLOC Supervisor: Set alert limit") command = pack_set_alert_limit_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "23": + if cmd_str == "23": q.add_log_cmd("PLOC Supervisor: Set ADC enabled channels") command = pack_set_adc_enabled_channels_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "24": + if cmd_str == "24": q.add_log_cmd("PLOC Supervisor: Set ADC window and stride") command = pack_set_adc_window_and_stride_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "25": + if cmd_str == "25": q.add_log_cmd("PLOC Supervisor: Set ADC threshold") command = pack_set_adc_threshold_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "26": + if cmd_str == "26": q.add_log_cmd("PLOC Supervisor: Request latchup status report") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.GET_LATCHUP_STATUS_REPORT ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "27": + if cmd_str == "27": q.add_log_cmd("PLOC Supervisor: Copy ADC data to MRAM") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.COPY_ADC_DATA_TO_MRAM ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "30": + if cmd_str == "30": q.add_log_cmd("PLOC Supervisor: Run auto EM tests") command = pack_auto_em_tests_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "31": + if cmd_str == "31": q.add_log_cmd("PLOC Supervisor: Wipe MRAM") command = pack_mram_wipe_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "35": + if cmd_str == "35": q.add_log_cmd("PLOC Supervisor: Set GPIO command") command = pack_set_gpio_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "36": + if cmd_str == "36": q.add_log_cmd("PLOC Supervisor: Read GPIO command") command = pack_read_gpio_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "37": + if cmd_str == "37": q.add_log_cmd("PLOC Supervisor: Restart supervisor") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.RESTART_SUPERVISOR ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.START_UPDATE: + if cmd_str in OpCode.START_UPDATE: q.add_log_cmd("PLOC Supversior: Start new MPSoC SW update") command = pack_update_command(object_id.as_bytes, True) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.PERFORM_UPDATE: + if cmd_str in OpCode.PERFORM_UPDATE: q.add_log_cmd("PLOC Supervisor: Perform MPSoC SW update") command = pack_update_command(object_id.as_bytes, False) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "43": + if cmd_str == "43": q.add_log_cmd("PLOC Supervisor: Terminate supervisor process") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.TERMINATE_SUPV_HELPER ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "44": + if cmd_str == "44": q.add_log_cmd("PLOC Supervisor: Start MPSoC quiet") command = object_id.as_bytes + struct.pack("!I", SupvActionId.START_MPSOC_QUIET) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "45": + if cmd_str == "45": q.add_log_cmd("PLOC Supervisor: Set shutdown timeout") command = pack_set_shutdown_timeout_command(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.FACTORY_FLASH: + if cmd_str in OpCode.FACTORY_FLASH: q.add_log_cmd(f"{prefix}: {Info.FACTORY_FLASH}") command = object_id.as_bytes + struct.pack("!I", SupvActionId.FACTORY_FLASH) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "47": + if cmd_str == "47": q.add_log_cmd("PLOC Supervisor: Enable auto TM") command = object_id.as_bytes + struct.pack("!I", SupvActionId.ENABLE_AUTO_TM) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "48": + if cmd_str == "48": q.add_log_cmd("PLOC Supervisor: Disable auto TM") command = object_id.as_bytes + struct.pack("!I", SupvActionId.DISABLE_AUTO_TM) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "51": + if cmd_str == "51": q.add_log_cmd("PLOC Supervisor: Logging request event buffers") command = pack_logging_buffer_request(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "52": + if cmd_str == "52": q.add_log_cmd("PLOC Supervisor: Logging clear counters") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.LOGGING_CLEAR_COUNTERS ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "53": + if cmd_str == "53": q.add_log_cmd("PLOC Supervisor: Logging set topic") command = pack_logging_set_topic(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "54": + if cmd_str == "54": q.add_log_cmd("PLOC Supervisor: Logging request counters") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.LOGGING_REQUEST_COUNTERS ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "55": + if cmd_str == "55": q.add_log_cmd("PLOC Supervisor: Request ADC report") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.REQUEST_ADC_REPORT ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "56": + if cmd_str == "56": q.add_log_cmd("PLOC Supervisor: Reset PL") command = object_id.as_bytes + struct.pack("!I", SupvActionId.RESET_PL) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "57": + if cmd_str == "57": q.add_log_cmd("PLOC Supervisor: Enable NVMs") nvm01 = int(input("Enable (1) or disable(0) NVM 0 and 1: ")) nvm3 = int(input("Enable (1) or disable(0) NVM 3: ")) @@ -458,11 +417,11 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 + struct.pack("B", nvm3) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "58": + if cmd_str == "58": q.add_log_cmd("PLOC Supervisor: Continue update") command = object_id.as_bytes + struct.pack("!I", SupvActionId.CONTINUE_UPDATE) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCodes.MEM_CHECK: + if cmd_str == OpCode.MEM_CHECK: custom_data = bytearray() update_file = get_update_file() memory_id = int(input("Specify memory ID: ")) @@ -545,9 +504,9 @@ def get_latchup_id() -> int: description_string = "Description".ljust(description_column_width) print(f"{key_string} | {description_string}") print(separator_string) - for key in latchup_id_dict: + for key in LATCHUP_ID_DICT: key_string = key.ljust(key_column_width) - description_string = latchup_id_dict[key].ljust(description_column_width) + description_string = LATCHUP_ID_DICT[key].ljust(description_column_width) print(f"{key_string} | {description_string}") return int(input("Specify latchup ID: ")) diff --git a/eive_tmtc/tmtc/payload/scex.py b/eive_tmtc/tmtc/payload/scex.py index 2b5a198..d39e078 100644 --- a/eive_tmtc/tmtc/payload/scex.py +++ b/eive_tmtc/tmtc/payload/scex.py @@ -2,16 +2,12 @@ import enum import json from spacepackets.ecss import PusTelecommand - -from eive_tmtc.config.definitions import CustomServiceList -from tmtccmd.config.tmtc import tmtc_definitions_provider -from tmtccmd.pus.s200_fsfw_mode import Mode, pack_mode_data, Subservice -from tmtccmd.tmtc import DefaultPusQueueHelper, service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.config.tmtc import CmdTreeNode from tmtccmd.pus.s8_fsfw_action import create_action_cmd -from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper -from eive_tmtc.config.object_ids import SCEX_HANDLER_ID +from tmtccmd.pus.s200_fsfw_mode import Mode, Subservice, pack_mode_data +from tmtccmd.tmtc import DefaultPusQueueHelper +from eive_tmtc.config.object_ids import SCEX_HANDLER_ID USE_SCEX_CONF_FILE = True @@ -26,10 +22,8 @@ class OpCode: ALL_CELLS_CMD = "allcells" FRAM = "fram" - ON = "on" SWITCH_ON = "on" - OFF = "off" - SWITCH_OFF = OFF + SWITCH_OFF = "off" NORMAL = "normal" @@ -59,28 +53,20 @@ class Info: NORMAL = "Switch SCEX to normal mode" -@tmtc_definitions_provider -def add_scex_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(keys=OpCode.PING, info=Info.PING) - oce.add(keys=OpCode.ION_CMD, info=Info.ION_CMD) - oce.add(keys=OpCode.TEMP_CMD, info=Info.TEMP_CMD) - oce.add(keys=OpCode.EXP_STATUS_CMD, info=Info.EXP_STATUS_CMD) - oce.add(keys=OpCode.ONE_CELLS_CMD, info=Info.ONE_CELLS_CMD) - - oce.add(keys=OpCode.ALL_CELLS_CMD, info=Info.ALL_CELLS_CMD) - oce.add(keys=OpCode.FRAM, info=Info.FRAM) - oce.add(keys=OpCode.ON, info=Info.SWITCH_ON) - oce.add(keys=OpCode.OFF, info=Info.SWITCH_OFF) - oce.add(keys=OpCode.NORMAL, info=Info.NORMAL) - - defs.add_service( - name=CustomServiceList.SCEX.value, info="SCEX Device", op_code_entry=oce - ) +def create_scex_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + scex_node = CmdTreeNode("ploc_mpsoc", "PLOC MPSoC") + for op_code, info in combined_dict.items(): + scex_node.add_child(CmdTreeNode(op_code, info)) + return scex_node def pack_scex_cmds(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 - if cmd_str == OpCode.ON: + if cmd_str == OpCode.SWITCH_ON: q.add_log_cmd(Info.SWITCH_ON) q.add_pus_tc( PusTelecommand( @@ -98,7 +84,7 @@ def pack_scex_cmds(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 app_data=pack_mode_data(SCEX_HANDLER_ID, Mode.NORMAL, 0), ) ) - if cmd_str == OpCode.OFF: + if cmd_str == OpCode.SWITCH_OFF: q.add_log_cmd(Info.SWITCH_OFF) q.add_pus_tc( PusTelecommand( @@ -158,7 +144,8 @@ def pack_scex_cmds(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 dac_weight1 = json_data["dac_weight1"] dac_weight2 = json_data["dac_weight2"] dac_weight3 = json_data["dac_weight3"] - + else: + raise ValueError("CLI support for SCEX params not implemented") # in app_data # app_data.extend(struct.pack("!H", first_dac)) app_data.append(cell_select) @@ -192,6 +179,8 @@ def pack_scex_cmds(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 dac_weight2 = json_data["dac_weight2"] dac_weight3 = json_data["dac_weight3"] + else: + raise ValueError("CLI support for SCEX params not implemented") # in app_data # app_data.extend(struct.pack("!H", first_dac)) append_16_bit_val(packet=app_data, val=first_dac[cn]) diff --git a/tmtcc.py b/tmtcc.py index 0f10f09..c801358 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -30,6 +30,7 @@ from tmtccmd.config.args import ( PreArgsParsingWrapper, ProcedureParamsWrapper, SetupParams, + perform_tree_printout, ) from tmtccmd.core import BackendRequest from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter @@ -133,6 +134,9 @@ def setup_params() -> Tuple[SetupWrapper, int]: hk_level = int(post_arg_parsing_wrapper.args_raw.hk) else: hk_level = 0 + if params.app_params.print_tree: + perform_tree_printout(params.app_params, hook_obj.get_command_definitions()) + sys.exit(0) params.apid = PUS_APID if params.com_if is None: raise ValueError("could not determine a COM interface.") -- 2.43.0 From d640d547bd439c6059dbaee2bb414c20b844c429 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 13:51:33 +0100 Subject: [PATCH 11/42] OOF3 --- eive_tmtc/config/hook.py | 47 +++++++----- eive_tmtc/tmtc/__init__.py | 3 - eive_tmtc/tmtc/acs/subsystem.py | 57 +++++++-------- eive_tmtc/tmtc/com/__init__.py | 1 - eive_tmtc/tmtc/com/subsystem.py | 90 ++++++++++------------- eive_tmtc/tmtc/health.py | 44 ++++++----- eive_tmtc/tmtc/payload/ploc_mpsoc.py | 10 ++- eive_tmtc/tmtc/payload/subsystem.py | 27 +++---- eive_tmtc/tmtc/power/__init__.py | 2 - eive_tmtc/tmtc/power/bpx_batt.py | 90 +++++++++++------------ eive_tmtc/tmtc/power/pwr_ctrl.py | 105 ++++++++++++--------------- eive_tmtc/tmtc/power/subsystem.py | 40 +++++----- eive_tmtc/tmtc/system.py | 39 ++++++---- eive_tmtc/tmtc/test.py | 45 ++++-------- eive_tmtc/tmtc/tm_store.py | 47 ++++++------ 15 files changed, 300 insertions(+), 347 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index 444d032..3f32f34 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -1,17 +1,27 @@ from typing import Optional -from eive_tmtc.config.definitions import SPACE_PACKET_IDS -from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node -from eive_tmtc.tmtc.payload.scex import create_scex_node -from eive_tmtc.tmtc.time import create_time_node -from eive_tmtc.tmtc.payload.ploc_mpsoc import create_ploc_mpsoc_node -from tmtccmd import HookBase, CcsdsTmtcBackend +from tmtccmd import CcsdsTmtcBackend, HookBase from tmtccmd.com import ComInterface from tmtccmd.config import CmdTreeNode - -from eive_tmtc.config.retvals import get_retval_dict from tmtccmd.util import ObjectIdDictT, RetvalDictT +from eive_tmtc.config.definitions import SPACE_PACKET_IDS +from eive_tmtc.config.retvals import get_retval_dict +from eive_tmtc.tmtc.com.subsystem import create_com_subsystem_node +from eive_tmtc.tmtc.health import create_global_health_node +from eive_tmtc.tmtc.acs.subsystem import create_acs_subsystem_node +from eive_tmtc.tmtc.payload.ploc_mpsoc import create_ploc_mpsoc_node +from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node +from eive_tmtc.tmtc.payload.scex import create_scex_node +from eive_tmtc.tmtc.payload.subsystem import create_payload_subsystem_node +from eive_tmtc.tmtc.power.bpx_batt import create_bpx_batt_node +from eive_tmtc.tmtc.power.pwr_ctrl import create_pwr_ctrl_node +from eive_tmtc.tmtc.power.subsystem import create_eps_subsystem_node +from eive_tmtc.tmtc.system import create_system_node +from eive_tmtc.tmtc.test import create_test_node +from eive_tmtc.tmtc.time import create_time_node +from eive_tmtc.tmtc.tm_store import create_persistent_tm_store_node + class EiveHookObject(HookBase): def __init__(self, json_cfg_path: str): @@ -34,9 +44,7 @@ class EiveHookObject(HookBase): assy_node = CmdTreeNode("assy", "Assembly Commands") assy_node.add_child(mode_node) - system_node = CmdTreeNode("sys", "EIVE System") - - acs_node = CmdTreeNode("acs", "ACS Subsystem") + acs_node = create_acs_subsystem_node() acs_brd_assy_node = CmdTreeNode("acs_brd_assy", "ACS Board Assembly") acs_brd_assy_node.add_child(mode_node) mgm_devs = CmdTreeNode("mgm_devs", "MGM Devices") @@ -88,7 +96,7 @@ class EiveHookObject(HookBase): tcs_brd_assy = CmdTreeNode("tcs_brd_assy", "TCS Board Assembly") tcs_node.add_child(tcs_brd_assy) - com_node = CmdTreeNode("com", "COM Subsystem") + com_node = create_com_subsystem_node() syrlinks_node = CmdTreeNode("syrlinks", "Syrlinks") syrlinks_node.add_child(dev_node) syrlinks_node.add_child(assy_node) @@ -97,19 +105,19 @@ class EiveHookObject(HookBase): ccsds_node.add_child(action_node) com_node.add_child(syrlinks_node) - eps_node = CmdTreeNode("eps", "EPS Subsystem") + eps_node = create_eps_subsystem_node() acu_node = CmdTreeNode("acu", "PCDU ACU component") pdu_1_node = CmdTreeNode("pdu1", "PCDU PDU 1 component") pdu_2_node = CmdTreeNode("pdu2", "PCDU PDU 2 component") p60_dock_node = CmdTreeNode("p60_dock", "PCDU P60 Dock component") - bat_node = CmdTreeNode("bat", "Battery Component") + eps_node.add_child(create_pwr_ctrl_node()) eps_node.add_child(acu_node) eps_node.add_child(pdu_1_node) eps_node.add_child(pdu_2_node) eps_node.add_child(p60_dock_node) - eps_node.add_child(bat_node) + eps_node.add_child(create_bpx_batt_node()) - payload_node = CmdTreeNode("payload", "Payload Subsystem") + payload_node = create_payload_subsystem_node() pl_pcdu = CmdTreeNode("pl_pcdu", "Payload PCDU") payload_node.add_child(pl_pcdu) payload_node.add_child(create_scex_node()) @@ -122,8 +130,11 @@ class EiveHookObject(HookBase): obdh_node.add_child(xiphos_wdt) obdh_node.add_child(core_ctrl) obdh_node.add_child(create_time_node()) + obdh_node.add_child(create_persistent_tm_store_node()) - root_node.add_child(system_node) + root_node.add_child(create_test_node()) + root_node.add_child(create_system_node()) + root_node.add_child(create_global_health_node()) root_node.add_child(acs_node) root_node.add_child(tcs_node) root_node.add_child(com_node) @@ -134,8 +145,8 @@ class EiveHookObject(HookBase): def get_communication_interface(self, com_if_key: str) -> Optional[ComInterface]: from tmtccmd.config.com import ( - create_com_interface_default, create_com_interface_cfg_default, + create_com_interface_default, ) assert self.cfg_path is not None diff --git a/eive_tmtc/tmtc/__init__.py b/eive_tmtc/tmtc/__init__.py index 2c6f4c8..84ed9c4 100644 --- a/eive_tmtc/tmtc/__init__.py +++ b/eive_tmtc/tmtc/__init__.py @@ -1,7 +1,4 @@ -from .payload.subsystem import add_payload_subsystem_cmds from .solar_array_deployment import add_sa_depl_cmds -from .test import add_test_defs -from .health import add_health_cmd_defs from .system import add_system_cmd_defs from .tm_store import add_persistent_tm_store_cmd_defs from .tcs import add_tmp_sens_cmds diff --git a/eive_tmtc/tmtc/acs/subsystem.py b/eive_tmtc/tmtc/acs/subsystem.py index 657c8e7..f250344 100644 --- a/eive_tmtc/tmtc/acs/subsystem.py +++ b/eive_tmtc/tmtc/acs/subsystem.py @@ -1,22 +1,19 @@ import enum -from typing import Tuple, Dict +from typing import Dict, Tuple -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 -from eive_tmtc.config.definitions import CustomServiceList from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, + CmdTreeNode, ) from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.tmtc import DefaultPusQueueHelper + +from eive_tmtc.config.object_ids import ACS_SUBSYSTEM_ID +from eive_tmtc.tmtc.acs.defs import AcsMode, SafeSubmode +from eive_tmtc.tmtc.common import pack_mode_cmd_with_info -class OpCode(str, enum.Enum): +class CmdStr(str, enum.Enum): OFF = "off" SAFE = "safe" DETUMBLE = "detumble" @@ -41,23 +38,20 @@ class Info(str, enum.Enum): 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), + CmdStr.OFF: (AcsMode.OFF, 0, Info.OFF), + CmdStr.SAFE: (AcsMode.SAFE, SafeSubmode.DEFAULT, Info.SAFE), + CmdStr.DETUMBLE: (AcsMode.SAFE, SafeSubmode.DETUMBLE, Info.DETUMBLE), + CmdStr.IDLE: (AcsMode.IDLE, 0, Info.IDLE), + CmdStr.PTG_TARGET: (AcsMode.PTG_TARGET, 0, Info.PTG_TARGET), + CmdStr.PTG_TARGET_GS: (AcsMode.PTG_TARGET_GS, 0, Info.PTG_TARGET_GS), + CmdStr.PTG_TARGET_NADIR: (AcsMode.PTG_NADIR, 0, Info.PTG_TARGET_NADIR), + CmdStr.PTG_TARGET_INERTIAL: (AcsMode.PTG_INERTIAL, 0, Info.PTG_TARGET_INERTIAL), } -@service_provider(CustomServiceList.ACS_SS.value) -def build_acs_subsystem_cmd(p: ServiceProviderParams): - op_code = p.op_code - q = p.queue_helper +def build_acs_subsystem_cmd(q: DefaultPusQueueHelper, cmd_path: str): info_prefix = "ACS Subsystem" - if op_code in OpCode.REPORT_ALL_MODES: + if cmd_path in CmdStr.REPORT_ALL_MODES: q.add_log_cmd(f"{info_prefix}: {Info.REPORT_ALL_MODES}") q.add_pus_tc( PusTelecommand( @@ -66,7 +60,7 @@ def build_acs_subsystem_cmd(p: ServiceProviderParams): app_data=ACS_SUBSYSTEM_ID, ) ) - mode_info_tup = HANDLER_LIST.get(op_code) + mode_info_tup = HANDLER_LIST.get(cmd_path) if mode_info_tup is None: return pack_mode_cmd_with_info( @@ -78,10 +72,9 @@ 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(): - oce.add(op_code, info) - oce.add(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES) - defs.add_service(CustomServiceList.ACS_SS, "ACS Subsystem", oce) +def create_acs_subsystem_node() -> CmdTreeNode: + node = CmdTreeNode("acs", "ACS Subsystem") + for cmd_str, (_, _, info) in HANDLER_LIST.items(): + node.add_child(CmdTreeNode(cmd_str, info)) + node.add_child(CmdTreeNode(CmdStr.REPORT_ALL_MODES, Info.REPORT_ALL_MODES)) + return node diff --git a/eive_tmtc/tmtc/com/__init__.py b/eive_tmtc/tmtc/com/__init__.py index b70bd5c..e69de29 100644 --- a/eive_tmtc/tmtc/com/__init__.py +++ b/eive_tmtc/tmtc/com/__init__.py @@ -1 +0,0 @@ -from .subsystem import add_com_subsystem_cmds diff --git a/eive_tmtc/tmtc/com/subsystem.py b/eive_tmtc/tmtc/com/subsystem.py index 900981f..ba8c098 100644 --- a/eive_tmtc/tmtc/com/subsystem.py +++ b/eive_tmtc/tmtc/com/subsystem.py @@ -1,30 +1,25 @@ import enum -from eive_tmtc.config.definitions import CustomServiceList -from eive_tmtc.config.object_ids import COM_SUBSYSTEM_ID -from eive_tmtc.tmtc.com.syrlinks_handler import Datarate -from tmtccmd.pus.s20_fsfw_param_defs import create_scalar_u8_parameter - -from .defs import Mode as ComMode - from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, -) -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams -from tmtccmd.pus.s200_fsfw_mode import ( - create_mode_command, - create_read_mode_command, - create_announce_mode_command, - create_announce_mode_recursive_command, + CmdTreeNode, ) from tmtccmd.pus.s20_fsfw_param import ( create_load_param_cmd, + create_scalar_u32_parameter, ) +from tmtccmd.pus.s20_fsfw_param_defs import create_scalar_u8_parameter +from tmtccmd.pus.s200_fsfw_mode import ( + create_announce_mode_command, + create_announce_mode_recursive_command, + create_mode_command, + create_read_mode_command, +) +from tmtccmd.tmtc import DefaultPusQueueHelper -from tmtccmd.pus.s20_fsfw_param import create_scalar_u32_parameter +from eive_tmtc.config.object_ids import COM_SUBSYSTEM_ID +from eive_tmtc.tmtc.com.syrlinks_handler import Datarate + +from .defs import Mode as ComMode class ParameterId(enum.IntEnum): @@ -48,9 +43,9 @@ class OpCode: class Info: RX_ONLY = "Syrlinks RX Only" - TX_AND_RX_DEF_DATARATE = "Syrlinks with TX default datarate" - TX_AND_RX_LOW_DATARATE = "Syrlinks with TX low datarate (BPSK modulation)" - TX_AND_RX_HIGH_DATARATE = "Syrlinks with TX high datarate (0QPSK modulation)" + TX_AND_RX_DEF_RATE = "Syrlinks with TX default datarate" + TX_AND_RX_LOW_RATE = "Syrlinks with TX low datarate (BPSK modulation)" + TX_AND_RX_HIGH_RATE = "Syrlinks with TX high datarate (0QPSK modulation)" TX_AND_RX_CARRIER_WAVE = "Syrlinks with TX carrier wave" UPDATE_DEFAULT_DATARATE_LOW = "Configure default low datarate (BPSK modulation)" UPDATE_DEFAULT_DATARATE_HIGH = "Configure default high datarate (0QPSK modulation)" @@ -60,30 +55,27 @@ class Info: ANNOUNCE_MODE_RECURSIVE = "Announce mode recursively" -@service_provider(CustomServiceList.COM_SS) -def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901 - q = p.queue_helper - o = p.op_code +def build_com_subsystem_cmd(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 prefix = "COM Subsystem" - if o == OpCode.RX_ONLY: + if cmd_str == OpCode.RX_ONLY: q.add_log_cmd(Info.RX_ONLY) q.add_pus_tc(create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_ONLY, 0)) - elif o == OpCode.TX_AND_RX_DEF_RATE: + elif cmd_str == OpCode.TX_AND_RX_DEF_RATE: q.add_log_cmd(Info.TX_AND_RX_DEF_DATARATE) q.add_pus_tc( create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_AND_TX_DEF_DATARATE, 0) ) - elif o == OpCode.TX_AND_RX_LOW_RATE: + elif cmd_str == OpCode.TX_AND_RX_LOW_RATE: q.add_log_cmd(Info.TX_AND_RX_LOW_DATARATE) q.add_pus_tc( create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_AND_TX_LOW_DATARATE, 0) ) - elif o == OpCode.TX_AND_RX_HIGH_RATE: + elif cmd_str == OpCode.TX_AND_RX_HIGH_RATE: q.add_log_cmd(Info.TX_AND_RX_HIGH_DATARATE) q.add_pus_tc( create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_AND_TX_HIGH_DATARATE, 0) ) - if o == OpCode.UPDATE_DEFAULT_DATARATE_LOW: + if cmd_str == OpCode.UPDATE_DEFAULT_DATARATE_LOW: q.add_log_cmd(f"{prefix}: {Info.UPDATE_DEFAULT_DATARATE_LOW}") q.add_pus_tc( create_load_param_cmd( @@ -95,7 +87,7 @@ def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901 ) ) ) - if o == OpCode.UPDATE_DEFAULT_DATARATE_HIGH: + if cmd_str == OpCode.UPDATE_DEFAULT_DATARATE_HIGH: q.add_log_cmd(f"{prefix}: {Info.UPDATE_DEFAULT_DATARATE_HIGH}") q.add_pus_tc( create_load_param_cmd( @@ -107,12 +99,12 @@ def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901 ) ) ) - elif o == OpCode.TX_AND_RX_CARRIER_WAVE: + elif cmd_str == OpCode.TX_AND_RX_CARRIER_WAVE: q.add_log_cmd(Info.TX_AND_RX_CARRIER_WAVE) q.add_pus_tc( create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_AND_TX_CARRIER_WAVE, 0) ) - elif o == OpCode.CHANGE_TRANSMITTER_TIMEOUT: + elif cmd_str == OpCode.CHANGE_TRANSMITTER_TIMEOUT: timeout = int(input("Specify timeout to set [ms]: ")) q.add_log_cmd(Info.CHANGE_TRANSMITTER_TIMEOUT) q.add_pus_tc( @@ -125,28 +117,24 @@ def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901 ) ) ) - elif o == OpCode.READ_MODE: + elif cmd_str == OpCode.READ_MODE: q.add_log_cmd(Info.READ_MODE) q.add_pus_tc(create_read_mode_command(COM_SUBSYSTEM_ID)) - elif o == OpCode.ANNOUNCE_MODE: + elif cmd_str == OpCode.ANNOUNCE_MODE: q.add_log_cmd(Info.ANNOUNCE_MODE) q.add_pus_tc(create_announce_mode_command(COM_SUBSYSTEM_ID)) - elif o == OpCode.ANNOUNCE_MODE_RECURSIVE: + elif cmd_str == OpCode.ANNOUNCE_MODE_RECURSIVE: q.add_log_cmd(Info.ANNOUNCE_MODE_RECURSIVE) q.add_pus_tc(create_announce_mode_recursive_command(COM_SUBSYSTEM_ID)) -@tmtc_definitions_provider -def add_com_subsystem_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(OpCode.RX_ONLY, Info.RX_ONLY) - oce.add(OpCode.TX_AND_RX_LOW_RATE, Info.TX_AND_RX_LOW_DATARATE) - oce.add(OpCode.TX_AND_RX_HIGH_RATE, Info.TX_AND_RX_HIGH_DATARATE) - oce.add(OpCode.TX_AND_RX_DEF_RATE, Info.TX_AND_RX_DEF_DATARATE) - oce.add(OpCode.UPDATE_DEFAULT_DATARATE_LOW, Info.UPDATE_DEFAULT_DATARATE_LOW) - oce.add(OpCode.UPDATE_DEFAULT_DATARATE_HIGH, Info.UPDATE_DEFAULT_DATARATE_HIGH) - oce.add(OpCode.CHANGE_TRANSMITTER_TIMEOUT, Info.CHANGE_TRANSMITTER_TIMEOUT) - oce.add(OpCode.READ_MODE, Info.READ_MODE) - oce.add(OpCode.ANNOUNCE_MODE, Info.ANNOUNCE_MODE) - oce.add(OpCode.ANNOUNCE_MODE_RECURSIVE, Info.ANNOUNCE_MODE_RECURSIVE) - defs.add_service(CustomServiceList.COM_SS, "COM Subsystem", oce) +def create_com_subsystem_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("com", "COM Subsystem") + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node diff --git a/eive_tmtc/tmtc/health.py b/eive_tmtc/tmtc/health.py index 70efb4c..4b551b2 100644 --- a/eive_tmtc/tmtc/health.py +++ b/eive_tmtc/tmtc/health.py @@ -1,14 +1,12 @@ -from eive_tmtc.config.definitions import CustomServiceList -from eive_tmtc.tmtc.obj_prompt import prompt_object from spacepackets.ecss import PusTelecommand from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, + CmdTreeNode, ) -from tmtccmd.tmtc import service_provider -from tmtccmd.pus.s201_fsfw_health import Subservice, FsfwHealth -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.pus.s201_fsfw_health import FsfwHealth, Subservice +from tmtccmd.tmtc import DefaultPusQueueHelper + +from eive_tmtc.config.definitions import CustomServiceList +from eive_tmtc.tmtc.obj_prompt import prompt_object class OpCode: @@ -30,11 +28,8 @@ def prompt_health() -> FsfwHealth: return FsfwHealth(health_idx) -@service_provider(CustomServiceList.HEALTH) -def pack_test_command(p: ServiceProviderParams): - o = p.op_code - q = p.queue_helper - if o == OpCode.SET_HEALTH: +def pack_health_cmd(q: DefaultPusQueueHelper, cmd_str: str): + if cmd_str == OpCode.SET_HEALTH: app_data = bytearray(prompt_object()) health = prompt_health() app_data.append(health) @@ -44,7 +39,7 @@ def pack_test_command(p: ServiceProviderParams): service=201, subservice=Subservice.TC_SET_HEALTH, app_data=app_data ) ) - elif o == OpCode.ANNOUNCE_HEALTH: + elif cmd_str == OpCode.ANNOUNCE_HEALTH: app_data = bytearray(prompt_object()) q.add_log_cmd(Info.ANNOUNCE_HEALTH) q.add_pus_tc( @@ -52,19 +47,22 @@ def pack_test_command(p: ServiceProviderParams): service=201, subservice=Subservice.TC_ANNOUNCE_HEALTH, app_data=app_data ) ) - elif o == OpCode.ANNOUNCE_HEALTH_ALL: + elif cmd_str == OpCode.ANNOUNCE_HEALTH_ALL: q.add_log_cmd(Info.ANNOUNCE_HEALTH_ALL) q.add_pus_tc( PusTelecommand(service=201, subservice=Subservice.TC_ANNOUNCE_HEALTH_ALL) ) else: - raise ValueError(f"unknown op code {o} for service {CustomServiceList.HEALTH}") + raise ValueError( + f"unknown command string {cmd_str} for service {CustomServiceList.HEALTH}" + ) -@tmtc_definitions_provider -def add_health_cmd_defs(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(OpCode.ANNOUNCE_HEALTH_ALL, Info.ANNOUNCE_HEALTH_ALL) - oce.add(OpCode.ANNOUNCE_HEALTH, Info.ANNOUNCE_HEALTH) - oce.add(OpCode.SET_HEALTH, Info.SET_HEALTH) - defs.add_service(CustomServiceList.HEALTH, info="Health Service", op_code_entry=oce) +def create_global_health_node() -> CmdTreeNode: + health_node = CmdTreeNode("health", "Health Commands") + health_node.add_child( + CmdTreeNode(OpCode.ANNOUNCE_HEALTH_ALL, Info.ANNOUNCE_HEALTH_ALL) + ) + health_node.add_child(CmdTreeNode(OpCode.ANNOUNCE_HEALTH, Info.ANNOUNCE_HEALTH)) + health_node.add_child(CmdTreeNode(OpCode.SET_HEALTH, Info.SET_HEALTH)) + return health_node diff --git a/eive_tmtc/tmtc/payload/ploc_mpsoc.py b/eive_tmtc/tmtc/payload/ploc_mpsoc.py index 9953b9f..ddb434b 100644 --- a/eive_tmtc/tmtc/payload/ploc_mpsoc.py +++ b/eive_tmtc/tmtc/payload/ploc_mpsoc.py @@ -151,10 +151,10 @@ def create_ploc_mpsoc_node() -> CmdTreeNode: ] info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] combined_dict = dict(zip(op_code_strs, info_strs)) - ploc_mpsoc = CmdTreeNode("ploc_mpsoc", "PLOC MPSoC") + node = CmdTreeNode("ploc_mpsoc", "PLOC MPSoC") for op_code, info in combined_dict.items(): - ploc_mpsoc.add_child(CmdTreeNode(op_code, info)) - return ploc_mpsoc + node.add_child(CmdTreeNode(op_code, info)) + return node @tmtc_definitions_provider @@ -679,7 +679,9 @@ def handle_mpsoc_data_reply(action_id: int, pw: PrintWrapper, custom_data: bytea current_idx = 0 dir_name_short = custom_data[current_idx : current_idx + 12].decode("utf-8") current_idx += 12 - num_elements = struct.unpack("!I", custom_data[current_idx : current_idx + 4])[0] + num_elements = struct.unpack("!I", custom_data[current_idx : current_idx + 4])[ + 0 + ] elem_names = [] elem_attrs = [] elem_sizes = [] diff --git a/eive_tmtc/tmtc/payload/subsystem.py b/eive_tmtc/tmtc/payload/subsystem.py index 69010d6..529865e 100644 --- a/eive_tmtc/tmtc/payload/subsystem.py +++ b/eive_tmtc/tmtc/payload/subsystem.py @@ -1,14 +1,11 @@ import enum from typing import Dict, Tuple -from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import PL_SUBSYSTEM_ID from spacepackets.ecss import PusTelecommand from eive_tmtc.tmtc.common import pack_mode_cmd_with_info -from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry -from tmtccmd.config.tmtc import tmtc_definitions_provider -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.config import CmdTreeNode +from tmtccmd.tmtc import DefaultPusQueueHelper from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservice @@ -36,12 +33,9 @@ HANDLER_LIST: Dict[str, Tuple[int, str]] = { } -@service_provider(CustomServiceList.PL_SS) -def build_acs_subsystem_cmd(p: ServiceProviderParams): - op_code = p.op_code - q = p.queue_helper +def build_acs_subsystem_cmd(q: DefaultPusQueueHelper, cmd_str: str): info_prefix = "ACS Subsystem" - if op_code in OpCode.REPORT_ALL_MODES: + if cmd_str == OpCode.REPORT_ALL_MODES: q.add_log_cmd(f"{info_prefix}: {Info.REPORT_ALL_MODES}") q.add_pus_tc( PusTelecommand( @@ -50,7 +44,7 @@ def build_acs_subsystem_cmd(p: ServiceProviderParams): app_data=PL_SUBSYSTEM_ID, ) ) - mode_info_tup = HANDLER_LIST.get(op_code) + mode_info_tup = HANDLER_LIST.get(cmd_str) if mode_info_tup is None: return pack_mode_cmd_with_info( @@ -62,9 +56,8 @@ def build_acs_subsystem_cmd(p: ServiceProviderParams): ) -@tmtc_definitions_provider -def add_payload_subsystem_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(OpCode.OFF, Info.OFF) - oce.add(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES) - defs.add_service(CustomServiceList.PL_SS, "Payload Subsystem", oce) +def create_payload_subsystem_node() -> CmdTreeNode: + payload_node = CmdTreeNode("payload", "Payload Subsystem") + payload_node.add_child(CmdTreeNode(OpCode.OFF, Info.OFF)) + payload_node.add_child(CmdTreeNode(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES)) + return payload_node diff --git a/eive_tmtc/tmtc/power/__init__.py b/eive_tmtc/tmtc/power/__init__.py index b1d859b..e69de29 100644 --- a/eive_tmtc/tmtc/power/__init__.py +++ b/eive_tmtc/tmtc/power/__init__.py @@ -1,2 +0,0 @@ -from .subsystem import add_eps_subsystem_cmds -from .pwr_ctrl import pwr_cmd_defs diff --git a/eive_tmtc/tmtc/power/bpx_batt.py b/eive_tmtc/tmtc/power/bpx_batt.py index 8fd387c..155cc10 100644 --- a/eive_tmtc/tmtc/power/bpx_batt.py +++ b/eive_tmtc/tmtc/power/bpx_batt.py @@ -1,23 +1,19 @@ import enum import struct -from eive_tmtc.pus_tm.defs import PrintWrapper from spacepackets.ecss import PusTelecommand - -from eive_tmtc.config.definitions import CustomServiceList -from eive_tmtc.config.object_ids import BPX_HANDLER_ID from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, + CmdTreeNode, ) -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams -from tmtccmd.pus.s8_fsfw_action import create_action_cmd -from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid -from tmtccmd.pus.s200_fsfw_mode import pack_mode_data, Mode -from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter +from tmtccmd.pus.s8_fsfw_action import create_action_cmd +from tmtccmd.pus.s200_fsfw_mode import Mode, pack_mode_data +from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices +from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid +from tmtccmd.tmtc import DefaultPusQueueHelper + +from eive_tmtc.config.object_ids import BPX_HANDLER_ID +from eive_tmtc.pus_tm.defs import PrintWrapper class BpxSetId(enum.IntEnum): @@ -54,38 +50,38 @@ class BpxOpCode: REBOOT = "reboot" -@tmtc_definitions_provider -def add_bpx_cmd_definitions(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(keys=BpxOpCode.ON, info="On command") - oce.add(keys=BpxOpCode.OFF, info="Off command") - oce.add(keys=BpxOpCode.HK, info="Request BPX HK") - oce.add(keys=BpxOpCode.RST_BOOT_CNT, info="Reset Boot Count") - oce.add(keys=BpxOpCode.RST_CFG, info="Reset Config to stored default settings") - oce.add(keys=BpxOpCode.SET_CFG, info="Set BPX configuration") - oce.add(keys=BpxOpCode.MAN_HEATER_ON, info="Manual heater on") - oce.add(keys=BpxOpCode.MAN_HEATER_OFF, info="Manual heater off") - oce.add(keys=BpxOpCode.REQUEST_CFG, info="Request Configuration Struct (Step 1)") - oce.add( - keys=BpxOpCode.REQUEST_CFG_HK, info="Request Configuration Struct HK (Step 2)" +def create_bpx_batt_node() -> CmdTreeNode: + node = CmdTreeNode("bat", "BPX battery device") + node.add_child(CmdTreeNode(BpxOpCode.ON, "ON command")) + node.add_child(CmdTreeNode(BpxOpCode.OFF, "OFF command")) + node.add_child(CmdTreeNode(BpxOpCode.HK, "HK command")) + node.add_child(CmdTreeNode(BpxOpCode.RST_BOOT_CNT, "Reset boot count")) + node.add_child( + CmdTreeNode(BpxOpCode.RST_CFG, "Reset Config to stored default settings") ) - oce.add(keys=BpxOpCode.REBOOT, info="Reboot Command") - defs.add_service( - name=CustomServiceList.BPX_BATTERY.value, - info="BPX Battery Handler", - op_code_entry=oce, + node.add_child(CmdTreeNode(BpxOpCode.SET_CFG, "Set BPX configuration")) + node.add_child(CmdTreeNode(BpxOpCode.MAN_HEATER_ON, "Manual heater on")) + node.add_child(CmdTreeNode(BpxOpCode.MAN_HEATER_OFF, "Manual heater off")) + node.add_child( + CmdTreeNode(BpxOpCode.REQUEST_CFG, "Request Configuration Struct (Step 1)") ) + node.add_child( + CmdTreeNode( + BpxOpCode.REQUEST_CFG_HK, "Request Configuration Struct HK (Step 2)" + ) + ) + node.add_child(CmdTreeNode(BpxOpCode.REBOOT, "Reboot Command")) + return node -@service_provider(CustomServiceList.BPX_BATTERY.value) -def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is okay here. - op_code = p.op_code - q = p.queue_helper - if op_code == BpxOpCode.HK: +def pack_bpx_commands( + q: DefaultPusQueueHelper, cmd_str: str +): # noqa C901: Complexity is okay here. + if cmd_str == BpxOpCode.HK: q.add_log_cmd("Requesting BPX battery HK set") sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetId.GET_HK_SET) q.add_pus_tc(generate_one_hk_command(sid=sid)) - if op_code == BpxOpCode.OFF: + if cmd_str == BpxOpCode.OFF: q.add_log_cmd("Off mode") mode_cmd = pack_mode_data(BPX_HANDLER_ID, Mode.OFF, 0) q.add_pus_tc( @@ -95,7 +91,7 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka app_data=mode_cmd, ) ) - if op_code == BpxOpCode.ON: + if cmd_str == BpxOpCode.ON: q.add_log_cmd("On mode") mode_cmd = pack_mode_data(BPX_HANDLER_ID, Mode.ON, 0) q.add_pus_tc( @@ -105,21 +101,21 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka app_data=mode_cmd, ) ) - if op_code == BpxOpCode.RST_BOOT_CNT: + if cmd_str == BpxOpCode.RST_BOOT_CNT: q.add_log_cmd("Resetting reboot counters") q.add_pus_tc( create_action_cmd( object_id=BPX_HANDLER_ID, action_id=BpxActionId.RESET_COUNTERS ) ) - if op_code == BpxOpCode.RST_CFG: + if cmd_str == BpxOpCode.RST_CFG: q.add_log_cmd("Reset BPX configuration") q.add_pus_tc( create_action_cmd( object_id=BPX_HANDLER_ID, action_id=BpxActionId.CONFIG_CMD ) ) - if op_code == BpxOpCode.SET_CFG: + if cmd_str == BpxOpCode.SET_CFG: q.add_log_cmd("Setting BPX configuration") user_data = bytearray() batt_mode = BpxHeaterModeSelect( @@ -137,21 +133,21 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka user_data=user_data, ) ) - if op_code == BpxOpCode.REQUEST_CFG: + if cmd_str == BpxOpCode.REQUEST_CFG: q.add_log_cmd("Requesting configuration struct") q.add_pus_tc( create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.GET_CFG) ) - if op_code == BpxOpCode.REQUEST_CFG_HK: + if cmd_str == BpxOpCode.REQUEST_CFG_HK: q.add_log_cmd("Requesting configuration struct HK") sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetId.GET_CFG_SET) q.add_pus_tc(generate_one_hk_command(sid=sid)) - if op_code == BpxOpCode.REBOOT: + if cmd_str == BpxOpCode.REBOOT: q.add_log_cmd("Rebooting BPX battery") q.add_pus_tc( create_action_cmd(object_id=BPX_HANDLER_ID, action_id=BpxActionId.REBOOT) ) - if op_code == BpxOpCode.MAN_HEATER_ON: + if cmd_str == BpxOpCode.MAN_HEATER_ON: q.add_log_cmd("BPX manual heater on with seconds burntime") burn_time = int(input("BPX heater burn time in seconds [1-65535]: ")) if burn_time < 1 or burn_time > 65535: @@ -163,7 +159,7 @@ def pack_bpx_commands(p: ServiceProviderParams): # noqa C901: Complexity is oka user_data=struct.pack("!H", burn_time), ) ) - if op_code == BpxOpCode.MAN_HEATER_OFF: + if cmd_str == BpxOpCode.MAN_HEATER_OFF: q.add_log_cmd("BPX manual heater off") q.add_pus_tc( create_action_cmd( diff --git a/eive_tmtc/tmtc/power/pwr_ctrl.py b/eive_tmtc/tmtc/power/pwr_ctrl.py index ecab1dd..4488491 100644 --- a/eive_tmtc/tmtc/power/pwr_ctrl.py +++ b/eive_tmtc/tmtc/power/pwr_ctrl.py @@ -3,32 +3,26 @@ import enum import logging import struct -from eive_tmtc.config.definitions import CustomServiceList -from eive_tmtc.config.object_ids import PWR_CONTROLLER -from eive_tmtc.pus_tm.defs import PrintWrapper from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, -) -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.queue import DefaultPusQueueHelper -from tmtccmd.pus.s200_fsfw_mode import Mode, pack_mode_command -from tmtccmd.tmtc.decorator import ServiceProviderParams -from tmtccmd.pus.tc.s3_fsfw_hk import ( - generate_one_hk_command, - make_sid, - enable_periodic_hk_command_with_interval, - disable_periodic_hk_command, + CmdTreeNode, ) from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter - from tmtccmd.pus.s20_fsfw_param import create_load_param_cmd - from tmtccmd.pus.s20_fsfw_param_defs import ( - create_scalar_float_parameter, create_scalar_double_parameter, + create_scalar_float_parameter, ) +from tmtccmd.pus.s200_fsfw_mode import Mode, pack_mode_command +from tmtccmd.pus.tc.s3_fsfw_hk import ( + disable_periodic_hk_command, + enable_periodic_hk_command_with_interval, + generate_one_hk_command, + make_sid, +) +from tmtccmd.tmtc.queue import DefaultPusQueueHelper + +from eive_tmtc.config.object_ids import PWR_CONTROLLER +from eive_tmtc.pus_tm.defs import PrintWrapper _LOGGER = logging.getLogger(__name__) @@ -51,17 +45,17 @@ class ParamId(enum.IntEnum): HIGHER_MODES_LIMIT = 6 -class OpCodes: - OFF = ["mode_off"] - ON = ["mode_on"] - NML = ["mode_normal"] - SET_PARAMETER = ["set_parameter"] - REQUEST_CORE_HK = ["core_hk"] - ENABLE_CORE_HK = ["core_enable_hk"] - DISABLE_CORE_HK = ["core_disable_hk"] - REQUEST_ENABLE_PL_HK = ["enable_pl_hk"] - ENABLE_ENABLE_PL_HK = ["enable_pl_enable_hk"] - DISABLE_ENABLE_PL_HK = ["enable_pl_disable_hk"] +class OpCode: + OFF = "off" + ON = "on" + NML = "normal" + SET_PARAMETER = "set_parameter" + REQUEST_CORE_HK = "core_hk" + ENABLE_CORE_HK = "core_enable_hk" + DISABLE_CORE_HK = "core_disable_hk" + REQUEST_ENABLE_PL_HK = "enable_pl_hk" + ENABLE_ENABLE_PL_HK = "enable_pl_enable_hk" + DISABLE_ENABLE_PL_HK = "enable_pl_disable_hk" class Info: @@ -77,46 +71,37 @@ class Info: DISABLE_ENABLE_PL_HK = "Disable Enable PL HK Data Generation" -@tmtc_definitions_provider -def pwr_cmd_defs(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(keys=OpCodes.OFF, info=Info.OFF) - oce.add(keys=OpCodes.ON, info=Info.ON) - oce.add(keys=OpCodes.NML, info=Info.NML) - oce.add(keys=OpCodes.SET_PARAMETER, info=Info.SET_PARAMETER) - oce.add(keys=OpCodes.REQUEST_CORE_HK, info=Info.REQUEST_CORE_HK) - oce.add(keys=OpCodes.ENABLE_CORE_HK, info=Info.ENABLE_CORE_HK) - oce.add(keys=OpCodes.DISABLE_CORE_HK, info=Info.DISABLE_CORE_HK) - oce.add(keys=OpCodes.REQUEST_ENABLE_PL_HK, info=Info.REQUEST_ENABLE_PL_HK) - oce.add(keys=OpCodes.ENABLE_ENABLE_PL_HK, info=Info.ENABLE_ENABLE_PL_HK) - oce.add(keys=OpCodes.DISABLE_ENABLE_PL_HK, info=Info.DISABLE_ENABLE_PL_HK) - defs.add_service( - name=CustomServiceList.PWR_CTRL.value, info="PWR Controller", op_code_entry=oce - ) +def create_pwr_ctrl_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("pwr_ctrl", "Power Controller") + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node -@service_provider(CustomServiceList.PWR_CTRL.value) -def pack_acs_ctrl_command(p: ServiceProviderParams): - op_code = p.op_code - q = p.queue_helper - if op_code in OpCodes.OFF: +def pack_acs_ctrl_command(q: DefaultPusQueueHelper, cmd_str: str): + if cmd_str == OpCode.OFF: q.add_log_cmd(f"{Info.OFF}") q.add_pus_tc(pack_mode_command(PWR_CONTROLLER, Mode.OFF, 0)) - elif op_code in OpCodes.ON: + elif cmd_str == OpCode.ON: q.add_log_cmd(f"{Info.ON}") q.add_pus_tc(pack_mode_command(PWR_CONTROLLER, Mode.ON, 0)) - elif op_code in OpCodes.NML: + elif cmd_str == OpCode.NML: q.add_log_cmd(f"{Info.NML}") q.add_pus_tc(pack_mode_command(PWR_CONTROLLER, Mode.NORMAL, 0)) - elif op_code in OpCodes.SET_PARAMETER: + elif cmd_str in OpCode.SET_PARAMETER: q.add_log_cmd(f"{Info.SET_PARAMETER}") set_pwr_ctrl_param(q) - elif op_code in OpCodes.REQUEST_CORE_HK: + elif cmd_str == OpCode.REQUEST_CORE_HK: q.add_log_cmd(Info.REQUEST_CORE_HK) q.add_pus_tc( generate_one_hk_command(make_sid(PWR_CONTROLLER, SetId.CORE_HK_SET)) ) - elif op_code in OpCodes.ENABLE_CORE_HK: + elif cmd_str == OpCode.ENABLE_CORE_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_CORE_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -124,19 +109,19 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_CORE_HK: + elif cmd_str == OpCode.DISABLE_CORE_HK: q.add_log_cmd(Info.DISABLE_CORE_HK) q.add_pus_tc( disable_periodic_hk_command( False, make_sid(PWR_CONTROLLER, SetId.CORE_HK_SET) ) ) - elif op_code in OpCodes.REQUEST_ENABLE_PL_HK: + elif cmd_str == OpCode.REQUEST_ENABLE_PL_HK: q.add_log_cmd(Info.REQUEST_ENABLE_PL_HK) q.add_pus_tc( generate_one_hk_command(make_sid(PWR_CONTROLLER, SetId.ENABLE_PL_SET)) ) - elif op_code in OpCodes.ENABLE_ENABLE_PL_HK: + elif cmd_str == OpCode.ENABLE_ENABLE_PL_HK: interval = float(input("Please specify interval in floating point seconds: ")) q.add_log_cmd(Info.ENABLE_ENABLE_PL_HK) cmd_tuple = enable_periodic_hk_command_with_interval( @@ -144,7 +129,7 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): ) q.add_pus_tc(cmd_tuple[0]) q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_ENABLE_PL_HK: + elif cmd_str == OpCode.DISABLE_ENABLE_PL_HK: q.add_log_cmd(Info.DISABLE_ENABLE_PL_HK) q.add_pus_tc( disable_periodic_hk_command( diff --git a/eive_tmtc/tmtc/power/subsystem.py b/eive_tmtc/tmtc/power/subsystem.py index 71c1443..6af172e 100644 --- a/eive_tmtc/tmtc/power/subsystem.py +++ b/eive_tmtc/tmtc/power/subsystem.py @@ -1,18 +1,16 @@ import enum -from typing import Tuple, Dict +from typing import Dict, Tuple from spacepackets.ecss import PusTelecommand -from eive_tmtc.tmtc.common import pack_mode_cmd_with_info -from eive_tmtc.config.object_ids import EPS_SUBSYSTEM_ID -from eive_tmtc.config.definitions import CustomServiceList from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, + CmdTreeNode, ) -from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices, Mode -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.pus.s200_fsfw_mode import Mode +from tmtccmd.pus.s200_fsfw_mode import Subservice as ModeSubservices +from tmtccmd.tmtc import DefaultPusQueueHelper + +from eive_tmtc.config.object_ids import EPS_SUBSYSTEM_ID +from eive_tmtc.tmtc.common import pack_mode_cmd_with_info class OpCode(str, enum.Enum): @@ -33,12 +31,9 @@ HANDLER_LIST: Dict[str, Tuple[int, int, str]] = { } -@service_provider(CustomServiceList.EPS_SS.value) -def build_eps_subsystem_cmd(p: ServiceProviderParams): - op_code = p.op_code - q = p.queue_helper +def build_eps_subsystem_cmd(q: DefaultPusQueueHelper, cmd_str: str): info_prefix = "EPS Subsystem" - if op_code in OpCode.REPORT_ALL_MODES: + if cmd_str in OpCode.REPORT_ALL_MODES: q.add_log_cmd(f"{info_prefix}: {Info.REPORT_ALL_MODES}") q.add_pus_tc( PusTelecommand( @@ -47,7 +42,7 @@ def build_eps_subsystem_cmd(p: ServiceProviderParams): app_data=EPS_SUBSYSTEM_ID, ) ) - mode_info_tup = HANDLER_LIST.get(op_code) + mode_info_tup = HANDLER_LIST.get(cmd_str) if mode_info_tup is None: return pack_mode_cmd_with_info( @@ -59,10 +54,9 @@ def build_eps_subsystem_cmd(p: ServiceProviderParams): ) -@tmtc_definitions_provider -def add_eps_subsystem_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - 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.EPS_SS, "EPS Subsystem", oce) +def create_eps_subsystem_node() -> CmdTreeNode: + eps_node = CmdTreeNode("eps", "EPS Subsystem") + for cmd_str, (_, _, info) in HANDLER_LIST.items(): + eps_node.add_child(CmdTreeNode(cmd_str, info)) + eps_node.add_child(CmdTreeNode(OpCode.REPORT_ALL_MODES, Info.REPORT_ALL_MODES)) + return eps_node diff --git a/eive_tmtc/tmtc/system.py b/eive_tmtc/tmtc/system.py index b040131..36a0c17 100644 --- a/eive_tmtc/tmtc/system.py +++ b/eive_tmtc/tmtc/system.py @@ -3,18 +3,18 @@ import enum from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.tmtc.acs.subsystem import AcsMode from tmtccmd.config.tmtc import ( + CmdTreeNode, tmtc_definitions_provider, TmtcDefinitionWrapper, OpCodeEntry, ) -from tmtccmd.tmtc import service_provider +from tmtccmd.tmtc import DefaultPusQueueHelper from eive_tmtc.config.object_ids import EIVE_SYSTEM_ID from tmtccmd.pus.s200_fsfw_mode import ( create_mode_command, create_announce_mode_recursive_command, ) from tmtccmd.pus.s8_fsfw_action import create_action_cmd -from tmtccmd.tmtc.decorator import ServiceProviderParams class SystemMode: @@ -55,40 +55,49 @@ class Info: REBOOT_I2C = "Reboot I2C bus" -@service_provider(CustomServiceList.SYSTEM.value) -def build_system_cmds(p: ServiceProviderParams): - o = p.op_code - q = p.queue_helper +def build_system_cmds(q: DefaultPusQueueHelper, cmd_str: str): prefix = "EIVE System" - if o == OpCode.SAFE_MODE: + if cmd_str == OpCode.SAFE_MODE: q.add_log_cmd(f"{prefix}: {Info.SAFE_MODE}") q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.SAFE, 0)) - elif o == OpCode.IDLE_MODE: + elif cmd_str == OpCode.IDLE_MODE: q.add_log_cmd(f"{prefix}: {Info.IDLE_MODE}") q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.IDLE, 0)) - elif o == OpCode.NADIR_MODE: + elif cmd_str == OpCode.NADIR_MODE: q.add_log_cmd(f"{prefix}: {Info.NADIR_MODE}") q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.PTG_NADIR, 0)) - elif o == OpCode.TARGET_MODE: + elif cmd_str == OpCode.TARGET_MODE: q.add_log_cmd(f"{prefix}: {Info.TARGET_MODE}") q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.PTG_TARGET, 0)) - elif o == OpCode.TARGET_GS_MODE: + elif cmd_str == OpCode.TARGET_GS_MODE: q.add_log_cmd(f"{prefix}: {Info.TARGET_GS_MODE}") q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.PTG_TARGET_GS, 0)) - elif o == OpCode.INERTIAL_MODE: + elif cmd_str == OpCode.INERTIAL_MODE: q.add_log_cmd(f"{prefix}: {Info.INERTIAL_MODE}") q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.PTG_INERTIAL, 0)) - elif o == OpCode.ANNOUNCE_MODES: + elif cmd_str == OpCode.ANNOUNCE_MODES: q.add_log_cmd(f"{prefix}: {Info.ANNOUNCE_MODES}") q.add_pus_tc(create_announce_mode_recursive_command(EIVE_SYSTEM_ID)) - elif o == OpCode.BOOT_MODE: + elif cmd_str == OpCode.BOOT_MODE: q.add_log_cmd(f"{prefix}: {Info.BOOT_MODE}") q.add_pus_tc(create_mode_command(EIVE_SYSTEM_ID, SystemMode.BOOT, 0)) - elif o == OpCode.REBOOT_I2C: + elif cmd_str == OpCode.REBOOT_I2C: q.add_log_cmd(f"{prefix}: {Info.REBOOT_I2C}") q.add_pus_tc(create_action_cmd(EIVE_SYSTEM_ID, ActionId.EXECUTE_I2C_REBOOT)) +def create_system_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("system", "EIVE System") + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node + + @tmtc_definitions_provider def add_system_cmd_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/test.py b/eive_tmtc/tmtc/test.py index c484a38..876713b 100644 --- a/eive_tmtc/tmtc/test.py +++ b/eive_tmtc/tmtc/test.py @@ -1,16 +1,10 @@ -from spacepackets.ecss import PusTelecommand, PusService -from tmtccmd.config import CoreServiceList -from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, -) +from spacepackets.ecss import PusService, PusTelecommand +from tmtccmd.config import CmdTreeNode from tmtccmd.pus.s17_test import create_service_17_ping_command -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.tmtc import DefaultPusQueueHelper -class OpCodes: +class OpCode: PING = "ping" TRIGGER_EVENT = "trig_event" PING_WITH_DATA = "ping_with_data" @@ -22,31 +16,22 @@ class Info: PING_WITH_DATA = "Ping with data. Size of sent data is sent back" -@tmtc_definitions_provider -def add_test_defs(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(keys=OpCodes.PING, info=Info.PING) - oce.add(keys=OpCodes.TRIGGER_EVENT, info=Info.TRIGGER_EVENT) - oce.add(keys=OpCodes.PING_WITH_DATA, info=Info.PING_WITH_DATA) - - defs.add_service( - name=CoreServiceList.SERVICE_17_ALT, - info="PUS 17 Test Service", - op_code_entry=oce, - ) +def create_test_node() -> CmdTreeNode: + node = CmdTreeNode("test", "Test Commands") + node.add_child(CmdTreeNode(OpCode.PING, Info.PING)) + node.add_child(CmdTreeNode(OpCode.TRIGGER_EVENT, Info.TRIGGER_EVENT)) + node.add_child(CmdTreeNode(OpCode.PING_WITH_DATA, Info.PING_WITH_DATA)) + return node -@service_provider(CoreServiceList.SERVICE_17_ALT) -def pack_test_command(p: ServiceProviderParams): - info = p.info - q = p.queue_helper - if info.op_code == OpCodes.PING: +def pack_test_command(q: DefaultPusQueueHelper, cmd_path: str): + if cmd_path == OpCode.PING: q.add_log_cmd("Sending PUS TC [17,1]") q.add_pus_tc(create_service_17_ping_command()) - if info.op_code == OpCodes.TRIGGER_EVENT: + if cmd_path == OpCode.TRIGGER_EVENT: q.add_log_cmd("Sending PUS TC Event Trigger [17, 128]") q.add_pus_tc(PusTelecommand(service=PusService.S17_TEST, subservice=128)) - if info.op_code == OpCodes.PING_WITH_DATA: + if cmd_path == OpCode.PING_WITH_DATA: q.add_log_cmd("Sending Ping With Data, Size Reported Back [17, 129]") while True: data_size = int(input("Please specify data size [0-1024]: ")) @@ -55,7 +40,7 @@ def pack_test_command(p: ServiceProviderParams): break dummy_data = bytearray() next_byte = True - for i in range(data_size): + for _ in range(data_size): dummy_data.append(int(next_byte)) next_byte = not next_byte q.add_pus_tc( diff --git a/eive_tmtc/tmtc/tm_store.py b/eive_tmtc/tmtc/tm_store.py index 3f4fc5f..6d5f9e8 100644 --- a/eive_tmtc/tmtc/tm_store.py +++ b/eive_tmtc/tmtc/tm_store.py @@ -3,26 +3,25 @@ import enum import logging import math import struct +from typing import Tuple +from dateutil.parser import parse +from spacepackets.ecss.pus_15_tm_storage import Subservice +from spacepackets.ecss.tc import PusTelecommand +from tmtccmd.config import CmdTreeNode, TmtcDefinitionWrapper +from tmtccmd.config.tmtc import OpCodeEntry +from tmtccmd.tmtc.queue import DefaultPusQueueHelper +from tmtccmd.util import ObjectIdU32 + +from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import ( + CFDP_TM_STORE, HK_TM_STORE, MISC_TM_STORE, - OK_TM_STORE, NOT_OK_TM_STORE, - CFDP_TM_STORE, + OK_TM_STORE, get_object_ids, ) -from eive_tmtc.config.definitions import CustomServiceList -from tmtccmd.config import TmtcDefinitionWrapper -from tmtccmd.config.tmtc import tmtc_definitions_provider, OpCodeEntry -from tmtccmd.tmtc import service_provider -from tmtccmd.tmtc.decorator import ServiceProviderParams -from dateutil.parser import parse - -from spacepackets.ecss import PusService # noqa -from spacepackets.ecss.tc import PusTelecommand -from spacepackets.ecss.pus_15_tm_storage import Subservice -from tmtccmd.util import ObjectIdU32 class OpCode: @@ -38,11 +37,8 @@ class Info: _LOGGER = logging.getLogger(__name__) -@service_provider(CustomServiceList.TM_STORE) -def pack_tm_store_commands(p: ServiceProviderParams): - q = p.queue_helper - o = p.op_code - if o == OpCode.DELETE_UP_TO: +def pack_tm_store_commands(q: DefaultPusQueueHelper, cmd_path: str): + if cmd_path == OpCode.DELETE_UP_TO: obj_id, store_string = store_select_prompt() app_data = bytearray(obj_id.as_bytes) delete_up_to_time = time_prompt("Determining deletion end time") @@ -56,7 +52,7 @@ def pack_tm_store_commands(p: ServiceProviderParams): service=15, subservice=Subservice.DELETE_UP_TO, app_data=app_data ) ) - elif o == OpCode.RETRIEVAL_BY_TIME_RANGE: + elif cmd_path == OpCode.RETRIEVAL_BY_TIME_RANGE: q.add_log_cmd(Info.RETRIEVAL_BY_TIME_RANGE) obj_id, store_string = store_select_prompt() app_data = bytearray(obj_id.as_bytes) @@ -80,7 +76,15 @@ def pack_tm_store_commands(p: ServiceProviderParams): ) -@tmtc_definitions_provider +def create_persistent_tm_store_node() -> CmdTreeNode: + node = CmdTreeNode("tm_store", "Persistent TM Store") + node.add_child(CmdTreeNode(OpCode.DELETE_UP_TO, Info.DELETE_UP_TO)) + node.add_child( + CmdTreeNode(OpCode.RETRIEVAL_BY_TIME_RANGE, Info.RETRIEVAL_BY_TIME_RANGE) + ) + return node + + def add_persistent_tm_store_cmd_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() oce.add(keys=OpCode.DELETE_UP_TO, info=Info.DELETE_UP_TO) @@ -130,6 +134,7 @@ def time_prompt(info_str: str) -> datetime.datetime: return time_prompt_fully_manually() elif time_input_key == 2: return time_prompt_offset_from_now() + raise ValueError("can not determine datetime") def time_prompt_fully_manually() -> datetime.datetime: @@ -160,7 +165,7 @@ def time_prompt_offset_from_now() -> datetime.datetime: return time_now_with_offset -def store_select_prompt() -> (ObjectIdU32, str): +def store_select_prompt() -> Tuple[ObjectIdU32, str]: obj_id_dict = get_object_ids() print("Available TM stores:") for k, v in STORE_DICT.items(): -- 2.43.0 From ae239031ed9e249099fb26cae2136e94aed575be Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 14:13:00 +0100 Subject: [PATCH 12/42] removed old service provider API --- eive_tmtc/tmtc/__init__.py | 1 - eive_tmtc/tmtc/acs/acs_board.py | 18 ++----- eive_tmtc/tmtc/acs/sus_board.py | 61 ++++++++---------------- eive_tmtc/tmtc/solar_array_deployment.py | 39 ++++++--------- 4 files changed, 39 insertions(+), 80 deletions(-) diff --git a/eive_tmtc/tmtc/__init__.py b/eive_tmtc/tmtc/__init__.py index 84ed9c4..7385d19 100644 --- a/eive_tmtc/tmtc/__init__.py +++ b/eive_tmtc/tmtc/__init__.py @@ -1,4 +1,3 @@ -from .solar_array_deployment import add_sa_depl_cmds from .system import add_system_cmd_defs from .tm_store import add_persistent_tm_store_cmd_defs from .tcs import add_tmp_sens_cmds diff --git a/eive_tmtc/tmtc/acs/acs_board.py b/eive_tmtc/tmtc/acs/acs_board.py index 5d1d41b..7ac7bcc 100644 --- a/eive_tmtc/tmtc/acs/acs_board.py +++ b/eive_tmtc/tmtc/acs/acs_board.py @@ -1,16 +1,15 @@ import enum -from eive_tmtc.config.definitions import CustomServiceList from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, OpCodeEntry, + TmtcDefinitionWrapper, + tmtc_definitions_provider, ) -from tmtccmd.tmtc import service_provider, DefaultPusQueueHelper -from tmtccmd.tmtc.decorator import ServiceProviderParams from tmtccmd.pus.s200_fsfw_mode import Mode -from eive_tmtc.config.object_ids import ACS_BOARD_ASS_ID +from tmtccmd.tmtc import DefaultPusQueueHelper +from eive_tmtc.config.definitions import CustomServiceList +from eive_tmtc.config.object_ids import ACS_BOARD_ASS_ID from eive_tmtc.tmtc.common import pack_mode_cmd_with_info @@ -89,13 +88,6 @@ def pack_acs_command(q: DefaultPusQueueHelper, cmd_str: str): ) -@service_provider(CustomServiceList.ACS_BRD_ASS) -def pack_acs_command_provider(p: ServiceProviderParams): - op_code = p.op_code - q = p.queue_helper - pack_acs_command(q, op_code) - - @tmtc_definitions_provider def add_acs_board_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/acs/sus_board.py b/eive_tmtc/tmtc/acs/sus_board.py index cc419a4..18dbcb4 100644 --- a/eive_tmtc/tmtc/acs/sus_board.py +++ b/eive_tmtc/tmtc/acs/sus_board.py @@ -1,22 +1,19 @@ -from eive_tmtc.config.definitions import CustomServiceList +from tmtccmd.config.tmtc import ( + CmdTreeNode, +) +from tmtccmd.pus.s200_fsfw_mode import Mode +from tmtccmd.tmtc import DefaultPusQueueHelper + from eive_tmtc.config.object_ids import SUS_BOARD_ASS_ID from eive_tmtc.tmtc.acs.acs_board import DualSideSubmode from eive_tmtc.tmtc.common import pack_mode_cmd_with_info -from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, -) -from tmtccmd.tmtc import service_provider, DefaultPusQueueHelper -from tmtccmd.tmtc.decorator import ServiceProviderParams -from tmtccmd.pus.s200_fsfw_mode import Mode class SusOpCode: - SUS_ASS_NOM_SIDE = ["0", "nom"] - SUS_ASS_RED_SIDE = ["1", "red"] - SUS_ASS_DUAL_MODE = ["2", "dual"] - SUS_ASS_OFF = ["3", "off"] + SUS_ASS_NOM_SIDE = "nom" + SUS_ASS_RED_SIDE = "red" + SUS_ASS_DUAL_MODE = "dual" + SUS_ASS_OFF = "off" def pack_sus_cmds(q: DefaultPusQueueHelper, op_code: str): @@ -54,34 +51,16 @@ def pack_sus_cmds(q: DefaultPusQueueHelper, op_code: str): ) -@service_provider(CustomServiceList.SUS_BRD_ASS) -def pack_sus_cmds_prvoider(p: ServiceProviderParams): - op_code = p.op_code - q = p.queue_helper - pack_sus_cmds(q, op_code) - - -@tmtc_definitions_provider -def add_sus_board_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add( - keys=SusOpCode.SUS_ASS_NOM_SIDE, - info="Switch SUS board to nominal side", +def create_sus_board_node() -> CmdTreeNode: + node = CmdTreeNode("sus_brd_assy", "SUS board assembly") + node.add_child( + CmdTreeNode(SusOpCode.SUS_ASS_RED_SIDE, "Switch SUS board to nominal side") ) - oce.add( - keys=SusOpCode.SUS_ASS_RED_SIDE, - info="Switch SUS board to redundant side", + node.add_child( + CmdTreeNode(SusOpCode.SUS_ASS_RED_SIDE, "Switch SUS board to redundant side") ) - oce.add( - keys=SusOpCode.SUS_ASS_OFF, - info="Switch off SUS board", - ) - oce.add( - keys=SusOpCode.SUS_ASS_DUAL_MODE, - info="Switch SUS board to dual mode", - ) - defs.add_service( - name=CustomServiceList.SUS_BRD_ASS.value, - info="SUS Board Assembly", - op_code_entry=oce, + node.add_child(CmdTreeNode(SusOpCode.SUS_ASS_OFF, "Switch SUS board off")) + node.add_child( + CmdTreeNode(SusOpCode.SUS_ASS_DUAL_MODE, "Switch SUS board to dual mode") ) + return node diff --git a/eive_tmtc/tmtc/solar_array_deployment.py b/eive_tmtc/tmtc/solar_array_deployment.py index 201a48c..c0858b7 100644 --- a/eive_tmtc/tmtc/solar_array_deployment.py +++ b/eive_tmtc/tmtc/solar_array_deployment.py @@ -9,17 +9,14 @@ import logging import struct -from eive_tmtc.config.definitions import CustomServiceList -from eive_tmtc.config.object_ids import SOLAR_ARRAY_DEPLOYMENT_ID from spacepackets.ecss import PusTelecommand from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, - OpCodeEntry, + CmdTreeNode, ) -from tmtccmd.tmtc import service_provider, DefaultPusQueueHelper from tmtccmd.pus.s8_fsfw_action import create_action_cmd -from tmtccmd.tmtc.decorator import ServiceProviderParams +from tmtccmd.tmtc import DefaultPusQueueHelper + +from eive_tmtc.config.object_ids import SOLAR_ARRAY_DEPLOYMENT_ID class OpCode: @@ -38,25 +35,17 @@ class ActionId: MANUAL_DEPLOYMENT = 5 -@tmtc_definitions_provider -def add_sa_depl_cmds(defs: TmtcDefinitionWrapper): - oce = OpCodeEntry() - oce.add(keys=OpCode.MANUAL_DEPLOYMENT, info=Info.MANUAL_DEPLOYMENT) - oce.add(keys=OpCode.BURN_SA_0_ONLY, info=Info.BURN_SA_0_ONLY) - oce.add(keys=OpCode.BURN_SA_1_ONLY, info=Info.BURN_SA_1_ONLY) - defs.add_service( - name=CustomServiceList.SA_DEPLYOMENT, - info="Solar Array Deployment", - op_code_entry=oce, - ) +def add_solar_array_deployment_node() -> CmdTreeNode: + node = CmdTreeNode("solar_array_deployment", "Solar Array Deployment") + node.add_child(CmdTreeNode(OpCode.MANUAL_DEPLOYMENT, Info.MANUAL_DEPLOYMENT)) + node.add_child(CmdTreeNode(OpCode.BURN_SA_0_ONLY, Info.BURN_SA_0_ONLY)) + node.add_child(CmdTreeNode(OpCode.BURN_SA_1_ONLY, Info.BURN_SA_1_ONLY)) + return node -@service_provider(CustomServiceList.SA_DEPLYOMENT) -def pack_solar_array_deployment_test_into(p: ServiceProviderParams): - q = p.queue_helper - op_code = p.op_code +def pack_solar_array_deployment_test_into(q: DefaultPusQueueHelper, cmd_str: str): switch_interval_ms = 0 - if op_code == OpCode.MANUAL_DEPLOYMENT: + if cmd_str == OpCode.MANUAL_DEPLOYMENT: while True: burn_time_secs = prompt_burn_time() if burn_time_secs < 0: @@ -80,9 +69,9 @@ def pack_solar_array_deployment_test_into(p: ServiceProviderParams): q.add_pus_tc( pack_manual_array_depl_cmd(burn_time_secs, switch_interval_ms, dry_run) ) - elif op_code in OpCode.BURN_SA_0_ONLY: + elif cmd_str == OpCode.BURN_SA_0_ONLY: burn_one_channel_only(q, 0) - elif op_code in OpCode.BURN_SA_1_ONLY: + elif cmd_str == OpCode.BURN_SA_1_ONLY: burn_one_channel_only(q, 1) -- 2.43.0 From af02c106b95997d8339174da3f0a7ba0a4937638 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 16:40:27 +0100 Subject: [PATCH 13/42] looking good --- eive_tmtc/config/hook.py | 18 ++--- eive_tmtc/tmtc/com/ccsds_handler.py | 25 +++++-- eive_tmtc/tmtc/com/syrlinks_handler.py | 15 ++++ eive_tmtc/tmtc/core.py | 89 +++++++++++++++-------- eive_tmtc/tmtc/payload/ploc_mpsoc.py | 3 +- eive_tmtc/tmtc/payload/ploc_supervisor.py | 2 +- eive_tmtc/tmtc/power/bpx_batt.py | 2 +- eive_tmtc/tmtc/power/pwr_ctrl.py | 2 +- 8 files changed, 105 insertions(+), 51 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index 3f32f34..658d2f3 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -7,9 +7,12 @@ from tmtccmd.util import ObjectIdDictT, RetvalDictT from eive_tmtc.config.definitions import SPACE_PACKET_IDS from eive_tmtc.config.retvals import get_retval_dict -from eive_tmtc.tmtc.com.subsystem import create_com_subsystem_node -from eive_tmtc.tmtc.health import create_global_health_node +from eive_tmtc.tmtc.core import create_core_node from eive_tmtc.tmtc.acs.subsystem import create_acs_subsystem_node +from eive_tmtc.tmtc.com.ccsds_handler import create_ccsds_node +from eive_tmtc.tmtc.com.subsystem import create_com_subsystem_node +from eive_tmtc.tmtc.com.syrlinks_handler import create_syrlinks_node +from eive_tmtc.tmtc.health import create_global_health_node from eive_tmtc.tmtc.payload.ploc_mpsoc import create_ploc_mpsoc_node from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node from eive_tmtc.tmtc.payload.scex import create_scex_node @@ -97,13 +100,8 @@ class EiveHookObject(HookBase): tcs_node.add_child(tcs_brd_assy) com_node = create_com_subsystem_node() - syrlinks_node = CmdTreeNode("syrlinks", "Syrlinks") - syrlinks_node.add_child(dev_node) - syrlinks_node.add_child(assy_node) - syrlinks_node.add_child(action_node) - ccsds_node = CmdTreeNode("ccsds", "CCSDS Handler") - ccsds_node.add_child(action_node) - com_node.add_child(syrlinks_node) + com_node.add_child(create_syrlinks_node()) + com_node.add_child(create_ccsds_node()) eps_node = create_eps_subsystem_node() acu_node = CmdTreeNode("acu", "PCDU ACU component") @@ -128,7 +126,7 @@ class EiveHookObject(HookBase): xiphos_wdt = CmdTreeNode("wdt", "Xiphos WDT") core_ctrl = CmdTreeNode("core", "Core Controller") obdh_node.add_child(xiphos_wdt) - obdh_node.add_child(core_ctrl) + obdh_node.add_child(create_core_node()) obdh_node.add_child(create_time_node()) obdh_node.add_child(create_persistent_tm_store_node()) diff --git a/eive_tmtc/tmtc/com/ccsds_handler.py b/eive_tmtc/tmtc/com/ccsds_handler.py index 5ddcc97..0e25134 100644 --- a/eive_tmtc/tmtc/com/ccsds_handler.py +++ b/eive_tmtc/tmtc/com/ccsds_handler.py @@ -8,6 +8,8 @@ import enum import struct +from tmtccmd.config import CmdTreeNode + from eive_tmtc.config.definitions import CustomServiceList from spacepackets.ecss.tc import PusTelecommand from tmtccmd.config.tmtc import ( @@ -51,11 +53,11 @@ class Submode(enum.IntEnum): class OpCode: - ENABLE_WITH_LOW_DATARATE = ["enable_low_datarate"] - ENABLE_WITH_HIGH_DATARATE = ["enable_high_datarate"] - DISABLE = ["disable"] - ENABLE_ACTION = ["legacy_enable_tx"] - DISABLE_ACTION = ["legacy_disable_tx"] + ENABLE_WITH_LOW_DATARATE = "enable_low_datarate" + ENABLE_WITH_HIGH_DATARATE = "enable_high_datarate" + DISABLE = "disable" + ENABLE_ACTION = "legacy_enable_tx" + DISABLE_ACTION = "legacy_disable_tx" class Info: @@ -116,6 +118,19 @@ def pack_ccsds_handler_command( # noqa C901 q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) + +def create_ccsds_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("ccsds", "CCSDS Handler", hide_children_for_print=True) + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node + + @tmtc_definitions_provider def add_ccsds_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/com/syrlinks_handler.py b/eive_tmtc/tmtc/com/syrlinks_handler.py index 8a1fada..800c89d 100644 --- a/eive_tmtc/tmtc/com/syrlinks_handler.py +++ b/eive_tmtc/tmtc/com/syrlinks_handler.py @@ -9,6 +9,8 @@ import enum import logging import math +from tmtccmd.config import CmdTreeNode + from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.tmtc.com.defs import Mode as ComMode from eive_tmtc.config.definitions import CustomServiceList @@ -57,6 +59,7 @@ class OpCode: HK_TX_REGS = "hk_tx_regs" TX_STATUS = "tx_status" RX_STATUS = "rx_status" + SET_CW = "tx_cw" class Info: @@ -102,6 +105,18 @@ class Datarate(enum.IntEnum): HIGH_RATE_MODULATION_0QPSK = 1 +def create_syrlinks_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("syrlinks", "Syrlinks Device", hide_children_for_print=True) + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node + + @tmtc_definitions_provider def add_syrlinks_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/core.py b/eive_tmtc/tmtc/core.py index d7b4170..988e568 100644 --- a/eive_tmtc/tmtc/core.py +++ b/eive_tmtc/tmtc/core.py @@ -9,7 +9,7 @@ from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.config.definitions import CustomServiceList from spacepackets.ecss import PusTelecommand -from tmtccmd.config import TmtcDefinitionWrapper +from tmtccmd.config import CmdTreeNode, TmtcDefinitionWrapper from tmtccmd.tmtc import DefaultPusQueueHelper from tmtccmd.pus.s8_fsfw_action import create_action_cmd @@ -90,20 +90,20 @@ class OpCode: RM_HELPER = "rm_helper" MKDIR_HELPER = "mkdir_helper" SET_PREF_SD = "set_pref_sd" - REBOOT_XSC = ["reboot_xsc"] - XSC_REBOOT_SELF = ["reboot_self"] - XSC_REBOOT_0_0 = ["reboot_00"] - XSC_REBOOT_0_1 = ["reboot_01"] - XSC_REBOOT_1_0 = ["reboot_10"] - XSC_REBOOT_1_1 = ["reboot_11"] - REBOOT_FULL = ["reboot_regular"] - GET_HK = ["get_hk"] - OBSW_UPDATE_FROM_SD_0 = ["obsw_update_sd0"] - OBSW_UPDATE_FROM_SD_1 = ["obsw_update_sd1"] - OBSW_UPDATE_FROM_TMP = ["obsw_update_tmp"] - SWITCH_TO_SD_0 = ["switch_to_sd_0"] - SWITCH_TO_SD_1 = ["switch_to_sd_1"] - SWITCH_TO_BOTH_SD_CARDS = ["switch_to_both_sd_cards"] + REBOOT_XSC = "reboot_xsc" + XSC_REBOOT_SELF = "reboot_self" + XSC_REBOOT_0_0 = "reboot_00" + XSC_REBOOT_0_1 = "reboot_01" + XSC_REBOOT_1_0 = "reboot_10" + XSC_REBOOT_1_1 = "reboot_11" + REBOOT_FULL = "reboot_regular" + GET_HK = "get_hk" + OBSW_UPDATE_FROM_SD_0 = "obsw_update_sd0" + OBSW_UPDATE_FROM_SD_1 = "obsw_update_sd1" + OBSW_UPDATE_FROM_TMP = "obsw_update_tmp" + SWITCH_TO_SD_0 = "switch_to_sd_0" + SWITCH_TO_SD_1 = "switch_to_sd_1" + SWITCH_TO_BOTH_SD_CARDS = "switch_to_both_sd_cards" READ_REBOOT_MECHANISM_INFO = "rbh_info" ENABLE_REBOOT_FILE_HANDLING = "rwd_on" DISABLE_REBOOT_FILE_HANDLING = "rwd_off" @@ -127,6 +127,11 @@ class Info: SET_PREF_SD = "Set preferred SD card" REBOOT_XSC = "XSC reboot with prompt" REBOOT_FULL = "Full regular reboot" + XSC_REBOOT_SELF = "Reboot Self" + XSC_REBOOT_0_0 = "Reboot to 0 0" + XSC_REBOOT_0_1 = "Reboot to 0 1" + XSC_REBOOT_1_0 = "Reboot to 1 0" + XSC_REBOOT_1_1 = "Reboot to 1 1" OBSW_UPDATE_FROM_SD_0 = "Update OBSW from SD Card 0" OBSW_UPDATE_FROM_SD_1 = "Update OBSW from SD Card 1" OBSW_UPDATE_FROM_TMP = "Update OBSW from tmp folder" @@ -140,8 +145,17 @@ class Info: MV_HELPER = "Filesystem Move Helper" RM_HELPER = "Filesystem Removal Helper" MKDIR_HELPER = "Filesystem Directory Creation Helper" + ENABLE_REBOOT_FILE_HANDLING = "Enable reboot file handling" + DISABLE_REBOOT_FILE_HANDLING = "Disable reboot file handling" + RESET_ALL_REBOOT_COUNTERS = "Reset all reboot counters" + RWD_RESET_REBOOT_COUNTER_00 = "Reset reboot counter 0 0" + RWD_RESET_REBOOT_COUNTER_01 = "Reset reboot counter 0 0" + RWD_RESET_REBOOT_COUNTER_10 = "Reset reboot counter 1 0" + RWD_RESET_REBOOT_COUNTER_11 = "Reset reboot counter 1 1" + RWD_SET_MAX_REBOOT_CNT = "rwd_max_cnt" AUTO_SWITCH_ENABLE = "Enable Auto-Switch Feature with a specific target image" AUTO_SWITCH_DISABLE = "Disable Auto-Switch Feature" + GET_HK = "get_hk" class Chip(enum.IntEnum): @@ -162,6 +176,17 @@ class SystemctlCmd(enum.IntEnum): RESTART = 2 +def create_core_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("core", "Core Controller", hide_children_for_print=True) + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node + @tmtc_definitions_provider def add_core_controller_definitions(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() @@ -260,7 +285,7 @@ def pack_core_commands( # noqa C901 q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_BOOT_COUNTS) ) - elif cmd_str in OpCode.REBOOT_XSC: + elif cmd_str == OpCode.REBOOT_XSC: reboot_self, chip_select, copy_select = determine_reboot_params() add_xsc_reboot_cmd( q=q, @@ -268,14 +293,14 @@ def pack_core_commands( # noqa C901 chip=chip_select, copy=copy_select, ) - elif cmd_str in OpCode.REBOOT_FULL: + elif cmd_str == OpCode.REBOOT_FULL: q.add_log_cmd(f"Core Command: {Info.REBOOT_FULL}") q.add_pus_tc( create_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionId.FULL_REBOOT ) ) - elif cmd_str in OpCode.XSC_REBOOT_SELF: + elif cmd_str == OpCode.XSC_REBOOT_SELF: add_xsc_reboot_cmd(q=q, reboot_self=True) elif cmd_str == OpCode.SYSTEMCTL_CMD_EXECUTOR: print("systemctl command types: ") @@ -304,22 +329,22 @@ def pack_core_commands( # noqa C901 user_data=custom_cmd.encode(), ) ) - elif cmd_str in OpCode.XSC_REBOOT_0_0: + elif cmd_str == OpCode.XSC_REBOOT_0_0: add_xsc_reboot_cmd( q=q, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_0_NOM ) - elif cmd_str in OpCode.XSC_REBOOT_0_1: + elif cmd_str == OpCode.XSC_REBOOT_0_1: add_xsc_reboot_cmd( q=q, reboot_self=False, chip=Chip.CHIP_0, copy=Copy.COPY_1_GOLD, ) - elif cmd_str in OpCode.XSC_REBOOT_1_0: + elif cmd_str == OpCode.XSC_REBOOT_1_0: add_xsc_reboot_cmd( q=q, reboot_self=False, chip=Chip.CHIP_1, copy=Copy.COPY_0_NOM ) - elif cmd_str in OpCode.XSC_REBOOT_1_1: + elif cmd_str == OpCode.XSC_REBOOT_1_1: add_xsc_reboot_cmd( q=q, reboot_self=False, @@ -381,16 +406,16 @@ def pack_core_commands( # noqa C901 user_data=bytes([max_count]), ) ) - elif cmd_str in OpCode.OBSW_UPDATE_FROM_SD_0: + elif cmd_str == OpCode.OBSW_UPDATE_FROM_SD_0: q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_0) q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_SD_0)) - elif cmd_str in OpCode.OBSW_UPDATE_FROM_SD_1: + elif cmd_str == OpCode.OBSW_UPDATE_FROM_SD_1: q.add_log_cmd(Info.OBSW_UPDATE_FROM_SD_1) q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_SD_1)) - elif cmd_str in OpCode.OBSW_UPDATE_FROM_TMP: + elif cmd_str == OpCode.OBSW_UPDATE_FROM_TMP: q.add_log_cmd(Info.OBSW_UPDATE_FROM_TMP) q.add_pus_tc(pack_obsw_update_cmd(ActionId.UPDATE_OBSW_FROM_TMP)) - elif cmd_str in OpCode.AUTO_SWITCH_ENABLE: + elif cmd_str == OpCode.AUTO_SWITCH_ENABLE: q.add_log_cmd(Info.AUTO_SWITCH_ENABLE) chip, copy = determine_chip_and_copy() user_data = bytes([chip, copy]) @@ -399,26 +424,26 @@ def pack_core_commands( # noqa C901 CORE_CONTROLLER_ID, ActionId.AUTO_SWITCH_ENABLE, user_data ) ) - elif cmd_str in OpCode.AUTO_SWITCH_DISABLE: + elif cmd_str == OpCode.AUTO_SWITCH_DISABLE: q.add_log_cmd(Info.AUTO_SWITCH_DISABLE) q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.AUTO_SWITCH_DISABLE) ) - elif cmd_str in OpCode.SWITCH_TO_SD_0: + elif cmd_str == OpCode.SWITCH_TO_SD_0: q.add_log_cmd(Info.SWITCH_TO_SD_0) q.add_pus_tc( create_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionId.SWITCH_TO_SD_0 ) ) - elif cmd_str in OpCode.SWITCH_TO_SD_1: + elif cmd_str == OpCode.SWITCH_TO_SD_1: q.add_log_cmd(Info.SWITCH_TO_SD_1) q.add_pus_tc( create_action_cmd( object_id=CORE_CONTROLLER_ID, action_id=ActionId.SWITCH_TO_SD_1 ) ) - elif cmd_str in OpCode.SWITCH_TO_BOTH_SD_CARDS: + elif cmd_str == OpCode.SWITCH_TO_BOTH_SD_CARDS: while True: active_sd_card = int(input("Please specify active SD card [0/1]: ")) if active_sd_card not in [0, 1]: @@ -432,11 +457,11 @@ def pack_core_commands( # noqa C901 user_data=bytes([active_sd_card]), ) ) - elif cmd_str in OpCode.GET_HK: + elif cmd_str == OpCode.GET_HK: q.add_log_cmd("Requesting housekeeping set") sid = make_sid(object_id=CORE_CONTROLLER_ID, set_id=SetId.HK) q.add_pus_tc(generate_one_hk_command(sid)) - elif cmd_str in OpCode.SET_PREF_SD: + elif cmd_str == OpCode.SET_PREF_SD: q.add_log_cmd("Set preferred SD card") pref_sd = int( input("Specify which SD card to set as the preferred one (0/1): ") diff --git a/eive_tmtc/tmtc/payload/ploc_mpsoc.py b/eive_tmtc/tmtc/payload/ploc_mpsoc.py index ddb434b..0d509c6 100644 --- a/eive_tmtc/tmtc/payload/ploc_mpsoc.py +++ b/eive_tmtc/tmtc/payload/ploc_mpsoc.py @@ -151,12 +151,13 @@ def create_ploc_mpsoc_node() -> CmdTreeNode: ] info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] combined_dict = dict(zip(op_code_strs, info_strs)) - node = CmdTreeNode("ploc_mpsoc", "PLOC MPSoC") + node = CmdTreeNode("ploc_mpsoc", "PLOC MPSoC", hide_children_for_print=True) for op_code, info in combined_dict.items(): node.add_child(CmdTreeNode(op_code, info)) return node +# Legacy command definitions. @tmtc_definitions_provider def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index 3b39969..dec8459 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -178,7 +178,7 @@ def create_ploc_supv_node() -> CmdTreeNode: ] info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] combined_dict = dict(zip(op_code_strs, info_strs)) - node = CmdTreeNode("ploc_supv", "PLOC Supervisor") + node = CmdTreeNode("ploc_supv", "PLOC Supervisor", hide_children_for_print=True) for op_code, info in combined_dict.items(): node.add_child(CmdTreeNode(op_code, info)) return node diff --git a/eive_tmtc/tmtc/power/bpx_batt.py b/eive_tmtc/tmtc/power/bpx_batt.py index 155cc10..76ed79e 100644 --- a/eive_tmtc/tmtc/power/bpx_batt.py +++ b/eive_tmtc/tmtc/power/bpx_batt.py @@ -51,7 +51,7 @@ class BpxOpCode: def create_bpx_batt_node() -> CmdTreeNode: - node = CmdTreeNode("bat", "BPX battery device") + node = CmdTreeNode("bat", "BPX battery device", hide_children_for_print=True) node.add_child(CmdTreeNode(BpxOpCode.ON, "ON command")) node.add_child(CmdTreeNode(BpxOpCode.OFF, "OFF command")) node.add_child(CmdTreeNode(BpxOpCode.HK, "HK command")) diff --git a/eive_tmtc/tmtc/power/pwr_ctrl.py b/eive_tmtc/tmtc/power/pwr_ctrl.py index 4488491..c774a40 100644 --- a/eive_tmtc/tmtc/power/pwr_ctrl.py +++ b/eive_tmtc/tmtc/power/pwr_ctrl.py @@ -77,7 +77,7 @@ def create_pwr_ctrl_node() -> CmdTreeNode: ] info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] combined_dict = dict(zip(op_code_strs, info_strs)) - node = CmdTreeNode("pwr_ctrl", "Power Controller") + node = CmdTreeNode("pwr_ctrl", "Power Controller", hide_children_for_print=True) for op_code, info in combined_dict.items(): node.add_child(CmdTreeNode(op_code, info)) return node -- 2.43.0 From 21a38ae76a582f57d075400188907eec45eec58c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 18:39:12 +0100 Subject: [PATCH 14/42] use new the new leaf suppression feature --- eive_tmtc/config/hook.py | 3 +-- eive_tmtc/tmtc/acs/subsystem.py | 2 +- eive_tmtc/tmtc/com/ccsds_handler.py | 1 - eive_tmtc/tmtc/com/subsystem.py | 2 +- eive_tmtc/tmtc/core.py | 1 + 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index 658d2f3..b499a30 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -7,7 +7,7 @@ from tmtccmd.util import ObjectIdDictT, RetvalDictT from eive_tmtc.config.definitions import SPACE_PACKET_IDS from eive_tmtc.config.retvals import get_retval_dict -from eive_tmtc.tmtc.core import create_core_node +from eive_tmtc.tmtc.core import create_core_node from eive_tmtc.tmtc.acs.subsystem import create_acs_subsystem_node from eive_tmtc.tmtc.com.ccsds_handler import create_ccsds_node from eive_tmtc.tmtc.com.subsystem import create_com_subsystem_node @@ -124,7 +124,6 @@ class EiveHookObject(HookBase): obdh_node = CmdTreeNode("obdh", "OBDH Subsystem") xiphos_wdt = CmdTreeNode("wdt", "Xiphos WDT") - core_ctrl = CmdTreeNode("core", "Core Controller") obdh_node.add_child(xiphos_wdt) obdh_node.add_child(create_core_node()) obdh_node.add_child(create_time_node()) diff --git a/eive_tmtc/tmtc/acs/subsystem.py b/eive_tmtc/tmtc/acs/subsystem.py index f250344..b1a1c97 100644 --- a/eive_tmtc/tmtc/acs/subsystem.py +++ b/eive_tmtc/tmtc/acs/subsystem.py @@ -73,7 +73,7 @@ def build_acs_subsystem_cmd(q: DefaultPusQueueHelper, cmd_path: str): def create_acs_subsystem_node() -> CmdTreeNode: - node = CmdTreeNode("acs", "ACS Subsystem") + node = CmdTreeNode("acs", "ACS Subsystem", hide_children_which_are_leaves=True) for cmd_str, (_, _, info) in HANDLER_LIST.items(): node.add_child(CmdTreeNode(cmd_str, info)) node.add_child(CmdTreeNode(CmdStr.REPORT_ALL_MODES, Info.REPORT_ALL_MODES)) diff --git a/eive_tmtc/tmtc/com/ccsds_handler.py b/eive_tmtc/tmtc/com/ccsds_handler.py index 0e25134..4d59ee5 100644 --- a/eive_tmtc/tmtc/com/ccsds_handler.py +++ b/eive_tmtc/tmtc/com/ccsds_handler.py @@ -118,7 +118,6 @@ def pack_ccsds_handler_command( # noqa C901 q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - def create_ccsds_node() -> CmdTreeNode: op_code_strs = [ getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") diff --git a/eive_tmtc/tmtc/com/subsystem.py b/eive_tmtc/tmtc/com/subsystem.py index ba8c098..7e784a9 100644 --- a/eive_tmtc/tmtc/com/subsystem.py +++ b/eive_tmtc/tmtc/com/subsystem.py @@ -134,7 +134,7 @@ def create_com_subsystem_node() -> CmdTreeNode: ] info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] combined_dict = dict(zip(op_code_strs, info_strs)) - node = CmdTreeNode("com", "COM Subsystem") + node = CmdTreeNode("com", "COM Subsystem", hide_children_which_are_leaves=True) for op_code, info in combined_dict.items(): node.add_child(CmdTreeNode(op_code, info)) return node diff --git a/eive_tmtc/tmtc/core.py b/eive_tmtc/tmtc/core.py index 988e568..23a018f 100644 --- a/eive_tmtc/tmtc/core.py +++ b/eive_tmtc/tmtc/core.py @@ -187,6 +187,7 @@ def create_core_node() -> CmdTreeNode: node.add_child(CmdTreeNode(op_code, info)) return node + @tmtc_definitions_provider def add_core_controller_definitions(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() -- 2.43.0 From 688602e4862bf6bbf5574c9bbbb98556b6541e71 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 19:13:22 +0100 Subject: [PATCH 15/42] cleaning up --- .../{procedure_packer.py => cmd_demux.py} | 253 +++++++++++------- eive_tmtc/pus_tc/tc_handler.py | 4 +- 2 files changed, 151 insertions(+), 106 deletions(-) rename eive_tmtc/pus_tc/{procedure_packer.py => cmd_demux.py} (66%) diff --git a/eive_tmtc/pus_tc/procedure_packer.py b/eive_tmtc/pus_tc/cmd_demux.py similarity index 66% rename from eive_tmtc/pus_tc/procedure_packer.py rename to eive_tmtc/pus_tc/cmd_demux.py index 52e3daa..1d7d286 100644 --- a/eive_tmtc/pus_tc/procedure_packer.py +++ b/eive_tmtc/pus_tc/cmd_demux.py @@ -1,7 +1,7 @@ """Hook function which packs telecommands based on service and operation code string """ import logging -from typing import cast +from typing import cast, List from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd @@ -70,53 +70,48 @@ from tmtccmd.util import ObjectIdU32 from eive_tmtc.utility.input_helper import InputHelper -def handle_default_procedure( # noqa C901: Complexity okay here. - info: DefaultProcedureInfo, - queue_helper: DefaultPusQueueHelper, -): - cmd_path = info.cmd_path - assert cmd_path is not None - cmd_path_list = cmd_path.split("/") - if cmd_path_list[0] == "/": - cmd_path_list = cmd_path_list[1:] - if len(cmd_path_list) == 0: - raise ValueError( - "command path list empty. Full command path {cmd_path} might have invalid format" - ) +def handle_eps_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): obj_id_man = get_object_ids() - if cmd_path_list == ["eps", "p60_dock"]: + assert len(cmd_path_list) >= 1 + if cmd_path_list[1] == "p60_dock": object_id = cast(ObjectIdU32, obj_id_man.get(P60_DOCK_HANDLER)) assert len(cmd_path_list) >= 2 return pack_p60dock_cmds( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list == ["tcs", "rtd_devs"]: - assert len(cmd_path_list) >= 2 - return pack_rtd_commands( - object_id=None, q=queue_helper, cmd_str=cmd_path_list[2] - ) - if cmd_path_list == ["eps", "pdu1"]: + if cmd_path_list[1] == "pdu1": object_id = cast(ObjectIdU32, obj_id_man.get(PDU_1_HANDLER_ID)) return pack_pdu1_commands( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list == ["eps", "pdu2"]: + if cmd_path_list[1] == "pdu2": object_id = cast(ObjectIdU32, obj_id_man.get(PDU_2_HANDLER_ID)) return pack_pdu2_commands( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list == ["eps", "acu"]: + if cmd_path_list[1] == "acu": object_id = cast(ObjectIdU32, obj_id_man.get(ACU_HANDLER_ID)) return pack_acu_commands( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list == ["tcs"]: - assert len(cmd_path_list) >= 1 - return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[1]) - if cmd_path_list == ["tcs", "tcs_ctrl"]: + assert len(cmd_path_list) >= 2 + return pack_power_commands(queue_helper, cmd_path_list[1]) + + +def handle_tcs_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): + obj_id_man = get_object_ids() + if cmd_path_list[1] == "tcs_brd_assy": + assert len(cmd_path_list) >= 3 + return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list[1] == "rtd_devs": + assert len(cmd_path_list) >= 2 + return pack_rtd_commands( + object_id=None, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list[1] == "tcs_ctrl": assert len(cmd_path_list) >= 2 return pack_tcs_ctrl_commands(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list == ["tcs", "tmp1075_devs"]: + if cmd_path_list[1] == "tmp1075_devs": menu_dict = { "0": ("TMP1075 TCS Board 0", TMP1075_HANDLER_TCS_BRD_0_ID), "1": ("TMP1075 TCS Board 1", TMP1075_HANDLER_TCS_BRD_1_ID), @@ -132,113 +127,163 @@ def handle_default_procedure( # noqa C901: Complexity okay here. return pack_tmp1075_test_into( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list == ["tcs", "heaters"]: + if cmd_path_list[1] == "heaters": object_id = HEATER_CONTROLLER_ID return pack_heater_cmds( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list == ["acs", "mgt"]: + return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[1]) + + +def handle_acs_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): + obj_id_man = get_object_ids() + assert len(cmd_path_list) >= 2 + if cmd_path_list[1] == "mgt": object_id = cast(ObjectIdU32, obj_id_man.get(IMTQ_HANDLER_ID)) return create_imtq_command( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list == ["acs", "rw_assy", "rw_1"]: - assert len(cmd_path_list) >= 4 - return create_single_rw_cmd( - object_id=RW1_ID, rw_idx=1, q=queue_helper, cmd_str=cmd_path_list[3] - ) - if cmd_path_list == ["acs", "rw_assy", "rw_2"]: - assert len(cmd_path_list) >= 4 - return create_single_rw_cmd( - object_id=RW2_ID, rw_idx=2, q=queue_helper, cmd_str=cmd_path_list[3] - ) - if cmd_path_list == ["acs", "rw_assy", "rw_3"]: - return create_single_rw_cmd( - object_id=RW3_ID, rw_idx=3, q=queue_helper, cmd_str=cmd_path_list[3] - ) - if cmd_path_list == ["acs", "rw_assy", "rw_4"]: - return create_single_rw_cmd( - object_id=RW4_ID, rw_idx=4, q=queue_helper, cmd_str=cmd_path_list[3] - ) - if cmd_path_list == ["acs", "acs_brd_assy", "mgm_devs"]: - assert len(cmd_path_list) >= 4 - return handle_mgm_cmd(q=queue_helper, cmd_str=cmd_path_list[3]) - if cmd_path_list == ["payload", "rad_sensor"]: - assert len(cmd_path_list) >= 3 - object_id = cast(ObjectIdU32, obj_id_man.get(RAD_SENSOR_ID)) - return create_rad_sensor_cmd( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] - ) - if cmd_path_list == ["acs", "str"]: + if cmd_path_list[1] == "str": object_id = cast(ObjectIdU32, obj_id_man.get(STAR_TRACKER_ID)) assert len(cmd_path_list) >= 3 return pack_star_tracker_commands( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list == ["acs", "str_img_helper"]: + + if cmd_path_list[1] == "rws": + assert len(cmd_path_list) >= 3 + if cmd_path_list[2] == "rw_assy": + assert len(cmd_path_list) >= 4 + return pack_rw_ass_cmds( + q=queue_helper, object_id=RW_ASSEMBLY, cmd_str=cmd_path_list[3] + ) + if cmd_path_list[2] == "rw_1": + assert len(cmd_path_list) >= 4 + return create_single_rw_cmd( + object_id=RW1_ID, rw_idx=1, q=queue_helper, cmd_str=cmd_path_list[3] + ) + if cmd_path_list[2] == "rw_2": + assert len(cmd_path_list) >= 4 + return create_single_rw_cmd( + object_id=RW2_ID, rw_idx=2, q=queue_helper, cmd_str=cmd_path_list[3] + ) + if cmd_path_list[2] == "rw_3": + assert len(cmd_path_list) >= 4 + return create_single_rw_cmd( + object_id=RW3_ID, rw_idx=3, q=queue_helper, cmd_str=cmd_path_list[3] + ) + if cmd_path_list[2] == "rw_4": + assert len(cmd_path_list) >= 4 + return create_single_rw_cmd( + object_id=RW4_ID, rw_idx=4, q=queue_helper, cmd_str=cmd_path_list[3] + ) + + if cmd_path_list[1] == "gnss_devs": + assert len(cmd_path_list) >= 3 + return pack_gps_command( + object_id=oids.GPS_CONTROLLER, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list[1:] == ["acs_brd_assy", "mgm_devs"]: + assert len(cmd_path_list) >= 4 + return handle_mgm_cmd(q=queue_helper, cmd_str=cmd_path_list[3]) + if cmd_path_list[1] == "str_img_helper": assert len(cmd_path_list) >= 3 object_id = cast(ObjectIdU32, obj_id_man.get(STR_IMG_HELPER_ID)) return pack_str_img_helper_command( object_id=object_id, q=queue_helper, op_code=cmd_path_list[2] ) - if cmd_path_list == ["acs", "acs_ctrl"]: + if cmd_path_list[1] == "acs_ctrl": assert len(cmd_path_list) >= 3 return pack_acs_ctrl_command(queue_helper, cmd_path_list[2]) - if cmd_path_list == ["obdh", "core"]: - assert len(cmd_path_list) >= 3 - return pack_core_commands(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list == ["eps"]: - assert len(cmd_path_list) >= 2 - return pack_power_commands(queue_helper, cmd_path_list[2]) - if cmd_path_list == ["acs"]: - assert len(cmd_path_list) >= 2 - return pack_acs_command(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list == ["acs", "gnss_devs"]: - assert len(cmd_path_list) >= 3 - return pack_gps_command( - object_id=oids.GPS_CONTROLLER, q=queue_helper, cmd_str=cmd_path_list[2] - ) - if cmd_path_list == ["com", "ccsds"]: - object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID)) - assert len(cmd_path_list) >= 3 - return pack_ccsds_handler_command( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] - ) - if cmd_path_list == ["com", "pdec"]: - assert len(cmd_path_list) >= 3 - return pack_pdec_handler_commands( - object_id=PDEC_HANDLER_ID, q=queue_helper, cmd_str=cmd_path_list[2] - ) - if cmd_path_list == ["com", "syrlinks"]: - object_id = cast(ObjectIdU32, obj_id_man.get(SYRLINKS_HANDLER_ID)) - assert len(cmd_path_list) >= 3 - return pack_syrlinks_command( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] - ) - if cmd_path_list == ["acs", "gyro_devs"]: + if cmd_path_list[1] == "gyro_devs": assert len(cmd_path_list) >= 3 return handle_gyr_cmd(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list == ["payload", "pl_pcdu"]: + return pack_acs_command(q=queue_helper, cmd_str=cmd_path_list[2]) + + +def handle_payload_procedure( + queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str] +): + obj_id_man = get_object_ids() + assert len(cmd_path_list) >= 2 + if cmd_path_list == "rad_sensor": + assert len(cmd_path_list) >= 3 + object_id = cast(ObjectIdU32, obj_id_man.get(RAD_SENSOR_ID)) + return create_rad_sensor_cmd( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list[1] == "pl_pcdu": assert len(cmd_path_list) >= 3 return pack_pl_pcdu_commands(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list == ["tcs", "tcs_brd_assy"]: - assert len(cmd_path_list) >= 3 - return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list == ["acs", "rws", "rw_assy"]: - assert len(cmd_path_list) >= 4 - return pack_rw_ass_cmds( - q=queue_helper, object_id=RW_ASSEMBLY, cmd_str=cmd_path_list[3] - ) - if cmd_path_list == ["payload", "scex"]: + if cmd_path_list[1] == "scex": assert len(cmd_path_list) >= 3 return pack_scex_cmds( cmd_str=cmd_path_list[2], q=queue_helper, ) - if cmd_path_list == ["core", "xiphos_wdt"]: + + +def handle_obdh_procedure( + queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str] +): + assert len(cmd_path_list) >= 2 + if cmd_path_list[1] == "core": + assert len(cmd_path_list) >= 3 + return pack_core_commands(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list[1] == "xiphos_wdt": return pack_wdt_commands(queue_helper, cmd_path_list[2]) - if "time" in cmd_path_list: + if cmd_path_list[1] == "time": return pack_time_management_cmd(queue_helper, cmd_path_list[1]) + + +def handle_com_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): + obj_id_man = get_object_ids() + assert len(cmd_path_list) >= 2 + + if cmd_path_list[1] == "ccsds": + object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID)) + assert len(cmd_path_list) >= 3 + return pack_ccsds_handler_command( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list[1] == "pdec": + assert len(cmd_path_list) >= 3 + return pack_pdec_handler_commands( + object_id=PDEC_HANDLER_ID, q=queue_helper, cmd_str=cmd_path_list[2] + ) + if cmd_path_list[1] == "syrlinks": + object_id = cast(ObjectIdU32, obj_id_man.get(SYRLINKS_HANDLER_ID)) + assert len(cmd_path_list) >= 3 + return pack_syrlinks_command( + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + ) + + +def handle_default_procedure( # noqa C901: Complexity okay here. + info: DefaultProcedureInfo, + queue_helper: DefaultPusQueueHelper, +): + cmd_path = info.cmd_path + assert cmd_path is not None + cmd_path_list = cmd_path.split("/") + if cmd_path_list[0] == "/": + cmd_path_list = cmd_path_list[1:] + if len(cmd_path_list) == 0: + raise ValueError( + "command path list empty. Full command path {cmd_path} might have invalid format" + ) + if cmd_path_list[0] == "eps": + return handle_eps_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "tcs": + return handle_tcs_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "acs": + return handle_acs_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "payload": + return handle_payload_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "obdh": + return handle_obdh_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "com": + return handle_com_procedure(queue_helper, cmd_path_list[1:]) logging.getLogger(__name__).warning( f"invalid or unimplemented command path {cmd_path}" ) diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index 85dbf42..371c7fb 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -6,7 +6,7 @@ from eive_tmtc.config.definitions import ( PUS_APID, CFDP_LOCAL_ENTITY_ID, ) -from eive_tmtc.pus_tc.procedure_packer import handle_default_procedure +from eive_tmtc.pus_tc.cmd_demux import handle_default_procedure from eive_tmtc.cfdp.handler import CfdpInCcsdsHandler from tmtccmd import TcHandlerBase, ProcedureWrapper from tmtccmd.cfdp.defs import CfdpRequestType @@ -69,7 +69,7 @@ class TcHandler(TcHandlerBase): def feed_cb(self, info: ProcedureWrapper, wrapper: FeedWrapper): self.queue_helper.queue_wrapper = wrapper.queue_wrapper if info.proc_type == TcProcedureType.DEFAULT: - handle_default_procedure(self, info.to_def_procedure(), self.queue_helper) + handle_default_procedure(info.to_def_procedure(), self.queue_helper) elif info.proc_type == TcProcedureType.CFDP: self.handle_cfdp_procedure(info) -- 2.43.0 From f756df43a24f77db1badfb52de6174cb8f256848 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 19:22:51 +0100 Subject: [PATCH 16/42] last tests --- eive_tmtc/pus_tc/cmd_demux.py | 64 ++++++++++++++++++---------------- eive_tmtc/pus_tc/tc_handler.py | 4 +-- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/eive_tmtc/pus_tc/cmd_demux.py b/eive_tmtc/pus_tc/cmd_demux.py index 1d7d286..81b8213 100644 --- a/eive_tmtc/pus_tc/cmd_demux.py +++ b/eive_tmtc/pus_tc/cmd_demux.py @@ -6,6 +6,7 @@ from typing import cast, List from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd from eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command +from eive_tmtc.tmtc.test import pack_test_command from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd from eive_tmtc.tmtc.power.power import pack_power_commands from eive_tmtc.tmtc.tcs.ctrl import pack_tcs_ctrl_commands @@ -70,6 +71,39 @@ from tmtccmd.util import ObjectIdU32 from eive_tmtc.utility.input_helper import InputHelper +def handle_pus_procedure( # noqa C901: Complexity okay here. + info: DefaultProcedureInfo, + queue_helper: DefaultPusQueueHelper, +): + cmd_path = info.cmd_path + assert cmd_path is not None + cmd_path_list = cmd_path.split("/") + if cmd_path_list[0] == "/": + cmd_path_list = cmd_path_list[1:] + if len(cmd_path_list) == 0: + raise ValueError( + "command path list empty. Full command path {cmd_path} might have invalid format" + ) + if cmd_path_list[0] == "eps": + return handle_eps_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "tcs": + return handle_tcs_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "acs": + return handle_acs_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "payload": + return handle_payload_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "obdh": + return handle_obdh_procedure(queue_helper, cmd_path_list[1:]) + if cmd_path_list[0] == "test": + assert len(cmd_path_list) >= 1 + return pack_test_command(queue_helper, cmd_path_list[1]) + if cmd_path_list[0] == "com": + return handle_com_procedure(queue_helper, cmd_path_list[1:]) + logging.getLogger(__name__).warning( + f"invalid or unimplemented command path {cmd_path}" + ) + + def handle_eps_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): obj_id_man = get_object_ids() assert len(cmd_path_list) >= 1 @@ -257,33 +291,3 @@ def handle_com_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: Lis return pack_syrlinks_command( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - - -def handle_default_procedure( # noqa C901: Complexity okay here. - info: DefaultProcedureInfo, - queue_helper: DefaultPusQueueHelper, -): - cmd_path = info.cmd_path - assert cmd_path is not None - cmd_path_list = cmd_path.split("/") - if cmd_path_list[0] == "/": - cmd_path_list = cmd_path_list[1:] - if len(cmd_path_list) == 0: - raise ValueError( - "command path list empty. Full command path {cmd_path} might have invalid format" - ) - if cmd_path_list[0] == "eps": - return handle_eps_procedure(queue_helper, cmd_path_list[1:]) - if cmd_path_list[0] == "tcs": - return handle_tcs_procedure(queue_helper, cmd_path_list[1:]) - if cmd_path_list[0] == "acs": - return handle_acs_procedure(queue_helper, cmd_path_list[1:]) - if cmd_path_list[0] == "payload": - return handle_payload_procedure(queue_helper, cmd_path_list[1:]) - if cmd_path_list[0] == "obdh": - return handle_obdh_procedure(queue_helper, cmd_path_list[1:]) - if cmd_path_list[0] == "com": - return handle_com_procedure(queue_helper, cmd_path_list[1:]) - logging.getLogger(__name__).warning( - f"invalid or unimplemented command path {cmd_path}" - ) diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index 371c7fb..68fad09 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -6,7 +6,7 @@ from eive_tmtc.config.definitions import ( PUS_APID, CFDP_LOCAL_ENTITY_ID, ) -from eive_tmtc.pus_tc.cmd_demux import handle_default_procedure +from eive_tmtc.pus_tc.cmd_demux import handle_pus_procedure from eive_tmtc.cfdp.handler import CfdpInCcsdsHandler from tmtccmd import TcHandlerBase, ProcedureWrapper from tmtccmd.cfdp.defs import CfdpRequestType @@ -69,7 +69,7 @@ class TcHandler(TcHandlerBase): def feed_cb(self, info: ProcedureWrapper, wrapper: FeedWrapper): self.queue_helper.queue_wrapper = wrapper.queue_wrapper if info.proc_type == TcProcedureType.DEFAULT: - handle_default_procedure(info.to_def_procedure(), self.queue_helper) + handle_pus_procedure(info.to_def_procedure(), self.queue_helper) elif info.proc_type == TcProcedureType.CFDP: self.handle_cfdp_procedure(info) -- 2.43.0 From 2bb917eab7474988b43934683d304cf5ff79e021 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 19:25:04 +0100 Subject: [PATCH 17/42] last bugfixes --- eive_tmtc/pus_tc/cmd_demux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eive_tmtc/pus_tc/cmd_demux.py b/eive_tmtc/pus_tc/cmd_demux.py index 81b8213..7e45679 100644 --- a/eive_tmtc/pus_tc/cmd_demux.py +++ b/eive_tmtc/pus_tc/cmd_demux.py @@ -78,7 +78,7 @@ def handle_pus_procedure( # noqa C901: Complexity okay here. cmd_path = info.cmd_path assert cmd_path is not None cmd_path_list = cmd_path.split("/") - if cmd_path_list[0] == "/": + if cmd_path_list[0] == "": cmd_path_list = cmd_path_list[1:] if len(cmd_path_list) == 0: raise ValueError( -- 2.43.0 From 756944cae373f11587482ac3b7fbdf009e05412c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 19:38:04 +0100 Subject: [PATCH 18/42] that should be it --- eive_tmtc/pus_tc/cmd_demux.py | 135 ++++++++++++++++---------------- eive_tmtc/tmtc/com/subsystem.py | 8 +- 2 files changed, 70 insertions(+), 73 deletions(-) diff --git a/eive_tmtc/pus_tc/cmd_demux.py b/eive_tmtc/pus_tc/cmd_demux.py index 7e45679..ec87f79 100644 --- a/eive_tmtc/pus_tc/cmd_demux.py +++ b/eive_tmtc/pus_tc/cmd_demux.py @@ -6,6 +6,7 @@ from typing import cast, List from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd from eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command +from eive_tmtc.tmtc.com.subsystem import build_com_subsystem_procedure from eive_tmtc.tmtc.test import pack_test_command from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd from eive_tmtc.tmtc.power.power import pack_power_commands @@ -106,46 +107,48 @@ def handle_pus_procedure( # noqa C901: Complexity okay here. def handle_eps_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): obj_id_man = get_object_ids() - assert len(cmd_path_list) >= 1 - if cmd_path_list[1] == "p60_dock": + if len(cmd_path_list) == 1: + return pack_power_commands(queue_helper, cmd_path_list[0]) + assert len(cmd_path_list) >= 2 + if cmd_path_list[0] == "p60_dock": object_id = cast(ObjectIdU32, obj_id_man.get(P60_DOCK_HANDLER)) assert len(cmd_path_list) >= 2 return pack_p60dock_cmds( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) - if cmd_path_list[1] == "pdu1": + if cmd_path_list[0] == "pdu1": object_id = cast(ObjectIdU32, obj_id_man.get(PDU_1_HANDLER_ID)) return pack_pdu1_commands( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) - if cmd_path_list[1] == "pdu2": + if cmd_path_list[0] == "pdu2": object_id = cast(ObjectIdU32, obj_id_man.get(PDU_2_HANDLER_ID)) return pack_pdu2_commands( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) - if cmd_path_list[1] == "acu": + if cmd_path_list[0] == "acu": object_id = cast(ObjectIdU32, obj_id_man.get(ACU_HANDLER_ID)) return pack_acu_commands( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) - assert len(cmd_path_list) >= 2 - return pack_power_commands(queue_helper, cmd_path_list[1]) def handle_tcs_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): obj_id_man = get_object_ids() - if cmd_path_list[1] == "tcs_brd_assy": - assert len(cmd_path_list) >= 3 - return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list[1] == "rtd_devs": + if len(cmd_path_list) == 1: + return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[0]) + assert len(cmd_path_list) >= 2 + if cmd_path_list[0] == "tcs_brd_assy": + return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[1]) + if cmd_path_list[0] == "rtd_devs": assert len(cmd_path_list) >= 2 return pack_rtd_commands( - object_id=None, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=None, q=queue_helper, cmd_str=cmd_path_list[1] ) - if cmd_path_list[1] == "tcs_ctrl": + if cmd_path_list[0] == "tcs_ctrl": assert len(cmd_path_list) >= 2 return pack_tcs_ctrl_commands(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list[1] == "tmp1075_devs": + if cmd_path_list[0] == "tmp1075_devs": menu_dict = { "0": ("TMP1075 TCS Board 0", TMP1075_HANDLER_TCS_BRD_0_ID), "1": ("TMP1075 TCS Board 1", TMP1075_HANDLER_TCS_BRD_1_ID), @@ -159,80 +162,77 @@ def handle_tcs_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: Lis object_id = obj_id_man.get(menu_dict[tmp_select][1]) assert object_id is not None return pack_tmp1075_test_into( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) - if cmd_path_list[1] == "heaters": + if cmd_path_list[0] == "heaters": object_id = HEATER_CONTROLLER_ID return pack_heater_cmds( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) - return pack_tcs_sys_commands(q=queue_helper, cmd_str=cmd_path_list[1]) def handle_acs_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): obj_id_man = get_object_ids() + if len(cmd_path_list) == 1: + return pack_acs_command(q=queue_helper, cmd_str=cmd_path_list[0]) assert len(cmd_path_list) >= 2 - if cmd_path_list[1] == "mgt": + if cmd_path_list[0] == "mgt": object_id = cast(ObjectIdU32, obj_id_man.get(IMTQ_HANDLER_ID)) return create_imtq_command( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) - if cmd_path_list[1] == "str": + if cmd_path_list[0] == "str": object_id = cast(ObjectIdU32, obj_id_man.get(STAR_TRACKER_ID)) - assert len(cmd_path_list) >= 3 return pack_star_tracker_commands( - object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) - if cmd_path_list[1] == "rws": + if cmd_path_list[0] == "rws": assert len(cmd_path_list) >= 3 - if cmd_path_list[2] == "rw_assy": + if cmd_path_list[1] == "rw_assy": assert len(cmd_path_list) >= 4 return pack_rw_ass_cmds( - q=queue_helper, object_id=RW_ASSEMBLY, cmd_str=cmd_path_list[3] + q=queue_helper, object_id=RW_ASSEMBLY, cmd_str=cmd_path_list[2] ) - if cmd_path_list[2] == "rw_1": + if cmd_path_list[1] == "rw_1": assert len(cmd_path_list) >= 4 return create_single_rw_cmd( - object_id=RW1_ID, rw_idx=1, q=queue_helper, cmd_str=cmd_path_list[3] + object_id=RW1_ID, rw_idx=1, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list[2] == "rw_2": + if cmd_path_list[1] == "rw_2": assert len(cmd_path_list) >= 4 return create_single_rw_cmd( - object_id=RW2_ID, rw_idx=2, q=queue_helper, cmd_str=cmd_path_list[3] + object_id=RW2_ID, rw_idx=2, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list[2] == "rw_3": + if cmd_path_list[1] == "rw_3": assert len(cmd_path_list) >= 4 return create_single_rw_cmd( - object_id=RW3_ID, rw_idx=3, q=queue_helper, cmd_str=cmd_path_list[3] + object_id=RW3_ID, rw_idx=3, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list[2] == "rw_4": + if cmd_path_list[1] == "rw_4": assert len(cmd_path_list) >= 4 return create_single_rw_cmd( - object_id=RW4_ID, rw_idx=4, q=queue_helper, cmd_str=cmd_path_list[3] + object_id=RW4_ID, rw_idx=4, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list[1] == "gnss_devs": - assert len(cmd_path_list) >= 3 + if cmd_path_list[0] == "gnss_devs": return pack_gps_command( - object_id=oids.GPS_CONTROLLER, q=queue_helper, cmd_str=cmd_path_list[2] + object_id=oids.GPS_CONTROLLER, q=queue_helper, cmd_str=cmd_path_list[1] ) - if cmd_path_list[1:] == ["acs_brd_assy", "mgm_devs"]: - assert len(cmd_path_list) >= 4 - return handle_mgm_cmd(q=queue_helper, cmd_str=cmd_path_list[3]) - if cmd_path_list[1] == "str_img_helper": + if cmd_path_list[0] == "acs_brd_assy": assert len(cmd_path_list) >= 3 + if cmd_path_list[1] == "mgm_devs": + return handle_mgm_cmd(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list[1] == "gyro_devs": + assert len(cmd_path_list) >= 3 + return handle_gyr_cmd(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list[0] == "str_img_helper": object_id = cast(ObjectIdU32, obj_id_man.get(STR_IMG_HELPER_ID)) return pack_str_img_helper_command( - object_id=object_id, q=queue_helper, op_code=cmd_path_list[2] + object_id=object_id, q=queue_helper, op_code=cmd_path_list[1] ) - if cmd_path_list[1] == "acs_ctrl": - assert len(cmd_path_list) >= 3 - return pack_acs_ctrl_command(queue_helper, cmd_path_list[2]) - if cmd_path_list[1] == "gyro_devs": - assert len(cmd_path_list) >= 3 - return handle_gyr_cmd(q=queue_helper, cmd_str=cmd_path_list[2]) - return pack_acs_command(q=queue_helper, cmd_str=cmd_path_list[2]) + if cmd_path_list[0] == "acs_ctrl": + return pack_acs_ctrl_command(queue_helper, cmd_path_list[1]) def handle_payload_procedure( @@ -240,16 +240,16 @@ def handle_payload_procedure( ): obj_id_man = get_object_ids() assert len(cmd_path_list) >= 2 - if cmd_path_list == "rad_sensor": + if cmd_path_list[0] == "rad_sensor": assert len(cmd_path_list) >= 3 object_id = cast(ObjectIdU32, obj_id_man.get(RAD_SENSOR_ID)) return create_rad_sensor_cmd( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list[1] == "pl_pcdu": + if cmd_path_list[0] == "pl_pcdu": assert len(cmd_path_list) >= 3 return pack_pl_pcdu_commands(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list[1] == "scex": + if cmd_path_list[0] == "scex": assert len(cmd_path_list) >= 3 return pack_scex_cmds( cmd_str=cmd_path_list[2], @@ -261,33 +261,30 @@ def handle_obdh_procedure( queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str] ): assert len(cmd_path_list) >= 2 - if cmd_path_list[1] == "core": - assert len(cmd_path_list) >= 3 - return pack_core_commands(q=queue_helper, cmd_str=cmd_path_list[2]) - if cmd_path_list[1] == "xiphos_wdt": - return pack_wdt_commands(queue_helper, cmd_path_list[2]) - if cmd_path_list[1] == "time": + if cmd_path_list[0] == "core": + return pack_core_commands(q=queue_helper, cmd_str=cmd_path_list[1]) + if cmd_path_list[0] == "xiphos_wdt": + return pack_wdt_commands(queue_helper, cmd_path_list[1]) + if cmd_path_list[0] == "time": return pack_time_management_cmd(queue_helper, cmd_path_list[1]) def handle_com_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: List[str]): obj_id_man = get_object_ids() + if len(cmd_path_list) == 1: + return build_com_subsystem_procedure(queue_helper, cmd_path_list[0]) assert len(cmd_path_list) >= 2 - - if cmd_path_list[1] == "ccsds": + if cmd_path_list[0] == "ccsds": object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID)) - assert len(cmd_path_list) >= 3 return pack_ccsds_handler_command( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list[1] == "pdec": - assert len(cmd_path_list) >= 3 + if cmd_path_list[0] == "pdec": return pack_pdec_handler_commands( object_id=PDEC_HANDLER_ID, q=queue_helper, cmd_str=cmd_path_list[2] ) - if cmd_path_list[1] == "syrlinks": + if cmd_path_list[0] == "syrlinks": object_id = cast(ObjectIdU32, obj_id_man.get(SYRLINKS_HANDLER_ID)) - assert len(cmd_path_list) >= 3 return pack_syrlinks_command( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[2] ) diff --git a/eive_tmtc/tmtc/com/subsystem.py b/eive_tmtc/tmtc/com/subsystem.py index 7e784a9..d8630ed 100644 --- a/eive_tmtc/tmtc/com/subsystem.py +++ b/eive_tmtc/tmtc/com/subsystem.py @@ -55,23 +55,23 @@ class Info: ANNOUNCE_MODE_RECURSIVE = "Announce mode recursively" -def build_com_subsystem_cmd(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 +def build_com_subsystem_procedure(q: DefaultPusQueueHelper, cmd_str: str): # noqa C901 prefix = "COM Subsystem" if cmd_str == OpCode.RX_ONLY: q.add_log_cmd(Info.RX_ONLY) q.add_pus_tc(create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_ONLY, 0)) elif cmd_str == OpCode.TX_AND_RX_DEF_RATE: - q.add_log_cmd(Info.TX_AND_RX_DEF_DATARATE) + q.add_log_cmd(Info.TX_AND_RX_DEF_RATE) q.add_pus_tc( create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_AND_TX_DEF_DATARATE, 0) ) elif cmd_str == OpCode.TX_AND_RX_LOW_RATE: - q.add_log_cmd(Info.TX_AND_RX_LOW_DATARATE) + q.add_log_cmd(Info.TX_AND_RX_LOW_RATE) q.add_pus_tc( create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_AND_TX_LOW_DATARATE, 0) ) elif cmd_str == OpCode.TX_AND_RX_HIGH_RATE: - q.add_log_cmd(Info.TX_AND_RX_HIGH_DATARATE) + q.add_log_cmd(Info.TX_AND_RX_HIGH_RATE) q.add_pus_tc( create_mode_command(COM_SUBSYSTEM_ID, ComMode.RX_AND_TX_HIGH_DATARATE, 0) ) -- 2.43.0 From 77c2c915395b4fd50d09238fe9e8308e56c19766 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 19:42:26 +0100 Subject: [PATCH 19/42] health and system cmds --- eive_tmtc/pus_tc/cmd_demux.py | 104 ++++++++++++++++++---------------- eive_tmtc/tmtc/health.py | 2 +- eive_tmtc/tmtc/test.py | 2 +- 3 files changed, 56 insertions(+), 52 deletions(-) diff --git a/eive_tmtc/pus_tc/cmd_demux.py b/eive_tmtc/pus_tc/cmd_demux.py index ec87f79..84d2d0f 100644 --- a/eive_tmtc/pus_tc/cmd_demux.py +++ b/eive_tmtc/pus_tc/cmd_demux.py @@ -1,74 +1,72 @@ """Hook function which packs telecommands based on service and operation code string """ import logging -from typing import cast, List +from typing import List, cast -from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd - -from eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command -from eive_tmtc.tmtc.com.subsystem import build_com_subsystem_procedure -from eive_tmtc.tmtc.test import pack_test_command -from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd -from eive_tmtc.tmtc.power.power import pack_power_commands -from eive_tmtc.tmtc.tcs.ctrl import pack_tcs_ctrl_commands -from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands -from eive_tmtc.tmtc.payload.scex import pack_scex_cmds -from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands -from eive_tmtc.tmtc.time import pack_time_management_cmd from tmtccmd import DefaultProcedureInfo from tmtccmd.tmtc import DefaultPusQueueHelper +from tmtccmd.util import ObjectIdU32 -from eive_tmtc.tmtc.power.p60dock import pack_p60dock_cmds -from eive_tmtc.tmtc.power.pdu2 import pack_pdu2_commands -from eive_tmtc.tmtc.power.pdu1 import pack_pdu1_commands -from eive_tmtc.tmtc.power.acu import pack_acu_commands -from eive_tmtc.tmtc.acs.imtq import create_imtq_command -from eive_tmtc.tmtc.tcs.heater import pack_heater_cmds -from eive_tmtc.tmtc.acs.reaction_wheels import ( - create_single_rw_cmd, - pack_rw_ass_cmds, -) -from eive_tmtc.tmtc.com.ccsds_handler import pack_ccsds_handler_command -from eive_tmtc.tmtc.core import pack_core_commands -from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands -from eive_tmtc.tmtc.com.syrlinks_handler import pack_syrlinks_command -from eive_tmtc.tmtc.com.pdec_handler import pack_pdec_handler_commands -from eive_tmtc.tmtc.wdt import pack_wdt_commands -from eive_tmtc.tmtc.acs.acs_board import pack_acs_command +import eive_tmtc.config.object_ids as oids from eive_tmtc.config.object_ids import ( - P60_DOCK_HANDLER, - PDU_1_HANDLER_ID, - PDU_2_HANDLER_ID, ACU_HANDLER_ID, - TMP1075_HANDLER_TCS_BRD_0_ID, - TMP1075_HANDLER_TCS_BRD_1_ID, - TMP1075_HANDLER_PLPCDU_0_ID, - TMP1075_HANDLER_IF_BRD_ID, + CCSDS_HANDLER_ID, HEATER_CONTROLLER_ID, IMTQ_HANDLER_ID, + P60_DOCK_HANDLER, + PDEC_HANDLER_ID, + PDU_1_HANDLER_ID, + PDU_2_HANDLER_ID, + RAD_SENSOR_ID, RW1_ID, RW2_ID, RW3_ID, RW4_ID, - RAD_SENSOR_ID, + RW_ASSEMBLY, STAR_TRACKER_ID, - CCSDS_HANDLER_ID, - PDEC_HANDLER_ID, STR_IMG_HELPER_ID, SYRLINKS_HANDLER_ID, - RW_ASSEMBLY, + TMP1075_HANDLER_IF_BRD_ID, + TMP1075_HANDLER_PLPCDU_0_ID, + TMP1075_HANDLER_TCS_BRD_0_ID, + TMP1075_HANDLER_TCS_BRD_1_ID, get_object_ids, ) - -from eive_tmtc.tmtc.tcs.tmp1075 import pack_tmp1075_test_into +from eive_tmtc.tmtc.acs.acs_board import pack_acs_command +from eive_tmtc.tmtc.acs.acs_ctrl import pack_acs_ctrl_command from eive_tmtc.tmtc.acs.gps import pack_gps_command -from eive_tmtc.tmtc.payload.rad_sensor import create_rad_sensor_cmd -from eive_tmtc.tmtc.payload.plpcdu import pack_pl_pcdu_commands +from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd +from eive_tmtc.tmtc.acs.imtq import create_imtq_command +from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd +from eive_tmtc.tmtc.acs.reaction_wheels import ( + create_single_rw_cmd, + pack_rw_ass_cmds, +) +from eive_tmtc.tmtc.acs.star_tracker import pack_star_tracker_commands from eive_tmtc.tmtc.acs.str_img_helper import pack_str_img_helper_command - -import eive_tmtc.config.object_ids as oids -from tmtccmd.util import ObjectIdU32 - +from eive_tmtc.tmtc.com.ccsds_handler import pack_ccsds_handler_command +from eive_tmtc.tmtc.com.pdec_handler import pack_pdec_handler_commands +from eive_tmtc.tmtc.com.subsystem import build_com_subsystem_procedure +from eive_tmtc.tmtc.com.syrlinks_handler import pack_syrlinks_command +from eive_tmtc.tmtc.core import pack_core_commands +from eive_tmtc.tmtc.health import build_health_cmds +from eive_tmtc.tmtc.payload.plpcdu import pack_pl_pcdu_commands +from eive_tmtc.tmtc.payload.rad_sensor import create_rad_sensor_cmd +from eive_tmtc.tmtc.payload.scex import pack_scex_cmds +from eive_tmtc.tmtc.power.acu import pack_acu_commands +from eive_tmtc.tmtc.power.p60dock import pack_p60dock_cmds +from eive_tmtc.tmtc.power.pdu1 import pack_pdu1_commands +from eive_tmtc.tmtc.power.pdu2 import pack_pdu2_commands +from eive_tmtc.tmtc.power.power import pack_power_commands +from eive_tmtc.tmtc.system import build_system_cmds +from eive_tmtc.tmtc.tcs.ctrl import pack_tcs_ctrl_commands +from eive_tmtc.tmtc.tcs.heater import pack_heater_cmds +from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands +from eive_tmtc.tmtc.tcs.subsystem import pack_tcs_sys_commands +from eive_tmtc.tmtc.tcs.tmp1075 import pack_tmp1075_test_into +from eive_tmtc.tmtc.test import build_test_commands +from eive_tmtc.tmtc.time import pack_time_management_cmd +from eive_tmtc.tmtc.wdt import pack_wdt_commands from eive_tmtc.utility.input_helper import InputHelper @@ -85,6 +83,12 @@ def handle_pus_procedure( # noqa C901: Complexity okay here. raise ValueError( "command path list empty. Full command path {cmd_path} might have invalid format" ) + if cmd_path_list[0] == "system": + assert len(cmd_path_list) >= 1 + return build_system_cmds(queue_helper, cmd_path_list[1]) + if cmd_path_list[0] == "health": + assert len(cmd_path_list) >= 1 + return build_health_cmds(queue_helper, cmd_path_list[1]) if cmd_path_list[0] == "eps": return handle_eps_procedure(queue_helper, cmd_path_list[1:]) if cmd_path_list[0] == "tcs": @@ -97,7 +101,7 @@ def handle_pus_procedure( # noqa C901: Complexity okay here. return handle_obdh_procedure(queue_helper, cmd_path_list[1:]) if cmd_path_list[0] == "test": assert len(cmd_path_list) >= 1 - return pack_test_command(queue_helper, cmd_path_list[1]) + return build_test_commands(queue_helper, cmd_path_list[1]) if cmd_path_list[0] == "com": return handle_com_procedure(queue_helper, cmd_path_list[1:]) logging.getLogger(__name__).warning( diff --git a/eive_tmtc/tmtc/health.py b/eive_tmtc/tmtc/health.py index 4b551b2..2ab13bd 100644 --- a/eive_tmtc/tmtc/health.py +++ b/eive_tmtc/tmtc/health.py @@ -28,7 +28,7 @@ def prompt_health() -> FsfwHealth: return FsfwHealth(health_idx) -def pack_health_cmd(q: DefaultPusQueueHelper, cmd_str: str): +def build_health_cmds(q: DefaultPusQueueHelper, cmd_str: str): if cmd_str == OpCode.SET_HEALTH: app_data = bytearray(prompt_object()) health = prompt_health() diff --git a/eive_tmtc/tmtc/test.py b/eive_tmtc/tmtc/test.py index 876713b..ffc2214 100644 --- a/eive_tmtc/tmtc/test.py +++ b/eive_tmtc/tmtc/test.py @@ -24,7 +24,7 @@ def create_test_node() -> CmdTreeNode: return node -def pack_test_command(q: DefaultPusQueueHelper, cmd_path: str): +def build_test_commands(q: DefaultPusQueueHelper, cmd_path: str): if cmd_path == OpCode.PING: q.add_log_cmd("Sending PUS TC [17,1]") q.add_pus_tc(create_service_17_ping_command()) -- 2.43.0 From 947bcf57f550444a577c139c8bf13f30eafd498e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 22 Nov 2023 19:44:24 +0100 Subject: [PATCH 20/42] done for today --- eive_tmtc/pus_tc/cmd_demux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eive_tmtc/pus_tc/cmd_demux.py b/eive_tmtc/pus_tc/cmd_demux.py index 84d2d0f..649eda8 100644 --- a/eive_tmtc/pus_tc/cmd_demux.py +++ b/eive_tmtc/pus_tc/cmd_demux.py @@ -70,7 +70,7 @@ from eive_tmtc.tmtc.wdt import pack_wdt_commands from eive_tmtc.utility.input_helper import InputHelper -def handle_pus_procedure( # noqa C901: Complexity okay here. +def handle_pus_procedure( info: DefaultProcedureInfo, queue_helper: DefaultPusQueueHelper, ): -- 2.43.0 From d2fc53c1fa47fcc725441344ab230f4f75544f4e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Nov 2023 16:05:19 +0100 Subject: [PATCH 21/42] cmd history introduction --- .gitignore | 1 + eive_tmtc/config/hook.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 630695e..192f482 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ log /gps_log.txt /config/*.json +/.tmtc-history.txt /scex_conf.json /tmtc_conf.json /seqcnt*.txt diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index b499a30..8088464 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -1,8 +1,10 @@ from typing import Optional +from prompt_toolkit.history import FileHistory from tmtccmd import CcsdsTmtcBackend, HookBase from tmtccmd.com import ComInterface from tmtccmd.config import CmdTreeNode +from tmtccmd.config.hook import History from tmtccmd.util import ObjectIdDictT, RetvalDictT from eive_tmtc.config.definitions import SPACE_PACKET_IDS @@ -168,3 +170,6 @@ class EiveHookObject(HookBase): def get_retval_dict(self) -> RetvalDictT: return get_retval_dict() + + def get_cmd_history(self) -> Optional[History]: + return FileHistory(".tmtc-history.txt") -- 2.43.0 From 76fee820e95911e1294891189099c44e7bd9faf3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Nov 2023 17:24:25 +0100 Subject: [PATCH 22/42] continuing node setup --- eive_tmtc/config/hook.py | 25 ++++++------ eive_tmtc/tmtc/acs/acs_ctrl.py | 4 +- eive_tmtc/tmtc/acs/gps.py | 46 +++++++++++++--------- eive_tmtc/tmtc/acs/imtq.py | 70 ++++++++++++++++++++++++++++++++++ eive_tmtc/tmtc/tcs/ctrl.py | 19 +++++++++ eive_tmtc/tmtc/tcs/heater.py | 52 +++++++++++++++---------- 6 files changed, 165 insertions(+), 51 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index 8088464..96b0957 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -1,6 +1,6 @@ from typing import Optional -from prompt_toolkit.history import FileHistory +from prompt_toolkit.history import FileHistory from tmtccmd import CcsdsTmtcBackend, HookBase from tmtccmd.com import ComInterface from tmtccmd.config import CmdTreeNode @@ -9,11 +9,14 @@ from tmtccmd.util import ObjectIdDictT, RetvalDictT from eive_tmtc.config.definitions import SPACE_PACKET_IDS from eive_tmtc.config.retvals import get_retval_dict -from eive_tmtc.tmtc.core import create_core_node +from eive_tmtc.tmtc.acs.acs_ctrl import create_acs_ctrl_node +from eive_tmtc.tmtc.acs.gps import create_gnss_node +from eive_tmtc.tmtc.acs.imtq import create_mgt_node from eive_tmtc.tmtc.acs.subsystem import create_acs_subsystem_node from eive_tmtc.tmtc.com.ccsds_handler import create_ccsds_node from eive_tmtc.tmtc.com.subsystem import create_com_subsystem_node from eive_tmtc.tmtc.com.syrlinks_handler import create_syrlinks_node +from eive_tmtc.tmtc.core import create_core_node from eive_tmtc.tmtc.health import create_global_health_node from eive_tmtc.tmtc.payload.ploc_mpsoc import create_ploc_mpsoc_node from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node @@ -23,6 +26,8 @@ from eive_tmtc.tmtc.power.bpx_batt import create_bpx_batt_node from eive_tmtc.tmtc.power.pwr_ctrl import create_pwr_ctrl_node from eive_tmtc.tmtc.power.subsystem import create_eps_subsystem_node from eive_tmtc.tmtc.system import create_system_node +from eive_tmtc.tmtc.tcs.ctrl import create_tcs_ctrl_node +from eive_tmtc.tmtc.tcs.heater import create_heater_node from eive_tmtc.tmtc.test import create_test_node from eive_tmtc.tmtc.time import create_time_node from eive_tmtc.tmtc.tm_store import create_persistent_tm_store_node @@ -56,10 +61,7 @@ class EiveHookObject(HookBase): gyro_devs = CmdTreeNode("gyro_devs", "Gyro Devices") acs_brd_assy_node.add_child(mgm_devs) acs_brd_assy_node.add_child(gyro_devs) - acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller") - acs_ctrl.add_child(mode_node) - acs_ctrl.add_child(action_node) - acs_ctrl.add_child(param_node) + acs_ctrl = create_acs_ctrl_node() rws = CmdTreeNode("rws", "Reaction Wheel Devices") rw_assy = CmdTreeNode("rw_assy", "Reaction Wheel Assembly") rw_1 = CmdTreeNode("rw_1", "Reaction Wheel 1") @@ -71,29 +73,26 @@ class EiveHookObject(HookBase): rws.add_child(rw_2) rws.add_child(rw_3) rws.add_child(rw_4) - mgt = CmdTreeNode("mgt", "ISIS MGT") - mgt.add_child(dev_node) - mgt.add_child(assy_node) star_tracker = CmdTreeNode("str", "Star Tracker") star_tracker_img_helper = CmdTreeNode( "str_img_helper", "Star Tracker Image Helper" ) star_tracker.add_child(star_tracker_img_helper) - gnss_devs = CmdTreeNode("gnss", "GNSS Devices") + gnss_devs = create_gnss_node() acs_node.add_child(acs_brd_assy_node) acs_node.add_child(acs_ctrl) acs_node.add_child(mode_node) acs_node.add_child(rws) - acs_node.add_child(mgt) + acs_node.add_child(create_mgt_node()) acs_node.add_child(star_tracker) acs_node.add_child(gnss_devs) tcs_node = CmdTreeNode("tcs", "TCS Subsystem") tmp_1075_node = CmdTreeNode("tmp1075_devs", "TMP1075 Devices") rtds_node = CmdTreeNode("rtd_devs", "RTD Devices") - heaters_node = CmdTreeNode("heaters", "Heater Devices") - tcs_ctrl = CmdTreeNode("tcs_ctrl", "TCS Controller") + heaters_node = create_heater_node() + tcs_ctrl = create_tcs_ctrl_node() tcs_node.add_child(rtds_node) tcs_node.add_child(tmp_1075_node) tcs_node.add_child(tcs_ctrl) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index def521b..4a8df2d 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -217,7 +217,9 @@ def create_acs_ctrl_node() -> CmdTreeNode: ] info_strs = [getattr(Info, key) for key in dir(OpCodes) if not key.startswith("__")] combined_dict = dict(zip(op_code_strs, info_strs)) - acs_ctrl = CmdTreeNode("acs_ctrl", "ACS Controller") + acs_ctrl = CmdTreeNode( + "acs_ctrl", "ACS Controller", hide_children_which_are_leaves=True + ) for op_code, info in combined_dict.items(): acs_ctrl.add_child(CmdTreeNode(op_code, info)) return acs_ctrl diff --git a/eive_tmtc/tmtc/acs/gps.py b/eive_tmtc/tmtc/acs/gps.py index 8662612..a99a7f0 100644 --- a/eive_tmtc/tmtc/acs/gps.py +++ b/eive_tmtc/tmtc/acs/gps.py @@ -5,7 +5,7 @@ import struct from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.pus_tm.defs import PrintWrapper -from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry +from tmtccmd.config import CmdTreeNode, TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.pus.s200_fsfw_mode import create_mode_command, Mode from tmtccmd.tmtc import DefaultPusQueueHelper @@ -27,13 +27,13 @@ class GpsInfo: class OpCode: OFF = "off" ON = "on" - REQ_CORE_HK = ["core_hk_request"] - ENABLE_CORE_HK = ["core_hk_enable"] - DISABLE_CORE_HK = ["core_hk_disable"] - REQ_SKYVIEW_HK = ["skyview_hk_request"] - ENABLE_SKYVIEW_HK = ["skyview_hk_enable"] - DISABLE_SKYVIEW_HK = ["skyview_hk_disable"] - RESET_GNSS = ["reset"] + REQ_CORE_HK = "core_hk_request" + ENABLE_CORE_HK = "core_hk_enable" + DISABLE_CORE_HK = "core_hk_disable" + REQ_SKYVIEW_HK = "skyview_hk_request" + ENABLE_SKYVIEW_HK = "skyview_hk_enable" + DISABLE_SKYVIEW_HK = "skyview_hk_disable" + RESET_GNSS = "reset" class Info: @@ -53,6 +53,18 @@ class SetId(enum.IntEnum): SKYVIEW_HK = 1 +def create_gnss_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("gnss", "GNSS device", hide_children_for_print=True) + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node + + @tmtc_definitions_provider def add_gps_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() @@ -75,10 +87,10 @@ def add_gps_cmds(defs: TmtcDefinitionWrapper): def pack_gps_command( # noqa: C901 object_id: bytes, q: DefaultPusQueueHelper, cmd_str: str ): # noqa: C901: - if cmd_str in OpCode.RESET_GNSS: + if cmd_str == OpCode.RESET_GNSS: # TODO: This needs to be re-implemented _LOGGER.warning("Reset pin handling needs to be re-implemented") - if cmd_str in OpCode.ENABLE_CORE_HK: + if cmd_str == OpCode.ENABLE_CORE_HK: interval = float(input("Please specify interval in floating point seconds: ")) if interval <= 0: raise ValueError("invalid interval") @@ -90,21 +102,21 @@ def pack_gps_command( # noqa: C901 ) for cmd in cmds: q.add_pus_tc(cmd) - if cmd_str in OpCode.DISABLE_CORE_HK: + if cmd_str == OpCode.DISABLE_CORE_HK: q.add_log_cmd(f"gps: {Info.DISABLE_CORE_HK}") q.add_pus_tc( create_disable_periodic_hk_command_with_diag( diag=False, sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK) ) ) - if cmd_str in OpCode.REQ_CORE_HK: + if cmd_str == OpCode.REQ_CORE_HK: q.add_log_cmd(f"GPS: {Info.REQ_CORE_HK}") q.add_pus_tc( create_request_one_hk_command( sid=make_sid(object_id=object_id, set_id=SetId.CORE_HK) ) ) - if cmd_str in OpCode.ENABLE_SKYVIEW_HK: + if cmd_str == OpCode.ENABLE_SKYVIEW_HK: interval = float(input("Please specify interval in floating point seconds: ")) if interval <= 0: raise ValueError("invalid interval") @@ -116,24 +128,24 @@ def pack_gps_command( # noqa: C901 ) for cmd in cmds: q.add_pus_tc(cmd) - if cmd_str in OpCode.DISABLE_SKYVIEW_HK: + if cmd_str == OpCode.DISABLE_SKYVIEW_HK: q.add_log_cmd(f"gps: {Info.DISABLE_SKYVIEW_HK}") q.add_pus_tc( create_disable_periodic_hk_command_with_diag( diag=False, sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK) ) ) - if cmd_str in OpCode.REQ_SKYVIEW_HK: + if cmd_str == OpCode.REQ_SKYVIEW_HK: q.add_log_cmd(f"GPS: {Info.REQ_SKYVIEW_HK}") q.add_pus_tc( create_request_one_hk_command( sid=make_sid(object_id=object_id, set_id=SetId.SKYVIEW_HK) ) ) - if cmd_str in OpCode.ON: + if cmd_str == OpCode.ON: q.add_log_cmd(f"GPS: {Info.ON}") q.add_pus_tc(create_mode_command(object_id, Mode.ON, 0)) - if cmd_str in OpCode.OFF: + if cmd_str == OpCode.OFF: q.add_log_cmd(f"GPS: {Info.OFF}") q.add_pus_tc(create_mode_command(object_id, Mode.OFF, 0)) diff --git a/eive_tmtc/tmtc/acs/imtq.py b/eive_tmtc/tmtc/acs/imtq.py index 919d411..53cc9a2 100644 --- a/eive_tmtc/tmtc/acs/imtq.py +++ b/eive_tmtc/tmtc/acs/imtq.py @@ -10,6 +10,8 @@ import logging import struct from typing import List +from tmtccmd.config import CmdTreeNode + from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.pus_tm.defs import PrintWrapper from spacepackets.ecss.tc import PusTelecommand @@ -91,6 +93,74 @@ class ImtqActionId: read_self_test_results = bytearray([0x0, 0x0, 0x0, 0x0D]) +CTN = CmdTreeNode + + +def create_mgt_node() -> CmdTreeNode: + node = CmdTreeNode( + "mgt", "iMTQ MGT device node", hide_children_which_are_leaves=True + ) + node.add_child(CmdTreeNode(OpCode.OFF, "Mode OFF")) + node.add_child(CmdTreeNode(OpCode.ON, "Mode ON")) + node.add_child(CmdTreeNode(OpCode.NORMAL, "Mode Normal")) + node.add_child(CmdTreeNode(OpCode.OFF, "Mode OFF")) + node.add_child( + CmdTreeNode(OpCode.REQUEST_ENG_HK_NO_TORQUE, "Request Engineering HK One Shot") + ) + node.add_child( + CmdTreeNode( + OpCode.REQUEST_ENG_HK_WITH_TORQUE, + "Request Engineering HK One Shot during Torque", + ) + ) + node.add_child( + CmdTreeNode(OpCode.ENABLE_ENG_HK_NO_TORQUE, "Enable ENG HK not torque") + ) + node.add_child( + CmdTreeNode(OpCode.ENABLE_ENG_HK_WITH_TORQUE, "Enable ENG HK with torque") + ) + node.add_child( + CmdTreeNode(OpCode.DISABLE_ENG_HK_NO_TORQUE, "Disable ENG HK not torque") + ) + node.add_child( + CmdTreeNode(OpCode.DISABLE_ENG_HK_WITH_TORQUE, "Disable ENG HK with torque") + ) + node.add_child( + CmdTreeNode( + OpCode.REQUEST_MGM_RAW_NO_TORQUE, + "Request MGM Raw Without Torque HK One Shot", + ) + ) + node.add_child( + CmdTreeNode(OpCode.ENABLE_MGM_RAW_NO_TORQUE, "Enable MGM Raw Without Torque HK") + ) + node.add_child( + CmdTreeNode( + OpCode.DISABLE_MGM_RAW_NO_TORQUE, "Disable MGM Raw Without Torque HK" + ) + ) + node.add_child( + CmdTreeNode( + OpCode.REQUEST_MGM_RAW_WITH_TORQUE, + "Request MGM Raw With Torque HK One Shot", + ) + ) + node.add_child( + CmdTreeNode(OpCode.ENABLE_MGM_RAW_WITH_TORQUE, "Enable MGM Raw With Torque HK") + ) + node.add_child( + CTN(OpCode.DISABLE_MGM_RAW_WITH_TORQUE, "Disable MGM Raw With Torque HK") + ) + node.add_child(CTN(OpCode.POS_X_SELF_TEST, "IMTQ perform pos X self test")) + node.add_child(CTN(OpCode.NEG_X_SELF_TEST, "IMTQ perform neg X self test")) + node.add_child(CTN(OpCode.POS_Y_SELF_TEST, "IMTQ perform pos Y self test")) + node.add_child(CTN(OpCode.NEG_Y_SELF_TEST, "IMTQ perform neg Y self test")) + node.add_child(CTN(OpCode.POS_Z_SELF_TEST, "IMTQ perform pos Z self test")) + node.add_child(CTN(OpCode.NEG_Z_SELF_TEST, "IMTQ perform neg Z self test")) + node.add_child(CTN(OpCode.SET_DIPOLE, "IMTQ command dipole")) + return node + + @tmtc_definitions_provider def add_imtq_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/tcs/ctrl.py b/eive_tmtc/tmtc/tcs/ctrl.py index 4f644f8..5df4252 100644 --- a/eive_tmtc/tmtc/tcs/ctrl.py +++ b/eive_tmtc/tmtc/tcs/ctrl.py @@ -3,6 +3,7 @@ from eive_tmtc.config.object_ids import TCS_CONTROLLER from eive_tmtc.tmtc.tcs import CtrlSetId from eive_tmtc.tmtc.tcs.brd_assy import pack_tcs_ass_cmds from tmtccmd.config.tmtc import ( + CmdTreeNode, tmtc_definitions_provider, TmtcDefinitionWrapper, OpCodeEntry, @@ -76,6 +77,24 @@ def pack_tcs_ctrl_commands(q: DefaultPusQueueHelper, cmd_str: str): pack_tcs_ass_cmds(q, cmd_str) +CTN = CmdTreeNode + + +def create_tcs_ctrl_node() -> CmdTreeNode: + node = CmdTreeNode( + "tcs_ctrl", "TCS Controller", hide_children_which_are_leaves=True + ) + node.add_child(CTN(CmdStr.ENABLE_TEMP_SET, CmdInfo.ENABLE_TEMP_SET)) + node.add_child( + CTN(CmdStr.REQUEST_PRIMARY_TEMP_SET, CmdInfo.REQUEST_PRIMARY_TEMP_SET) + ) + node.add_child(CTN(CmdStr.REQUEST_DEVICE_TEMP_SET, CmdInfo.REQUEST_DEVICE_TEMP_SET)) + node.add_child(CTN(CmdStr.REQUEST_DEVICE_SUS_SET, CmdInfo.REQUEST_DEVICE_SUS_SET)) + node.add_child(CTN(CmdStr.REQUEST_HEATER_INFO, CmdInfo.REQUEST_HEATER_INFO)) + node.add_child(CTN(CmdStr.REQUEST_TCS_CTRL_INFO, CmdInfo.REQUEST_TCS_CTRL_INFO)) + return node + + @tmtc_definitions_provider def add_tcs_ctrl_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/tcs/heater.py b/eive_tmtc/tmtc/tcs/heater.py index 0ce09ae..99fe3eb 100644 --- a/eive_tmtc/tmtc/tcs/heater.py +++ b/eive_tmtc/tmtc/tcs/heater.py @@ -5,21 +5,21 @@ """ import enum +from spacepackets.ecss.tc import PusTelecommand +from tmtccmd.config import CmdTreeNode, OpCodeEntry, TmtcDefinitionWrapper +from tmtccmd.config.tmtc import tmtc_definitions_provider +from tmtccmd.pus.s8_fsfw_action import create_action_cmd +from tmtccmd.pus.s201_fsfw_health import ( + FsfwHealth, + Subservice, + pack_set_health_cmd_data, +) +from tmtccmd.tmtc import DefaultPusQueueHelper +from tmtccmd.util.obj_id import ObjectIdU32 + from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import get_object_ids from eive_tmtc.tmtc.tcs.defs import Heater -from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry -from tmtccmd.config.tmtc import tmtc_definitions_provider -from tmtccmd.tmtc import DefaultPusQueueHelper -from tmtccmd.util.obj_id import ObjectIdU32 -from tmtccmd.pus.s201_fsfw_health import ( - pack_set_health_cmd_data, - FsfwHealth, - Subservice, -) -from tmtccmd.pus.s8_fsfw_action import create_action_cmd -from spacepackets.ecss.tc import PusTelecommand - HEATER_LOCATION = [ "PLOC Processing Board", @@ -34,10 +34,10 @@ HEATER_LOCATION = [ class OpCode: - HEATER_CMD = ["switch_cmd"] - HEATER_EXT_CTRL = ["set_ext_ctrl"] - HEATER_FAULTY_CMD = ["set_faulty"] - HEATER_HEALTHY_CMD = ["set_healthy"] + HEATER_CMD = "switch_cmd" + HEATER_EXT_CTRL = "set_ext_ctrl" + HEATER_FAULTY_CMD = "set_faulty" + HEATER_HEALTHY_CMD = "set_healthy" class Info: @@ -55,6 +55,18 @@ class ActionIds(enum.IntEnum): SWITCH_HEATER = 0 +CTN = CmdTreeNode + + +def create_heater_node() -> CmdTreeNode: + node = CmdTreeNode("heater", "Heater Device", hide_children_which_are_leaves=True) + node.add_child(CTN(OpCode.HEATER_CMD, Info.HEATER_CMD)) + node.add_child(CTN(OpCode.HEATER_HEALTHY_CMD, Info.HEATER_HEALTHY_CMD)) + node.add_child(CTN(OpCode.HEATER_EXT_CTRL, Info.HEATER_EXT_CTRL)) + node.add_child(CTN(OpCode.HEATER_FAULTY_CMD, Info.HEATER_FAULTY_CMD)) + return node + + @tmtc_definitions_provider def add_heater_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() @@ -70,7 +82,7 @@ def add_heater_cmds(defs: TmtcDefinitionWrapper): def pack_heater_cmds(object_id: bytes, cmd_str: str, q: DefaultPusQueueHelper): - if cmd_str in OpCode.HEATER_CMD: + if cmd_str == OpCode.HEATER_CMD: q.add_log_cmd("Heater Switching") heater_number = prompt_heater() while True: @@ -90,7 +102,7 @@ def pack_heater_cmds(object_id: bytes, cmd_str: str, q: DefaultPusQueueHelper): debug_string = f"Switching heater {heater_number} {act_str}" q.add_log_cmd(debug_string) q.add_pus_tc(pack_switch_heater_command(object_id, heater_number, action)) - if cmd_str in OpCode.HEATER_EXT_CTRL: + if cmd_str == OpCode.HEATER_EXT_CTRL: heater_number = prompt_heater() obj_id = heater_idx_to_obj(heater_number) health_cmd( @@ -100,7 +112,7 @@ def pack_heater_cmds(object_id: bytes, cmd_str: str, q: DefaultPusQueueHelper): health_str="External Control", heater_idx=heater_number, ) - if cmd_str in OpCode.HEATER_FAULTY_CMD: + if cmd_str == OpCode.HEATER_FAULTY_CMD: heater_number = prompt_heater() obj_id = heater_idx_to_obj(heater_number) health_cmd( @@ -110,7 +122,7 @@ def pack_heater_cmds(object_id: bytes, cmd_str: str, q: DefaultPusQueueHelper): health_str="Faulty", heater_idx=heater_number, ) - if cmd_str in OpCode.HEATER_HEALTHY_CMD: + if cmd_str == OpCode.HEATER_HEALTHY_CMD: heater_number = prompt_heater() obj_id = heater_idx_to_obj(heater_number) health_cmd( -- 2.43.0 From 3cf312073a59b9a02aaa049a6dd1b796e98e976a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Nov 2023 17:34:34 +0100 Subject: [PATCH 23/42] continue conversion --- eive_tmtc/config/hook.py | 8 ++++---- eive_tmtc/pus_tc/cmd_demux.py | 4 +++- eive_tmtc/tmtc/payload/plpcdu.py | 35 +++++++++++++++++++++++--------- eive_tmtc/tmtc/power/pwr_ctrl.py | 2 +- eive_tmtc/tmtc/wdt.py | 8 ++++++++ 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index 96b0957..e118857 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -20,6 +20,7 @@ from eive_tmtc.tmtc.core import create_core_node from eive_tmtc.tmtc.health import create_global_health_node from eive_tmtc.tmtc.payload.ploc_mpsoc import create_ploc_mpsoc_node from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node +from eive_tmtc.tmtc.payload.plpcdu import create_pl_pcdu_node from eive_tmtc.tmtc.payload.scex import create_scex_node from eive_tmtc.tmtc.payload.subsystem import create_payload_subsystem_node from eive_tmtc.tmtc.power.bpx_batt import create_bpx_batt_node @@ -31,6 +32,7 @@ from eive_tmtc.tmtc.tcs.heater import create_heater_node from eive_tmtc.tmtc.test import create_test_node from eive_tmtc.tmtc.time import create_time_node from eive_tmtc.tmtc.tm_store import create_persistent_tm_store_node +from eive_tmtc.tmtc.wdt import create_wdt_node class EiveHookObject(HookBase): @@ -117,15 +119,13 @@ class EiveHookObject(HookBase): eps_node.add_child(create_bpx_batt_node()) payload_node = create_payload_subsystem_node() - pl_pcdu = CmdTreeNode("pl_pcdu", "Payload PCDU") - payload_node.add_child(pl_pcdu) + payload_node.add_child(create_pl_pcdu_node()) payload_node.add_child(create_scex_node()) payload_node.add_child(create_ploc_mpsoc_node()) payload_node.add_child(create_ploc_supv_node()) obdh_node = CmdTreeNode("obdh", "OBDH Subsystem") - xiphos_wdt = CmdTreeNode("wdt", "Xiphos WDT") - obdh_node.add_child(xiphos_wdt) + obdh_node.add_child(create_wdt_node()) obdh_node.add_child(create_core_node()) obdh_node.add_child(create_time_node()) obdh_node.add_child(create_persistent_tm_store_node()) diff --git a/eive_tmtc/pus_tc/cmd_demux.py b/eive_tmtc/pus_tc/cmd_demux.py index 649eda8..7cded08 100644 --- a/eive_tmtc/pus_tc/cmd_demux.py +++ b/eive_tmtc/pus_tc/cmd_demux.py @@ -58,6 +58,7 @@ from eive_tmtc.tmtc.power.p60dock import pack_p60dock_cmds from eive_tmtc.tmtc.power.pdu1 import pack_pdu1_commands from eive_tmtc.tmtc.power.pdu2 import pack_pdu2_commands from eive_tmtc.tmtc.power.power import pack_power_commands +from eive_tmtc.tmtc.power.pwr_ctrl import pack_power_ctrl_command from eive_tmtc.tmtc.system import build_system_cmds from eive_tmtc.tmtc.tcs.ctrl import pack_tcs_ctrl_commands from eive_tmtc.tmtc.tcs.heater import pack_heater_cmds @@ -114,9 +115,10 @@ def handle_eps_procedure(queue_helper: DefaultPusQueueHelper, cmd_path_list: Lis if len(cmd_path_list) == 1: return pack_power_commands(queue_helper, cmd_path_list[0]) assert len(cmd_path_list) >= 2 + if cmd_path_list[0] == "pwr_ctrl": + return pack_power_ctrl_command(queue_helper, cmd_path_list[1]) if cmd_path_list[0] == "p60_dock": object_id = cast(ObjectIdU32, obj_id_man.get(P60_DOCK_HANDLER)) - assert len(cmd_path_list) >= 2 return pack_p60dock_cmds( object_id=object_id, q=queue_helper, cmd_str=cmd_path_list[1] ) diff --git a/eive_tmtc/tmtc/payload/plpcdu.py b/eive_tmtc/tmtc/payload/plpcdu.py index ea151bd..4e56fde 100644 --- a/eive_tmtc/tmtc/payload/plpcdu.py +++ b/eive_tmtc/tmtc/payload/plpcdu.py @@ -6,7 +6,7 @@ from typing import Optional from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.pus_tm.defs import PrintWrapper -from tmtccmd.config import TmtcDefinitionWrapper +from tmtccmd.config import CmdTreeNode, TmtcDefinitionWrapper from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider from tmtccmd.tmtc import DefaultPusQueueHelper @@ -34,7 +34,6 @@ _LOGGER = logging.getLogger(__name__) class OpCode: - SWITCH_HPA_ON_PROC = ["0", "proc_hpa"] SWITCH_ON = "on" SWITCH_OFF = "off" NORMAL_SSR = "nml_ssr" @@ -52,12 +51,12 @@ class OpCode: UPDATE_V_LOWER_LIMIT = "update_v_lower_limit" UPDATE_V_UPPER_LIMIT = "update_v_upper_limit" - INJECT_SSR_TO_DRO_FAILURE = ["10", "inject_ssr_dro_fault"] - INJECT_DRO_TO_X8_FAILURE = ["11", "inject_dro_x8_fault"] - INJECT_X8_TO_TX_FAILURE = ["12", "inject_x8_tx_fault"] - INJECT_TX_TO_MPA_FAILURE = ["13", "inject_tx_mpa_fault"] - INJECT_MPA_TO_HPA_FAILURE = ["14", "inject_mpa_hpa_fault"] - INJECT_ALL_ON_FAILURE = ["15", "inject_all_on_fault"] + INJECT_SSR_TO_DRO_FAILURE = "inject_ssr_dro_fault" + INJECT_DRO_TO_X8_FAILURE = "inject_dro_x8_fault" + INJECT_X8_TO_TX_FAILURE = "inject_x8_tx_fault" + INJECT_TX_TO_MPA_FAILURE = "inject_tx_mpa_fault" + INJECT_MPA_TO_HPA_FAILURE = "inject_mpa_hpa_fault" + INJECT_ALL_ON_FAILURE = "inject_all_on_fault" class Info: @@ -71,12 +70,17 @@ class Info: NORMAL_MPA = f"{NORMAL}, MPA on" NORMAL_HPA = f"{NORMAL}, HPA on" REQ_OS_HK = "Request One Shot HK" - SWITCH_HPA_ON_PROC = "Switch HPA on procedure" ENABLE_HK = "Enable HK" DISABLE_HK = "Disable HK" UPDATE_I_UPPER_LIMIT = "Update upper current parameter" UPDATE_V_LOWER_LIMIT = "Update lower voltage parameter" UPDATE_V_UPPER_LIMIT = "Update upper voltage parameter" + INJECT_SSR_TO_DRO_FAILURE = "Inject SSR to DRO failure" + INJECT_DRO_TO_X8_FAILURE = "Inject DRO to X8 failure" + INJECT_X8_TO_TX_FAILURE = "Inject X8 to TX failure" + INJECT_TX_TO_MPA_FAILURE = "Inject TX to MPA failure" + INJECT_MPA_TO_HPA_FAILURE = "Inject MPA to HPA failure" + INJECT_ALL_ON_FAILURE = "Inject all on failure" class SetId(enum.IntEnum): @@ -173,10 +177,21 @@ class DevSelect(enum.IntEnum): HPA = 5 +def create_pl_pcdu_node() -> CmdTreeNode: + op_code_strs = [ + getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__") + ] + info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")] + combined_dict = dict(zip(op_code_strs, info_strs)) + node = CmdTreeNode("pl_pcdu", "Payload PCDU", hide_children_for_print=True) + for op_code, info in combined_dict.items(): + node.add_child(CmdTreeNode(op_code, info)) + return node + + @tmtc_definitions_provider def add_pl_pcdu_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() - oce.add(keys=OpCode.SWITCH_HPA_ON_PROC, info=Info.SWITCH_HPA_ON_PROC) oce.add(keys=OpCode.SWITCH_ON, info=Info.SWITCH_ON) oce.add(keys=OpCode.SWITCH_OFF, info=Info.SWITCH_OFF) oce.add(keys=OpCode.NORMAL_SSR, info=Info.NORMAL_SSR) diff --git a/eive_tmtc/tmtc/power/pwr_ctrl.py b/eive_tmtc/tmtc/power/pwr_ctrl.py index c774a40..51b364d 100644 --- a/eive_tmtc/tmtc/power/pwr_ctrl.py +++ b/eive_tmtc/tmtc/power/pwr_ctrl.py @@ -83,7 +83,7 @@ def create_pwr_ctrl_node() -> CmdTreeNode: return node -def pack_acs_ctrl_command(q: DefaultPusQueueHelper, cmd_str: str): +def pack_power_ctrl_command(q: DefaultPusQueueHelper, cmd_str: str): if cmd_str == OpCode.OFF: q.add_log_cmd(f"{Info.OFF}") q.add_pus_tc(pack_mode_command(PWR_CONTROLLER, Mode.OFF, 0)) diff --git a/eive_tmtc/tmtc/wdt.py b/eive_tmtc/tmtc/wdt.py index ac827ab..139d2d2 100644 --- a/eive_tmtc/tmtc/wdt.py +++ b/eive_tmtc/tmtc/wdt.py @@ -1,5 +1,6 @@ import enum from tmtccmd.config.tmtc import ( + CmdTreeNode, OpCodeEntry, TmtcDefinitionWrapper, tmtc_definitions_provider, @@ -33,6 +34,13 @@ def pack_wdt_commands(q: DefaultPusQueueHelper, cmd_str: str): q.add_pus_tc(create_action_cmd(XIPHOS_WDT_ID, ActionId.DISABLE)) +def create_wdt_node() -> CmdTreeNode: + node = CmdTreeNode("xiphos_wdt", "Xiphos Watchdog Timer") + node.add_child(CmdTreeNode(OpCode.ENABLE, Info.ENABLE)) + node.add_child(CmdTreeNode(OpCode.DISABLE, Info.DISABLE)) + return node + + @tmtc_definitions_provider def add_xiphos_wdt_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() -- 2.43.0 From d4147d84027a62f2d240d83571bf30ff5ea47bdb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Nov 2023 17:41:46 +0100 Subject: [PATCH 24/42] not much missing --- eive_tmtc/config/hook.py | 9 +++++--- eive_tmtc/tmtc/acs/star_tracker.py | 37 +++++++++++++++++++++++++++++- eive_tmtc/tmtc/tcs/rtd.py | 11 ++++++++- eive_tmtc/tmtc/tcs/tmp1075.py | 11 +++++++++ 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index e118857..ea66912 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -12,6 +12,7 @@ from eive_tmtc.config.retvals import get_retval_dict from eive_tmtc.tmtc.acs.acs_ctrl import create_acs_ctrl_node from eive_tmtc.tmtc.acs.gps import create_gnss_node from eive_tmtc.tmtc.acs.imtq import create_mgt_node +from eive_tmtc.tmtc.acs.star_tracker import create_str_node from eive_tmtc.tmtc.acs.subsystem import create_acs_subsystem_node from eive_tmtc.tmtc.com.ccsds_handler import create_ccsds_node from eive_tmtc.tmtc.com.subsystem import create_com_subsystem_node @@ -29,6 +30,8 @@ from eive_tmtc.tmtc.power.subsystem import create_eps_subsystem_node from eive_tmtc.tmtc.system import create_system_node from eive_tmtc.tmtc.tcs.ctrl import create_tcs_ctrl_node from eive_tmtc.tmtc.tcs.heater import create_heater_node +from eive_tmtc.tmtc.tcs.rtd import create_rtd_node +from eive_tmtc.tmtc.tcs.tmp1075 import create_tmp_sens_node from eive_tmtc.tmtc.test import create_test_node from eive_tmtc.tmtc.time import create_time_node from eive_tmtc.tmtc.tm_store import create_persistent_tm_store_node @@ -75,7 +78,7 @@ class EiveHookObject(HookBase): rws.add_child(rw_2) rws.add_child(rw_3) rws.add_child(rw_4) - star_tracker = CmdTreeNode("str", "Star Tracker") + star_tracker = create_str_node() star_tracker_img_helper = CmdTreeNode( "str_img_helper", "Star Tracker Image Helper" ) @@ -91,8 +94,8 @@ class EiveHookObject(HookBase): acs_node.add_child(gnss_devs) tcs_node = CmdTreeNode("tcs", "TCS Subsystem") - tmp_1075_node = CmdTreeNode("tmp1075_devs", "TMP1075 Devices") - rtds_node = CmdTreeNode("rtd_devs", "RTD Devices") + tmp_1075_node = create_tmp_sens_node() + rtds_node = create_rtd_node() heaters_node = create_heater_node() tcs_ctrl = create_tcs_ctrl_node() tcs_node.add_child(rtds_node) diff --git a/eive_tmtc/tmtc/acs/star_tracker.py b/eive_tmtc/tmtc/acs/star_tracker.py index f891b9e..754b0c1 100644 --- a/eive_tmtc/tmtc/acs/star_tracker.py +++ b/eive_tmtc/tmtc/acs/star_tracker.py @@ -14,7 +14,7 @@ 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 import CmdTreeNode, TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.pus.tc.s3_fsfw_hk import ( create_request_one_diag_command, @@ -1147,6 +1147,41 @@ def handle_read_secondary_tm_set(pw: PrintWrapper, custom_data: bytes): pw.dlog(f"Unknown Set ID {set_id}") +def create_str_node() -> CmdTreeNode: + node = CmdTreeNode("str", "Star Tracker Device") + node.add_child(CmdTreeNode(OpCodes.ON_BOOTLOADER, "Mode On, Submode Bootloader")) + node.add_child(CmdTreeNode(OpCodes.ON_FIRMWARE, "Mode On, Submode Firmware")) + node.add_child(CmdTreeNode(OpCodes.NORMAL, "Mode Normal")) + node.add_child(CmdTreeNode(OpCodes.OFF, "Mode Off")) + node.add_child(CmdTreeNode(OpCodes.PING, "Star Tracker: Ping")) + node.add_child(CmdTreeNode(OpCodes.TAKE_IMAGE, "Take Image")) + node.add_child(CmdTreeNode(OpCodes.UPLOAD_IMAGE, Info.UPLOAD_IMAGE)) + node.add_child(CmdTreeNode(OpCodes.DOWNLOAD_IMAGE, Info.DOWNLOAD_IMAGE)) + node.add_child(CmdTreeNode(OpCodes.ONE_SHOOT_HK, Info.ONE_SHOOT_HK)) + node.add_child(CmdTreeNode(OpCodes.ENABLE_HK, Info.ENABLE_HK)) + node.add_child(CmdTreeNode(OpCodes.DISABLE_HK, Info.DISABLE_HK)) + node.add_child( + CmdTreeNode(OpCodes.SET_IMG_PROCESSOR_MODE, Info.SET_IMG_PROCESSOR_MODE) + ) + node.add_child( + CmdTreeNode( + OpCodes.ADD_SECONDARY_TM_TO_NORMAL_MODE, + Info.ADD_SECONDARY_TM_TO_NORMAL_MODE, + ) + ) + node.add_child( + CmdTreeNode(OpCodes.READ_SECONDARY_TM_SET, Info.READ_SECONDARY_TM_SET) + ) + node.add_child( + CmdTreeNode(OpCodes.RESET_SECONDARY_TM_SET, Info.RESET_SECONDARY_TM_SET) + ) + node.add_child(CmdTreeNode(OpCodes.FW_UPDATE, Info.FW_UPDATE)) + node.add_child( + CmdTreeNode(OpCodes.SET_TIME_FROM_SYS_TIME, Info.SET_TIME_FROM_SYS_TIME) + ) + return node + + @tmtc_definitions_provider def add_str_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/tcs/rtd.py b/eive_tmtc/tmtc/tcs/rtd.py index 5c24dea..6890284 100644 --- a/eive_tmtc/tmtc/tcs/rtd.py +++ b/eive_tmtc/tmtc/tcs/rtd.py @@ -5,7 +5,7 @@ import struct from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.pus_tm.defs import PrintWrapper from spacepackets.ecss import PusTelecommand -from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry +from tmtccmd.config import CmdTreeNode, TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.tmtc import DefaultPusQueueHelper @@ -95,6 +95,15 @@ class CmdInfo: WRITE_CONFIG = "Write config" +def create_rtd_node() -> CmdTreeNode: + node = CmdTreeNode("rtd", "RTD commands", hide_children_which_are_leaves=True) + node.add_child(CmdTreeNode(CmdStr.ON, CmdInfo.ON)) + node.add_child(CmdTreeNode(CmdStr.NORMAL, CmdInfo.NORMAL)) + node.add_child(CmdTreeNode(CmdStr.OFF, CmdInfo.OFF)) + node.add_child(CmdTreeNode(CmdStr.WRITE_CONFIG, CmdInfo.WRITE_CONFIG)) + return node + + @tmtc_definitions_provider def specify_rtd_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/tcs/tmp1075.py b/eive_tmtc/tmtc/tcs/tmp1075.py index 5b89251..f4105d3 100644 --- a/eive_tmtc/tmtc/tcs/tmp1075.py +++ b/eive_tmtc/tmtc/tcs/tmp1075.py @@ -8,6 +8,8 @@ import enum import struct +from tmtccmd.config import CmdTreeNode + from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.pus_tm.defs import PrintWrapper from spacepackets.ecss.tc import PusTelecommand @@ -71,6 +73,15 @@ def pack_tmp1075_test_into( return q +def create_tmp_sens_node() -> CmdTreeNode: + node = CmdTreeNode("tmp_1075", "TMP1075 Temperatur Sensors") + node.add_child(CmdTreeNode(CmdStr.OFF, CmdInfo.OFF)) + node.add_child(CmdTreeNode(CmdStr.ON, CmdInfo.ON)) + node.add_child(CmdTreeNode(CmdStr.NML, CmdInfo.NML)) + node.add_child(CmdTreeNode(CmdStr.HK, CmdInfo.HK)) + return node + + @tmtc_definitions_provider def add_tmp_sens_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() -- 2.43.0 From 35e25bf6d0f9a2c957e6db790e00447b290ab023 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Nov 2023 17:42:52 +0100 Subject: [PATCH 25/42] small fix for STR node --- eive_tmtc/tmtc/acs/star_tracker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eive_tmtc/tmtc/acs/star_tracker.py b/eive_tmtc/tmtc/acs/star_tracker.py index 754b0c1..8822a3e 100644 --- a/eive_tmtc/tmtc/acs/star_tracker.py +++ b/eive_tmtc/tmtc/acs/star_tracker.py @@ -1148,7 +1148,7 @@ def handle_read_secondary_tm_set(pw: PrintWrapper, custom_data: bytes): def create_str_node() -> CmdTreeNode: - node = CmdTreeNode("str", "Star Tracker Device") + node = CmdTreeNode("str", "Star Tracker Device", hide_children_which_are_leaves=True) node.add_child(CmdTreeNode(OpCodes.ON_BOOTLOADER, "Mode On, Submode Bootloader")) node.add_child(CmdTreeNode(OpCodes.ON_FIRMWARE, "Mode On, Submode Firmware")) node.add_child(CmdTreeNode(OpCodes.NORMAL, "Mode Normal")) -- 2.43.0 From 1660e27ec155480a638082202222f4d7cb2f7aae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Nov 2023 17:04:30 +0100 Subject: [PATCH 26/42] hopefully soon done --- eive_tmtc/config/hook.py | 18 ++--- eive_tmtc/tmtc/acs/star_tracker.py | 34 +++++----- eive_tmtc/tmtc/payload/ploc_supervisor.py | 2 +- eive_tmtc/tmtc/power/acu.py | 12 +++- eive_tmtc/tmtc/power/common_power.py | 59 +++++++++++++--- eive_tmtc/tmtc/power/p60dock.py | 15 +++++ eive_tmtc/tmtc/power/pdu1.py | 67 ++++++++++++++++-- eive_tmtc/tmtc/power/pdu2.py | 82 ++++++++++++++++++++++- eive_tmtc/tmtc/power/power.py | 18 ++++- 9 files changed, 266 insertions(+), 41 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index ea66912..e9f2ad8 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -24,6 +24,11 @@ from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node from eive_tmtc.tmtc.payload.plpcdu import create_pl_pcdu_node from eive_tmtc.tmtc.payload.scex import create_scex_node from eive_tmtc.tmtc.payload.subsystem import create_payload_subsystem_node +from eive_tmtc.tmtc.power.p60dock import create_p60_dock_node +from eive_tmtc.tmtc.power.power import create_power_node +from eive_tmtc.tmtc.power.acu import create_acu_node +from eive_tmtc.tmtc.power.pdu1 import create_pdu1_node +from eive_tmtc.tmtc.power.pdu2 import create_pdu2_node from eive_tmtc.tmtc.power.bpx_batt import create_bpx_batt_node from eive_tmtc.tmtc.power.pwr_ctrl import create_pwr_ctrl_node from eive_tmtc.tmtc.power.subsystem import create_eps_subsystem_node @@ -110,15 +115,12 @@ class EiveHookObject(HookBase): com_node.add_child(create_ccsds_node()) eps_node = create_eps_subsystem_node() - acu_node = CmdTreeNode("acu", "PCDU ACU component") - pdu_1_node = CmdTreeNode("pdu1", "PCDU PDU 1 component") - pdu_2_node = CmdTreeNode("pdu2", "PCDU PDU 2 component") - p60_dock_node = CmdTreeNode("p60_dock", "PCDU P60 Dock component") eps_node.add_child(create_pwr_ctrl_node()) - eps_node.add_child(acu_node) - eps_node.add_child(pdu_1_node) - eps_node.add_child(pdu_2_node) - eps_node.add_child(p60_dock_node) + eps_node.add_child(create_power_node()) + eps_node.add_child(create_acu_node()) + eps_node.add_child(create_pdu1_node()) + eps_node.add_child(create_pdu2_node()) + eps_node.add_child(create_p60_dock_node()) eps_node.add_child(create_bpx_batt_node()) payload_node = create_payload_subsystem_node() diff --git a/eive_tmtc/tmtc/acs/star_tracker.py b/eive_tmtc/tmtc/acs/star_tracker.py index f211085..3ade217 100644 --- a/eive_tmtc/tmtc/acs/star_tracker.py +++ b/eive_tmtc/tmtc/acs/star_tracker.py @@ -1159,35 +1159,35 @@ def create_str_node() -> CmdTreeNode: node = CmdTreeNode( "str", "Star Tracker Device", hide_children_which_are_leaves=True ) - node.add_child(CmdTreeNode(OpCodes.ON_BOOTLOADER, "Mode On, Submode Bootloader")) - node.add_child(CmdTreeNode(OpCodes.ON_FIRMWARE, "Mode On, Submode Firmware")) - node.add_child(CmdTreeNode(OpCodes.NORMAL, "Mode Normal")) - node.add_child(CmdTreeNode(OpCodes.OFF, "Mode Off")) - node.add_child(CmdTreeNode(OpCodes.PING, "Star Tracker: Ping")) - node.add_child(CmdTreeNode(OpCodes.TAKE_IMAGE, "Take Image")) - node.add_child(CmdTreeNode(OpCodes.UPLOAD_IMAGE, Info.UPLOAD_IMAGE)) - node.add_child(CmdTreeNode(OpCodes.DOWNLOAD_IMAGE, Info.DOWNLOAD_IMAGE)) - node.add_child(CmdTreeNode(OpCodes.ONE_SHOOT_HK, Info.ONE_SHOOT_HK)) - node.add_child(CmdTreeNode(OpCodes.ENABLE_HK, Info.ENABLE_HK)) - node.add_child(CmdTreeNode(OpCodes.DISABLE_HK, Info.DISABLE_HK)) + node.add_child(CmdTreeNode(OpCode.ON_BOOTLOADER, "Mode On, Submode Bootloader")) + node.add_child(CmdTreeNode(OpCode.ON_FIRMWARE, "Mode On, Submode Firmware")) + node.add_child(CmdTreeNode(OpCode.NORMAL, "Mode Normal")) + node.add_child(CmdTreeNode(OpCode.OFF, "Mode Off")) + node.add_child(CmdTreeNode(OpCode.PING, "Star Tracker: Ping")) + node.add_child(CmdTreeNode(OpCode.TAKE_IMAGE, "Take Image")) + node.add_child(CmdTreeNode(OpCode.UPLOAD_IMAGE, Info.UPLOAD_IMAGE)) + node.add_child(CmdTreeNode(OpCode.DOWNLOAD_IMAGE, Info.DOWNLOAD_IMAGE)) + node.add_child(CmdTreeNode(OpCode.ONE_SHOOT_HK, Info.ONE_SHOOT_HK)) + node.add_child(CmdTreeNode(OpCode.ENABLE_HK, Info.ENABLE_HK)) + node.add_child(CmdTreeNode(OpCode.DISABLE_HK, Info.DISABLE_HK)) node.add_child( - CmdTreeNode(OpCodes.SET_IMG_PROCESSOR_MODE, Info.SET_IMG_PROCESSOR_MODE) + CmdTreeNode(OpCode.SET_IMG_PROCESSOR_MODE, Info.SET_IMG_PROCESSOR_MODE) ) node.add_child( CmdTreeNode( - OpCodes.ADD_SECONDARY_TM_TO_NORMAL_MODE, + OpCode.ADD_SECONDARY_TM_TO_NORMAL_MODE, Info.ADD_SECONDARY_TM_TO_NORMAL_MODE, ) ) node.add_child( - CmdTreeNode(OpCodes.READ_SECONDARY_TM_SET, Info.READ_SECONDARY_TM_SET) + CmdTreeNode(OpCode.READ_SECONDARY_TM_SET, Info.READ_SECONDARY_TM_SET) ) node.add_child( - CmdTreeNode(OpCodes.RESET_SECONDARY_TM_SET, Info.RESET_SECONDARY_TM_SET) + CmdTreeNode(OpCode.RESET_SECONDARY_TM_SET, Info.RESET_SECONDARY_TM_SET) ) - node.add_child(CmdTreeNode(OpCodes.FW_UPDATE, Info.FW_UPDATE)) + node.add_child(CmdTreeNode(OpCode.FW_UPDATE, Info.FW_UPDATE)) node.add_child( - CmdTreeNode(OpCodes.SET_TIME_FROM_SYS_TIME, Info.SET_TIME_FROM_SYS_TIME) + CmdTreeNode(OpCode.SET_TIME_FROM_SYS_TIME, Info.SET_TIME_FROM_SYS_TIME) ) return node diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index 2c63a71..e5a2cd9 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -148,7 +148,7 @@ class Info(str, enum.Enum): value: str OFF = "Switch Off" ON = "Switch On" - NML = "Switch Normal" + NORMAL = "Switch Normal" HK_TO_OBC = "Request HK from PLOC SUPV" START_MPSOC = "Start MPSoC" SHUTDOWN_MPSOC = "Shutdown MPSoC" diff --git a/eive_tmtc/tmtc/power/acu.py b/eive_tmtc/tmtc/power/acu.py index ecfda8c..ba7a0c7 100644 --- a/eive_tmtc/tmtc/power/acu.py +++ b/eive_tmtc/tmtc/power/acu.py @@ -8,6 +8,7 @@ import struct from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.tmtc.power.common_power import ( + add_gomspace_nodes, pack_common_gomspace_cmds, add_gomspace_cmd_defs, req_hk_cmds, @@ -16,7 +17,7 @@ from eive_tmtc.tmtc.power.common_power import ( OBC_ENDIANNESS, unpack_array_in_data, ) -from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry +from tmtccmd.config import CmdTreeNode, TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.tmtc import DefaultPusQueueHelper @@ -50,6 +51,15 @@ class Info: TEST = "ACU Test" +def create_acu_node() -> CmdTreeNode: + node = CmdTreeNode( + "acu", "P60 PCDU ACU device", hide_children_which_are_leaves=True + ) + add_gomspace_nodes(node) + node.add_child(CmdTreeNode(OpCode.TEST[0], Info.TEST)) + return node + + @tmtc_definitions_provider def add_acu_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/power/common_power.py b/eive_tmtc/tmtc/power/common_power.py index f9d746d..0668e51 100644 --- a/eive_tmtc/tmtc/power/common_power.py +++ b/eive_tmtc/tmtc/power/common_power.py @@ -1,6 +1,6 @@ import enum import struct -from typing import List +from typing import List, Tuple from eive_tmtc.gomspace.gomspace_common import ( pack_set_u8_param_command, @@ -14,8 +14,7 @@ from eive_tmtc.gomspace.gomspace_common import ( pack_reboot_command, ) from eive_tmtc.gomspace.gomspace_pdu_definitions import OUT_ENABLE_LIST -from spacepackets.ecss import PusTelecommand -from tmtccmd.config import OpCodeEntry +from tmtccmd.config import CmdTreeNode, OpCodeEntry from tmtccmd.tmtc import DefaultPusQueueHelper from tmtccmd.pus.tc.s3_fsfw_hk import ( make_sid, @@ -258,7 +257,7 @@ def req_hk_cmds( q: DefaultPusQueueHelper, op_code: str, obj_id: bytes, - set_id_pair: [int, int], + set_id_pair: Tuple[int, int], ): if op_code in PowerOpCodes.REQUEST_CORE_HK_ONCE: q.add_log_cmd(f"{prefix}: {PowerInfo.REQUEST_CORE_HK_ONCE}") @@ -270,10 +269,6 @@ def req_hk_cmds( q.add_pus_tc(generate_one_hk_command(sid=hk_sid)) -def pack_pdu_disable_safe_off_cmd() -> PusTelecommand: - pass - - def generic_on_cmd( object_id: bytes, q: DefaultPusQueueHelper, info_str: str, out_idx: int ): @@ -311,6 +306,54 @@ def add_common_power_defs(oce: OpCodeEntry): oce.add(keys=PowerOpCodes.DISABLE_INFO_HK, info=PowerInfo.DISABLE_INFO_HK) +def add_gomspace_nodes(node: CmdTreeNode): + node.add_child( + CmdTreeNode( + PowerOpCodes.REQUEST_CORE_HK_ONCE[0], PowerInfo.REQUEST_CORE_HK_ONCE + ) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.REQUEST_AUX_HK_ONCE[0], PowerInfo.REQUEST_AUX_HK_ONCE) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.ENABLE_INFO_HK[0], PowerInfo.ENABLE_INFO_HK) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.DISABLE_INFO_HK[0], PowerInfo.DISABLE_INFO_HK) + ) + node.add_child( + CmdTreeNode( + PowerOpCodes.REQUEST_CORE_HK_ONCE[0], + PowerInfo.REQUEST_CORE_HK_ONCE, + ) + ) + node.add_child( + CmdTreeNode( + PowerOpCodes.REQUEST_AUX_HK_ONCE[0], + PowerInfo.REQUEST_AUX_HK_ONCE, + ) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.PRINT_LATCHUPS[0], PowerInfo.PRINT_LATCHUPS) + ) + node.add_child(CmdTreeNode(GomspaceOpCode.GET_PARAM[0], GsInfo.GET_PARAMETER)) + node.add_child(CmdTreeNode(GomspaceOpCode.REBOOT[0], GsInfo.REBOOT)) + node.add_child( + CmdTreeNode(GomspaceOpCode.SET_INTEGER_PARAM[0], GsInfo.SET_PARAMETER) + ) + node.add_child( + CmdTreeNode(GomspaceOpCode.REQUEST_CONFIG_TABLE[0], GsInfo.REQUEST_CONFIG_TABLE) + ) + node.add_child(CmdTreeNode(GomspaceOpCode.SAVE_TABLE[0], GsInfo.SAVE_TABLE)) + node.add_child( + CmdTreeNode(GomspaceOpCode.SAVE_TABLE_DEFAULT[0], GsInfo.SAVE_TABLE_DEFAULT) + ) + node.add_child(CmdTreeNode(GomspaceOpCode.LOAD_TABLE[0], GsInfo.LOAD_TABLE)) + node.add_child( + CmdTreeNode(GomspaceOpCode.RESET_GND_WATCHDOG[0], GsInfo.RESET_GND_WATCHDOG) + ) + + def add_gomspace_cmd_defs(oce: OpCodeEntry): oce.add( keys=PowerOpCodes.REQUEST_CORE_HK_ONCE, diff --git a/eive_tmtc/tmtc/power/p60dock.py b/eive_tmtc/tmtc/power/p60dock.py index f99b45f..cd63ec4 100644 --- a/eive_tmtc/tmtc/power/p60dock.py +++ b/eive_tmtc/tmtc/power/p60dock.py @@ -5,7 +5,9 @@ @author J. Meier @date 13.12.2020 """ +from tmtccmd.config import CmdTreeNode from eive_tmtc.tmtc.power.common_power import ( + add_gomspace_nodes, pack_common_gomspace_cmds, req_hk_cmds, pack_common_power_cmds, @@ -243,5 +245,18 @@ def pack_p60dock_cmds( # noqa C901: Complexity okay here. q.add_pus_tc(pack_set_u16_param_command(objb, invalid_address, parameter)) +def create_p60_dock_node() -> CmdTreeNode: + node = CmdTreeNode( + "p60_dock", "P60 PCDU dock device", hide_children_which_are_leaves=True + ) + add_gomspace_nodes(node) + node.add_child(CmdTreeNode(CmdString.STACK_3V3_ON, CmdInfo.STACK_3V3_ON)) + node.add_child(CmdTreeNode(CmdString.STACK_3V3_OFF, CmdInfo.STACK_3V3_OFF)) + node.add_child(CmdTreeNode(CmdString.STACK_5V_ON, CmdInfo.STACK_5V_ON)) + node.add_child(CmdTreeNode(CmdString.STACK_5V_OFF, CmdInfo.STACK_5V_OFF)) + node.add_child(CmdTreeNode(CmdString.TEST, "P60 Tests")) + return node + + def p60_dock_req_hk_cmds(q: DefaultPusQueueHelper, op_code: str): req_hk_cmds("P60 Dock", q, op_code, P60_DOCK_HANDLER, [SetId.CORE, SetId.AUX]) diff --git a/eive_tmtc/tmtc/power/pdu1.py b/eive_tmtc/tmtc/power/pdu1.py index fb3c627..6c113fb 100644 --- a/eive_tmtc/tmtc/power/pdu1.py +++ b/eive_tmtc/tmtc/power/pdu1.py @@ -14,6 +14,7 @@ from eive_tmtc.gomspace.gomspace_common import ( ) from eive_tmtc.gomspace.gomspace_pdu_definitions import PduHkTable from eive_tmtc.tmtc.power.common_power import ( + add_gomspace_nodes, pack_common_gomspace_cmds, req_hk_cmds, PowerOpCodes, @@ -23,14 +24,12 @@ from eive_tmtc.tmtc.power.common_power import ( create_generic_on_cmd, create_generic_off_cmd, pack_common_power_cmds, - GomspaceOpCode, - GsInfo, add_common_power_defs, SetId, ) from spacepackets.ecss import PusTelecommand -from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper +from tmtccmd.config import CmdTreeNode, OpCodeEntry, TmtcDefinitionWrapper from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.tmtc import DefaultPusQueueHelper from tmtccmd.util import ObjectIdU32 @@ -166,6 +165,67 @@ def add_pdu1_common_defs(oce: OpCodeEntry): oce.add(keys=PowerOpCodes.SCEX_OFF, info=info_off_pdu1(Pdu1InfoBase.SCEX)) +def add_pdu1_subnodes(node: CmdTreeNode): + node.add_child(CmdTreeNode(PowerOpCodes.TCS_ON[0], info_on_pdu1(Pdu1InfoBase.TCS))) + node.add_child( + CmdTreeNode(PowerOpCodes.TCS_OFF[0], info_off_pdu1(Pdu1InfoBase.TCS)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.STAR_TRACKER_ON[0], info_on_pdu1(Pdu1InfoBase.STR)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.STAR_TRACKER_OFF[0], info_off_pdu1(Pdu1InfoBase.STR)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.SUS_N_ON[0], info_on_pdu1(Pdu1InfoBase.SUS_N)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.SUS_N_OFF[0], info_off_pdu1(Pdu1InfoBase.SUS_N)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.ACS_A_ON[0], info_on_pdu1(Pdu1InfoBase.ACS_A)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.ACS_A_OFF[0], info_off_pdu1(Pdu1InfoBase.ACS_A)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.SYRLINKS_ON[0], info_on_pdu1(Pdu1InfoBase.SYRLINKS)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.SYRLINKS_OFF[0], info_off_pdu1(Pdu1InfoBase.SYRLINKS)) + ) + node.add_child(CmdTreeNode(PowerOpCodes.MGT_ON[0], info_on_pdu1(Pdu1InfoBase.MGT))) + node.add_child( + CmdTreeNode(PowerOpCodes.MGT_OFF[0], info_off_pdu1(Pdu1InfoBase.MGT)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.PLOC_ON[0], info_on_pdu1(Pdu1InfoBase.PLOC)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.PLOC_OFF[0], info_off_pdu1(Pdu1InfoBase.PLOC)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.SCEX_ON[0], info_on_pdu1(Pdu1InfoBase.SCEX)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.SCEX_OFF[0], info_off_pdu1(Pdu1InfoBase.SCEX)) + ) + + +def create_pdu1_node() -> CmdTreeNode: + node = CmdTreeNode( + "pdu1", "P60 PCDU PDU1 device", hide_children_which_are_leaves=True + ) + add_gomspace_nodes(node) + add_pdu1_subnodes(node) + node.add_child( + CmdTreeNode( + PowerOpCodes.PRINT_SWITCH_V_I[0], "PDU1: Print Switches, Voltages, Currents" + ) + ) + return node + + @tmtc_definitions_provider def add_pdu1_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() @@ -176,7 +236,6 @@ def add_pdu1_cmds(defs: TmtcDefinitionWrapper): keys=PowerOpCodes.PRINT_SWITCH_V_I, info="PDU1: Print Switches, Voltages, Currents", ) - oce.add(keys=GomspaceOpCode.GET_PARAM, info=GsInfo.GET_PARAMETER) defs.add_service( name=CustomServiceList.PDU1.value, diff --git a/eive_tmtc/tmtc/power/pdu2.py b/eive_tmtc/tmtc/power/pdu2.py index 82aa898..48da8a5 100644 --- a/eive_tmtc/tmtc/power/pdu2.py +++ b/eive_tmtc/tmtc/power/pdu2.py @@ -19,6 +19,7 @@ from eive_tmtc.gomspace.gomspace_common import ( ) from eive_tmtc.gomspace.gomspace_pdu_definitions import PduHkTable, PduConfigTable from eive_tmtc.tmtc.power.common_power import ( + add_gomspace_nodes, pack_common_gomspace_cmds, req_hk_cmds, PowerOpCodes, @@ -32,7 +33,7 @@ from eive_tmtc.tmtc.power.common_power import ( add_common_power_defs, ) from spacepackets.ecss import PusTelecommand -from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper +from tmtccmd.config import CmdTreeNode, OpCodeEntry, TmtcDefinitionWrapper from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.tmtc import DefaultPusQueueHelper from tmtccmd.util import ObjectIdU32 @@ -171,6 +172,85 @@ def add_pdu2_cmds(defs: TmtcDefinitionWrapper): ) +def add_pdu2_subnodes(node: CmdTreeNode): + node.add_child( + CmdTreeNode(PowerOpCodes.ACS_B_ON[0], info_on_pdu2(Pdu2InfoBase.ACS_B)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.ACS_B_OFF[0], info_off_pdu2(Pdu2InfoBase.ACS_B)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.SUS_R_ON[0], info_on_pdu2(Pdu2InfoBase.SUS_R)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.SUS_R_OFF[0], info_off_pdu2(Pdu2InfoBase.SUS_R)) + ) + node.add_child(CmdTreeNode(PowerOpCodes.RW_ON[0], info_on_pdu2(Pdu2InfoBase.RW))) + node.add_child(CmdTreeNode(PowerOpCodes.RW_OFF[0], info_off_pdu2(Pdu2InfoBase.RW))) + node.add_child( + CmdTreeNode( + PowerOpCodes.PL_PCDU_VBAT_NOM_ON[0], + info_on_pdu2(Pdu2InfoBase.PL_PCDU_BAT_NOM), + ) + ) + node.add_child( + CmdTreeNode( + PowerOpCodes.PL_PCDU_VBAT_NOM_OFF[0], + info_off_pdu2(Pdu2InfoBase.PL_PCDU_BAT_NOM), + ) + ) + node.add_child( + CmdTreeNode( + PowerOpCodes.PL_PCDU_VBAT_RED_ON[0], + info_on_pdu2(Pdu2InfoBase.PL_PCDU_BAT_RED), + ) + ) + node.add_child( + CmdTreeNode( + PowerOpCodes.PL_PCDU_VBAT_RED_OFF[0], + info_off_pdu2(Pdu2InfoBase.PL_PCDU_BAT_RED), + ) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.HEATER_ON[0], info_on_pdu2(Pdu2InfoBase.HEATER)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.HEATER_OFF[0], info_off_pdu2(Pdu2InfoBase.HEATER)) + ) + node.add_child( + CmdTreeNode( + PowerOpCodes.SOLAR_ARRAY_DEPL_ON[0], + info_on_pdu2(Pdu2InfoBase.SOLAR_ARRAY_DEPL), + ) + ) + node.add_child( + CmdTreeNode( + PowerOpCodes.SOLAR_ARRAY_DEPL_OFF[0], + info_off_pdu2(Pdu2InfoBase.SOLAR_ARRAY_DEPL), + ) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.PL_CAM_ON[0], info_on_pdu2(Pdu2InfoBase.PL_CAM)) + ) + node.add_child( + CmdTreeNode(PowerOpCodes.PL_CAM_OFF[0], info_off_pdu2(Pdu2InfoBase.PL_CAM)) + ) + + +def create_pdu2_node() -> CmdTreeNode: + node = CmdTreeNode( + "pdu2", "P60 PCDU PDU2 device", hide_children_which_are_leaves=True + ) + add_gomspace_nodes(node) + add_pdu2_subnodes(node) + node.add_child( + CmdTreeNode( + PowerOpCodes.PRINT_SWITCH_V_I[0], "PDU2: Print Switches, Voltages, Currents" + ) + ) + return node + + def pdu2_switch_cmds(q: DefaultPusQueueHelper, op_code: str): # noqa C901 if op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_ON: pl_pcdu_bat_nom_on_cmd(q) diff --git a/eive_tmtc/tmtc/power/power.py b/eive_tmtc/tmtc/power/power.py index 64ce23f..83f112b 100644 --- a/eive_tmtc/tmtc/power/power.py +++ b/eive_tmtc/tmtc/power/power.py @@ -16,18 +16,20 @@ from eive_tmtc.config.object_ids import ( get_object_ids, ) from eive_tmtc.tmtc.power.pdu1 import ( + add_pdu1_subnodes, pdu1_req_hk_cmds, pdu1_switch_cmds, add_pdu1_common_defs, add_pdu1_cmds, ) from eive_tmtc.tmtc.power.pdu2 import ( + add_pdu2_subnodes, pdu2_req_hk_cmds, add_pdu2_common_defs, pdu2_switch_cmds, add_pdu2_cmds, ) -from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry +from tmtccmd.config import CmdTreeNode, TmtcDefinitionWrapper, OpCodeEntry from eive_tmtc.config.object_ids import PCDU_HANDLER_ID from eive_tmtc.tmtc.power.p60dock import CmdString, CmdInfo, p60_dock_req_hk_cmds @@ -132,6 +134,20 @@ def add_p60_cmds(defs: TmtcDefinitionWrapper): ) +def create_power_node() -> CmdTreeNode: + node = CmdTreeNode("power", "Power commands", hide_children_which_are_leaves=True) + add_pdu1_subnodes(node) + add_pdu2_subnodes(node) + node.add_child(CmdTreeNode(PowerOpCodes.SWITCHER_HK[0], PowerInfo.SWITCHER_HK)) + node.add_child(CmdTreeNode(PowerOpCodes.INFO_ALL[0], PowerInfo.INFO_ALL)) + node.add_child(CmdTreeNode(PowerOpCodes.INFO_CORE[0], PowerInfo.INFO_CORE)) + node.add_child(CmdTreeNode(PowerOpCodes.INFO_AUX[0], PowerInfo.INFO_AUX)) + node.add_child( + CmdTreeNode(PowerOpCodes.RESET_ALL_GND_WDTS[0], PowerInfo.RESET_ALL_GND_WDTS) + ) + return node + + @tmtc_definitions_provider def add_power_cmd_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() -- 2.43.0 From 3da1c2c26281aa40376e413fa1adfe99b334404f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Nov 2023 17:27:24 +0100 Subject: [PATCH 27/42] add some more ACS devices --- eive_tmtc/config/hook.py | 52 +++++++++----------------- eive_tmtc/tmtc/acs/acs_board.py | 48 ++++++++++++++++++++++++ eive_tmtc/tmtc/acs/gyros.py | 11 ++++++ eive_tmtc/tmtc/acs/mgms.py | 9 ++++- eive_tmtc/tmtc/acs/reaction_wheels.py | 53 ++++++++++++++++++++++----- 5 files changed, 128 insertions(+), 45 deletions(-) diff --git a/eive_tmtc/config/hook.py b/eive_tmtc/config/hook.py index e9f2ad8..864b264 100644 --- a/eive_tmtc/config/hook.py +++ b/eive_tmtc/config/hook.py @@ -9,9 +9,16 @@ from tmtccmd.util import ObjectIdDictT, RetvalDictT from eive_tmtc.config.definitions import SPACE_PACKET_IDS from eive_tmtc.config.retvals import get_retval_dict +from eive_tmtc.tmtc.acs.acs_board import create_acs_board_node from eive_tmtc.tmtc.acs.acs_ctrl import create_acs_ctrl_node from eive_tmtc.tmtc.acs.gps import create_gnss_node +from eive_tmtc.tmtc.acs.gyros import create_gyros_node from eive_tmtc.tmtc.acs.imtq import create_mgt_node +from eive_tmtc.tmtc.acs.mgms import create_mgms_node +from eive_tmtc.tmtc.acs.reaction_wheels import ( + create_reaction_wheel_assembly_node, + create_reaction_wheels_nodes, +) from eive_tmtc.tmtc.acs.star_tracker import create_str_node from eive_tmtc.tmtc.acs.subsystem import create_acs_subsystem_node from eive_tmtc.tmtc.com.ccsds_handler import create_ccsds_node @@ -24,12 +31,12 @@ from eive_tmtc.tmtc.payload.ploc_supervisor import create_ploc_supv_node from eive_tmtc.tmtc.payload.plpcdu import create_pl_pcdu_node from eive_tmtc.tmtc.payload.scex import create_scex_node from eive_tmtc.tmtc.payload.subsystem import create_payload_subsystem_node -from eive_tmtc.tmtc.power.p60dock import create_p60_dock_node -from eive_tmtc.tmtc.power.power import create_power_node from eive_tmtc.tmtc.power.acu import create_acu_node +from eive_tmtc.tmtc.power.bpx_batt import create_bpx_batt_node +from eive_tmtc.tmtc.power.p60dock import create_p60_dock_node from eive_tmtc.tmtc.power.pdu1 import create_pdu1_node from eive_tmtc.tmtc.power.pdu2 import create_pdu2_node -from eive_tmtc.tmtc.power.bpx_batt import create_bpx_batt_node +from eive_tmtc.tmtc.power.power import create_power_node from eive_tmtc.tmtc.power.pwr_ctrl import create_pwr_ctrl_node from eive_tmtc.tmtc.power.subsystem import create_eps_subsystem_node from eive_tmtc.tmtc.system import create_system_node @@ -49,40 +56,16 @@ class EiveHookObject(HookBase): def get_command_definitions(self) -> CmdTreeNode: root_node = CmdTreeNode.root_node() - mode_node = CmdTreeNode("mode", "Mode Commands") - hk_node = CmdTreeNode("hk", "HK Commands") - action_node = CmdTreeNode("action", "Action Commands") - param_node = CmdTreeNode("params", "Parameter Commands") - health_node = CmdTreeNode("health", "Health Commands") - dev_node = CmdTreeNode("dev", "Device Commands") - dev_node.add_child(hk_node) - dev_node.add_child(mode_node) - dev_node.add_child(health_node) - dev_node.add_child(param_node) - # Not strictly necessary, but I do not know a single device which does not have actions.. - dev_node.add_child(action_node) - assy_node = CmdTreeNode("assy", "Assembly Commands") - assy_node.add_child(mode_node) - acs_node = create_acs_subsystem_node() - acs_brd_assy_node = CmdTreeNode("acs_brd_assy", "ACS Board Assembly") - acs_brd_assy_node.add_child(mode_node) - mgm_devs = CmdTreeNode("mgm_devs", "MGM Devices") - gyro_devs = CmdTreeNode("gyro_devs", "Gyro Devices") - acs_brd_assy_node.add_child(mgm_devs) - acs_brd_assy_node.add_child(gyro_devs) + acs_brd_assy_node = create_acs_board_node() + acs_brd_assy_node.add_child(create_mgms_node()) + acs_brd_assy_node.add_child(create_gyros_node()) acs_ctrl = create_acs_ctrl_node() + rw_list = create_reaction_wheels_nodes() rws = CmdTreeNode("rws", "Reaction Wheel Devices") - rw_assy = CmdTreeNode("rw_assy", "Reaction Wheel Assembly") - rw_1 = CmdTreeNode("rw_1", "Reaction Wheel 1") - rw_2 = CmdTreeNode("rw_2", "Reaction Wheel 2") - rw_3 = CmdTreeNode("rw_3", "Reaction Wheel 3") - rw_4 = CmdTreeNode("rw_4", "Reaction Wheel 4") - rws.add_child(rw_assy) - rws.add_child(rw_1) - rws.add_child(rw_2) - rws.add_child(rw_3) - rws.add_child(rw_4) + for rw in rw_list: + rws.add_child(rw) + rws.add_child(create_reaction_wheel_assembly_node()) star_tracker = create_str_node() star_tracker_img_helper = CmdTreeNode( "str_img_helper", "Star Tracker Image Helper" @@ -92,7 +75,6 @@ class EiveHookObject(HookBase): acs_node.add_child(acs_brd_assy_node) acs_node.add_child(acs_ctrl) - acs_node.add_child(mode_node) acs_node.add_child(rws) acs_node.add_child(create_mgt_node()) acs_node.add_child(star_tracker) diff --git a/eive_tmtc/tmtc/acs/acs_board.py b/eive_tmtc/tmtc/acs/acs_board.py index 7ac7bcc..97f60dd 100644 --- a/eive_tmtc/tmtc/acs/acs_board.py +++ b/eive_tmtc/tmtc/acs/acs_board.py @@ -1,6 +1,7 @@ import enum from tmtccmd.config.tmtc import ( + CmdTreeNode, OpCodeEntry, TmtcDefinitionWrapper, tmtc_definitions_provider, @@ -88,6 +89,53 @@ def pack_acs_command(q: DefaultPusQueueHelper, cmd_str: str): ) +def create_acs_board_node() -> CmdTreeNode: + node = CmdTreeNode("acs_brd", "ACS Board", hide_children_which_are_leaves=True) + node.add_child( + CmdTreeNode( + AcsOpCodes.ACS_ASS_A_SIDE[0], + "Switch to ACS board A side", + ) + ) + node.add_child( + CmdTreeNode( + AcsOpCodes.ACS_ASS_B_SIDE[0], + "Switch to ACS board B side", + ) + ) + node.add_child( + CmdTreeNode( + AcsOpCodes.ACS_ASS_DUAL_MODE[0], + "Switch to ACS board dual mode", + ) + ) + node.add_child( + CmdTreeNode( + AcsOpCodes.ACS_ASS_A_ON[0], + "Switch ACS board A side on", + ) + ) + node.add_child( + CmdTreeNode( + AcsOpCodes.ACS_ASS_B_ON[0], + "Switch ACS board B side on", + ) + ) + node.add_child( + CmdTreeNode( + AcsOpCodes.ACS_ASS_DUAL_ON[0], + "Switch ACS board dual mode on", + ) + ) + node.add_child( + CmdTreeNode( + AcsOpCodes.ACS_ASS_OFF[0], + "Switch off ACS board", + ) + ) + return node + + @tmtc_definitions_provider def add_acs_board_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/acs/gyros.py b/eive_tmtc/tmtc/acs/gyros.py index 11da367..a66b23d 100644 --- a/eive_tmtc/tmtc/acs/gyros.py +++ b/eive_tmtc/tmtc/acs/gyros.py @@ -3,6 +3,7 @@ import logging import struct from spacepackets.ecss import PusTelecommand +from tmtccmd.config import CmdTreeNode from tmtccmd.tmtc import DefaultPusQueueHelper from tmtccmd.pus.s201_fsfw_health import pack_set_health_cmd_data, FsfwHealth from tmtccmd.pus.s201_fsfw_health import Subservice @@ -177,6 +178,16 @@ def handle_l3g_gyro_hk( pw.dlog(f"Temperature {temp} °C") +def create_gyros_node() -> CmdTreeNode: + node = CmdTreeNode("gyros", "Gyroscope devices") + node.add_child(CmdTreeNode(OpCode.CORE_HK, "Request Core HK")) + node.add_child(CmdTreeNode(OpCode.CFG_HK, "Request CFG HK")) + node.add_child(CmdTreeNode(OpCode.NML, "Normal Mode")) + node.add_child(CmdTreeNode(OpCode.OFF, "Off Mode")) + node.add_child(CmdTreeNode(OpCode.SET_FAULTY, "Set Faulty")) + return node + + @tmtc_definitions_provider def add_gyr_cmd_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/acs/mgms.py b/eive_tmtc/tmtc/acs/mgms.py index f6f877b..c262937 100644 --- a/eive_tmtc/tmtc/acs/mgms.py +++ b/eive_tmtc/tmtc/acs/mgms.py @@ -2,7 +2,7 @@ import enum import struct from eive_tmtc.config.definitions import CustomServiceList -from tmtccmd.config import OpCodeEntry +from tmtccmd.config import CmdTreeNode, OpCodeEntry import eive_tmtc.config.object_ids as obj_ids from eive_tmtc.config.object_ids import ( @@ -107,6 +107,13 @@ def handle_mgm_rm3100_hk_data( ) +def create_mgms_node() -> CmdTreeNode: + node = CmdTreeNode("mgms", "Magnetometer devices") + node.add_child(CmdTreeNode(OpCode.NORMAL, "Normal Mode")) + node.add_child(CmdTreeNode(OpCode.OFF, "Off Mode")) + return node + + @tmtc_definitions_provider def add_mgm_cmd_defs(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() diff --git a/eive_tmtc/tmtc/acs/reaction_wheels.py b/eive_tmtc/tmtc/acs/reaction_wheels.py index 5f07864..ec635c2 100644 --- a/eive_tmtc/tmtc/acs/reaction_wheels.py +++ b/eive_tmtc/tmtc/acs/reaction_wheels.py @@ -10,7 +10,7 @@ from typing import List from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.config.object_ids import RW1_ID, RW2_ID, RW3_ID, RW4_ID -from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry +from tmtccmd.config import CmdTreeNode, TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.tmtc import DefaultPusQueueHelper from tmtccmd.pus.tc.s3_fsfw_hk import ( @@ -53,11 +53,11 @@ class InfoDev: class OpCodesAss: - ON = ["0", "on"] - NML = ["1", "nml"] - OFF = ["2", "off"] - ALL_SPEED_UP = ["3", "speed_up"] - ALL_SPEED_OFF = ["4", "speed_off"] + ON = "on" + NML = "nml" + OFF = "off" + ALL_SPEED_UP = "speed_up" + ALL_SPEED_OFF = "speed_off" class ActionId: @@ -99,6 +99,41 @@ class RampTime: MS_1000 = 1000 +def create_reaction_wheels_nodes() -> List[CmdTreeNode]: + nodes = [] + for i in range(4): + next_node = CmdTreeNode( + f"rw_{i}", f"Reaction Wheel {i}", hide_children_which_are_leaves=True + ) + next_node.add_child(CmdTreeNode(InfoDev.SPEED, OpCodesDev.SPEED)) + next_node.add_child(CmdTreeNode(InfoDev.ON, OpCodesDev.ON)) + next_node.add_child(CmdTreeNode(InfoDev.OFF, OpCodesDev.OFF)) + next_node.add_child(CmdTreeNode(InfoDev.NML, OpCodesDev.NML)) + next_node.add_child(CmdTreeNode(InfoDev.REQ_TM, OpCodesDev.REQ_TM)) + next_node.add_child(CmdTreeNode(InfoDev.GET_STATUS, OpCodesDev.GET_STATUS)) + next_node.add_child(CmdTreeNode(InfoDev.GET_TM, OpCodesDev.GET_TM)) + next_node.add_child( + CmdTreeNode(InfoDev.ENABLE_STATUS_HK, OpCodesDev.ENABLE_STATUS_HK) + ) + next_node.add_child( + CmdTreeNode(InfoDev.DISABLE_STATUS_HK, OpCodesDev.DISABLE_STATUS_HK) + ) + nodes.append(next_node) + return nodes + + +def create_reaction_wheel_assembly_node() -> CmdTreeNode: + node = CmdTreeNode( + "rw_assy", "Reaction Wheels Assembly", hide_children_which_are_leaves=True + ) + node.add_child(CmdTreeNode(InfoAss.ON, OpCodesAss.ON)) + node.add_child(CmdTreeNode(InfoAss.NML, OpCodesAss.NML)) + node.add_child(CmdTreeNode(InfoAss.OFF, OpCodesAss.OFF)) + node.add_child(CmdTreeNode(InfoAss.ALL_SPEED_UP, OpCodesAss.ALL_SPEED_UP)) + node.add_child(CmdTreeNode(InfoAss.ALL_SPEED_OFF, OpCodesAss.ALL_SPEED_OFF)) + return node + + @tmtc_definitions_provider def add_rw_cmds(defs: TmtcDefinitionWrapper): oce = OpCodeEntry() @@ -182,14 +217,14 @@ def create_single_rw_cmd( # noqa C901: Complexity is okay here. q.add_pus_tc( create_action_cmd(object_id=object_id, action_id=ActionId.REQUEST_TM) ) - if cmd_str in OpCodesDev.GET_STATUS: + if cmd_str == OpCodesDev.GET_STATUS: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.GET_STATUS}") q.add_pus_tc( generate_one_diag_command( sid=make_sid(object_id=object_id, set_id=RwSetId.STATUS_SET_ID) ) ) - if cmd_str in OpCodesDev.ENABLE_STATUS_HK: + if cmd_str == OpCodesDev.ENABLE_STATUS_HK: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.ENABLE_STATUS_HK}") interval = float(input("Please enter HK interval in floating point seconds: ")) cmds = enable_periodic_hk_command_with_interval( @@ -197,7 +232,7 @@ def create_single_rw_cmd( # noqa C901: Complexity is okay here. ) for cmd in cmds: q.add_pus_tc(cmd) - if cmd_str in OpCodesDev.DISABLE_STATUS_HK: + if cmd_str == OpCodesDev.DISABLE_STATUS_HK: q.add_log_cmd(f"RW {rw_idx}: {InfoDev.DISABLE_STATUS_HK}") q.add_pus_tc( disable_periodic_hk_command( -- 2.43.0 From eb302e5cf16115628ea1d179341cc3a4bc40764b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Nov 2023 18:33:09 +0100 Subject: [PATCH 28/42] use released version of tmtccmd --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3bb074a..29b78e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,8 +29,8 @@ classifiers = [ "Topic :: Scientific/Engineering" ] dependencies = [ - # "tmtccmd ~= 8.0.0rc0", - "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@main", + "tmtccmd ~= 8.0.0rc0", + # "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@main", "python-dateutil ~= 2.8", ] -- 2.43.0 From f1f4a1e9a04967f74f94a7441668b04bb47f5a2b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 30 Nov 2023 10:16:29 +0100 Subject: [PATCH 29/42] prepare next release --- CHANGELOG.md | 2 ++ pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0867215..279e5bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ list yields a list of all related PRs for each release. # [unreleased] +# [v5.11.0] 2023-11-30 + ## Added - Added new commands to disable channel order checks partially for the payload PCDU normal modes. diff --git a/pyproject.toml b/pyproject.toml index b9017d4..57362e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "eive-tmtc" description = "TMTC Commander EIVE" readme = "README.md" -version = "5.10.1" +version = "5.11.0" requires-python = ">=3.10" license = {text = "Apache-2.0"} authors = [ -- 2.43.0 From c1f4a3f59d53fb0045f953a73e5b9dfb6ca8cb6f Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 1 Dec 2023 13:01:14 +0100 Subject: [PATCH 30/42] more health --- eive_tmtc/tmtc/obj_prompt.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/eive_tmtc/tmtc/obj_prompt.py b/eive_tmtc/tmtc/obj_prompt.py index 659bead..c472a01 100644 --- a/eive_tmtc/tmtc/obj_prompt.py +++ b/eive_tmtc/tmtc/obj_prompt.py @@ -4,6 +4,7 @@ from eive_tmtc.config.object_ids import ( GPS_0_HEALTH_DEV, GYRO_0_ADIS_HANDLER_ID, GYRO_1_L3G_HANDLER_ID, + GYRO_2_ADIS_HANDLER_ID, ACS_BOARD_ASS_ID, RW_ASSEMBLY, SUS_BOARD_ASS_ID, @@ -38,14 +39,15 @@ ACS_OBJ_DICT = { 5: ("iMTQ MGT", IMTQ_HANDLER_ID), 6: ("GYR 0 ADIS", GYRO_0_ADIS_HANDLER_ID), 7: ("GYR 1 L3G", GYRO_1_L3G_HANDLER_ID), - 8: ("MGM 0 LIS3", MGM_0_LIS3_HANDLER_ID), - 9: ("MGM 1 RM3100", MGM_1_RM3100_HANDLER_ID), - 10: ("GPS 0 Health Device", GPS_0_HEALTH_DEV), - 11: ("SUS 0", SUS_0_N_LOC_XFYFZM_PT_XF), - 12: ("SUS 6", SUS_6_R_LOC_XFYBZM_PT_XF), - 13: ("RW 1", RW1_ID), - 14: ("RW 2", RW2_ID), - 15: ("STR", STAR_TRACKER_ID), + 8: ("GYR 2 ADIS", GYRO_2_ADIS_HANDLER_ID), + 9: ("MGM 0 LIS3", MGM_0_LIS3_HANDLER_ID), + 10: ("MGM 1 RM3100", MGM_1_RM3100_HANDLER_ID), + 11: ("GPS 0 Health Device", GPS_0_HEALTH_DEV), + 12: ("SUS 0", SUS_0_N_LOC_XFYFZM_PT_XF), + 13: ("SUS 6", SUS_6_R_LOC_XFYBZM_PT_XF), + 14: ("RW 1", RW1_ID), + 15: ("RW 2", RW2_ID), + 16: ("STR", STAR_TRACKER_ID), } TCS_OBJ_DICT = { -- 2.43.0 From 77010937b869705e8ec347b872f8511403218a92 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 1 Dec 2023 13:01:31 +0100 Subject: [PATCH 31/42] tle action reply --- eive_tmtc/tmtc/acs/acs_ctrl.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index dcd74e9..7d0bef3 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -65,6 +65,7 @@ class ActionId(enum.IntEnum): RESET_MEKF = 1 RESTORE_MEKF_NONFINITE_RECOVERY = 2 UPDATE_TLE = 3 + READ_TLE = 4 CTRL_STRAT_DICT = { @@ -110,6 +111,7 @@ class OpCodes: RESET_MEKF = ["reset_mekf"] RESTORE_MEKF_NONFINITE_RECOVERY = ["restore_mekf_nonfinite_recovery"] UPDATE_TLE = ["update_tle"] + READ_TLE = ["read_tle"] SET_PARAMETER_SCALAR = ["set_scalar_param"] SET_PARAMETER_VECTOR = ["set_vector_param"] SET_PARAMETER_MATRIX = ["set_matrix_param"] @@ -161,6 +163,7 @@ class Info: RESET_MEKF = "Reset the MEKF" RESTORE_MEKF_NONFINITE_RECOVERY = "Restore MEKF non-finite recovery" UPDATE_TLE = "Update TLE" + READ_TLE = "Read the currently stored TLE" SET_PARAMETER_SCALAR = "Set Scalar Parameter" SET_PARAMETER_VECTOR = "Set Vector Parameter" SET_PARAMETER_MATRIX = "Set Matrix Parameter" @@ -229,6 +232,7 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): info=Info.RESTORE_MEKF_NONFINITE_RECOVERY, ) oce.add(keys=OpCodes.UPDATE_TLE, info=Info.UPDATE_TLE) + oce.add(keys=OpCodes.READ_TLE, info=Info.READ_TLE) oce.add(keys=OpCodes.SET_PARAMETER_SCALAR, info=Info.SET_PARAMETER_SCALAR) oce.add(keys=OpCodes.SET_PARAMETER_VECTOR, info=Info.SET_PARAMETER_VECTOR) oce.add(keys=OpCodes.SET_PARAMETER_MATRIX, info=Info.SET_PARAMETER_MATRIX) @@ -333,6 +337,9 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 print("The line does not have the required length of 69 characters") tle = line1.encode() + line2.encode() q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.UPDATE_TLE, tle)) + elif op_code in OpCodes.READ_TLE: + q.add_log_cmd(f"{Info.READ_TLE}") + q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.READ_TLE)) elif op_code in OpCodes.SET_PARAMETER_SCALAR: q.add_log_cmd(f"{Info.SET_PARAMETER_SCALAR}") set_acs_ctrl_param_scalar(q) @@ -1247,6 +1254,22 @@ def handle_fused_rot_rate_data(pw: PrintWrapper, hk_data: bytes): FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3) +def handle_acs_ctrl_action_replies( + action_id: int, pw: PrintWrapper, custom_data: bytes +): + if action_id == ActionId.READ_TLE: + handle_read_tle(pw, custom_data) + + +def handle_read_tle(pw: PrintWrapper, custom_data: bytes): + pw.dlog("Received TLE") + data_length = 69 * 2 + if len(custom_data) != data_length: + raise ValueError(f"Received data of unexpected length {len(custom_data)}") + tle = custom_data.decode() + pw.dlog(f"{tle[0:69]}\n{tle[69:69*2]}") + + def perform_mgm_calibration( # noqa C901: Complexity okay pw: PrintWrapper, mgm_tuple: Tuple ): # noqa C901: Complexity okay -- 2.43.0 From 35e3f8b572fd521580ce1db371f79489c03dad51 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 1 Dec 2023 13:02:23 +0100 Subject: [PATCH 32/42] call action reply handling --- eive_tmtc/pus_tm/action_reply_handler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eive_tmtc/pus_tm/action_reply_handler.py b/eive_tmtc/pus_tm/action_reply_handler.py index 32730e3..aadccd8 100644 --- a/eive_tmtc/pus_tm/action_reply_handler.py +++ b/eive_tmtc/pus_tm/action_reply_handler.py @@ -10,6 +10,7 @@ from eive_tmtc.config.object_ids import ( CORE_CONTROLLER_ID, STAR_TRACKER_ID, P60_DOCK_HANDLER, + ACS_CONTROLLER, ) from eive_tmtc.tmtc.acs.imtq import ImtqActionId from eive_tmtc.pus_tm.defs import PrintWrapper @@ -17,6 +18,7 @@ from eive_tmtc.tmtc.core import handle_core_ctrl_action_replies from eive_tmtc.tmtc.payload.ploc_mpsoc import handle_mpsoc_data_reply from eive_tmtc.tmtc.payload.ploc_supervisor import SupvActionId from eive_tmtc.tmtc.acs.star_tracker import handle_star_tracker_action_replies +from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_action_replies from eive_tmtc.tmtc.power.tm import handle_get_param_data_reply from tmtccmd.pus.s8_fsfw_action import Service8FsfwTm from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter @@ -53,6 +55,8 @@ def handle_action_reply( return handle_core_ctrl_action_replies(action_id, pw, custom_data) elif object_id.as_bytes == STAR_TRACKER_ID: return handle_star_tracker_action_replies(action_id, pw, custom_data) + elif object_id.as_bytes == ACS_CONTROLLER: + return handle_acs_ctrl_action_replies(action_id, pw, custom_data) elif object_id.as_bytes in [ ACU_HANDLER_ID, PDU_1_HANDLER_ID, -- 2.43.0 From e7e97ff2d34015bc7a8a947cd831ccb4c0c5c3c9 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 1 Dec 2023 13:03:38 +0100 Subject: [PATCH 33/42] i never pushed this lul --- eive_tmtc/pus_tm/hk_handler.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eive_tmtc/pus_tm/hk_handler.py b/eive_tmtc/pus_tm/hk_handler.py index 8391f69..949d165 100644 --- a/eive_tmtc/pus_tm/hk_handler.py +++ b/eive_tmtc/pus_tm/hk_handler.py @@ -13,6 +13,7 @@ from eive_tmtc.tmtc.payload.rad_sensor import handle_rad_sensor_data from eive_tmtc.tmtc.acs.sus import handle_sus_hk from eive_tmtc.tmtc.payload.ploc_supervisor import handle_supv_hk_data from eive_tmtc.tmtc.acs.reaction_wheels import handle_rw_hk_data +from eive_tmtc.tmtc.power.pwr_ctrl import handle_pwr_ctrl_hk_data from eive_tmtc.tmtc.com.syrlinks_handler import handle_syrlinks_hk_data from eive_tmtc.tmtc.tcs import handle_thermal_controller_hk_data from eive_tmtc.tmtc.tcs.tmp1075 import handle_tmp_1075_hk_data @@ -201,6 +202,10 @@ def handle_regular_hk_print( # noqa C901: Complexity okay here return handle_acs_ctrl_hk_data( pw=pw, set_id=set_id, hk_data=hk_data, packet_time=packet_dt ) + elif objb == obj_ids.PWR_CONTROLLER: + return handle_pwr_ctrl_hk_data( + pw=pw, set_id=set_id, hk_data=hk_data, packet_time=packet_dt + ) else: _LOGGER.info( f"Service 3 TM: Parsing for object {object_id} and set ID {set_id} " -- 2.43.0 From 8de88127c3f92adbaa3c6eb07ceae83743839aa1 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 5 Dec 2023 09:57:07 +0100 Subject: [PATCH 34/42] this is much better --- eive_tmtc/tmtc/acs/acs_ctrl.py | 462 ++++++++------------------------- 1 file changed, 108 insertions(+), 354 deletions(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 7d0bef3..f281b54 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -29,9 +29,9 @@ from tmtccmd.pus.s20_fsfw_param_defs import ( from tmtccmd.pus.s200_fsfw_mode import Mode, pack_mode_command from tmtccmd.pus.tc.s3_fsfw_hk import ( create_request_one_diag_command, + create_request_one_hk_command, disable_periodic_hk_command, enable_periodic_hk_command_with_interval, - generate_one_hk_command, make_sid, ) from tmtccmd.tmtc import service_provider @@ -54,10 +54,17 @@ class SetId(enum.IntEnum): GYR_RAW_SET = 4 GYR_PROC_SET = 5 GPS_PROC_SET = 6 - MEKF_DATA = 7 + ATTITUDE_ESTIMATION_DATA = 7 CTRL_VAL_DATA = 8 ACTUATOR_CMD_DATA = 9 FUSED_ROT_RATE_DATA = 10 + FUSED_ROT_RATE_SOURCE_DATA = 11 + + +class DataSetRequest(enum.IntEnum): + ONESHOT = 0 + ENABLE = 1 + DISABLE = 2 class ActionId(enum.IntEnum): @@ -99,55 +106,25 @@ GPS_COURCE_DICT = { class OpCodes: - OFF = ["off"] - 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"] - RESTORE_MEKF_NONFINITE_RECOVERY = ["restore_mekf_nonfinite_recovery"] - UPDATE_TLE = ["update_tle"] - READ_TLE = ["read_tle"] - SET_PARAMETER_SCALAR = ["set_scalar_param"] - SET_PARAMETER_VECTOR = ["set_vector_param"] - SET_PARAMETER_MATRIX = ["set_matrix_param"] - REQUEST_RAW_MGM_HK = ["mgm_raw_hk"] - ENABLE_RAW_MGM_HK = ["mgm_raw_enable_hk"] - DISABLE_RAW_MGM_HK = ["mgm_raw_disable_hk"] - REQUEST_PROC_MGM_HK = ["mgm_proc_hk"] - ENABLE_PROC_MGM_HK = ["mgm_proc_enable_hk"] - DISABLE_PROC_MGM_HK = ["mgm_proc_disable_hk"] - REQUEST_RAW_SUS_HK = ["sus_raw_hk"] - ENABLE_RAW_SUS_HK = ["sus_raw_enable_hk"] - DISABLE_RAW_SUS_HK = ["sus_raw_disable_hk"] - REQUEST_PROC_SUS_HK = ["sus_proc_hk"] - ENABLE_PROC_SUS_HK = ["sus_proc_enable_hk"] - DISABLE_PROC_SUS_HK = ["sus_proc_disable_hk"] - REQUEST_RAW_GYR_HK = ["gyr_raw_hk"] - ENABLE_RAW_GYR_HK = ["gyr_raw_enable_hk"] - DISABLE_RAW_GYR_HK = ["gyr_raw_disable_hk"] - REQUEST_PROC_GYR_HK = ["gyr_proc_hk"] - ENABLE_PROC_GYR_HK = ["gyr_proc_enable_hk"] - DISABLE_PROC_GYR_HK = ["gyr_proc_disable_hk"] - REQUEST_PROC_GPS_HK = ["gps_proc_hk"] - ENABLE_PROC_GPS_HK = ["gps_proc_enable_hk"] - DISABLE_PROC_GPS_HK = ["gps_proc_disable_hk"] - REQUEST_MEKF_HK = ["mekf_hk"] - ENABLE_MEKF_HK = ["mekf_enable_hk"] - DISABLE_MEKF_HK = ["mekf_disable_hk"] - REQUEST_CTRL_VAL_HK = ["ctrl_val_hk"] - ENABLE_CTRL_VAL_HK = ["ctrl_val_enable_hk"] - DISABLE_CTRL_VAL_HK = ["ctrl_val_disable_hk"] - REQUEST_ACT_CMD_HK = ["act_cmd_hk"] - ENABLE_ACT_CMD_HK = ["act_cmd_enable_hk"] - DISABLE_ACT_CMD_HK = ["act_cmd_disable_hk"] - REQUEST_FUSED_ROT_RATE_HK = ["f_rot_rate_hk"] - ENABLE_FUSED_ROT_RATE_HK = ["f_rot_rate_enable_hk"] - DISABLE_FUSED_ROT_RATE_HK = ["f_rot_rate_disable_hk"] + OFF = "off" + 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" + RESTORE_MEKF_NONFINITE_RECOVERY = "restore_mekf_nonfinite_recovery" + UPDATE_TLE = "update_tle" + READ_TLE = "read_tle" + SET_PARAMETER_SCALAR = "set_scalar_param" + SET_PARAMETER_VECTOR = "set_vector_param" + SET_PARAMETER_MATRIX = "set_matrix_param" + ONE_SHOOT_HK = "one_shot_hk" + ENABLE_HK = "enable_hk" + DISABLE_HK = "disable_hk" class Info: @@ -167,39 +144,9 @@ class Info: SET_PARAMETER_SCALAR = "Set Scalar Parameter" SET_PARAMETER_VECTOR = "Set Vector Parameter" SET_PARAMETER_MATRIX = "Set Matrix Parameter" - REQUEST_RAW_MGM_HK = "Request Raw MGM HK once" - ENABLE_RAW_MGM_HK = "Enable Raw MGM HK data generation" - DISABLE_RAW_MGM_HK = "Disable Raw MGM HK data generation" - REQUEST_PROC_MGM_HK = "Request Processed MGM HK" - ENABLE_PROC_MGM_HK = "Enable Processed MGM HK data generation" - DISABLE_PROC_MGM_HK = "Disable Processed MGM HK data generation" - REQUEST_RAW_SUS_HK = "Request Raw SUS HK" - ENABLE_RAW_SUS_HK = "Enable Raw SUS HK data generation" - DISABLE_RAW_SUS_HK = "Disable Raw SUS HK data generation" - REQUEST_PROC_SUS_HK = "Request Processed SUS HK" - ENABLE_PROC_SUS_HK = "Enable Processed SUS HK data generation" - DISABLE_PROC_SUS_HK = "Disable Processed MGM HK data generation" - REQUEST_RAW_GYR_HK = "Request Raw GYR HK" - ENABLE_RAW_GYR_HK = "Enable Raw GYR HK data generation" - DISABLE_RAW_GYR_HK = "Disable Raw GYR HK data generation" - REQUEST_PROC_GYR_HK = "Request Processed GYR HK" - ENABLE_PROC_GYR_HK = "Enable Processed GYR HK data generation" - DISABLE_PROC_GYR_HK = "Disable Processed GYR HK data generation" - REQUEST_PROC_GPS_HK = "Request Processed GPS HK" - ENABLE_PROC_GPS_HK = "Enable Processed GPS HK data generation" - DISABLE_PROC_GPS_HK = "Disable Processed GPS HK data generation" - REQUEST_MEKF_HK = "Request MEKF HK" - ENABLE_MEKF_HK = "Enable MEKF HK data generation" - DISABLE_MEKF_HK = "Disable MEKF HK data generation" - REQUEST_CTRL_VAL_HK = "Request Control Values HK" - ENABLE_CTRL_VAL_HK = "Enable Control Values HK data generation" - DISABLE_CTRL_VAL_HK = "Disable Control Values HK data generation" - REQUEST_ACT_CMD_HK = "Request Actuator Commands HK" - ENABLE_ACT_CMD_HK = "Enable Actuator Commands HK data generation" - DISABLE_ACT_CMD_HK = "Disable Actuator Commands HK data generation" - REQUEST_FUSED_ROT_RATE_HK = "Request Fused Rotational Rates HK" - ENABLE_FUSED_ROT_RATE_HK = "Enable Fused Rotational Rates HK data generation" - DISABLE_FUSED_ROT_RATE_HK = "Disable Fused Rotational Rates HK data generation" + ONE_SHOOT_HK = "One shoot HK Set" + ENABLE_HK = "Enable Periodic HK" + DISABLE_HK = "Disable Periodic HK" PERFORM_MGM_CALIBRATION = False @@ -236,39 +183,9 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): oce.add(keys=OpCodes.SET_PARAMETER_SCALAR, info=Info.SET_PARAMETER_SCALAR) oce.add(keys=OpCodes.SET_PARAMETER_VECTOR, info=Info.SET_PARAMETER_VECTOR) oce.add(keys=OpCodes.SET_PARAMETER_MATRIX, info=Info.SET_PARAMETER_MATRIX) - oce.add(keys=OpCodes.REQUEST_RAW_MGM_HK, info=Info.REQUEST_RAW_MGM_HK) - oce.add(keys=OpCodes.ENABLE_RAW_MGM_HK, info=Info.ENABLE_RAW_MGM_HK) - oce.add(keys=OpCodes.DISABLE_RAW_MGM_HK, info=Info.DISABLE_RAW_MGM_HK) - oce.add(keys=OpCodes.REQUEST_PROC_MGM_HK, info=Info.REQUEST_PROC_MGM_HK) - oce.add(keys=OpCodes.ENABLE_PROC_MGM_HK, info=Info.ENABLE_PROC_MGM_HK) - oce.add(keys=OpCodes.DISABLE_PROC_MGM_HK, info=Info.DISABLE_PROC_MGM_HK) - oce.add(keys=OpCodes.REQUEST_RAW_SUS_HK, info=Info.REQUEST_RAW_SUS_HK) - oce.add(keys=OpCodes.ENABLE_RAW_SUS_HK, info=Info.ENABLE_RAW_SUS_HK) - oce.add(keys=OpCodes.DISABLE_RAW_SUS_HK, info=Info.DISABLE_RAW_SUS_HK) - oce.add(keys=OpCodes.REQUEST_PROC_SUS_HK, info=Info.REQUEST_PROC_SUS_HK) - oce.add(keys=OpCodes.ENABLE_PROC_SUS_HK, info=Info.ENABLE_PROC_SUS_HK) - oce.add(keys=OpCodes.DISABLE_PROC_SUS_HK, info=Info.DISABLE_PROC_SUS_HK) - oce.add(keys=OpCodes.REQUEST_RAW_GYR_HK, info=Info.REQUEST_RAW_GYR_HK) - oce.add(keys=OpCodes.ENABLE_RAW_GYR_HK, info=Info.ENABLE_RAW_GYR_HK) - oce.add(keys=OpCodes.DISABLE_RAW_GYR_HK, info=Info.DISABLE_RAW_GYR_HK) - oce.add(keys=OpCodes.REQUEST_PROC_GYR_HK, info=Info.REQUEST_PROC_GYR_HK) - oce.add(keys=OpCodes.ENABLE_PROC_GYR_HK, info=Info.ENABLE_PROC_GYR_HK) - oce.add(keys=OpCodes.DISABLE_PROC_GYR_HK, info=Info.DISABLE_PROC_GYR_HK) - oce.add(keys=OpCodes.REQUEST_PROC_GPS_HK, info=Info.REQUEST_PROC_GPS_HK) - oce.add(keys=OpCodes.ENABLE_PROC_GPS_HK, info=Info.ENABLE_PROC_GPS_HK) - oce.add(keys=OpCodes.DISABLE_PROC_GPS_HK, info=Info.DISABLE_PROC_GPS_HK) - oce.add(keys=OpCodes.REQUEST_MEKF_HK, info=Info.REQUEST_MEKF_HK) - oce.add(keys=OpCodes.ENABLE_MEKF_HK, info=Info.ENABLE_MEKF_HK) - oce.add(keys=OpCodes.DISABLE_MEKF_HK, info=Info.DISABLE_MEKF_HK) - oce.add(keys=OpCodes.REQUEST_CTRL_VAL_HK, info=Info.REQUEST_CTRL_VAL_HK) - oce.add(keys=OpCodes.ENABLE_CTRL_VAL_HK, info=Info.ENABLE_CTRL_VAL_HK) - oce.add(keys=OpCodes.DISABLE_CTRL_VAL_HK, info=Info.DISABLE_CTRL_VAL_HK) - oce.add(keys=OpCodes.REQUEST_ACT_CMD_HK, info=Info.REQUEST_ACT_CMD_HK) - oce.add(keys=OpCodes.ENABLE_ACT_CMD_HK, info=Info.ENABLE_ACT_CMD_HK) - oce.add(keys=OpCodes.DISABLE_ACT_CMD_HK, info=Info.DISABLE_ACT_CMD_HK) - oce.add(keys=OpCodes.REQUEST_FUSED_ROT_RATE_HK, info=Info.REQUEST_FUSED_ROT_RATE_HK) - oce.add(keys=OpCodes.ENABLE_FUSED_ROT_RATE_HK, info=Info.ENABLE_FUSED_ROT_RATE_HK) - oce.add(keys=OpCodes.DISABLE_FUSED_ROT_RATE_HK, info=Info.DISABLE_FUSED_ROT_RATE_HK) + oce.add(keys=OpCodes.ONE_SHOOT_HK, info=Info.ONE_SHOOT_HK) + oce.add(keys=OpCodes.ENABLE_HK, info=Info.ENABLE_HK) + oce.add(keys=OpCodes.DISABLE_HK, info=Info.DISABLE_HK) defs.add_service( name=CustomServiceList.ACS_CTRL.value, info="ACS Controller", op_code_entry=oce ) @@ -278,50 +195,50 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 op_code = p.op_code q = p.queue_helper - if op_code in OpCodes.OFF: + if op_code == OpCodes.OFF: q.add_log_cmd(f"{Info.OFF}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, Mode.OFF, 0)) - elif op_code in OpCodes.SAFE: + elif op_code == OpCodes.SAFE: q.add_log_cmd(f"{Info.SAFE}") q.add_pus_tc( pack_mode_command(ACS_CONTROLLER, AcsMode.SAFE, SafeSubmode.DEFAULT) ) - elif op_code in OpCodes.DTBL: + elif op_code == OpCodes.DTBL: q.add_log_cmd(f"{Info.DTBL}") q.add_pus_tc( pack_mode_command(ACS_CONTROLLER, AcsMode.SAFE, SafeSubmode.DETUMBLE) ) - elif op_code in OpCodes.IDLE: + elif op_code == OpCodes.IDLE: q.add_log_cmd(f"{Info.IDLE}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.IDLE, 0)) - elif op_code in OpCodes.NADIR: + elif op_code == OpCodes.NADIR: q.add_log_cmd(f"{Info.NADIR}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_NADIR, 0)) - elif op_code in OpCodes.TARGET: + elif op_code == OpCodes.TARGET: q.add_log_cmd(f"{Info.TARGET}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_TARGET, 0)) - elif op_code in OpCodes.GS: + elif op_code == OpCodes.GS: q.add_log_cmd(f"{Info.GS}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_TARGET_GS, 0)) - elif op_code in OpCodes.INERTIAL: + elif op_code == OpCodes.INERTIAL: q.add_log_cmd(f"{Info.INERTIAL}") q.add_pus_tc(pack_mode_command(ACS_CONTROLLER, AcsMode.PTG_INERTIAL, 0)) - elif op_code in OpCodes.SAFE_PTG: + elif op_code == OpCodes.SAFE_PTG: q.add_log_cmd(f"{Info.SAFE_PTG}") q.add_pus_tc( create_action_cmd( ACS_CONTROLLER, ActionId.SOLAR_ARRAY_DEPLOYMENT_SUCCESSFUL ) ) - elif op_code in OpCodes.RESET_MEKF: + elif op_code == OpCodes.RESET_MEKF: q.add_log_cmd(f"{Info.RESET_MEKF}") q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.RESET_MEKF)) - elif op_code in OpCodes.RESTORE_MEKF_NONFINITE_RECOVERY: + elif op_code == OpCodes.RESTORE_MEKF_NONFINITE_RECOVERY: q.add_log_cmd(f"{Info.RESTORE_MEKF_NONFINITE_RECOVERY}") q.add_pus_tc( create_action_cmd(ACS_CONTROLLER, ActionId.RESTORE_MEKF_NONFINITE_RECOVERY) ) - elif op_code in OpCodes.UPDATE_TLE: + elif op_code == OpCodes.UPDATE_TLE: q.add_log_cmd(f"{Info.UPDATE_TLE}") while True: line1 = input("Please input the first line of the TLE: ") @@ -337,242 +254,79 @@ def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 print("The line does not have the required length of 69 characters") tle = line1.encode() + line2.encode() q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.UPDATE_TLE, tle)) - elif op_code in OpCodes.READ_TLE: + elif op_code == OpCodes.READ_TLE: q.add_log_cmd(f"{Info.READ_TLE}") q.add_pus_tc(create_action_cmd(ACS_CONTROLLER, ActionId.READ_TLE)) - elif op_code in OpCodes.SET_PARAMETER_SCALAR: + elif op_code == OpCodes.SET_PARAMETER_SCALAR: q.add_log_cmd(f"{Info.SET_PARAMETER_SCALAR}") set_acs_ctrl_param_scalar(q) - elif op_code in OpCodes.SET_PARAMETER_VECTOR: + elif op_code == OpCodes.SET_PARAMETER_VECTOR: q.add_log_cmd(f"{Info.SET_PARAMETER_VECTOR}") set_acs_ctrl_param_vector(q) - elif op_code in OpCodes.SET_PARAMETER_MATRIX: + elif op_code == OpCodes.SET_PARAMETER_MATRIX: q.add_log_cmd(f"{Info.SET_PARAMETER_MATRIX}") set_acs_ctrl_param_matrix(q) - elif op_code in OpCodes.REQUEST_RAW_MGM_HK: - q.add_log_cmd(Info.REQUEST_RAW_MGM_HK) - q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.MGM_RAW_SET)) - ) - elif op_code in OpCodes.ENABLE_RAW_MGM_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_RAW_MGM_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.MGM_RAW_SET), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_RAW_MGM_HK: - q.add_log_cmd(Info.DISABLE_RAW_MGM_HK) - q.add_pus_tc( - disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.MGM_RAW_SET) - ) - ) - elif op_code in OpCodes.REQUEST_PROC_MGM_HK: - q.add_log_cmd(Info.REQUEST_PROC_MGM_HK) - q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.MGM_PROC_SET)) - ) - elif op_code in OpCodes.ENABLE_PROC_MGM_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_PROC_MGM_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.MGM_PROC_SET), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_PROC_MGM_HK: - q.add_log_cmd(Info.DISABLE_PROC_MGM_HK) - q.add_pus_tc( - disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.MGM_PROC_SET) - ) - ) - elif op_code in OpCodes.REQUEST_RAW_SUS_HK: - q.add_log_cmd(Info.REQUEST_RAW_SUS_HK) - q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.SUS_RAW_SET)) - ) - elif op_code in OpCodes.ENABLE_RAW_SUS_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_RAW_SUS_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.SUS_RAW_SET), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_RAW_SUS_HK: - q.add_log_cmd(Info.DISABLE_RAW_SUS_HK) - q.add_pus_tc( - disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.SUS_RAW_SET) - ) - ) - elif op_code in OpCodes.REQUEST_PROC_SUS_HK: - q.add_log_cmd(Info.REQUEST_PROC_SUS_HK) - q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.SUS_PROC_SET)) - ) - elif op_code in OpCodes.ENABLE_PROC_SUS_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_PROC_SUS_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.SUS_PROC_SET), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_PROC_SUS_HK: - q.add_log_cmd(Info.DISABLE_PROC_SUS_HK) - q.add_pus_tc( - disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.SUS_PROC_SET) - ) - ) - elif op_code in OpCodes.REQUEST_RAW_GYR_HK: - q.add_log_cmd(Info.REQUEST_RAW_GYR_HK) - q.add_pus_tc( - create_request_one_diag_command(make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET)) - ) - elif op_code in OpCodes.ENABLE_RAW_GYR_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_RAW_GYR_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - True, make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_RAW_GYR_HK: - q.add_log_cmd(Info.DISABLE_RAW_GYR_HK) - q.add_pus_tc( - disable_periodic_hk_command( - True, make_sid(ACS_CONTROLLER, SetId.GYR_RAW_SET) - ) - ) - elif op_code in OpCodes.REQUEST_PROC_GYR_HK: - q.add_log_cmd(Info.REQUEST_PROC_GYR_HK) - q.add_pus_tc( - create_request_one_diag_command( - make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET) - ) - ) - elif op_code in OpCodes.ENABLE_PROC_GYR_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_PROC_GYR_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - True, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_PROC_GYR_HK: - q.add_log_cmd(Info.DISABLE_PROC_GYR_HK) - q.add_pus_tc( - disable_periodic_hk_command( - True, make_sid(ACS_CONTROLLER, SetId.GYR_PROC_SET) - ) - ) - elif op_code in OpCodes.REQUEST_PROC_GPS_HK: - q.add_log_cmd(Info.REQUEST_PROC_GPS_HK) - q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.GPS_PROC_SET)) - ) - elif op_code in OpCodes.ENABLE_PROC_GPS_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_PROC_GPS_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.GPS_PROC_SET), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_PROC_GPS_HK: - q.add_log_cmd(Info.DISABLE_PROC_GPS_HK) - q.add_pus_tc( - disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.GPS_PROC_SET) - ) - ) - elif op_code in OpCodes.REQUEST_MEKF_HK: - q.add_log_cmd(Info.REQUEST_MEKF_HK) - q.add_pus_tc( - create_request_one_diag_command(make_sid(ACS_CONTROLLER, SetId.MEKF_DATA)) - ) - elif op_code in OpCodes.ENABLE_MEKF_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_MEKF_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - True, make_sid(ACS_CONTROLLER, SetId.MEKF_DATA), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_MEKF_HK: - q.add_log_cmd(Info.DISABLE_MEKF_HK) - q.add_pus_tc( - disable_periodic_hk_command(True, make_sid(ACS_CONTROLLER, SetId.MEKF_DATA)) - ) - elif op_code in OpCodes.REQUEST_CTRL_VAL_HK: - q.add_log_cmd(Info.REQUEST_CTRL_VAL_HK) - q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.CTRL_VAL_DATA)) - ) - elif op_code in OpCodes.ENABLE_CTRL_VAL_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_CTRL_VAL_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.CTRL_VAL_DATA), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_CTRL_VAL_HK: - q.add_log_cmd(Info.DISABLE_CTRL_VAL_HK) - q.add_pus_tc( - disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.CTRL_VAL_DATA) - ) - ) - elif op_code in OpCodes.REQUEST_ACT_CMD_HK: - q.add_log_cmd(Info.REQUEST_ACT_CMD_HK) - q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA)) - ) - elif op_code in OpCodes.ENABLE_ACT_CMD_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_ACT_CMD_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_ACT_CMD_HK: - q.add_log_cmd(Info.DISABLE_ACT_CMD_HK) - q.add_pus_tc( - disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.ACTUATOR_CMD_DATA) - ) - ) - elif op_code in OpCodes.REQUEST_FUSED_ROT_RATE_HK: - q.add_log_cmd(Info.REQUEST_FUSED_ROT_RATE_HK) - q.add_pus_tc( - generate_one_hk_command(make_sid(ACS_CONTROLLER, SetId.FUSED_ROT_RATE_DATA)) - ) - elif op_code in OpCodes.ENABLE_FUSED_ROT_RATE_HK: - interval = float(input("Please specify interval in floating point seconds: ")) - q.add_log_cmd(Info.ENABLE_FUSED_ROT_RATE_HK) - cmd_tuple = enable_periodic_hk_command_with_interval( - False, make_sid(ACS_CONTROLLER, SetId.FUSED_ROT_RATE_DATA), interval - ) - q.add_pus_tc(cmd_tuple[0]) - q.add_pus_tc(cmd_tuple[1]) - elif op_code in OpCodes.DISABLE_FUSED_ROT_RATE_HK: - q.add_log_cmd(Info.DISABLE_FUSED_ROT_RATE_HK) - q.add_pus_tc( - disable_periodic_hk_command( - False, make_sid(ACS_CONTROLLER, SetId.FUSED_ROT_RATE_DATA) - ) - ) + elif op_code == OpCodes.ONE_SHOOT_HK: + q.add_log_cmd(Info.ONE_SHOOT_HK) + request_dataset(q, DataSetRequest.ONESHOT) + elif op_code == OpCodes.ENABLE_HK: + q.add_log_cmd(Info.ENABLE_HK) + request_dataset(q, DataSetRequest.ENABLE) + elif op_code == OpCodes.DISABLE_HK: + q.add_log_cmd(Info.DISABLE_HK) + request_dataset(q, DataSetRequest.DISABLE) else: logging.getLogger(__name__).info(f"Unknown op code {op_code}") +def request_dataset(q: DefaultPusQueueHelper, req_type: DataSetRequest): + for val in SetId: + print("{:<2}: {:<20}".format(val, val.name)) + set_id = int(input("Specify the dataset \n" "")) + if set_id in [ + SetId.GYR_RAW_SET, + SetId.GPS_PROC_SET, + SetId.ATTITUDE_ESTIMATION_DATA, + ]: + is_diag = True + else: + is_diag = False + match req_type: + case DataSetRequest.ONESHOT: + if is_diag: + q.add_pus_tc( + create_request_one_diag_command(make_sid(ACS_CONTROLLER, set_id)) + ) + else: + q.add_pus_tc( + create_request_one_hk_command(make_sid(ACS_CONTROLLER, set_id)) + ) + case DataSetRequest.ENABLE: + interval = float( + input("Please specify interval in floating point seconds: ") + ) + + if is_diag: + cmd_tuple = enable_periodic_hk_command_with_interval( + True, make_sid(ACS_CONTROLLER, set_id), interval + ) + else: + cmd_tuple = enable_periodic_hk_command_with_interval( + False, make_sid(ACS_CONTROLLER, set_id), interval + ) + q.add_pus_tc(cmd_tuple[0]) + q.add_pus_tc(cmd_tuple[1]) + case DataSetRequest.DISABLE: + if is_diag: + q.add_pus_tc( + disable_periodic_hk_command(True, make_sid(ACS_CONTROLLER, set_id)) + ) + else: + q.add_pus_tc( + disable_periodic_hk_command(False, make_sid(ACS_CONTROLLER, set_id)) + ) + + def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): pt = int( input( @@ -778,7 +532,7 @@ def handle_acs_ctrl_hk_data( handle_gyr_data_processed(pw, hk_data) case SetId.GPS_PROC_SET: handle_gps_data_processed(pw, hk_data) - case SetId.MEKF_DATA: + case SetId.ATTITUDE_ESTIMATION_DATA: handle_mekf_data(pw, hk_data) case SetId.CTRL_VAL_DATA: handle_ctrl_val_data(pw, hk_data) -- 2.43.0 From 451c2c07ee749cac52eb1f69b0f64cbf3b5dbdbe Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 5 Dec 2023 16:41:29 +0100 Subject: [PATCH 35/42] stuff --- eive_tmtc/tmtc/acs/acs_ctrl.py | 144 +++++++++++++++++++++++++++------ 1 file changed, 119 insertions(+), 25 deletions(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index f281b54..7b8dbcb 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -97,13 +97,20 @@ CTRL_STRAT_DICT = { 31: "PTG_RAW", } -GPS_COURCE_DICT = { +GPS_SOURCE_DICT = { 0: "NONE", 1: "GPS", 2: "GPS_EXTRAPOLATED", 3: "SGP4", } +FUSED_ROT_RATE_SOURCE_DICT = { + 0: "NONE", + 1: "SUSMGM", + 2: "QUEST", + 3: "STR", +} + class OpCodes: OFF = "off" @@ -533,13 +540,15 @@ def handle_acs_ctrl_hk_data( case SetId.GPS_PROC_SET: handle_gps_data_processed(pw, hk_data) case SetId.ATTITUDE_ESTIMATION_DATA: - handle_mekf_data(pw, hk_data) + handle_attitude_estimation_data(pw, hk_data) case SetId.CTRL_VAL_DATA: handle_ctrl_val_data(pw, hk_data) case SetId.ACTUATOR_CMD_DATA: handle_act_cmd_data(pw, hk_data) case SetId.FUSED_ROT_RATE_DATA: handle_fused_rot_rate_data(pw, hk_data) + case SetId.FUSED_ROT_RATE_SOURCE_DATA: + handle_fused_rot_rate_source_data(pw, hk_data) def handle_acs_ctrl_sus_raw_data(pw: PrintWrapper, hk_data: bytes): @@ -561,7 +570,7 @@ def handle_acs_ctrl_sus_raw_data(pw: PrintWrapper, hk_data: bytes): sus_list_formatted = vec_fmt.format(*sus_list) current_idx += length pw.dlog(f"SUS {idx} RAW: {sus_list_formatted}") - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=12) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=12)) def handle_acs_ctrl_sus_processed_data(pw: PrintWrapper, hk_data: bytes): @@ -597,7 +606,7 @@ def handle_acs_ctrl_sus_processed_data(pw: PrintWrapper, hk_data: bytes): sun_ijk_model = vec_fmt.format(*sun_ijk_model) current_idx += inc_len pw.dlog(f"{'SUS ijk Model'.ljust(25)}: {sun_ijk_model}") - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=15) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=15)) def handle_raw_mgm_data(pw: PrintWrapper, hk_data: bytes): @@ -653,7 +662,7 @@ def handle_raw_mgm_data(pw: PrintWrapper, hk_data: bytes): pw.dlog(f"{entry[0].ljust(28)}: {entry[1]}") current_idx += 1 assert current_idx == 61 - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=6) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=6)) def handle_mgm_data_processed(pw: PrintWrapper, hk_data: bytes): @@ -707,7 +716,7 @@ def handle_mgm_data_processed(pw: PrintWrapper, hk_data: bytes): current_idx += inc_len if PERFORM_MGM_CALIBRATION: perform_mgm_calibration(pw, mgm_3) - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=8) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=8)) def handle_gyr_data_raw(pw: PrintWrapper, hk_data: bytes): @@ -741,7 +750,7 @@ def handle_gyr_data_raw(pw: PrintWrapper, hk_data: bytes): pw.dlog(f"{'GYR 1 L3'.ljust(15)}: {float_str_fmt.format(*gyr_1_l3)}") pw.dlog(f"{'GYR 2 ADIS'.ljust(15)}: {float_str_fmt.format(*gyr_2_adis)}") pw.dlog(f"{'GYR 3 L3'.ljust(15)}: {float_str_fmt.format(*gyr_3_l3)}") - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 4) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 4)) GYR_NAMES = ["GYR 0 ADIS", "GYR 1 L3", "GYR 2 ADIS", "GYR 3 L3"] @@ -767,7 +776,7 @@ def handle_gyr_data_processed(pw: PrintWrapper, hk_data: bytes): ] pw.dlog(f"GYR Vec Total: {gyr_vec_tot}") current_idx += inc_len - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=5) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=5)) def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes): @@ -821,8 +830,8 @@ def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes): fmt_source, hk_data[current_idx : current_idx + inc_len_source] )[0] current_idx += inc_len_source - if GPS_COURCE_DICT.get(source) is not None: - pw.dlog(f"GPS Source: {GPS_COURCE_DICT[source]}") + if GPS_SOURCE_DICT.get(source) is not None: + pw.dlog(f"GPS Source: {GPS_SOURCE_DICT[source]}") else: pw.dlog(f"'GPS Source (key unknown)': {source}") pw.dlog(f"GPS Latitude: {lat} [deg]") @@ -830,10 +839,10 @@ def handle_gps_data_processed(pw: PrintWrapper, hk_data: bytes): pw.dlog(f"GPS Altitude: {alt} [m]") pw.dlog(f"GPS Position: {pos} [m]") pw.dlog(f"GPS Velocity: {velo} [m/s]") - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=6) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=6)) -def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): +def handle_attitude_estimation_data(pw: PrintWrapper, hk_data: bytes): mekf_status = { 0: "UNINITIALIZED", 1: "NO_GYR_DATA", @@ -844,7 +853,7 @@ def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): 10: "INITIALIZED", 11: "RUNNING", } - pw.dlog("Received MEKF Set") + pw.dlog("Received Attitude Estimation Set") fmt_quat = "!dddd" fmt_str_4 = "[{:8.3f}, {:8.3f}, {:8.3f}, {:8.3f}]" fmt_str_3 = "[{:8.3f}, {:8.3f}, {:8.3f}]" @@ -853,11 +862,16 @@ def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): inc_len_quat = struct.calcsize(fmt_quat) inc_len_vec = struct.calcsize(fmt_vec) inc_len_sts = struct.calcsize(fmt_sts) - if len(hk_data) < inc_len_quat + inc_len_vec + inc_len_sts: - pw.dlog("Received HK set too small") + old_size = inc_len_quat + inc_len_vec + inc_len_sts + 1 + new_size = 2 * inc_len_quat + inc_len_vec + inc_len_sts + 1 + size = len(hk_data) + if size not in [old_size, new_size]: + pw.dlog(f"Received Attitude Estimation HK Set of unexpected size: {size}") return current_idx = 0 - quat = struct.unpack(fmt_quat, hk_data[current_idx : current_idx + inc_len_quat]) + mekf_quat = struct.unpack( + fmt_quat, hk_data[current_idx : current_idx + inc_len_quat] + ) current_idx += inc_len_quat rates = [ rate * 180 / math.pi @@ -872,9 +886,16 @@ def handle_mekf_data(pw: PrintWrapper, hk_data: bytes): pw.dlog(f"{'MEKF Status'.ljust(25)}: {mekf_status[status]}") else: pw.dlog(f"{'MEKF Raw Status (key unknown)'.ljust(25)}: {status}") - pw.dlog(f"{'MEKF Quaternion'.ljust(25)}: {fmt_str_4.format(*quat)}") + pw.dlog(f"{'MEKF Quaternion'.ljust(25)}: {fmt_str_4.format(*mekf_quat)}") pw.dlog(f"{'MEKF Rotational Rate'.ljust(25)}: {fmt_str_3.format(*rates)}") - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3) + if size == new_size: + quest_quat = struct.unpack( + fmt_quat, hk_data[current_idx : current_idx + inc_len_quat] + ) + pw.dlog(f"{'QUEST Quaternion'.ljust(25)}: {fmt_str_4.format(*quest_quat)}") + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=4)) + return + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3)) def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes): @@ -924,14 +945,14 @@ def handle_ctrl_val_data(pw: PrintWrapper, hk_data: bytes): ] current_idx += inc_len_vec if CTRL_STRAT_DICT.get(strat) is not None: - pw.dlog(f"{'Safe Ctrl Strategy'.ljust(25)}: {CTRL_STRAT_DICT[strat]}") + pw.dlog(f"{'Ctrl Strategy'.ljust(25)}: {CTRL_STRAT_DICT[strat]}") else: - pw.dlog(f"{'Safe Ctrl Strategy (key unknown)'.ljust(25)}: {strat}") + pw.dlog(f"{'Ctrl Strategy (key unknown)'.ljust(25)}: {strat}") pw.dlog(f"Control Values Target Quaternion: {tgt_quat}") pw.dlog(f"Control Values Error Quaternion: {err_quat}") pw.dlog(f"Control Values Error Angle: {err_ang} [deg]") pw.dlog(f"Control Values Target Rotational Rate: {tgt_rot} [deg/s]") - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=5) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=5)) def handle_act_cmd_data(pw: PrintWrapper, hk_data: bytes): @@ -970,15 +991,20 @@ def handle_act_cmd_data(pw: PrintWrapper, hk_data: bytes): pw.dlog(f"Actuator Commands RW Target Torque: {rw_tgt_torque}") pw.dlog(f"Actuator Commands RW Target Speed: {rw_tgt_speed}") pw.dlog(f"Actuator Commands MTQ Target Dipole: {mtq_tgt_dipole}") - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3) + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3)) def handle_fused_rot_rate_data(pw: PrintWrapper, hk_data: bytes): pw.dlog("Received Fused Rotation Rates Data Set") fmt_vec3_double = "!ddd" inc_len_vec3_double = struct.calcsize(fmt_vec3_double) - if len(hk_data) < 3 * inc_len_vec3_double: - pw.dlog("Received HK set too small") + fmt_source = "!B" + inc_len_source = struct.calcsize(fmt_source) + old_size = 3 * inc_len_vec3_double + 1 + new_size = 3 * inc_len_vec3_double + inc_len_source + 1 + size = len(hk_data) + if size not in [old_size, new_size]: + pw.dlog(f"Received Fused Rot Rate HK set of unexpected size: {len(hk_data)}") return current_idx = 0 rot_rate_orthogonal = [ @@ -1005,7 +1031,75 @@ def handle_fused_rot_rate_data(pw: PrintWrapper, hk_data: bytes): pw.dlog(f"Fused Rotational Rate Orthogonal: {rot_rate_orthogonal} [deg/s]") pw.dlog(f"Fused Rotational Rate Parallel: {rot_rate_parallel} [deg/s]") pw.dlog(f"Fused Rotational Rate Total: {rot_rate_total} [deg/s]") - FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3) + if size == new_size: + rot_rate_source = struct.unpack( + fmt_source, hk_data[current_idx : current_idx + inc_len_source] + )[0] + current_idx += inc_len_source + if FUSED_ROT_RATE_SOURCE_DICT.get(rot_rate_source) is not None: + pw.dlog( + f"Fused Rotational Rate Source: {FUSED_ROT_RATE_SOURCE_DICT[rot_rate_source]}" + ) + else: + pw.dlog(f"Ctrl Strategy (key unknown): {rot_rate_source}") + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=4)) + return + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3)) + + +def handle_fused_rot_rate_source_data(pw: PrintWrapper, hk_data: bytes): + pw.dlog("Received Fused Rotation Rates Sources Data Set") + fmt_vec3_double = "!ddd" + inc_len_vec3_double = struct.calcsize(fmt_vec3_double) + if len(hk_data) < 5 * inc_len_vec3_double: + pw.dlog("Received HK set too small") + return + current_idx = 0 + rot_rate_orthogonal_susmgm = [ + f"{val*180/math.pi:8.3f}" + for val in struct.unpack( + fmt_vec3_double, hk_data[current_idx : current_idx + inc_len_vec3_double] + ) + ] + current_idx += inc_len_vec3_double + rot_rate_parallel_susmgm = [ + f"{val*180/math.pi:8.3f}" + for val in struct.unpack( + fmt_vec3_double, hk_data[current_idx : current_idx + inc_len_vec3_double] + ) + ] + current_idx += inc_len_vec3_double + rot_rate_total_susmgm = [ + f"{val*180/math.pi:8.3f}" + for val in struct.unpack( + fmt_vec3_double, hk_data[current_idx : current_idx + inc_len_vec3_double] + ) + ] + current_idx += inc_len_vec3_double + rot_rate_total_quest = [ + f"{val * 180 / math.pi:8.3f}" + for val in struct.unpack( + fmt_vec3_double, hk_data[current_idx : current_idx + inc_len_vec3_double] + ) + ] + current_idx += inc_len_vec3_double + rot_rate_total_str = [ + f"{val * 180 / math.pi:8.3f}" + for val in struct.unpack( + fmt_vec3_double, hk_data[current_idx : current_idx + inc_len_vec3_double] + ) + ] + current_idx += inc_len_vec3_double + pw.dlog( + f"Fused Rotational Rate Orthogonal SUSMGM: {rot_rate_orthogonal_susmgm} [deg/s]" + ) + pw.dlog( + f"Fused Rotational Rate Parallel SUSMGM: {rot_rate_parallel_susmgm} [deg/s]" + ) + pw.dlog(f"Fused Rotational Rate Total SUSMGM: {rot_rate_total_susmgm} [deg/s]") + pw.dlog(f"Fused Rotational Rate Total QUEST: {rot_rate_total_quest} [deg/s]") + pw.dlog(f"Fused Rotational Rate Total STR: {rot_rate_total_str} [deg/s]") + pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=5)) def handle_acs_ctrl_action_replies( -- 2.43.0 From d477242881b9959e27a9d99553c2894c246ae228 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 6 Dec 2023 14:48:05 +0100 Subject: [PATCH 36/42] strats --- eive_tmtc/tmtc/acs/acs_ctrl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 7b8dbcb..0d11250 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -93,8 +93,9 @@ CTRL_STRAT_DICT = { 19: "SAFE_ECLIPSE_IDELING", 20: "DETUMBLE_FULL", 21: "DETUMBLE_DETERIORATED", - 30: "PTG_MEKF", - 31: "PTG_RAW", + 100: "PTG_MEKF", + 101: "PTG_STR", + 102: "PTG_QUEST", } GPS_SOURCE_DICT = { -- 2.43.0 From ee955e96fb80419ad1fddd0554abbc745376befd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Dec 2023 17:19:01 +0100 Subject: [PATCH 37/42] prepare v5.12.0 --- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 279e5bd..87cfe25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ list yields a list of all related PRs for each release. # [unreleased] +# [v5.12.0] 2023-12-06 + +## Added + +- New ACS controller commands. + # [v5.11.0] 2023-11-30 ## Added diff --git a/pyproject.toml b/pyproject.toml index 57362e8..fdab861 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "eive-tmtc" description = "TMTC Commander EIVE" readme = "README.md" -version = "5.11.0" +version = "5.12.0" requires-python = ">=3.10" license = {text = "Apache-2.0"} authors = [ -- 2.43.0 From 58def42281529f9694f5d997f2314af5bac19864 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Dec 2023 17:19:56 +0100 Subject: [PATCH 38/42] re-run generators --- eive_tmtc/config/events.csv | 3 ++- eive_tmtc/config/returnvalues.csv | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/eive_tmtc/config/events.csv b/eive_tmtc/config/events.csv index 656843f..97eeaf3 100644 --- a/eive_tmtc/config/events.csv +++ b/eive_tmtc/config/events.csv @@ -93,9 +93,10 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11203;0x2bc3;MEKF_INVALID_INFO;INFO;MEKF was not able to compute a solution. P1: MEKF state on exit;mission/acs/defs.h 11204;0x2bc4;MEKF_RECOVERY;INFO;MEKF is able to compute a solution again.;mission/acs/defs.h 11205;0x2bc5;MEKF_AUTOMATIC_RESET;INFO;MEKF performed an automatic reset after detection of nonfinite values.;mission/acs/defs.h -11206;0x2bc6;MEKF_INVALID_MODE_VIOLATION;HIGH;MEKF was not able to compute a solution during any pointing ACS mode for a prolonged time.;mission/acs/defs.h +11206;0x2bc6;PTG_CTRL_NO_ATTITUDE_INFORMATION;HIGH;For a prolonged time, no attitude information was available for the Pointing Controller. Falling back to Safe Mode.;mission/acs/defs.h 11207;0x2bc7;SAFE_MODE_CONTROLLER_FAILURE;HIGH;The ACS safe mode controller was not able to compute a solution and has failed. P1: Missing information about magnetic field, P2: Missing information about rotational rate;mission/acs/defs.h 11208;0x2bc8;TLE_TOO_OLD;INFO;The TLE for the SGP4 Propagator has become too old.;mission/acs/defs.h +11209;0x2bc9;TLE_FILE_READ_FAILED;LOW;The TLE could not be read from the filesystem.;mission/acs/defs.h 11300;0x2c24;SWITCH_CMD_SENT;INFO;Indicates that a FSFW object requested setting a switch P1: 1 if on was requested, 0 for off | P2: Switch Index;mission/power/defs.h 11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/power/defs.h 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h diff --git a/eive_tmtc/config/returnvalues.csv b/eive_tmtc/config/returnvalues.csv index d2922a1..e194ac6 100644 --- a/eive_tmtc/config/returnvalues.csv +++ b/eive_tmtc/config/returnvalues.csv @@ -593,6 +593,8 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x69c0;SPVRTVIF_BufTooSmall;No description;192;SUPV_RETURN_VALUES_IF;linux/payload/plocSupvDefs.h 0x69c1;SPVRTVIF_NoReplyTimeout;No description;193;SUPV_RETURN_VALUES_IF;linux/payload/plocSupvDefs.h 0x6a00;ACSCTRL_FileDeletionFailed;File deletion failed and at least one file is still existent.;0;ACS_CTRL;mission/controller/AcsController.h +0x6a01;ACSCTRL_WriteFileFailed;Writing the TLE to the file has failed.;1;ACS_CTRL;mission/controller/AcsController.h +0x6a02;ACSCTRL_ReadFileFailed;Reading the TLE to the file has failed.;2;ACS_CTRL;mission/controller/AcsController.h 0x6b02;ACSMEKF_MekfUninitialized;No description;2;ACS_MEKF;mission/controller/acs/MultiplicativeKalmanFilter.h 0x6b03;ACSMEKF_MekfNoGyrData;No description;3;ACS_MEKF;mission/controller/acs/MultiplicativeKalmanFilter.h 0x6b04;ACSMEKF_MekfNoModelVectors;No description;4;ACS_MEKF;mission/controller/acs/MultiplicativeKalmanFilter.h -- 2.43.0 From 1a132684a6afd43f4986034cbc29eab4d4612bc6 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 7 Dec 2023 13:54:09 +0100 Subject: [PATCH 39/42] small fix --- eive_tmtc/tmtc/acs/acs_ctrl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 0d11250..68623a3 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -893,6 +893,7 @@ def handle_attitude_estimation_data(pw: PrintWrapper, hk_data: bytes): quest_quat = struct.unpack( fmt_quat, hk_data[current_idx : current_idx + inc_len_quat] ) + current_idx += inc_len_quat pw.dlog(f"{'QUEST Quaternion'.ljust(25)}: {fmt_str_4.format(*quest_quat)}") pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=4)) return -- 2.43.0 From 5456d799650ef1c6223b571a7086fd45fe363f6b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Dec 2023 11:23:55 +0100 Subject: [PATCH 40/42] the endianness is actually really important here --- eive_tmtc/tmtc/core.py | 40 ++++++++++++++++++++++++++++------------ eive_tmtc/tmtc/test.py | 29 ++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/eive_tmtc/tmtc/core.py b/eive_tmtc/tmtc/core.py index a8f5faf..94e6a8a 100644 --- a/eive_tmtc/tmtc/core.py +++ b/eive_tmtc/tmtc/core.py @@ -5,22 +5,25 @@ import struct from pathlib import Path from typing import Tuple -from eive_tmtc.pus_tm.defs import PrintWrapper - -from eive_tmtc.config.definitions import CustomServiceList from spacepackets.ecss import PusTelecommand from tmtccmd.config import TmtcDefinitionWrapper - -from tmtccmd.tmtc import DefaultPusQueueHelper -from tmtccmd.pus.s8_fsfw_action import create_action_cmd -from tmtccmd.pus.tc.s3_fsfw_hk import make_sid, generate_one_hk_command -from tmtccmd.pus.s20_fsfw_param import ( - create_scalar_u8_parameter, - create_load_param_cmd, -) from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider -from eive_tmtc.config.object_ids import CORE_CONTROLLER_ID from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter +from tmtccmd.pus.s8_fsfw_action import create_action_cmd +from tmtccmd.pus.s11_tc_sched import ( + create_enable_tc_sched_cmd, + create_disable_tc_sched_cmd, +) +from tmtccmd.pus.s20_fsfw_param import ( + create_load_param_cmd, + create_scalar_u8_parameter, +) +from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid +from tmtccmd.tmtc import DefaultPusQueueHelper + +from eive_tmtc.config.definitions import CustomServiceList +from eive_tmtc.config.object_ids import CORE_CONTROLLER_ID +from eive_tmtc.pus_tm.defs import PrintWrapper _LOGGER = logging.getLogger(__name__) @@ -66,6 +69,7 @@ class ActionId(enum.IntEnum): MV_HELPER = 53 RM_HELPER = 54 MKDIR_HELPER = 55 + ENABLE_SCHEDULER = 56 class ParamId(enum.IntEnum): @@ -115,6 +119,8 @@ class OpCode: RWD_SET_MAX_REBOOT_CNT = "rwd_max_cnt" AUTO_SWITCH_ENABLE = "auto_switch_enable" AUTO_SWITCH_DISABLE = "auto_switch_disable" + ENABLE_SCHEDULER = "enable_scheduler" + DISABLE_SCHEDULER = "disable_scheduler" class Info: @@ -142,6 +148,8 @@ class Info: MKDIR_HELPER = "Filesystem Directory Creation Helper" AUTO_SWITCH_ENABLE = "Enable Auto-Switch Feature with a specific target image" AUTO_SWITCH_DISABLE = "Disable Auto-Switch Feature" + ENABLE_SCHEDULER = "Enable scheduler" + DISABLE_SCHEDULER = "Disable scheduler" class Chip(enum.IntEnum): @@ -241,6 +249,8 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper): oce.add(keys=OpCode.CP_HELPER, info=Info.CP_HELPER) oce.add(keys=OpCode.RM_HELPER, info=Info.RM_HELPER) oce.add(keys=OpCode.MKDIR_HELPER, info=Info.MKDIR_HELPER) + oce.add(keys=OpCode.ENABLE_SCHEDULER, info=Info.ENABLE_SCHEDULER) + oce.add(keys=OpCode.DISABLE_SCHEDULER, info=Info.DISABLE_SCHEDULER) defs.add_service(CustomServiceList.CORE.value, "Core Controller", oce) @@ -514,6 +524,12 @@ def pack_core_commands( # noqa C901 q.add_pus_tc( create_action_cmd(CORE_CONTROLLER_ID, ActionId.MKDIR_HELPER, user_data) ) + elif op_code == OpCode.ENABLE_SCHEDULER: + q.add_log_cmd(Info.ENABLE_SCHEDULER) + q.add_pus_tc(create_enable_tc_sched_cmd()) + elif op_code == OpCode.DISABLE_SCHEDULER: + q.add_log_cmd(Info.DISABLE_SCHEDULER) + q.add_pus_tc(create_disable_tc_sched_cmd()) else: _LOGGER.warning( f"Unknown operation code {op_code} for core controller commands" diff --git a/eive_tmtc/tmtc/test.py b/eive_tmtc/tmtc/test.py index c484a38..a5b36c8 100644 --- a/eive_tmtc/tmtc/test.py +++ b/eive_tmtc/tmtc/test.py @@ -1,10 +1,15 @@ -from spacepackets.ecss import PusTelecommand, PusService +import struct +import datetime +import math + +from spacepackets.ecss import PusService, PusTelecommand from tmtccmd.config import CoreServiceList from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, - TmtcDefinitionWrapper, OpCodeEntry, + TmtcDefinitionWrapper, + tmtc_definitions_provider, ) +from tmtccmd.pus.s11_tc_sched import create_time_tagged_cmd from tmtccmd.pus.s17_test import create_service_17_ping_command from tmtccmd.tmtc import service_provider from tmtccmd.tmtc.decorator import ServiceProviderParams @@ -14,12 +19,14 @@ class OpCodes: PING = "ping" TRIGGER_EVENT = "trig_event" PING_WITH_DATA = "ping_with_data" + SCHEDULE_PING = "sched_ping" class Info: PING = "Simple Ping and Connection Test" TRIGGER_EVENT = "Trigger an event" PING_WITH_DATA = "Ping with data. Size of sent data is sent back" + SCHEDULE_PING = "Schedule a ping" @tmtc_definitions_provider @@ -28,6 +35,7 @@ def add_test_defs(defs: TmtcDefinitionWrapper): oce.add(keys=OpCodes.PING, info=Info.PING) oce.add(keys=OpCodes.TRIGGER_EVENT, info=Info.TRIGGER_EVENT) oce.add(keys=OpCodes.PING_WITH_DATA, info=Info.PING_WITH_DATA) + oce.add(keys=OpCodes.SCHEDULE_PING, info=Info.SCHEDULE_PING) defs.add_service( name=CoreServiceList.SERVICE_17_ALT, @@ -46,6 +54,21 @@ def pack_test_command(p: ServiceProviderParams): if info.op_code == OpCodes.TRIGGER_EVENT: q.add_log_cmd("Sending PUS TC Event Trigger [17, 128]") q.add_pus_tc(PusTelecommand(service=PusService.S17_TEST, subservice=128)) + if info.op_code == OpCodes.SCHEDULE_PING: + q.add_log_cmd("Sending scheduled PUS ping") + # Generate a UNIX timestamp 30 seconds in the future using the datetime API with a UTC timezone + now = datetime.datetime.now(tz=datetime.timezone.utc) + second_offset_to_now = input("Please specify offset to now in seconds: ") + now += datetime.timedelta(seconds=int(second_offset_to_now)) + unix_stamp = struct.pack("!I", math.floor(now.timestamp())) + print(f"Sending ping scheuled at {now}") + ping = PusTelecommand(service=PusService.S17_TEST, subservice=128) + q.add_pus_tc( + create_time_tagged_cmd( + release_time=unix_stamp, + tc_to_insert=ping, + ) + ) if info.op_code == OpCodes.PING_WITH_DATA: q.add_log_cmd("Sending Ping With Data, Size Reported Back [17, 129]") while True: -- 2.43.0 From 747ad34eec5baa5199de49a1330687508c991550 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 13 Dec 2023 11:30:03 +0100 Subject: [PATCH 41/42] prev v5.12.1 --- CHANGELOG.md | 6 ++++++ eive_tmtc/config/returnvalues.csv | 1 + pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87cfe25..cedd0ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ list yields a list of all related PRs for each release. # [unreleased] +# [v5.12.1] 2023-12-13 + +## Added + +- A few new commands to test the TC scheduler. + # [v5.12.0] 2023-12-06 ## Added diff --git a/eive_tmtc/config/returnvalues.csv b/eive_tmtc/config/returnvalues.csv index e194ac6..76184dc 100644 --- a/eive_tmtc/config/returnvalues.csv +++ b/eive_tmtc/config/returnvalues.csv @@ -387,6 +387,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x4304;PUS11_InvalidRelativeTime;No description;4;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4305;PUS11_ContainedTcTooSmall;No description;5;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4306;PUS11_ContainedTcCrcMissmatch;No description;6;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h +0x4307;PUS11_MapIsFull;No description;7;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4400;FILS_GenericFileError;No description;0;FILE_SYSTEM;fsfw/src/fsfw/filesystem/HasFileSystemIF.h 0x4401;FILS_GenericDirError;No description;1;FILE_SYSTEM;fsfw/src/fsfw/filesystem/HasFileSystemIF.h 0x4402;FILS_FilesystemInactive;No description;2;FILE_SYSTEM;fsfw/src/fsfw/filesystem/HasFileSystemIF.h diff --git a/pyproject.toml b/pyproject.toml index fdab861..8c2cd28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta" name = "eive-tmtc" description = "TMTC Commander EIVE" readme = "README.md" -version = "5.12.0" +version = "5.12.1" requires-python = ">=3.10" license = {text = "Apache-2.0"} authors = [ -- 2.43.0 From db70b33bd60d1f3cc4d45f86fb12391c9560249a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Jan 2024 17:59:16 +0100 Subject: [PATCH 42/42] bump tmtccmd again --- eive_tmtc/cfdp/fault_handler.py | 20 ++++++++++++++------ eive_tmtc/cfdp/handler.py | 14 +++++++------- eive_tmtc/cfdp/user.py | 22 ++++++++++++++-------- eive_tmtc/pus_tc/tc_handler.py | 4 ++-- eive_tmtc/pus_tm/hk_handler.py | 2 +- eive_tmtc/tmtc/core.py | 8 +------- pyproject.toml | 3 ++- tmtcc.py | 6 +++--- 8 files changed, 44 insertions(+), 35 deletions(-) diff --git a/eive_tmtc/cfdp/fault_handler.py b/eive_tmtc/cfdp/fault_handler.py index 6387792..2694d4a 100644 --- a/eive_tmtc/cfdp/fault_handler.py +++ b/eive_tmtc/cfdp/fault_handler.py @@ -1,20 +1,28 @@ import logging -from spacepackets.cfdp import ConditionCode -from tmtccmd.cfdp.mib import DefaultFaultHandlerBase +from spacepackets.cfdp import ConditionCode, TransactionId +from cfdppy.mib import DefaultFaultHandlerBase _LOGGER = logging.getLogger(__name__) class EiveCfdpFaultHandler(DefaultFaultHandlerBase): - def notice_of_suspension_cb(self, cond: ConditionCode): + def notice_of_suspension_cb( + self, transaction_id: TransactionId, cond: ConditionCode, progress: int + ): _LOGGER.info(f"Received notice of suspension: {cond!r}") - def notice_of_cancellation_cb(self, cond: ConditionCode): + def notice_of_cancellation_cb( + self, transaction_id: TransactionId, cond: ConditionCode, progress: int + ): _LOGGER.info(f"Received notice of cancellation: {cond!r}") - def abandoned_cb(self, cond: ConditionCode): + def abandoned_cb( + self, transaction_id: TransactionId, cond: ConditionCode, progress: int + ): _LOGGER.info(f"Abandoned transaction: {cond!r}") - def ignore_cb(self, cond: ConditionCode): + def ignore_cb( + self, transaction_id: TransactionId, cond: ConditionCode, progress: int + ): _LOGGER.info(f"Ignored transaction: {cond!r}") diff --git a/eive_tmtc/cfdp/handler.py b/eive_tmtc/cfdp/handler.py index e950532..733d2fc 100644 --- a/eive_tmtc/cfdp/handler.py +++ b/eive_tmtc/cfdp/handler.py @@ -5,22 +5,22 @@ import deprecation from spacepackets import PacketType, SpacePacket, SpacePacketHeader from spacepackets.cfdp import GenericPduPacket, PduFactory from spacepackets.cfdp.pdu import PduHolder -from tmtccmd.cfdp import ( +from cfdppy import ( CfdpUserBase, LocalEntityCfg, RemoteEntityCfgTable, ) -from tmtccmd.cfdp.defs import CfdpState -from tmtccmd.cfdp.handler import ( +from cfdppy.defs import CfdpState +from cfdppy.handler import ( DestHandler, DestStateWrapper, SourceHandler, SourceStateWrapper, ) -from tmtccmd.cfdp.handler.common import PacketDestination, get_packet_destination -from tmtccmd.cfdp.mib import CheckTimerProvider -from tmtccmd.cfdp.request import PutRequest -from tmtccmd.util import ProvidesSeqCount +from cfdppy.handler.common import PacketDestination, get_packet_destination +from cfdppy.mib import CheckTimerProvider +from cfdppy.request import PutRequest +from spacepackets.seqcount import ProvidesSeqCount from tmtccmd.version import get_version diff --git a/eive_tmtc/cfdp/user.py b/eive_tmtc/cfdp/user.py index 9c9cd81..7806489 100644 --- a/eive_tmtc/cfdp/user.py +++ b/eive_tmtc/cfdp/user.py @@ -3,12 +3,13 @@ import logging from spacepackets.cfdp import ConditionCode from spacepackets.util import UnsignedByteField -from tmtccmd.cfdp import CfdpUserBase, TransactionId -from tmtccmd.cfdp.mib import CheckTimerProvider, Countdown, EntityType -from tmtccmd.cfdp.user import ( +from cfdppy import CfdpUserBase, TransactionId +from cfdppy.mib import CheckTimerProvider, Countdown, EntityType +from cfdppy.user import ( TransactionFinishedParams, MetadataRecvParams, FileSegmentRecvdParams, + TransactionParams, ) _LOGGER = logging.getLogger(__name__) @@ -25,17 +26,22 @@ class EiveCheckTimerProvider(CheckTimerProvider): class EiveCfdpUser(CfdpUserBase): - def transaction_indication(self, transaction_id: TransactionId): - _LOGGER.info(f"CFDP User: Start of File {transaction_id}") + def transaction_indication( + self, + transaction_indication_params: TransactionParams, + ): + _LOGGER.info( + f"CFDP User: Start of File {transaction_indication_params.transaction_id}" + ) def eof_sent_indication(self, transaction_id: TransactionId): _LOGGER.info(f"CFDP User: EOF sent for {transaction_id}") def transaction_finished_indication(self, params: TransactionFinishedParams): _LOGGER.info(f"CFDP User: {params.transaction_id} finished") - _LOGGER.info(f"Delivery Code: {params.delivery_code!r}") - _LOGGER.info(f"Condition code: {params.condition_code!r}") - _LOGGER.info(f"File delivery status: {params.delivery_code!r}") + _LOGGER.info(f"Delivery Code: {params.finished_params.delivery_code!r}") + _LOGGER.info(f"Condition code: {params.finished_params.condition_code!r}") + _LOGGER.info(f"File delivery status: {params.finished_params.delivery_code!r}") def metadata_recv_indication(self, params: MetadataRecvParams): pass diff --git a/eive_tmtc/pus_tc/tc_handler.py b/eive_tmtc/pus_tc/tc_handler.py index 68fad09..07d9a15 100644 --- a/eive_tmtc/pus_tc/tc_handler.py +++ b/eive_tmtc/pus_tc/tc_handler.py @@ -9,7 +9,7 @@ from eive_tmtc.config.definitions import ( from eive_tmtc.pus_tc.cmd_demux import handle_pus_procedure from eive_tmtc.cfdp.handler import CfdpInCcsdsHandler from tmtccmd import TcHandlerBase, ProcedureWrapper -from tmtccmd.cfdp.defs import CfdpRequestType +from cfdppy.defs import CfdpRequestType from tmtccmd.logging import get_current_time_string from tmtccmd.logging.pus import RawTmtcTimedLogWrapper from tmtccmd.tmtc import ( @@ -22,7 +22,7 @@ from tmtccmd.tmtc import ( ) from tmtccmd.config.cfdp import generic_cfdp_params_to_put_request from spacepackets.ecss import PusVerificator -from tmtccmd.util import FileSeqCountProvider +from spacepackets.seqcount import FileSeqCountProvider from spacepackets.cfdp import PduHolder, DirectiveType diff --git a/eive_tmtc/pus_tm/hk_handler.py b/eive_tmtc/pus_tm/hk_handler.py index 561f87d..9122091 100644 --- a/eive_tmtc/pus_tm/hk_handler.py +++ b/eive_tmtc/pus_tm/hk_handler.py @@ -21,9 +21,9 @@ from eive_tmtc.tmtc.com.syrlinks_handler import handle_syrlinks_hk_data from eive_tmtc.tmtc.tcs import handle_thermal_controller_hk_data from eive_tmtc.tmtc.tcs.tmp1075 import handle_tmp_1075_hk_data from tmtccmd.pus.tm.s3_fsfw_hk import ( - HkContentType, Service3FsfwTm, ) +from tmtccmd.pus.tm.s3_hk_base import HkContentType from tmtccmd.util.obj_id import ObjectIdU32, ObjectIdDictT from eive_tmtc.tmtc.power.bpx_batt import handle_bpx_hk_data diff --git a/eive_tmtc/tmtc/core.py b/eive_tmtc/tmtc/core.py index e86ae5b..a1db863 100644 --- a/eive_tmtc/tmtc/core.py +++ b/eive_tmtc/tmtc/core.py @@ -17,17 +17,10 @@ from tmtccmd.pus.s20_fsfw_param import ( ) from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter -from tmtccmd.pus.s8_fsfw_action import create_action_cmd from tmtccmd.pus.s11_tc_sched import ( create_enable_tc_sched_cmd, create_disable_tc_sched_cmd, ) -from tmtccmd.pus.s20_fsfw_param import ( - create_load_param_cmd, - create_scalar_u8_parameter, -) -from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid -from tmtccmd.tmtc import DefaultPusQueueHelper from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import CORE_CONTROLLER_ID @@ -165,6 +158,7 @@ class Info: RWD_RESET_REBOOT_COUNTER_00 = "Reset reboot counter 0 0" RWD_RESET_REBOOT_COUNTER_01 = "Reset reboot counter 0 0" RWD_RESET_REBOOT_COUNTER_10 = "Reset reboot counter 1 0" + GET_HK = "Get HK set" RWD_RESET_REBOOT_COUNTER_11 = "Reset reboot counter 1 1" RWD_SET_MAX_REBOOT_CNT = "rwd_max_cnt" AUTO_SWITCH_ENABLE = "Enable Auto-Switch Feature with a specific target image" diff --git a/pyproject.toml b/pyproject.toml index 1e93c65..ded70d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,8 @@ classifiers = [ "Topic :: Scientific/Engineering" ] dependencies = [ - "tmtccmd ~= 8.0.0rc0", + "tmtccmd ~= 8.0.0rc1", + "cfdp-py~=0.1.0", # "tmtccmd @ git+https://github.com/robamu-org/tmtccmd@main", "python-dateutil ~= 2.8", ] diff --git a/tmtcc.py b/tmtcc.py index d14962f..2ed7c7d 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -14,8 +14,8 @@ from spacepackets.cfdp import ( from spacepackets.ecss import PusVerificator from spacepackets.version import get_version as get_sp_version from tmtccmd import BackendBase -from tmtccmd.cfdp.handler import RemoteEntityCfgTable -from tmtccmd.cfdp.mib import ( +from cfdppy.handler import RemoteEntityCfgTable +from cfdppy.mib import ( IndicationCfg, LocalEntityCfg, RemoteEntityCfg, @@ -41,7 +41,7 @@ from tmtccmd.logging.pus import ( ) from tmtccmd.pus import VerificationWrapper from tmtccmd.tmtc import CcsdsTmHandler -from tmtccmd.util import FileSeqCountProvider, PusFileSeqCountProvider +from spacepackets.seqcount import FileSeqCountProvider, PusFileSeqCountProvider from eive_tmtc import APP_LOGGER from eive_tmtc.pus_tm.pus_handler import PusHandler, UnknownApidHandler -- 2.43.0