31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
|
import logging
|
||
|
from datetime import datetime
|
||
|
from typing import cast
|
||
|
|
||
|
from tmtccmd.pus.service_1_verification import Service1TMExtended
|
||
|
from tmtccmd.logging import get_console_logger
|
||
|
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
|
||
|
from config.retvals import get_retval_dict
|
||
|
|
||
|
LOGGER = get_console_logger()
|
||
|
|
||
|
|
||
|
def handle_service_1_packet(printer: FsfwTmTcPrinter, raw_tm: bytes):
|
||
|
tm_packet = Service1TMExtended.unpack(raw_telemetry=raw_tm)
|
||
|
printer.handle_long_tm_print(packet_if=tm_packet, info_if=tm_packet)
|
||
|
srv1_packet = cast(Service1TMExtended, tm_packet)
|
||
|
retval_dict = get_retval_dict()
|
||
|
if srv1_packet.has_tc_error_code:
|
||
|
retval_info = retval_dict.get(srv1_packet.error_code)
|
||
|
if retval_info is None:
|
||
|
LOGGER.info(
|
||
|
f"No returnvalue information found for error code {srv1_packet.error_code}"
|
||
|
)
|
||
|
else:
|
||
|
retval_string = (
|
||
|
f"Error Code information for code {srv1_packet.error_code}| "
|
||
|
f"Name: {retval_info.name} | Info: {retval_info.info}"
|
||
|
)
|
||
|
LOGGER.info(retval_string)
|
||
|
printer.file_logger.info(retval_string)
|