From 97b529318dbc654ec55fd765f892bff212918f39 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 Oct 2023 20:45:14 +0200 Subject: [PATCH] improve TM output --- eive_tmtc/pus_tm/pus_demux.py | 3 +-- eive_tmtc/tmtc/acs/star_tracker.py | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/eive_tmtc/pus_tm/pus_demux.py b/eive_tmtc/pus_tm/pus_demux.py index 0605291..f178990 100644 --- a/eive_tmtc/pus_tm/pus_demux.py +++ b/eive_tmtc/pus_tm/pus_demux.py @@ -2,7 +2,7 @@ """ import logging -from eive_tmtc.config.object_ids import get_object_ids, STAR_TRACKER_ID +from eive_tmtc.config.object_ids import get_object_ids from spacepackets.ecss import PusTelemetry from spacepackets.ecss.pus_17_test import Service17Tm from spacepackets.util import PrintFormats @@ -14,7 +14,6 @@ from tmtccmd.tm.pus_20_fsfw_param import Service20ParamDumpWrapper from tmtccmd.pus.s20_fsfw_param_defs import CustomSubservice as ParamSubservice from tmtccmd.tm.pus_200_fsfw_mode import Subservice as ModeSubservice from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter -from tmtccmd.util import ObjectIdU32 from .defs import PrintWrapper from .event_handler import handle_event_packet diff --git a/eive_tmtc/tmtc/acs/star_tracker.py b/eive_tmtc/tmtc/acs/star_tracker.py index 29d9f95..db29cb9 100644 --- a/eive_tmtc/tmtc/acs/star_tracker.py +++ b/eive_tmtc/tmtc/acs/star_tracker.py @@ -834,11 +834,14 @@ def unpack_time_hk(hk_data: bytes, current_idx: int, pw: PrintWrapper) -> int: (ticks, unix_time) = struct.unpack( ticks_time_fmt, hk_data[current_idx : current_idx + fmt_len] ) - unix_as_dt = datetime.datetime.fromtimestamp( - int(round(unix_time / 1e6)), tz=datetime.timezone.utc - ) - pw.dlog(f"Ticks: {ticks} | UNIX time: {unix_time}") - pw.dlog(f"UNIX as datetime: {unix_as_dt}") + try: + unix_as_dt = datetime.datetime.fromtimestamp( + int(round(unix_time / 1e6)), tz=datetime.timezone.utc + ) + pw.dlog(f"Ticks: {ticks} | UNIX time: {unix_time}") + pw.dlog(f"UNIX as datetime: {unix_as_dt}") + except ValueError as e: + _LOGGER.exception(e) current_idx += fmt_len return current_idx @@ -1031,14 +1034,19 @@ def handle_matched_centroids_set(hk_data: bytes, pw: PrintWrapper): y_errors = struct.unpack(fmt_floats, hk_data[current_idx : current_idx + inc_len]) current_idx += inc_len pw.dlog( - "{:<8} {:<8} {:<8} {:<8} {:<8}".format( + "{:<10} {:<10} {:<10} {:<10} {:<10}".format( "Star ID", "X", "Y", "X Error", "Y Error" ) ) for idx in range(16): pw.dlog( - "{:<8} {:<8} {:<8} {:<8} {:<8}".format( - star_id[idx], x_coords[idx], y_coords[idx], x_errors[idx], y_errors[idx] + "{:<10} {:<10} {:<10.3f} {:<10.3f} {:<10.3f} {:<10.3f}".format( + idx, + star_id[idx], + x_coords[idx], + y_coords[idx], + x_errors[idx], + y_errors[idx], ) ) FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=8)