From be09b3475d541403a5a15fd6f070503f579aadc1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 19 Jun 2023 17:16:00 +0200 Subject: [PATCH] linter fixes, version bump --- .flake8 | 1 + eive_tmtc/__init__.py | 8 +- eive_tmtc/config/definitions.py | 1 - eive_tmtc/config/object_ids.py | 2 +- eive_tmtc/gomspace/gomspace_common.py | 10 ++- eive_tmtc/pus_tc/cmd_definitions.py | 2 - eive_tmtc/pus_tc/procedure_packer.py | 6 +- eive_tmtc/pus_tc/prompt_parameters.py | 27 +++--- eive_tmtc/pus_tc/system/__init__.py | 1 - eive_tmtc/pus_tc/system/controllers.py | 3 +- eive_tmtc/pus_tc/system/proc.py | 16 +++- eive_tmtc/pus_tm/action_reply_handler.py | 14 +++- eive_tmtc/pus_tm/event_handler.py | 21 +++-- eive_tmtc/pus_tm/factory_hook.py | 4 +- eive_tmtc/pus_tm/hk_handling.py | 3 +- eive_tmtc/pus_tm/tm_tcp_server.py | 14 ++-- eive_tmtc/tmtc/acs/acs_ctrl.py | 28 ++++--- eive_tmtc/tmtc/acs/imtq.py | 7 +- eive_tmtc/tmtc/acs/mgms.py | 3 +- eive_tmtc/tmtc/acs/reaction_wheels.py | 10 +-- eive_tmtc/tmtc/acs/star_tracker.py | 2 +- eive_tmtc/tmtc/acs/str_img_helper.py | 3 +- eive_tmtc/tmtc/acs/sus.py | 2 +- eive_tmtc/tmtc/com/ccsds_handler.py | 3 +- eive_tmtc/tmtc/com/subsystem.py | 2 +- eive_tmtc/tmtc/com/syrlinks_handler.py | 2 +- eive_tmtc/tmtc/core.py | 4 +- eive_tmtc/tmtc/health.py | 2 - eive_tmtc/tmtc/obj_prompt.py | 2 - eive_tmtc/tmtc/payload/ploc_memory_dumper.py | 4 +- eive_tmtc/tmtc/payload/ploc_mpsoc.py | 6 +- eive_tmtc/tmtc/payload/ploc_supervisor.py | 6 +- eive_tmtc/tmtc/payload/rad_sensor.py | 2 +- eive_tmtc/tmtc/payload/scex.py | 2 +- eive_tmtc/tmtc/power/common_power.py | 2 +- eive_tmtc/tmtc/power/p60dock.py | 4 +- eive_tmtc/tmtc/power/pdu1.py | 18 +++- eive_tmtc/tmtc/power/pdu2.py | 18 +++- eive_tmtc/tmtc/power/plpcdu.py | 4 +- eive_tmtc/tmtc/power/power.py | 1 - eive_tmtc/tmtc/power/tm.py | 15 ++-- eive_tmtc/tmtc/solar_array_deployment.py | 3 +- eive_tmtc/tmtc/system.py | 1 - eive_tmtc/tmtc/tcs/tm.py | 2 - eive_tmtc/tmtc/tm_store.py | 3 +- eive_tmtc/utility/input_helper.py | 3 +- tmtcc.py | 10 +-- tmtcloop.py | 87 -------------------- 48 files changed, 179 insertions(+), 215 deletions(-) delete mode 100755 tmtcloop.py diff --git a/.flake8 b/.flake8 index 9dca1e5..6391e2d 100644 --- a/.flake8 +++ b/.flake8 @@ -7,6 +7,7 @@ exclude = .git, __pycache__, docs/conf.py, + deps old, build, dist, diff --git a/eive_tmtc/__init__.py b/eive_tmtc/__init__.py index a4fe42a..453ef2e 100644 --- a/eive_tmtc/__init__.py +++ b/eive_tmtc/__init__.py @@ -1,12 +1,12 @@ -__version__ = "3.1.2" +__version__ = "4.0.0" import logging from pathlib import Path SW_NAME = "eive-tmtc" -VERSION_MAJOR = 3 -VERSION_MINOR = 1 -VERSION_REVISION = 2 +VERSION_MAJOR = 4 +VERSION_MINOR = 0 +VERSION_REVISION = 0 EIVE_TMTC_ROOT = Path(__file__).parent PACKAGE_ROOT = EIVE_TMTC_ROOT.parent diff --git a/eive_tmtc/config/definitions.py b/eive_tmtc/config/definitions.py index a3cf5c3..a80444c 100644 --- a/eive_tmtc/config/definitions.py +++ b/eive_tmtc/config/definitions.py @@ -9,7 +9,6 @@ import enum from spacepackets import PacketType from spacepackets.ccsds import PacketId from spacepackets.util import UnsignedByteField -from pathlib import Path PUS_APID = 0x65 diff --git a/eive_tmtc/config/object_ids.py b/eive_tmtc/config/object_ids.py index 9f0ecd8..f0b165d 100644 --- a/eive_tmtc/config/object_ids.py +++ b/eive_tmtc/config/object_ids.py @@ -8,7 +8,7 @@ import os.path from typing import Dict from eive_tmtc import EIVE_TMTC_ROOT -from tmtccmd.util.obj_id import ObjectIdDictT, ObjectIdU32 +from tmtccmd.util.obj_id import ObjectIdU32 from tmtccmd.fsfw import parse_fsfw_objects_csv diff --git a/eive_tmtc/gomspace/gomspace_common.py b/eive_tmtc/gomspace/gomspace_common.py index 1c48705..0e102ca 100644 --- a/eive_tmtc/gomspace/gomspace_common.py +++ b/eive_tmtc/gomspace/gomspace_common.py @@ -74,7 +74,9 @@ def pack_get_param_command( memory_address: Union[int, bytes], parameter_size: int, ) -> PusTelecommand: - """Function to generate a command to retrieve parameters like the temperature from a gomspace device. + """Function to generate a command to retrieve parameters like the temperature from a + gomspace device. + @param object_id: The object id of the gomspace device handler. @param table_id: The table id of the gomspace device @param memory_address: Address offset within table of the value to read. @@ -218,9 +220,9 @@ def prompt_and_pack_set_integer_param_command( def pack_ping_command(object_id: ObjectIdU32, data: bytearray) -> PusTelecommand: """ " Function to generate the command to ping a gomspace device - @param object_id Object Id of the gomspace device handler. - @param data Bytearray containing the bytes to send to the gomspace device. For now the on board software - supports only the handling of up to 33 bytes. + :param object_id: Object Id of the gomspace device handler. + :param data: Bytearray containing the bytes to send to the gomspace device. For now the on board + software supports only the handling of up to 33 bytes. @note The ping request sends the specified data to a gompsace device. These data are simply copied by the device and then sent back. """ diff --git a/eive_tmtc/pus_tc/cmd_definitions.py b/eive_tmtc/pus_tc/cmd_definitions.py index cb52228..88ba312 100644 --- a/eive_tmtc/pus_tc/cmd_definitions.py +++ b/eive_tmtc/pus_tc/cmd_definitions.py @@ -1,7 +1,5 @@ -from eive_tmtc.config.definitions import CustomServiceList from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry, CoreServiceList from tmtccmd.config.tmtc import ( - tmtc_definitions_provider, call_all_definitions_providers, ) from tmtccmd.config.globals import get_default_tmtc_defs diff --git a/eive_tmtc/pus_tc/procedure_packer.py b/eive_tmtc/pus_tc/procedure_packer.py index 1c2376e..7022d52 100644 --- a/eive_tmtc/pus_tc/procedure_packer.py +++ b/eive_tmtc/pus_tc/procedure_packer.py @@ -29,7 +29,7 @@ from eive_tmtc.tmtc.acs.reaction_wheels import ( 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_test +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 @@ -75,7 +75,7 @@ from tmtccmd.util import ObjectIdU32 from eive_tmtc.utility.input_helper import InputHelper -def handle_default_procedure( +def handle_default_procedure( # noqa C901: Complexity okay here. tc_base: TcHandlerBase, info: DefaultProcedureInfo, queue_helper: DefaultPusQueueHelper, @@ -170,7 +170,7 @@ def handle_default_procedure( ) if service == CustomServiceList.CCSDS_HANDLER.value: object_id = cast(ObjectIdU32, obj_id_man.get(CCSDS_HANDLER_ID)) - return pack_ccsds_handler_test( + return pack_ccsds_handler_command( object_id=object_id, q=queue_helper, op_code=op_code ) if service == CustomServiceList.PDEC_HANDLER.value: diff --git a/eive_tmtc/pus_tc/prompt_parameters.py b/eive_tmtc/pus_tc/prompt_parameters.py index b9dde69..188e227 100644 --- a/eive_tmtc/pus_tc/prompt_parameters.py +++ b/eive_tmtc/pus_tc/prompt_parameters.py @@ -10,14 +10,11 @@ from PyQt5.QtWidgets import ( from PyQt5 import QtCore -from tmtccmd.config import CoreModeList -from tmtccmd.core.globals_manager import get_global - class Parameter: - def __init__(self, name: str, defaultValue: str, widget: QLineEdit): + def __init__(self, name: str, default_value: str, widget: QLineEdit): self.name = name - self.defaultValue = defaultValue + self.defaultValue = default_value self.widget = widget self.value = self.defaultValue self.widget.setPlaceholderText(self.defaultValue) @@ -34,9 +31,9 @@ class ParameterDialog(QDialog): self.setWindowTitle("Enter Parameters") - Buttons = QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Reset + buttons = QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Reset - self.buttonBox = QDialogButtonBox(Buttons) + self.buttonBox = QDialogButtonBox(buttons) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.buttonBox.button(QDialogButtonBox.Reset).clicked.connect(self._reset) @@ -54,14 +51,14 @@ class ParameterDialog(QDialog): self.parameters = {} - def addParameter(self, name: str, defaultValue: str): + def add_parameter(self, name: str, default_value: str): row = self.groupLayout.rowCount() + 1 description = QLabel(name) self.groupLayout.addWidget(description, row, 0) - valueWidget = QLineEdit() - self.groupLayout.addWidget(valueWidget, row, 1) + value_widget = QLineEdit() + self.groupLayout.addWidget(value_widget, row, 1) - parameter = Parameter(name, defaultValue, valueWidget) + parameter = Parameter(name, default_value, value_widget) self.parameters[name] = parameter @@ -69,10 +66,10 @@ class ParameterDialog(QDialog): for value in self.parameters.values(): value.reset() - def getParameters(self): + def get_parameters(self): output = {} for key, parameter in self.parameters.items(): - if parameter.widget != None: + if parameter.widget is not None: if parameter.widget.text() != "": parameter.value = parameter.widget.text() output[key] = parameter.value @@ -103,9 +100,9 @@ def prompt_parameters_cli(param_list) -> dict: def _gui_prompt(param_list) -> dict: dialog = ParameterDialog() for parameter in param_list: - dialog.addParameter(parameter["name"], parameter["defaultValue"]) + dialog.add_parameter(parameter["name"], parameter["defaultValue"]) dialog.exec_() - return dialog.getParameters() + return dialog.get_parameters() def _cli_prompt(param_list) -> dict: diff --git a/eive_tmtc/pus_tc/system/__init__.py b/eive_tmtc/pus_tc/system/__init__.py index 8b13789..e69de29 100644 --- a/eive_tmtc/pus_tc/system/__init__.py +++ b/eive_tmtc/pus_tc/system/__init__.py @@ -1 +0,0 @@ - diff --git a/eive_tmtc/pus_tc/system/controllers.py b/eive_tmtc/pus_tc/system/controllers.py index 5119ecf..6ffcceb 100644 --- a/eive_tmtc/pus_tc/system/controllers.py +++ b/eive_tmtc/pus_tc/system/controllers.py @@ -86,9 +86,8 @@ def pack_cmd_ctrl_to_nml( def get_object_from_op_code(op_code: str): try: return bytes.fromhex(op_code) - except: + except ValueError: pass - if op_code in OpCode.THERMAL_CONTROLLER: return obj_ids.THERMAL_CONTROLLER_ID if op_code in OpCode.CORE_CONTROLLER: diff --git a/eive_tmtc/pus_tc/system/proc.py b/eive_tmtc/pus_tc/system/proc.py index 5c38e53..54ab761 100644 --- a/eive_tmtc/pus_tc/system/proc.py +++ b/eive_tmtc/pus_tc/system/proc.py @@ -1,10 +1,12 @@ from __future__ import annotations +import struct import time from datetime import timedelta from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import get_object_ids +from spacepackets.ecss import PusTelecommand from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry from tmtccmd.config.tmtc import tmtc_definitions_provider @@ -14,7 +16,6 @@ from tmtccmd.pus.s11_tc_sched import ( create_enable_tc_sched_cmd, create_reset_tc_sched_cmd, ) -from tmtccmd.tc.pus_3_fsfw_hk import * import eive_tmtc.config.object_ids as oids from eive_tmtc.tmtc.tcs.brd_assy import OpCodeAssy as TcsOpCodes @@ -49,6 +50,11 @@ from eive_tmtc.tmtc.acs.gyros import ( L3gGyroSetId as L3gGyroSetIds_1_3, ) from eive_tmtc.tmtc.acs.gps import SetId as GpsSetIds +from tmtccmd.tc.pus_3_fsfw_hk import ( + make_sid, + disable_periodic_hk_command, + create_enable_periodic_hk_command_with_interval, +) class OpCode: @@ -154,7 +160,7 @@ def add_proc_cmds(defs: TmtcDefinitionWrapper): ) -def pack_generic_hk_listening_cmds( +def pack_generic_hk_listening_cmds( # noqa C901: Complexity okay here. q: DefaultPusQueueHelper, proc_key: str, sid_list: list[bytearray], @@ -222,7 +228,9 @@ def pack_generic_hk_listening_cmds( diag_list.clear() -def pack_proc_commands(q: DefaultPusQueueHelper, op_code: str): +def pack_proc_commands( # noqa C901: Complexity is okay here. + q: DefaultPusQueueHelper, op_code: str +): # noqa C901: Complexity okay here. sid_list = [] obj_id_dict = get_object_ids() if op_code in OpCode.RESET_SCHED: @@ -733,7 +741,7 @@ def enable_listen_to_hk_for_x_seconds( interval_seconds: float, ): q.add_log_cmd(f"Enabling periodic HK for {device}") - cmd_tuple = enable_periodic_hk_command_with_interval( + cmd_tuple = create_enable_periodic_hk_command_with_interval( diag=diag, sid=sid, interval_seconds=interval_seconds ) for cmd in cmd_tuple: diff --git a/eive_tmtc/pus_tm/action_reply_handler.py b/eive_tmtc/pus_tm/action_reply_handler.py index 3b48214..661812a 100644 --- a/eive_tmtc/pus_tm/action_reply_handler.py +++ b/eive_tmtc/pus_tm/action_reply_handler.py @@ -1,5 +1,16 @@ +import logging import struct -from eive_tmtc.config.object_ids import * +from eive_tmtc.config.object_ids import ( + ACU_HANDLER_ID, + PDU_1_HANDLER_ID, + PDU_2_HANDLER_ID, + IMTQ_HANDLER_ID, + PLOC_MPSOC_ID, + PLOC_SUPV_ID, + CORE_CONTROLLER_ID, + STAR_TRACKER_ID, + P60_DOCK_HANDLER, +) from eive_tmtc.tmtc.acs.imtq import ImtqActionId from eive_tmtc.pus_tm.defs import PrintWrapper from eive_tmtc.tmtc.core import handle_core_ctrl_action_replies @@ -10,6 +21,7 @@ from eive_tmtc.tmtc.power.tm import handle_get_param_data_reply from tmtccmd.tm import Service8FsfwTm from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from spacepackets.ccsds.time import CdsShortTimestamp +from tmtccmd.util import ObjectIdDictT _LOGGER = logging.getLogger(__name__) diff --git a/eive_tmtc/pus_tm/event_handler.py b/eive_tmtc/pus_tm/event_handler.py index cd670ed..3e613f5 100644 --- a/eive_tmtc/pus_tm/event_handler.py +++ b/eive_tmtc/pus_tm/event_handler.py @@ -17,7 +17,9 @@ from spacepackets.ccsds.time import CdsShortTimestamp _LOGGER = logging.getLogger(__name__) -def handle_event_packet(raw_tm: bytes, pw: PrintWrapper): +def handle_event_packet( # noqa C901: Complexity okay here + raw_tm: bytes, pw: PrintWrapper +): # noqa C901: Complexity okay here tm = Service5Tm.unpack(data=raw_tm, time_reader=CdsShortTimestamp.empty()) event_dict = get_event_dict() event_def = tm.event_definition @@ -33,7 +35,10 @@ def handle_event_packet(raw_tm: bytes, pw: PrintWrapper): obj_name = event_def.reporter_id.hex(sep=",") else: obj_name = obj_id_obj.name - generic_event_string = f"Object {obj_name} generated Event {info.name} (ID: {event_def.event_id:#04x}) at {tm.time_provider.as_date_time()}" + generic_event_string = ( + f"Object {obj_name} generated Event {info.name} (ID: {event_def.event_id:#04x}) " + f"at {tm.time_provider.as_date_time()}" + ) _LOGGER.info(generic_event_string) pw.file_logger.info( f"{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: {generic_event_string}" @@ -48,8 +53,8 @@ def handle_event_packet(raw_tm: bytes, pw: PrintWrapper): if info.name == "SUPV_UPDATE_PROGRESS" or info.name == "WRITE_MEMORY_FAILED": additional_event_info = f"Additional info: {info.info}" context = ( - f"Progress Percent: {event_def.param1 >> 24 & 0xff} | Sequence Count: {event_def.param1 & 0xffff} " - f"| Bytes Written: {event_def.param2}" + f"Progress Percent: {event_def.param1 >> 24 & 0xff} | " + f"Sequence Count: {event_def.param1 & 0xffff} | Bytes Written: {event_def.param2}" ) pw.dlog(additional_event_info) pw.dlog(context) @@ -75,7 +80,8 @@ def handle_event_packet(raw_tm: bytes, pw: PrintWrapper): elif event_def.param1 == Mode.RAW: mode_name = "Raw" pw.dlog( - f"Mode Number {event_def.param1}, Mode Name {mode_name}, Submode: {event_def.param2}" + f"Mode Number {event_def.param1}, Mode Name {mode_name}, " + f"Submode: {event_def.param2}" ) if info.name == "INDIVIDUAL_BOOT_COUNTS": boot_count_00 = (event_def.param1 >> 16) & 0xFFFF @@ -126,7 +132,10 @@ def handle_event_packet(raw_tm: bytes, pw: PrintWrapper): submode = event_def.param2 pw.dlog(f"Mode Number {mode}, Submode: {submode}") if not specific_handler: - additional_event_info = f"Additional info: {info.info} | P1: {event_def.param1} | P2: {event_def.param2}" + additional_event_info = ( + f"Additional info: {info.info} | P1: {event_def.param1} | " + f"P2: {event_def.param2}" + ) pw.dlog(additional_event_info) if not specific_handler: # printer.handle_long_tm_print(packet_if=tm.pus_tm, info_if=tm.pus_tm) diff --git a/eive_tmtc/pus_tm/factory_hook.py b/eive_tmtc/pus_tm/factory_hook.py index 5dc3669..6b74468 100644 --- a/eive_tmtc/pus_tm/factory_hook.py +++ b/eive_tmtc/pus_tm/factory_hook.py @@ -24,7 +24,7 @@ from .action_reply_handler import handle_action_reply _LOGGER = logging.getLogger(__name__) -def pus_factory_hook( +def pus_factory_hook( # noqa C901 : Complexity okay here packet: bytes, verif_wrapper: VerificationWrapper, printer: FsfwTmTcPrinter, @@ -78,7 +78,7 @@ def pus_factory_hook( elif isinstance(scalar_param, float): pw.dlog(f"Scalar floating point parameter: {scalar_param}") except ValueError as e: - pw.dlog("received {e} trying to parse scalar parameter") + 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 diff --git a/eive_tmtc/pus_tm/hk_handling.py b/eive_tmtc/pus_tm/hk_handling.py index 5c3edd9..1eb3c47 100644 --- a/eive_tmtc/pus_tm/hk_handling.py +++ b/eive_tmtc/pus_tm/hk_handling.py @@ -1,5 +1,4 @@ """HK Handling for EIVE OBSW""" -import datetime import logging # from pus_tm.tcp_server_objects import TCP_SEVER_SENSOR_TEMPERATURES @@ -85,7 +84,7 @@ def handle_hk_packet( _LOGGER.warning("HK definitions printout not implemented yet") -def handle_regular_hk_print( +def handle_regular_hk_print( # noqa C901: Complexity okay here printer: FsfwTmTcPrinter, object_id: ObjectIdU32, hk_packet: Service3Base, diff --git a/eive_tmtc/pus_tm/tm_tcp_server.py b/eive_tmtc/pus_tm/tm_tcp_server.py index f2a7e02..2d9b7d8 100644 --- a/eive_tmtc/pus_tm/tm_tcp_server.py +++ b/eive_tmtc/pus_tm/tm_tcp_server.py @@ -1,13 +1,13 @@ +import logging import socket from typing import Optional import json import base64 -from tmtccmd.logging import get_console_logger from tmtccmd.util.obj_id import ObjectIdU32 from dle_encoder import DleEncoder -LOGGER = get_console_logger() +_LOGGER = logging.getLogger(__name__) class TmTcpServer: @@ -29,8 +29,8 @@ class TmTcpServer: def __del__(self): try: self.close() - except: - LOGGER.warning("Could not close sockets!") + except IOError: + _LOGGER.warning("Could not close sockets!") def close(self): self.server_socket.close() @@ -45,8 +45,8 @@ class TmTcpServer: (self.client_connection, _) = self.server_socket.accept() self.client_connection.setblocking(False) print("Client connected") - except: - # no client waiting + except IOError: + return data_json_bytes = json.dumps(dictionary).encode() @@ -57,7 +57,7 @@ class TmTcpServer: try: sent_length = self.client_connection.send(data_json_bytes) - except: + except IOError: self.client_connection = None return if sent_length == 0: diff --git a/eive_tmtc/tmtc/acs/acs_ctrl.py b/eive_tmtc/tmtc/acs/acs_ctrl.py index 6ba6503..c763786 100644 --- a/eive_tmtc/tmtc/acs/acs_ctrl.py +++ b/eive_tmtc/tmtc/acs/acs_ctrl.py @@ -229,7 +229,7 @@ def acs_cmd_defs(defs: TmtcDefinitionWrapper): @service_provider(CustomServiceList.ACS_CTRL.value) -def pack_acs_ctrl_command(p: ServiceProviderParams): +def pack_acs_ctrl_command(p: ServiceProviderParams): # noqa C901 op_code = p.op_code q = p.queue_helper if op_code in OpCodes.OFF: @@ -507,7 +507,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameter=param, - ).pack() + ) ) ) case 1: @@ -519,7 +519,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameter=param, - ).pack() + ) ) ) case 2: @@ -531,7 +531,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameter=param, - ).pack() + ) ) ) case 3: @@ -543,7 +543,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameter=param, - ).pack() + ) ) ) case 4: @@ -555,7 +555,7 @@ def set_acs_ctrl_param_scalar(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameter=param, - ).pack() + ) ) ) @@ -603,7 +603,7 @@ def set_acs_ctrl_param_vector(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameters=param, - ).pack() + ) ) ) else: @@ -636,7 +636,7 @@ def set_acs_ctrl_param_matrix(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameters=param, - ).pack() + ) ) ) else: @@ -663,7 +663,7 @@ def set_acs_ctrl_param_matrix(q: DefaultPusQueueHelper): domain_id=sid, unique_id=pid, parameters=param, - ).pack() + ) ) ) else: @@ -1132,7 +1132,9 @@ def handle_act_cmd_data(pw: PrintWrapper, hk_data: bytes): FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=3) -def perform_mgm_calibration(pw: PrintWrapper, mgm_tuple: Tuple): +def perform_mgm_calibration( # noqa C901: Complexity okay + pw: PrintWrapper, mgm_tuple: Tuple +): # noqa C901: Complexity okay global CALIBR_SOCKET, CALIBRATION_ADDR try: declare_api_cmd = "declare_api_version 2" @@ -1146,7 +1148,7 @@ def perform_mgm_calibration(pw: PrintWrapper, mgm_tuple: Tuple): return else: if str(reply[0]) == "0": - pw.dlog(f"MGM calibration: API version 2 was not accepted") + pw.dlog("MGM calibration: API version 2 was not accepted") return if len(mgm_tuple) != 3: pw.dlog(f"MGM tuple has invalid length {len(mgm_tuple)}") @@ -1164,7 +1166,7 @@ def perform_mgm_calibration(pw: PrintWrapper, mgm_tuple: Tuple): return else: if str(reply[0]) == "0": - pw.dlog(f"MGM calibration: magnetmeter field format was not accepted") + pw.dlog("MGM calibration: magnetmeter field format was not accepted") return pw.dlog(f"Sent data {mgm_list} to Helmholtz Testbench successfully") except socket.timeout: @@ -1172,6 +1174,6 @@ def perform_mgm_calibration(pw: PrintWrapper, mgm_tuple: Tuple): except BlockingIOError as e: pw.dlog(f"Error {e}") except ConnectionResetError as e: - pw.dlog("Socket was closed") + pw.dlog(f"Socket was closed: {e}") except ConnectionRefusedError or OSError: pw.dlog("Connecting to Calibration Socket on addrss {} failed") diff --git a/eive_tmtc/tmtc/acs/imtq.py b/eive_tmtc/tmtc/acs/imtq.py index 1d40fab..cf739ea 100644 --- a/eive_tmtc/tmtc/acs/imtq.py +++ b/eive_tmtc/tmtc/acs/imtq.py @@ -24,7 +24,6 @@ from tmtccmd.tc.pus_3_fsfw_hk import ( generate_one_diag_command, generate_one_hk_command, create_request_one_diag_command, - create_enable_periodic_hk_command, create_disable_periodic_hk_command, create_enable_periodic_hk_command_with_interval, ) @@ -129,7 +128,9 @@ def add_imtq_cmds(defs: TmtcDefinitionWrapper): defs.add_service(CustomServiceList.IMTQ.value, "IMQT Device", oce) -def pack_imtq_test_into(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): +def pack_imtq_test_into( # noqa C901 + object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str +): q.add_log_cmd( f"Testing ISIS IMTQ handler with object id: {object_id.as_hex_string}" ) @@ -680,7 +681,7 @@ def handle_self_test_data(pw: PrintWrapper, hk_data: bytes): init_coil_z_temperature, err, raw_mag_x, - init_raw_mag_y, + raw_mag_y, raw_mag_z, cal_mag_x, cal_mag_y, diff --git a/eive_tmtc/tmtc/acs/mgms.py b/eive_tmtc/tmtc/acs/mgms.py index ab6a64f..dbe633c 100644 --- a/eive_tmtc/tmtc/acs/mgms.py +++ b/eive_tmtc/tmtc/acs/mgms.py @@ -17,7 +17,6 @@ from tmtccmd.config.tmtc import tmtc_definitions_provider, TmtcDefinitionWrapper from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode from tmtccmd.util import ObjectIdU32 -from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter class OpCode: @@ -99,7 +98,7 @@ def handle_mgm_rm3100_hk_data( object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes ): if set_id == MgmRm3100SetId.CORE_HK: - fmt_str = f"!fff" + fmt_str = "!fff" inc_len = struct.calcsize(fmt_str) (field_x, field_y, field_z) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len]) pw.dlog(f"Received MGM RM3100 from object {object_id}") diff --git a/eive_tmtc/tmtc/acs/reaction_wheels.py b/eive_tmtc/tmtc/acs/reaction_wheels.py index 77777eb..52cfaf4 100644 --- a/eive_tmtc/tmtc/acs/reaction_wheels.py +++ b/eive_tmtc/tmtc/acs/reaction_wheels.py @@ -144,7 +144,7 @@ def add_rw_cmds(defs: TmtcDefinitionWrapper): ) -def pack_single_rw_test_into( +def pack_single_rw_test_into( # noqa C901: Complexity is okay here. object_id: bytes, rw_idx: int, q: DefaultPusQueueHelper, op_code: str ): if op_code == OpCodesDev.SPEED: @@ -374,7 +374,7 @@ def handle_rw_hk_data( f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, " f"4: Running, speed changing" ) - pw.dlog(f"Number Of Invalid Packets:") + pw.dlog("Number Of Invalid Packets:") pw.dlog("CRC | Length | CMD") pw.dlog( f"{num_invalid_crc_packets} | {num_invalid_len_packets} | {num_invalid_cmd_packets}" @@ -385,8 +385,8 @@ def handle_rw_hk_data( ) pw.dlog("UART COM information:") pw.dlog( - f"NumBytesWritten | NumBytesRead | ParityErrs | NoiseErrs | FrameErrs | " - f"RegOverrunErrs | TotalErrs" + "NumBytesWritten | NumBytesRead | ParityErrs | NoiseErrs | FrameErrs | " + "RegOverrunErrs | TotalErrs" ) pw.dlog( f"{uart_num_of_bytes_written} | {uart_num_of_bytes_read} | {uart_num_parity_errors} | " @@ -394,7 +394,7 @@ def handle_rw_hk_data( f"{uart_total_num_errors}" ) pw.dlog("SPI COM Info:") - pw.dlog(f"NumBytesWritten | NumBytesRead | RegOverrunErrs | TotalErrs") + pw.dlog("NumBytesWritten | NumBytesRead | RegOverrunErrs | TotalErrs") pw.dlog( f"{spi_num_bytes_written} | {spi_num_bytes_read} | {spi_num_reg_overrun_errors} | " f"{spi_total_num_errors}" diff --git a/eive_tmtc/tmtc/acs/star_tracker.py b/eive_tmtc/tmtc/acs/star_tracker.py index 9ff1441..b45738d 100644 --- a/eive_tmtc/tmtc/acs/star_tracker.py +++ b/eive_tmtc/tmtc/acs/star_tracker.py @@ -202,7 +202,7 @@ def prompt_object_id_mode_cmd() -> bytes: return STAR_TRACKER_ID -def pack_star_tracker_commands( +def pack_star_tracker_commands( # noqa C901 object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str ): q.add_log_cmd( diff --git a/eive_tmtc/tmtc/acs/str_img_helper.py b/eive_tmtc/tmtc/acs/str_img_helper.py index 5fe6335..e33864a 100644 --- a/eive_tmtc/tmtc/acs/str_img_helper.py +++ b/eive_tmtc/tmtc/acs/str_img_helper.py @@ -4,7 +4,8 @@ @brief Commanding of the star tracker image helper object which is responsible for uploading and downloading images to/from the star tracker. @details Images to uplaod must be previously transferred to the OBC with the CFDP protocol. - Also downloaded images will be stored on the filesystem of the OBC and can be transferred via CFDP. + Also downloaded images will be stored on the filesystem of the OBC and can be + transferred via CFDP. @author J. Meier @date 29.11.2021 """ diff --git a/eive_tmtc/tmtc/acs/sus.py b/eive_tmtc/tmtc/acs/sus.py index 6540f89..90237f0 100644 --- a/eive_tmtc/tmtc/acs/sus.py +++ b/eive_tmtc/tmtc/acs/sus.py @@ -23,7 +23,7 @@ def handle_sus_hk( channels.append(struct.unpack("!H", hk_data[current_idx : current_idx + 2])) current_idx += 2 pw.dlog(f"Temperature: {temperature} C") - pw.dlog(f"AIN Channel | Raw Value (hex) | Raw Value (dec)") + pw.dlog("AIN Channel | Raw Value (hex) | Raw Value (dec)") for idx, val in enumerate(channels): pw.dlog(f"{idx} | {val[0]:#06x} |" + str(val[0]).ljust(5)) FsfwTmTcPrinter.get_validity_buffer( diff --git a/eive_tmtc/tmtc/com/ccsds_handler.py b/eive_tmtc/tmtc/com/ccsds_handler.py index 212d43e..5fa4985 100644 --- a/eive_tmtc/tmtc/com/ccsds_handler.py +++ b/eive_tmtc/tmtc/com/ccsds_handler.py @@ -18,7 +18,6 @@ from tmtccmd.config.tmtc import ( from tmtccmd.tc import DefaultPusQueueHelper from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode from tmtccmd.util import ObjectIdU32 -from eive_tmtc.config.object_ids import CCSDS_HANDLER_ID class ActionId(enum.IntEnum): @@ -67,7 +66,7 @@ class Info: DISABLE_ACTION = "Disable TX (legacy)" -def pack_ccsds_handler_test( +def pack_ccsds_handler_command( # noqa C901 object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str ): obyt = object_id.as_bytes diff --git a/eive_tmtc/tmtc/com/subsystem.py b/eive_tmtc/tmtc/com/subsystem.py index bd77cc5..7a2273e 100644 --- a/eive_tmtc/tmtc/com/subsystem.py +++ b/eive_tmtc/tmtc/com/subsystem.py @@ -61,7 +61,7 @@ class Info: @service_provider(CustomServiceList.COM_SS) -def build_com_subsystem_cmd(p: ServiceProviderParams): +def build_com_subsystem_cmd(p: ServiceProviderParams): # noqa C901 q = p.queue_helper o = p.op_code prefix = "COM Subsystem" diff --git a/eive_tmtc/tmtc/com/syrlinks_handler.py b/eive_tmtc/tmtc/com/syrlinks_handler.py index 2f99e93..d103900 100644 --- a/eive_tmtc/tmtc/com/syrlinks_handler.py +++ b/eive_tmtc/tmtc/com/syrlinks_handler.py @@ -142,7 +142,7 @@ def normal_mode_cmd(q: DefaultPusQueueHelper, info: str, submode: int): q.add_pus_tc(create_mode_command(SYRLINKS_HANDLER_ID, Mode.NORMAL, submode)) -def pack_syrlinks_command( +def pack_syrlinks_command( # noqa C901: Complexity okay here. object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str ): obyt = object_id.as_bytes diff --git a/eive_tmtc/tmtc/core.py b/eive_tmtc/tmtc/core.py index 7a8621a..68f435c 100644 --- a/eive_tmtc/tmtc/core.py +++ b/eive_tmtc/tmtc/core.py @@ -212,7 +212,9 @@ def add_core_controller_definitions(defs: TmtcDefinitionWrapper): defs.add_service(CustomServiceList.CORE.value, "Core Controller", oce) -def pack_core_commands(q: DefaultPusQueueHelper, op_code: str): +def pack_core_commands( # noqa C901 + q: DefaultPusQueueHelper, op_code: str +): # noqa: C901 , complexity okay here if op_code == OpCode.ANNOUNCE_VERSION: q.add_log_cmd(f"{Info.ANNOUNCE_VERSION}") q.add_pus_tc(create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_VERSION)) diff --git a/eive_tmtc/tmtc/health.py b/eive_tmtc/tmtc/health.py index c99351e..b9e99d9 100644 --- a/eive_tmtc/tmtc/health.py +++ b/eive_tmtc/tmtc/health.py @@ -1,5 +1,3 @@ -import struct - from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.tmtc.obj_prompt import prompt_object from spacepackets.ecss import PusTelecommand diff --git a/eive_tmtc/tmtc/obj_prompt.py b/eive_tmtc/tmtc/obj_prompt.py index 69ee1f5..8a797dd 100644 --- a/eive_tmtc/tmtc/obj_prompt.py +++ b/eive_tmtc/tmtc/obj_prompt.py @@ -1,9 +1,7 @@ from eive_tmtc.config.object_ids import ( ACS_SUBSYSTEM_ID, - ACS_CONTROLLER, IMTQ_HANDLER_ID, GPS_0_HEALTH_DEV, - GPS_1_HEALTH_DEV, GYRO_0_ADIS_HANDLER_ID, GYRO_1_L3G_HANDLER_ID, ACS_BOARD_ASS_ID, diff --git a/eive_tmtc/tmtc/payload/ploc_memory_dumper.py b/eive_tmtc/tmtc/payload/ploc_memory_dumper.py index 3315ad0..ef79bd0 100644 --- a/eive_tmtc/tmtc/payload/ploc_memory_dumper.py +++ b/eive_tmtc/tmtc/payload/ploc_memory_dumper.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- """ @file ploc_memory_dumper.py -@brief This file implements the command to dump memory sectors of the PLOC. Memories of the PLOC which can be dumped - are one MRAM, two flash memories and the SRAM. +@brief This file implements the command to dump memory sectors of the PLOC. Memories of the PLOC + which can be dumped are one MRAM, two flash memories and the SRAM. @author J. Meier @date 31.08.2021 """ diff --git a/eive_tmtc/tmtc/payload/ploc_mpsoc.py b/eive_tmtc/tmtc/payload/ploc_mpsoc.py index 6f1f93e..57cbc58 100644 --- a/eive_tmtc/tmtc/payload/ploc_mpsoc.py +++ b/eive_tmtc/tmtc/payload/ploc_mpsoc.py @@ -175,7 +175,9 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper): @service_provider(CustomServiceList.PLOC_MPSOC) -def pack_ploc_mpsoc_commands(p: ServiceProviderParams): +def pack_ploc_mpsoc_commands( # noqa C901 + p: ServiceProviderParams, +): # noqa C901: Complexity okay here. object_id = get_object_ids().get(PLOC_MPSOC_ID) q = p.queue_helper prefix = "PLOC MPSoC" @@ -422,7 +424,7 @@ def prepare_replay_write_sequence_cmd(object_id: bytes) -> bytearray: def prepare_cam_take_pic_cmd(object_id: bytes) -> bytearray: selection = input("Use default parameter? (Y/N): ") - if selection is "Y" or selection is "y": + if selection.lower() in ["y", "1", "yes"]: filename = "0:/test" encoder_setting_y = 7 quantization_y = 0 diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index 4765fd8..ac17aef 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -223,7 +223,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): @service_provider(CustomServiceList.PLOC_SUPV) -def pack_ploc_supv_commands(p: ServiceProviderParams): +def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 q = p.queue_helper op_code = p.op_code object_id = get_object_ids().get(PLOC_SUPV_ID) @@ -484,7 +484,9 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): def pack_sel_boot_image_cmd( object_id: bytes, mem: int, bp0: int, bp1: int, bp2: int ) -> bytearray: - """This function can be used to generate the command to select the image from which the MPSoC will boot + """This function can be used to generate the command to select the image from which the MPSoC + will boot. + @param object_id The object id of the PLOC supervisor handler. @param mem The memory from which the MPSoC shall boot (NVM0 - 0, NVM1 - 1) @param bp0 Partition pin 0 diff --git a/eive_tmtc/tmtc/payload/rad_sensor.py b/eive_tmtc/tmtc/payload/rad_sensor.py index 50b443a..f4ba809 100644 --- a/eive_tmtc/tmtc/payload/rad_sensor.py +++ b/eive_tmtc/tmtc/payload/rad_sensor.py @@ -111,7 +111,7 @@ def handle_rad_sensor_data(pw: PrintWrapper, set_id: int, hk_data: bytes): ) ain_dict = {0: ain0, 1: ain1, 4: ain4, 5: ain5, 6: ain6, 7: ain7} pw.dlog(f"Temperature: {temp} C") - pw.dlog(f"AIN Channel | Raw Value (hex) | Raw Value (dec)") + pw.dlog("AIN Channel | Raw Value (hex) | Raw Value (dec)") for idx, val in ain_dict.items(): pw.dlog(f"{idx} | {val:#06x} | {str(val).ljust(5)}") current_idx += inc_len diff --git a/eive_tmtc/tmtc/payload/scex.py b/eive_tmtc/tmtc/payload/scex.py index 6b62b6a..f7fb047 100644 --- a/eive_tmtc/tmtc/payload/scex.py +++ b/eive_tmtc/tmtc/payload/scex.py @@ -75,7 +75,7 @@ def add_scex_cmds(defs: TmtcDefinitionWrapper): @service_provider(CustomServiceList.SCEX.value) -def pack_scex_cmds(p: ServiceProviderParams): +def pack_scex_cmds(p: ServiceProviderParams): # noqa C901 op_code = p.op_code q = p.queue_helper if op_code in OpCode.SWITCH_ON: diff --git a/eive_tmtc/tmtc/power/common_power.py b/eive_tmtc/tmtc/power/common_power.py index 630745b..477a3fa 100644 --- a/eive_tmtc/tmtc/power/common_power.py +++ b/eive_tmtc/tmtc/power/common_power.py @@ -140,7 +140,7 @@ def pack_common_power_cmds( q.add_pus_tc(disable_periodic_hk_command(True, make_sid(objb, SetId.CORE))) -def pack_common_gomspace_cmds( +def pack_common_gomspace_cmds( # noqa C901: Complexity is okay here. prefix: str, object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str ): objb = object_id.as_bytes diff --git a/eive_tmtc/tmtc/power/p60dock.py b/eive_tmtc/tmtc/power/p60dock.py index 49c1e32..b8908a6 100644 --- a/eive_tmtc/tmtc/power/p60dock.py +++ b/eive_tmtc/tmtc/power/p60dock.py @@ -98,7 +98,9 @@ class P60DockHkTable: wdt_gnd_left = TableEntry(bytearray([0x00, 0xA8]), TableEntry.uint32_size) -def pack_p60dock_cmds(object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str): +def pack_p60dock_cmds( # noqa C901: Complexity okay here. + object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: 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) diff --git a/eive_tmtc/tmtc/power/pdu1.py b/eive_tmtc/tmtc/power/pdu1.py index 71114d9..b42c66a 100644 --- a/eive_tmtc/tmtc/power/pdu1.py +++ b/eive_tmtc/tmtc/power/pdu1.py @@ -3,8 +3,16 @@ @author J. Meier @date 17.12.2020 """ +import enum + from eive_tmtc.config.definitions import CustomServiceList from eive_tmtc.config.object_ids import PDU_1_HANDLER_ID +from eive_tmtc.gomspace.gomspace_common import ( + pack_ping_command, + TableIds, + pack_get_param_command, +) +from eive_tmtc.gomspace.gomspace_pdu_definitions import PduHkTable from eive_tmtc.tmtc.power.common_power import ( pack_common_gomspace_cmds, req_hk_cmds, @@ -17,15 +25,15 @@ from eive_tmtc.tmtc.power.common_power import ( pack_common_power_cmds, GomspaceOpCode, GsInfo, - PowerInfo, add_common_power_defs, SetId, ) +from spacepackets.ecss import PusTelecommand -from eive_tmtc.gomspace.gomspace_common import * -from eive_tmtc.gomspace.gomspace_pdu_definitions import * from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper from tmtccmd.config.tmtc import tmtc_definitions_provider +from tmtccmd.tc import DefaultPusQueueHelper +from tmtccmd.util import ObjectIdU32 class Pdu1InfoBase: @@ -102,7 +110,9 @@ def info_off_pdu1(base: str) -> str: return "PDU1: " + base + " off" -def pdu1_switch_cmds(q: DefaultPusQueueHelper, op_code: str): +def pdu1_switch_cmds( # noqa C901: Complexity is okay here. + q: DefaultPusQueueHelper, op_code: str +): # noqa C901: Complexity okay here if op_code in PowerOpCodes.TCS_ON: tcs_on_cmd(q) elif op_code in PowerOpCodes.TCS_OFF: diff --git a/eive_tmtc/tmtc/power/pdu2.py b/eive_tmtc/tmtc/power/pdu2.py index 8cbbb2c..f36c18c 100644 --- a/eive_tmtc/tmtc/power/pdu2.py +++ b/eive_tmtc/tmtc/power/pdu2.py @@ -6,7 +6,18 @@ @author J. Meier @date 17.12.2020 """ +import enum + from eive_tmtc.config.object_ids import PDU_2_HANDLER_ID +from eive_tmtc.gomspace.gomspace_common import ( + pack_reboot_command, + pack_ping_command, + pack_gnd_wdt_reset_command, + pack_get_param_command, + TableIds, + pack_request_full_hk_table_command, +) +from eive_tmtc.gomspace.gomspace_pdu_definitions import PduHkTable, PduConfigTable from eive_tmtc.tmtc.power.common_power import ( pack_common_gomspace_cmds, req_hk_cmds, @@ -20,10 +31,11 @@ from eive_tmtc.tmtc.power.common_power import ( SetId, add_common_power_defs, ) -from eive_tmtc.gomspace.gomspace_common import * -from eive_tmtc.gomspace.gomspace_pdu_definitions import * +from spacepackets.ecss import PusTelecommand from tmtccmd.config import OpCodeEntry, TmtcDefinitionWrapper from tmtccmd.config.tmtc import tmtc_definitions_provider +from tmtccmd.tc import DefaultPusQueueHelper +from tmtccmd.util import ObjectIdU32 class Pdu2InfoBase: @@ -159,7 +171,7 @@ def add_pdu2_cmds(defs: TmtcDefinitionWrapper): ) -def pdu2_switch_cmds(q: DefaultPusQueueHelper, op_code: str): +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) elif op_code in PowerOpCodes.PL_PCDU_VBAT_NOM_OFF: diff --git a/eive_tmtc/tmtc/power/plpcdu.py b/eive_tmtc/tmtc/power/plpcdu.py index 9ec2896..745d7b4 100644 --- a/eive_tmtc/tmtc/power/plpcdu.py +++ b/eive_tmtc/tmtc/power/plpcdu.py @@ -161,7 +161,9 @@ def add_pl_pcdu_cmds(defs: TmtcDefinitionWrapper): defs.add_service(CustomServiceList.PL_PCDU.value, "PL PCDU", oce) -def pack_pl_pcdu_commands(q: DefaultPusQueueHelper, op_code: str): +def pack_pl_pcdu_commands( # noqa C901: Complexity is okay here. + q: DefaultPusQueueHelper, op_code: str +): # noqa C901: Complexity is okay here. if op_code in OpCode.SWITCH_ON: pack_pl_pcdu_mode_cmd(q=q, info=Info.SWITCH_ON, mode=Mode.ON, submode=0) if op_code in OpCode.SWITCH_OFF: diff --git a/eive_tmtc/tmtc/power/power.py b/eive_tmtc/tmtc/power/power.py index 61f613d..e6d47c5 100644 --- a/eive_tmtc/tmtc/power/power.py +++ b/eive_tmtc/tmtc/power/power.py @@ -35,7 +35,6 @@ from eive_tmtc.tmtc.power.acu import add_acu_cmds, acu_req_hk_cmds from tmtccmd.tc.pus_3_fsfw_hk import ( create_request_one_diag_command, make_sid, - create_request_one_hk_command, ) from tmtccmd.config.tmtc import tmtc_definitions_provider from tmtccmd.tc import DefaultPusQueueHelper diff --git a/eive_tmtc/tmtc/power/tm.py b/eive_tmtc/tmtc/power/tm.py index dd93cf6..6c7971b 100644 --- a/eive_tmtc/tmtc/power/tm.py +++ b/eive_tmtc/tmtc/power/tm.py @@ -119,7 +119,7 @@ class DevicesInfoParser: return current_idx def print(self, pw: PrintWrapper): - pw.dlog(f"Device Type | Device State (0:None | 1:OK | 3:ERROR | 4:NOT FOUND)") + pw.dlog("Device Type | Device State (0:None | 1:OK | 3:ERROR | 4:NOT FOUND)") for i in range(len(self.dev_types)): pw.dlog( f"{self.map_idx_to_type(self.dev_types[i])} | {self.dev_statuses[i]}" @@ -181,7 +181,7 @@ def handle_pdu_data(pw: PrintWrapper, pdu_idx: int, set_id: int, hk_data: bytes) wdt = WdtInfo(pw=pw) current_idx = wdt.parse(wdt_data=hk_data[current_idx:], current_idx=current_idx) wdt.print() - pw.dlog(f"PDU Device Types: 0:FRAM|1:ADC|2:ADC|3:TempSens|4,5,6,7:Reserved") + pw.dlog("PDU Device Types: 0:FRAM|1:ADC|2:ADC|3:TempSens|4,5,6,7:Reserved") dev_parser.print(pw=pw) if set_id == SetId.CORE or set_id == SetId.CORE: pw.dlog(f"Received PDU HK from PDU {pdu_idx}") @@ -377,9 +377,7 @@ def handle_acu_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): current_idx += inc_len pw.dlog("Received ACU Core HK. Voltages in mV, currents in mA") pw.dlog(f"VCC {vcc} mV | VBAT {vbat} mV | MPPT Mode {mppt_mode}") - header_str = ( - f"Channel | Input U [mV] | Input I [mA] | U Boost [mV] | Power [mW]" - ) + header_str = "Channel | Input U [mV] | Input I [mA] | U Boost [mV] | Power [mW]" pw.dlog(header_str) for i in range(6): pw.dlog( @@ -416,7 +414,8 @@ def handle_acu_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): pw.dlog("Received ACU Aux HK. Voltages in mV, currents in mA") pw.dlog( - f"DAC Enable States: DAC 0 {dac_enb_str[0]} | DAC 1 {dac_enb_str[1]} | DAC 2 {dac_enb_str[2]}" + f"DAC Enable States: DAC 0 {dac_enb_str[0]} | DAC 1 {dac_enb_str[1]} | " + f"DAC 2 {dac_enb_str[2]}" ) pw.dlog(f"Boot Cause {boot_cause} | Reset Cause {reset_cause}") pw.dlog( @@ -424,8 +423,8 @@ def handle_acu_hk_data(pw: PrintWrapper, set_id: int, hk_data: bytes): ) pw.dlog( - f"ACU Dev Types: 0:FRAM|1:ADC|2:ADC|3:DAC|4:DAC|" - f"5:DAC|6:TempSens|7:Reserved" + "ACU Dev Types: 0:FRAM|1:ADC|2:ADC|3:DAC|4:DAC|" + "5:DAC|6:TempSens|7:Reserved" ) dev_parser.print(pw=pw) FsfwTmTcPrinter.get_validity_buffer( diff --git a/eive_tmtc/tmtc/solar_array_deployment.py b/eive_tmtc/tmtc/solar_array_deployment.py index 0d197f3..5b44460 100644 --- a/eive_tmtc/tmtc/solar_array_deployment.py +++ b/eive_tmtc/tmtc/solar_array_deployment.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- """ @file solar_array_deployment.py -@brief The test function in this file simply returns a command which triggers the solar array deployment. +@brief The test function in this file simply returns a command which triggers the solar array + deployment. @author J. Meier @date 15.02.2021 """ diff --git a/eive_tmtc/tmtc/system.py b/eive_tmtc/tmtc/system.py index ec849a2..981729b 100644 --- a/eive_tmtc/tmtc/system.py +++ b/eive_tmtc/tmtc/system.py @@ -11,7 +11,6 @@ from tmtccmd.tc import service_provider from eive_tmtc.config.object_ids import EIVE_SYSTEM_ID from tmtccmd.tc.pus_200_fsfw_mode import ( create_mode_command, - Mode, create_announce_mode_recursive_command, ) from tmtccmd.tc.pus_8_fsfw_funccmd import create_action_cmd diff --git a/eive_tmtc/tmtc/tcs/tm.py b/eive_tmtc/tmtc/tcs/tm.py index 30237b8..e73a6fa 100644 --- a/eive_tmtc/tmtc/tcs/tm.py +++ b/eive_tmtc/tmtc/tcs/tm.py @@ -1,11 +1,9 @@ import logging -import pprint import struct from eive_tmtc.pus_tm.defs import PrintWrapper from tmtccmd.fsfw import validity_buffer_list from tmtccmd.util import ObjectIdU32 -from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from .defs import CtrlSetId from .heater import HEATER_LOCATION diff --git a/eive_tmtc/tmtc/tm_store.py b/eive_tmtc/tmtc/tm_store.py index c0ab6e4..10a8683 100644 --- a/eive_tmtc/tmtc/tm_store.py +++ b/eive_tmtc/tmtc/tm_store.py @@ -148,7 +148,8 @@ def time_prompt_offset_from_now() -> datetime.datetime: seconds_offset = math.floor( float( input( - "Please enter the time as a offset from now in seconds. Negative offset is allowed: " + "Please enter the time as a offset from now in seconds. Negative offset is " + "allowed: " ) ) ) diff --git a/eive_tmtc/utility/input_helper.py b/eive_tmtc/utility/input_helper.py index 4e2473a..3a52b69 100644 --- a/eive_tmtc/utility/input_helper.py +++ b/eive_tmtc/utility/input_helper.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- """ @file input_helper.py -@brief This class can be used to get user input. A dictionary must be provided which describes the input options. +@brief This class can be used to get user input. A dictionary must be provided which describes the + input options. @author J. Meier @date 13.02.2021 """ diff --git a/tmtcc.py b/tmtcc.py index 60201a1..739ecf0 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -45,7 +45,7 @@ except ImportError as error: try: import tmtccmd -except ImportError as error: +except ImportError: run_tmtc_commander = None initialize_tmtc_commander = None tb = traceback.format_exc() @@ -204,7 +204,7 @@ class CfdpInCcsdsWrapper(SpecificApidHandlerBase): _LOGGER.info("Received File Data PDU TM") else: if pdu_base.directive_type == DirectiveType.FINISHED_PDU: - _LOGGER.info(f"Received Finished PDU TM") + _LOGGER.info("Received Finished PDU TM") else: _LOGGER.info( f"Received File Directive PDU with type {pdu_base.directive_type!r} TM" @@ -312,7 +312,7 @@ class TcHandler(TcHandlerBase): ) elif pdu.pdu_directive_type == DirectiveType.EOF_PDU: self.queue_helper.add_log_cmd( - f"CFDP Source: Sending EOF PDU" + "CFDP Source: Sending EOF PDU" ) else: fd_pdu = pdu.to_file_data_pdu() @@ -332,7 +332,7 @@ class TcHandler(TcHandlerBase): f"Finished queue for service {def_proc.service} and op code {def_proc.op_code}" ) elif info.proc_type == TcProcedureType.CFDP: - _LOGGER.info(f"Finished CFDP queue") + _LOGGER.info("Finished CFDP queue") def setup_params() -> SetupWrapper: @@ -437,7 +437,7 @@ def setup_backend( return tmtc_backend -def main(): +def main(): # noqa C901: Complexity okay here. print(f"-- eive tmtc v{__version__} --") print(f"-- spacepackets v{spacepackets.__version__} --") add_colorlog_console_logger(_LOGGER) diff --git a/tmtcloop.py b/tmtcloop.py deleted file mode 100755 index d177c83..0000000 --- a/tmtcloop.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python3 -"""EIVE TMTC Commander""" -import sys -import traceback - -try: - import tmtccmd.runner as tmtccmd - from tmtccmd.config import default_json_path, SetupArgs, CoreGlobalIds - from tmtccmd.config.definitions import CoreModeList - from tmtccmd.config.args import ( - create_default_args_parser, - add_default_tmtccmd_args, - parse_default_input_arguments, - handle_unspecified_args, - ) - from tmtccmd.ccsds.handler import CcsdsTmHandler, ApidHandler - from tmtccmd.logging import get_console_logger - from tmtccmd.logging.pus import create_tmtc_logger -except ImportError as error: - run_tmtc_commander = None - initialize_tmtc_commander = None - tb = traceback.format_exc() - print(tb) - print("Python tmtccmd submodule could not be imported") - sys.exit(1) - -try: - import spacepackets -except ImportError as error: - print(error) - print("Python spacepackets module could not be imported") - print( - 'Install with "cd spacepackets && python3 -m pip intall -e ." for interative installation' - ) - sys.exit(1) - -from config.definitions import PUS_APID -from pus_tc.procedure_packer import pre_tc_send_cb -from pus_tm.factory_hook import ccsds_tm_handler -from tmtcc import tmtcc_pre_args - - -def main(): - hook_obj = tmtcc_pre_args() - arg_parser = create_default_args_parser() - add_default_tmtccmd_args(arg_parser) - args = parse_default_input_arguments(arg_parser, hook_obj) - setup_args = SetupArgs( - hook_obj=hook_obj, use_gui=False, apid=PUS_APID, cli_args=args - ) - apid_handler = ApidHandler(cb=ccsds_tm_handler, queue_len=50, user_args=None) - ccsds_handler = CcsdsTmHandler() - ccsds_handler.add_tm_handler(apid=PUS_APID, handler=apid_handler) - tmtccmd.setup(setup_args=setup_args) - tmtccmd.add_ccsds_handler(ccsds_handler) - tmtc_backend = tmtccmd.create_default_tmtc_backend( - setup_args=setup_args, - tm_handler=ccsds_handler, - ) - tmtc_file_logger = create_tmtc_logger() - tmtc_backend.usr_send_wrapper = (pre_tc_send_cb, tmtc_file_logger) - - tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE) - - # get_console_logger().info("Disabling console logger for continuous operation") - # get_console_logger().setLevel("ERROR") - - tmtccmd.init_and_start_daemons(tmtc_backend=tmtc_backend) - tmtc_backend.perform_operation() - - # remove cmdline args so that we can reuse code - sys.argv = sys.argv[:1] - - while True: - args.service = None - args.op_code = None - handle_unspecified_args(args, hook_obj.get_service_op_code_dictionary()) - - tmtc_backend.set_service(args.service) - tmtc_backend.set_opcode(args.op_code) - tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE) - - tmtc_backend.perform_operation() - - -if __name__ == "__main__": - main()