Update PLOC SUPV TMTC handling #107
@ -2,6 +2,7 @@ import logging
|
|||||||
import os.path
|
import os.path
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from config.object_ids import get_object_ids
|
from config.object_ids import get_object_ids
|
||||||
|
from pus_tm.defs import PrintWrapper
|
||||||
|
|
||||||
from tmtccmd.tm import Service5Tm
|
from tmtccmd.tm import Service5Tm
|
||||||
from tmtccmd.logging import get_console_logger
|
from tmtccmd.logging import get_console_logger
|
||||||
@ -25,12 +26,10 @@ def get_event_dict() -> EventDictT:
|
|||||||
return __EVENT_DICT
|
return __EVENT_DICT
|
||||||
|
|
||||||
|
|
||||||
def handle_event_packet(
|
def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
|
||||||
raw_tm: bytes, printer: FsfwTmTcPrinter, file_logger: logging.Logger
|
pw = PrintWrapper(printer)
|
||||||
) -> str:
|
|
||||||
tm = Service5Tm.unpack(raw_telemetry=raw_tm)
|
tm = Service5Tm.unpack(raw_telemetry=raw_tm)
|
||||||
printer.handle_long_tm_print(packet_if=tm, info_if=tm)
|
printer.handle_long_tm_print(packet_if=tm, info_if=tm)
|
||||||
additional_event_info = ""
|
|
||||||
event_dict = get_event_dict()
|
event_dict = get_event_dict()
|
||||||
info = event_dict.get(tm.event_id)
|
info = event_dict.get(tm.event_id)
|
||||||
if info is None:
|
if info is None:
|
||||||
@ -48,20 +47,17 @@ def handle_event_packet(
|
|||||||
f"Object {obj_name} generated Event {tm.event_id} | {info.name}"
|
f"Object {obj_name} generated Event {tm.event_id} | {info.name}"
|
||||||
)
|
)
|
||||||
if info.name == "SUPV_UPDATE_PROGRESS":
|
if info.name == "SUPV_UPDATE_PROGRESS":
|
||||||
additional_event_info = (
|
additional_event_info = f"Additional info: {info.info}"
|
||||||
f"Additional info: {info.info} | "
|
context = f"Percent: {tm.param_1 >> 24 & 0xff} | Sequence Count: {tm.param_1 & 0xffff} | Bytes Written: {tm.param_2}"
|
||||||
f"Percent: {tm.param_1 >> 24 & 0xff} | Sequence Count: {tm.param_1 & 0xffff} | Bytes Written: {tm.param_2}"
|
pw.dlog(additional_event_info)
|
||||||
)
|
pw.dlog(context)
|
||||||
else:
|
else:
|
||||||
if info.info != "":
|
if info.info != "":
|
||||||
additional_event_info = (
|
additional_event_info = (
|
||||||
f"Additional info: {info.info} | P1: {tm.param_1} | P2: {tm.param_2}"
|
f"Additional info: {info.info} | P1: {tm.param_1} | P2: {tm.param_2}"
|
||||||
)
|
)
|
||||||
file_logger.info(
|
pw.dlog(additional_event_info)
|
||||||
|
pw.printer.file_logger.info(
|
||||||
f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: {generic_event_string}"
|
f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: {generic_event_string}"
|
||||||
)
|
)
|
||||||
LOGGER.info(generic_event_string)
|
LOGGER.info(generic_event_string)
|
||||||
if additional_event_info != "":
|
|
||||||
file_logger.info(additional_event_info)
|
|
||||||
print(additional_event_info)
|
|
||||||
return generic_event_string + " | " + additional_event_info
|
|
||||||
|
@ -35,7 +35,6 @@ def pus_factory_hook(
|
|||||||
LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}")
|
LOGGER.warning(f"Raw Packet: [{packet.hex(sep=',')}], REPR: {packet!r}")
|
||||||
return
|
return
|
||||||
service = tm_packet.service
|
service = tm_packet.service
|
||||||
file_logger = printer.file_logger
|
|
||||||
obj_id_dict = get_object_ids()
|
obj_id_dict = get_object_ids()
|
||||||
dedicated_handler = True
|
dedicated_handler = True
|
||||||
if service == 1:
|
if service == 1:
|
||||||
@ -43,7 +42,7 @@ def pus_factory_hook(
|
|||||||
elif service == 3:
|
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)
|
||||||
elif service == 5:
|
elif service == 5:
|
||||||
handle_event_packet(raw_tm=packet, printer=printer, file_logger=file_logger)
|
handle_event_packet(raw_tm=packet, printer=printer)
|
||||||
elif service == 8:
|
elif service == 8:
|
||||||
handle_action_reply(raw_tm=packet, printer=printer, obj_id_dict=obj_id_dict)
|
handle_action_reply(raw_tm=packet, printer=printer, obj_id_dict=obj_id_dict)
|
||||||
elif service == 17:
|
elif service == 17:
|
||||||
|
Loading…
Reference in New Issue
Block a user