service 200 cant reach mode handling

This commit is contained in:
Robin Müller 2022-10-11 15:08:00 +02:00
parent 61317e695c
commit fd5c234bc8
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 52 additions and 27 deletions

2
deps/tmtccmd vendored

@ -1 +1 @@
Subproject commit 96ca55b17a823ce10307e8aa6d8cd906323d1ae5
Subproject commit f3ea4108bd694c751887c1cbc2337a29eee064df

View File

@ -1,6 +1,7 @@
"""Core EIVE TM handler module
"""
from config.object_ids import get_object_ids
from config.retvals import get_retval_dict
from spacepackets.ecss import PusTelemetry
from spacepackets.ecss.pus_17_test import Service17Tm
from spacepackets.util import PrintFormats
@ -9,10 +10,12 @@ from tmtccmd.logging.pus import RawTmtcTimedLogWrapper
from tmtccmd.pus import VerificationWrapper
from tmtccmd.tm import Service20FsfwTm, Service200FsfwTm
from tmtccmd.tm.pus_17_test import Service17TmExtended
from tmtccmd.tm.pus_200_fsfw_modes import Subservices as ModeSubservices
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
from .defs import PrintWrapper
from .event_handler import handle_event_packet
from .verification_handler import handle_service_1_fsfw_packet
from .verification_handler import handle_service_1_fsfw_packet, generic_retval_printout
from .hk_handling import handle_hk_packet
from .action_reply_handler import handle_action_reply
@ -36,6 +39,7 @@ def pus_factory_hook(
return
service = tm_packet.service
obj_id_dict = get_object_ids()
pw = PrintWrapper(printer)
dedicated_handler = True
if service == 1:
handle_service_1_fsfw_packet(wrapper=verif_wrapper, raw_tm=packet)
@ -55,7 +59,17 @@ def pus_factory_hook(
dedicated_handler = False
elif service == 200:
tm_packet = Service200FsfwTm.unpack(raw_telemetry=packet)
dedicated_handler = False
if tm_packet.subservice == ModeSubservices.TM_CANT_REACH_MODE:
obj_id = tm_packet.object_id
obj_id_obj = obj_id_dict.get(obj_id)
retval = tm_packet.return_value
string_list = generic_retval_printout(retval)
pw.dlog(f"Received Mode Reply from {obj_id_obj}: Can't reach mode.")
for string in string_list:
pw.dlog(f"Reason: {string}")
dedicated_handler = True
else:
dedicated_handler = False
else:
LOGGER.info(f"The service {service} is not implemented in Telemetry Factory")
tm_packet.print_source_data(PrintFormats.HEX)

View File

@ -1,3 +1,5 @@
from typing import List, Optional
from spacepackets.ecss.pus_1_verification import UnpackParams, Service1Tm
from tmtccmd.logging import get_console_logger
from tmtccmd.pus import VerificationWrapper
@ -25,28 +27,37 @@ def handle_service_1_fsfw_packet(wrapper: VerificationWrapper, raw_tm: bytes):
else:
wrapper.log_to_console(tm_packet, res)
wrapper.log_to_file(tm_packet, res)
retval_dict = get_retval_dict()
if tm_packet.has_failure_notice:
retval_info = retval_dict.get(tm_packet.error_code.val)
if retval_info is None:
raw_err = tm_packet.error_code.val
LOGGER.info(
f"No returnvalue information found for error code with subsystem ID"
f" {(raw_err >> 8) & 0xff} and unique ID {raw_err & 0xff}"
)
else:
retval_string = (
f"Error Code information for code {tm_packet.error_code.val:#06x} | "
f"Name: {retval_info.name} | Info: {retval_info.info}"
)
error_param_1_str = (
f"Error Parameter 1: hex {fsfw_wrapper.error_param_1:#010x} "
f"dec {fsfw_wrapper.error_param_1} "
)
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)
str_list = generic_retval_printout(
tm_packet.error_code.val,
fsfw_wrapper.error_param_1,
fsfw_wrapper.error_param_2,
)
for string in str_list:
wrapper.dlog(string)
def generic_retval_printout(
retval: int, p1: Optional[int] = None, p2: Optional[int] = None
) -> List[str]:
retval_dict = get_retval_dict()
retval_info = retval_dict.get(retval)
if retval_info is None:
raw_err = retval
return [
f"No returnvalue information found for error code with "
f"subsystem ID {(raw_err >> 8) & 0xff} and unique ID {raw_err & 0xff}"
]
else:
retval_string = (
f"Error Code information for code {retval:#06x} | "
f"Name: {retval_info.name} | Info: {retval_info.info}"
)
string_list = [retval_string]
if p1:
error_param_1_str = f"Error Parameter 1: hex {p1:#010x} " f"dec {p1} "
string_list.append(error_param_1_str)
if p2:
error_param_2_str = f"Error Parameter 2: hex {p2:#010x} " f"dec {p2}"
string_list.append(error_param_2_str)
return string_list