2022-08-18 16:19:09 +02:00
|
|
|
from spacepackets.ecss.pus_1_verification import UnpackParams, Service1Tm
|
2022-04-05 17:05:11 +02:00
|
|
|
from tmtccmd.logging import get_console_logger
|
2022-07-04 15:22:53 +02:00
|
|
|
from tmtccmd.pus import VerificationWrapper
|
2022-08-18 16:26:10 +02:00
|
|
|
from tmtccmd.tm.pus_1_verification import Service1FsfwWrapper
|
2022-04-05 17:05:11 +02:00
|
|
|
from config.retvals import get_retval_dict
|
|
|
|
|
|
|
|
LOGGER = get_console_logger()
|
|
|
|
|
|
|
|
|
2022-08-18 16:19:09 +02:00
|
|
|
def handle_service_1_fsfw_packet(wrapper: VerificationWrapper, raw_tm: bytes):
|
2022-07-04 15:22:53 +02:00
|
|
|
if wrapper.console_logger is None or wrapper.file_logger is None:
|
|
|
|
raise ValueError(
|
|
|
|
"Console logger or file logger not valid. Please set a valid one"
|
|
|
|
)
|
2022-08-18 16:19:09 +02:00
|
|
|
# Error code with length 2 is FSFW specific
|
|
|
|
tm_packet = Service1Tm.unpack(data=raw_tm, params=UnpackParams(1, 2))
|
|
|
|
fsfw_wrapper = Service1FsfwWrapper(tm_packet)
|
2022-07-04 15:22:53 +02:00
|
|
|
res = wrapper.verificator.add_tm(tm_packet)
|
|
|
|
if res is None:
|
|
|
|
LOGGER.info(
|
|
|
|
f"Received Verification TM[{tm_packet.service}, {tm_packet.subservice}] "
|
|
|
|
f"with Request ID {tm_packet.tc_req_id.as_u32():#08x}"
|
|
|
|
)
|
|
|
|
LOGGER.warning(f"No matching telecommand found for {tm_packet.tc_req_id}")
|
|
|
|
else:
|
|
|
|
wrapper.log_to_console(tm_packet, res)
|
|
|
|
wrapper.log_to_file(tm_packet, res)
|
2022-04-05 17:05:11 +02:00
|
|
|
retval_dict = get_retval_dict()
|
2022-07-04 15:22:53 +02:00
|
|
|
if tm_packet.has_failure_notice:
|
|
|
|
retval_info = retval_dict.get(tm_packet.error_code.val)
|
2022-04-05 17:05:11 +02:00
|
|
|
if retval_info is None:
|
2022-08-18 14:08:05 +02:00
|
|
|
raw_err = tm_packet.error_code.val
|
2022-04-05 17:05:11 +02:00
|
|
|
LOGGER.info(
|
2022-08-18 14:08:05 +02:00
|
|
|
f"No returnvalue information found for error code with subsystem ID"
|
|
|
|
f" {(raw_err >> 8) & 0xff} and unique ID {raw_err & 0xff}"
|
2022-04-05 17:05:11 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
retval_string = (
|
2022-08-18 16:19:09 +02:00
|
|
|
f"Error Code information for code {tm_packet.error_code.val:#06x} | "
|
2022-04-05 17:05:11 +02:00
|
|
|
f"Name: {retval_info.name} | Info: {retval_info.info}"
|
|
|
|
)
|
2022-08-18 16:25:20 +02:00
|
|
|
error_param_1_str = (
|
|
|
|
f"Error Parameter 1: hex {fsfw_wrapper.error_param_1:#010x} "
|
2022-08-22 17:13:47 +02:00
|
|
|
f"dec {fsfw_wrapper.error_param_1} "
|
2022-08-18 16:25:20 +02:00
|
|
|
)
|
|
|
|
error_param_2_str = (
|
|
|
|
f"Error Parameter 2: hex {fsfw_wrapper.error_param_2:#010x} "
|
|
|
|
f"dec {fsfw_wrapper.error_param_2}"
|
|
|
|
)
|
|
|
|
wrapper.dlog(retval_string)
|
|
|
|
wrapper.dlog(error_param_1_str)
|
|
|
|
wrapper.dlog(error_param_2_str)
|