diff --git a/CHANGELOG.md b/CHANGELOG.md index e3dbd2e..df9fb14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ list yields a list of all related PRs for each release. - New TCS controller events +## Changed + +- HK level can be specified as CLI argument now. + # [v5.1.0] 2023-06-28 ## Added diff --git a/eive_tmtc/pus_tm/hk_handling.py b/eive_tmtc/pus_tm/hk_handling.py index 68cf432..fcc7e97 100644 --- a/eive_tmtc/pus_tm/hk_handling.py +++ b/eive_tmtc/pus_tm/hk_handling.py @@ -45,14 +45,13 @@ _LOGGER = logging.getLogger(__name__) FORWARD_SENSOR_TEMPS = False -# TODO: Transform this into a CLI argument -HK_OUTPUT_LEVEL = 1 def handle_hk_packet( raw_tm: bytes, obj_id_dict: ObjectIdDictT, printer: FsfwTmTcPrinter, + hk_level: int ): 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) @@ -73,9 +72,9 @@ def handle_hk_packet( hk_data=hk_data, ) try: - if HK_OUTPUT_LEVEL == 1: + if hk_level == 1: pass - elif HK_OUTPUT_LEVEL > 1: + elif hk_level > 1: handle_regular_hk_print( printer=printer, object_id=named_obj_id, diff --git a/eive_tmtc/pus_tm/pus_demux.py b/eive_tmtc/pus_tm/pus_demux.py index 89ccb11..66de46f 100644 --- a/eive_tmtc/pus_tm/pus_demux.py +++ b/eive_tmtc/pus_tm/pus_demux.py @@ -29,6 +29,7 @@ def pus_factory_hook( # noqa C901 : Complexity okay here verif_wrapper: VerificationWrapper, printer: FsfwTmTcPrinter, raw_logger: RawTmtcTimedLogWrapper, + hk_level: int ): if len(packet) < 8: _LOGGER.warning("Detected packet shorter than 8 bytes!") @@ -48,7 +49,7 @@ def pus_factory_hook( # noqa C901 : Complexity okay here if service == 1: handle_service_1_fsfw_packet(wrapper=verif_wrapper, raw_tm=packet) elif service == 3: - handle_hk_packet(printer=printer, raw_tm=packet, obj_id_dict=obj_id_dict) + handle_hk_packet(printer=printer, raw_tm=packet, obj_id_dict=obj_id_dict, hk_level=hk_level) elif service == 5: handle_event_packet(raw_tm=packet, pw=pw) elif service == 8: diff --git a/eive_tmtc/tmtc/tcs/defs.py b/eive_tmtc/tmtc/tcs/defs.py index 6ec5a0a..8eb631a 100644 --- a/eive_tmtc/tmtc/tcs/defs.py +++ b/eive_tmtc/tmtc/tcs/defs.py @@ -6,6 +6,7 @@ class CtrlSetId(enum.IntEnum): DEVICE_SENSORS = 1 SUS_TEMP_SENSORS = 2 HEATER_INFO = 4 + TCS_CTRL_INFO = 5 class TcsSubmode(enum.IntEnum): diff --git a/eive_tmtc/tmtc/tcs/tm.py b/eive_tmtc/tmtc/tcs/tm.py index e73a6fa..bdc9311 100644 --- a/eive_tmtc/tmtc/tcs/tm.py +++ b/eive_tmtc/tmtc/tcs/tm.py @@ -1,3 +1,4 @@ +import enum import logging import struct @@ -11,6 +12,34 @@ from .heater import HEATER_LOCATION _LOGGER = logging.getLogger(__name__) +class ThermalComponent(enum.IntEnum): + NONE = 0 + ACS_BOARD = 1 + MGT = 2 + RW = 3 + STR = 4 + IF_BOARD = 5 + TCS_BOARD = 6 + OBC = 7 + LEGACY_OBCIF_BOARD = 8 + SBAND_TRANSCEIVER = 9 + PCDUP60_BOARD = 10 + PCDUACU = 11 + PCDUPDU = 12 + PLPCDU_BOARD = 13 + PLOCMISSION_BOARD = 14 + PLOCPROCESSING_BOARD = 15 + DAC = 16 + CAMERA = 17 + DRO = 18 + X8 = 19 + HPA = 20 + TX = 21 + MPA = 22 + SCEX_BOARD = 23 + NUM_ENTRIES = 24 + + def handle_thermal_controller_hk_data( object_id: ObjectIdU32, pw: PrintWrapper, set_id: int, hk_data: bytes ): @@ -119,5 +148,7 @@ def handle_thermal_controller_hk_data( ) current_draw = struct.unpack("!H", hk_data[8:10])[0] print(f"Heater Power Channel Current Draw: {current_draw} mA") + elif set_id == CtrlSetId.TCS_CTRL_INFO: + pass else: _LOGGER.warning(f"Unimplemented set ID {set_id}") diff --git a/pyproject.toml b/pyproject.toml index 5915d1b..7abd90a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,9 +29,9 @@ classifiers = [ "Topic :: Scientific/Engineering" ] dependencies = [ - "tmtccmd ~= 5.0.0rc0", + # "tmtccmd ~= 5.0.0rc0", "python-dateutil ~= 2.8", - # tmtccmd @ git+https://github.com/robamu-org/tmtccmd@#egg=tmtccmd + tmtccmd @ git+https://github.com/robamu-org/tmtccmd@1b110d321ef85#egg=tmtccmd ] [project.urls] diff --git a/tmtcc.py b/tmtcc.py index 94a8d84..52db7f5 100755 --- a/tmtcc.py +++ b/tmtcc.py @@ -166,16 +166,18 @@ class PusHandler(SpecificApidHandlerBase): 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 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) + pus_factory_hook(packet, self.verif_wrapper, self.printer, self.raw_logger, self.hk_level) class UnknownApidHandler(GenericApidHandlerBase): @@ -335,13 +337,18 @@ class TcHandler(TcHandlerBase): _LOGGER.info("Finished CFDP queue") -def setup_params() -> SetupWrapper: +def setup_params() -> (SetupWrapper, int): hook_obj = EiveHookObject(default_json_path()) params = SetupParams() parser_wrapper = PreArgsParsingWrapper() parser_wrapper.create_default_parent_parser() parser_wrapper.create_default_parser() - parser_wrapper.add_def_proc_and_cfdp_as_subparsers() + tmtc_parser, cfdp_parser = parser_wrapper.add_def_proc_and_cfdp_as_subparsers() + tmtc_parser.add_argument( + "--hk", + help="HK output level", + default=2, + ) post_arg_parsing_wrapper = parser_wrapper.parse( setup_params=params, hook_obj=hook_obj ) @@ -352,13 +359,14 @@ def setup_params() -> SetupWrapper: post_arg_parsing_wrapper.set_params_with_prompts(proc_param_wrapper) else: post_arg_parsing_wrapper.set_params_without_prompts(proc_param_wrapper) + hk_level = post_arg_parsing_wrapper.args_raw.hk params.apid = PUS_APID if params.com_if is None: raise ValueError("could not determine a COM interface.") setup_wrapper = SetupWrapper( hook_obj=hook_obj, setup_params=params, proc_param_wrapper=proc_param_wrapper ) - return setup_wrapper + return setup_wrapper, hk_level def setup_cfdp_handler() -> CfdpInCcsdsWrapper: @@ -400,12 +408,13 @@ def setup_tmtc_handlers( printer: FsfwTmTcPrinter, raw_logger: RawTmtcTimedLogWrapper, gui: bool, + hk_level: int ) -> (CcsdsTmHandler, TcHandler): cfdp_in_ccsds_wrapper = setup_cfdp_handler() verification_wrapper = VerificationWrapper( verificator, _LOGGER, printer.file_logger ) - pus_handler = PusHandler(verification_wrapper, printer, raw_logger) + pus_handler = PusHandler(verification_wrapper, printer, raw_logger, hk_level) ccsds_handler = CustomCcsdsTmHandler(generic_handler=UnknownApidHandler(None)) ccsds_handler.add_apid_handler(pus_handler) ccsds_handler.add_apid_handler(cfdp_in_ccsds_wrapper) @@ -444,7 +453,7 @@ def main(): # noqa C901: Complexity okay here. # TODO: -V CLI argument to enable this? _LOGGER.setLevel(_LOG_LEVEL) try: - setup_wrapper = setup_params() + setup_wrapper, hk_level = setup_params() except KeyboardInterrupt as e: _LOGGER.info(f"{e}. Exiting") sys.exit(0) @@ -457,7 +466,7 @@ def main(): # noqa C901: Complexity okay here. ) pus_verificator = PusVerificator() ccsds_handler, tc_handler = setup_tmtc_handlers( - pus_verificator, printer, raw_logger, setup_wrapper.params.use_gui + pus_verificator, printer, raw_logger, setup_wrapper.params.use_gui, hk_level ) tmtccmd.setup(setup_wrapper)