|
|
|
@ -2,6 +2,7 @@ import logging
|
|
|
|
|
import struct
|
|
|
|
|
|
|
|
|
|
from spacepackets.ecss import PusTm
|
|
|
|
|
from tmtccmd.pus.s8_fsfw_action_defs import CustomSubservice
|
|
|
|
|
from eive_tmtc.config.object_ids import (
|
|
|
|
|
ACU_HANDLER_ID,
|
|
|
|
|
PDU_1_HANDLER_ID,
|
|
|
|
@ -22,59 +23,74 @@ from eive_tmtc.tmtc.payload.ploc_supervisor import SupvActionId
|
|
|
|
|
from eive_tmtc.tmtc.acs.star_tracker import handle_star_tracker_action_replies
|
|
|
|
|
from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_action_replies
|
|
|
|
|
from eive_tmtc.tmtc.power.tm import handle_get_param_data_reply
|
|
|
|
|
from tmtccmd.pus.s8_fsfw_action import Service8FsfwTm
|
|
|
|
|
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter
|
|
|
|
|
from spacepackets.ccsds.time import CdsShortTimestamp
|
|
|
|
|
from tmtccmd.util import ObjectIdDictT
|
|
|
|
|
from tmtccmd.util import ObjectIdBase, ObjectIdDictT, ObjectIdU32
|
|
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_action_reply(
|
|
|
|
|
raw_tm: bytes, printer: FsfwTmTcPrinter, obj_id_dict: ObjectIdDictT
|
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_action_service_tm(
|
|
|
|
|
raw_tm: bytes, pw: PrintWrapper, obj_id_dict: ObjectIdDictT
|
|
|
|
|
):
|
|
|
|
|
"""Core Action reply handler
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
tm_packet = PusTm.unpack(raw_tm, timestamp_len=CdsShortTimestamp.TIMESTAMP_SIZE)
|
|
|
|
|
pw = PrintWrapper(printer.file_logger)
|
|
|
|
|
if len(tm_packet.source_data) < 8:
|
|
|
|
|
_LOGGER.warn(
|
|
|
|
|
"invalid TM packet length for PUS 8 reply, must have at least 8 bytes"
|
|
|
|
|
_LOGGER.warning(
|
|
|
|
|
"received action service reply with source data smaller than 8 bytes"
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
object_id_raw = struct.unpack("!I", tm_packet.source_data[0:4])[0]
|
|
|
|
|
action_id = struct.unpack("!I", tm_packet.source_data[4:8])[0]
|
|
|
|
|
object_id = obj_id_dict.get(object_id_raw)
|
|
|
|
|
custom_data = tm_packet.source_data[8:]
|
|
|
|
|
generic_print_str = printer.generic_action_packet_tm_print(
|
|
|
|
|
packet=tm_packet, obj_id=object_id
|
|
|
|
|
)
|
|
|
|
|
pw.dlog(generic_print_str)
|
|
|
|
|
if object_id.as_bytes == IMTQ_HANDLER_ID:
|
|
|
|
|
return handle_imtq_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == PLOC_MPSOC_ID:
|
|
|
|
|
return handle_mpsoc_data_reply(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == PLOC_SUPV_ID:
|
|
|
|
|
return handle_supervisor_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == CORE_CONTROLLER_ID:
|
|
|
|
|
return handle_core_ctrl_action_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == STAR_TRACKER_ID:
|
|
|
|
|
return handle_star_tracker_action_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == ACS_CONTROLLER:
|
|
|
|
|
return handle_acs_ctrl_action_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes in [
|
|
|
|
|
ACU_HANDLER_ID,
|
|
|
|
|
PDU_1_HANDLER_ID,
|
|
|
|
|
PDU_2_HANDLER_ID,
|
|
|
|
|
P60_DOCK_HANDLER,
|
|
|
|
|
]:
|
|
|
|
|
return handle_get_param_data_reply(object_id, action_id, pw, custom_data)
|
|
|
|
|
if object_id is None:
|
|
|
|
|
object_id = ObjectIdU32(object_id_raw, "Unknown ID")
|
|
|
|
|
if tm_packet.subservice == CustomSubservice.TM_DATA_REPLY:
|
|
|
|
|
if object_id.as_bytes == IMTQ_HANDLER_ID:
|
|
|
|
|
return handle_imtq_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == PLOC_MPSOC_ID:
|
|
|
|
|
return handle_mpsoc_data_reply(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == PLOC_SUPV_ID:
|
|
|
|
|
return handle_supervisor_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == CORE_CONTROLLER_ID:
|
|
|
|
|
return handle_core_ctrl_action_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == STAR_TRACKER_ID:
|
|
|
|
|
return handle_star_tracker_action_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes == ACS_CONTROLLER:
|
|
|
|
|
return handle_acs_ctrl_action_replies(action_id, pw, custom_data)
|
|
|
|
|
elif object_id.as_bytes in [
|
|
|
|
|
ACU_HANDLER_ID,
|
|
|
|
|
PDU_1_HANDLER_ID,
|
|
|
|
|
PDU_2_HANDLER_ID,
|
|
|
|
|
P60_DOCK_HANDLER,
|
|
|
|
|
]:
|
|
|
|
|
return handle_get_param_data_reply(object_id, action_id, pw, custom_data)
|
|
|
|
|
else:
|
|
|
|
|
# TODO: Could add a handler here depending on action ID and object ID.
|
|
|
|
|
handle_action_data_reply(tm_packet, object_id, action_id, pw)
|
|
|
|
|
else:
|
|
|
|
|
pw.dlog(f"No dedicated action reply handler found for reply from {object_id}")
|
|
|
|
|
pw.dlog(f"Raw Data: {tm_packet.custom_data.hex(sep=',')}")
|
|
|
|
|
pw.dlog(
|
|
|
|
|
f"service 8 packet from {object_id} with action ID {action_id} "
|
|
|
|
|
f"and unknown subservice {tm_packet.subservice}"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_imtq_replies(action_id: int, pw: PrintWrapper, custom_data: bytearray):
|
|
|
|
|
def handle_action_data_reply(
|
|
|
|
|
tm_packet: PusTm, named_obj_id: ObjectIdBase, action_id: int, printer: PrintWrapper
|
|
|
|
|
):
|
|
|
|
|
print_string = (
|
|
|
|
|
f"service 8 data reply from {named_obj_id} with action ID {action_id} "
|
|
|
|
|
f"and data size {len(tm_packet.tm_data[8:])}"
|
|
|
|
|
)
|
|
|
|
|
printer.dlog(print_string)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_imtq_replies(action_id: int, pw: PrintWrapper, custom_data: bytes):
|
|
|
|
|
if action_id == struct.unpack("!I", ImtqActionId.get_commanded_dipole)[0]:
|
|
|
|
|
header_list = [
|
|
|
|
|
"Commanded X-Dipole",
|
|
|
|
@ -87,7 +103,7 @@ def handle_imtq_replies(action_id: int, pw: PrintWrapper, custom_data: bytearray
|
|
|
|
|
pw.dlog(f"{content_list}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_supervisor_replies(action_id: int, pw: PrintWrapper, custom_data: bytearray):
|
|
|
|
|
def handle_supervisor_replies(action_id: int, pw: PrintWrapper, custom_data: bytes):
|
|
|
|
|
if action_id == SupvActionId.DUMP_MRAM:
|
|
|
|
|
header_list = ["MRAM Dump"]
|
|
|
|
|
content_list = [custom_data[: len(custom_data)]]
|
|
|
|
|