This commit is contained in:
Robin Müller 2023-01-31 13:18:12 +01:00
commit 2793b354a6
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 28 additions and 34 deletions

View File

@ -20,69 +20,67 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
pw = PrintWrapper(printer)
tm = Service5Tm.unpack(raw_telemetry=raw_tm, time_reader=CdsShortTimestamp.empty())
event_dict = get_event_dict()
info = event_dict.get(tm.event_id)
event_def = tm.event_definition
info = event_dict.get(event_def.event_id)
if info is None:
LOGGER.warning(f"Event ID {tm.event_id} has no information")
LOGGER.warning(f"Event ID {event_def.event_id} has no information")
info = EventInfo()
info.name = "Unknown event"
obj_ids = get_object_ids()
obj_id_obj = obj_ids.get(tm.reporter_id.as_bytes)
obj_id_obj = obj_ids.get(event_def.reporter_id)
if obj_id_obj is None:
LOGGER.warning(f"Object ID 0x{tm.reporter_id.as_hex_string} has no name")
obj_name = tm.reporter_id.as_hex_string
LOGGER.warning(f"Object ID 0x{event_def.reporter_id.hex(sep=',')} has no name")
obj_name = event_def.reporter_id.hex(sep=",")
else:
obj_name = obj_id_obj.name
generic_event_string = (
f"Object {obj_name} generated Event {tm.event_id} | {info.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()}"
pw.printer.file_logger.info(
f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: {generic_event_string}"
)
LOGGER.info(generic_event_string)
specific_handler = True
if info.name == "MODE_TRANSITION_FAILED":
reason = generic_retval_printout(tm.param_1)
reason = generic_retval_printout(event_def.param1)
for string in reason:
pw.dlog(f"Reason from event parameter 1: {string}")
pw.dlog(f"Mode, sequence or table: {tm.param_2:#08x}")
pw.dlog(f"Mode, sequence or table: {event_def.param2:#08x}")
if info.name == "SUPV_UPDATE_PROGRESS" or info.name == "WRITE_MEMORY_FAILED":
additional_event_info = f"Additional info: {info.info}"
context = (
f"Progress Percent: {tm.param_1 >> 24 & 0xff} | Sequence Count: {tm.param_1 & 0xffff} "
f"| Bytes Written: {tm.param_2}"
f"Progress Percent: {event_def.param1 >> 24 & 0xff} | Sequence Count: {event_def.param1 & 0xffff} "
f"| Bytes Written: {event_def.param2}"
)
pw.dlog(additional_event_info)
pw.dlog(context)
if info.name == "MODE_INFO":
mode_name = "Unknown"
if obj_name == "ACS_SUBSYSTEM":
if tm.param_1 == Mode.OFF:
if event_def.param1 == Mode.OFF:
mode_name = "Off"
elif tm.param_1 == AcsMode.IDLE:
elif event_def.param1 == AcsMode.IDLE:
mode_name = "Idle"
elif tm.param_1 == AcsMode.DETUMBLE:
elif event_def.param1 == AcsMode.DETUMBLE:
mode_name = "Detumble"
elif tm.param_1 == AcsMode.SAFE:
elif event_def.param1 == AcsMode.SAFE:
mode_name = "Safe"
elif tm.param_1 == AcsMode.TARGET_PT:
elif event_def.param1 == AcsMode.TARGET_PT:
mode_name = "Target Pointing"
else:
if tm.param_1 == Mode.OFF:
if event_def.param1 == Mode.OFF:
mode_name = "Off"
elif tm.param_1 == Mode.ON:
elif event_def.param1 == Mode.ON:
mode_name = "On"
elif tm.param_1 == Mode.NORMAL:
elif event_def.param1 == Mode.NORMAL:
mode_name = "Normal"
elif tm.param_1 == Mode.RAW:
elif event_def.param1 == Mode.RAW:
mode_name = "Raw"
pw.dlog(f"Mode Number {tm.param_1}, Mode Name {mode_name}")
pw.dlog(f"Submode: {tm.param_2}")
pw.dlog(f"Mode Number {event_def.param1}, Mode Name {mode_name}")
pw.dlog(f"Submode: {event_def.param2}")
else:
specific_handler = False
if info.info != "":
additional_event_info = (
f"Additional info: {info.info} | P1: {tm.param_1} | P2: {tm.param_2}"
)
additional_event_info = f"Additional info: {info.info} | P1: {event_def.param1} | P2: {event_def.param2}"
pw.dlog(additional_event_info)
if not specific_handler:
printer.handle_long_tm_print(packet_if=tm, info_if=tm)
# printer.handle_long_tm_print(packet_if=tm.pus_tm, info_if=tm.pus_tm)
pass

View File

@ -72,7 +72,8 @@ from tmtccmd.tc import (
FeedWrapper,
TcProcedureType,
TcQueueEntryType,
DefaultPusQueueHelper, QueueWrapper,
DefaultPusQueueHelper,
QueueWrapper,
)
from tmtccmd.config import (
default_json_path,
@ -248,12 +249,7 @@ class TcHandler(TcHandlerBase):
if entry_helper.is_tc:
if entry_helper.entry_type == TcQueueEntryType.PUS_TC:
pus_tc_wrapper = entry_helper.to_pus_tc_entry()
pus_tc_wrapper.pus_tc.seq_count = (
self.seq_count_provider.get_and_increment()
)
pus_tc_wrapper.pus_tc.apid = PUS_APID
# Add TC after Sequence Count stamping
self.pus_verificator.add_tc(pus_tc_wrapper.pus_tc)
# pus_tc_wrapper.pus_tc.apid = PUS_APID
raw_tc = pus_tc_wrapper.pus_tc.pack()
self.pus_raw_logger.log_tc(pus_tc_wrapper.pus_tc)
tc_info_string = f"Sent {pus_tc_wrapper.pus_tc}"