""" @brief This file transfers control of housekeeping handling (PUS service 3) to the developer @details Template configuration file. Copy this folder to the TMTC commander root and adapt it to your needs. """ import struct from typing import Tuple from tmtc_core.pus_tm.tmtcc_pus_service_3 import Service3Base from tmtc_core.utility.tmtcc_logger import get_logger from config.tmtcc_object_ids import ObjectIds LOGGER = get_logger() def handle_user_hk_packet( object_id: bytearray, hk_data: bytearray, service3_packet: Service3Base) -> Tuple[list, list, bytearray]: """ This function is called when a Service 3 Housekeeping packet is received. @param object_id: @param hk_data: @param service3_packet: @return: """ if object_id == ObjectIds.SYRLINKS_HK_HANDLER.value: return handle_syrlinks_hk_data(hk_data) else: LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.") return [], [], bytearray(), 0 def handle_syrlinks_hk_data(hk_data: bytearray) -> Tuple[list, list, bytearray, int]: hk_header = [] hk_content = [] validity_buffer = bytearray() hk_header = ["RX Status", "RX Sensitivity", "RX Frequency Shift", "RX IQ Power", "RX AGC Value", "RX Demod Eb", "RX Demod N0", "RX Datarate"] rx_status = hk_data[0] rx_sensitivity = struct.unpack('!I', hk_data[1:5]) rx_frequency_shift = struct.unpack('!I', hk_data[5:9]) rx_iq_power = struct.unpack('!H', hk_data[9:13]) rx_agc_value = struct.unpack('!H', hk_data[13:17]) rx_demod_eb = struct.unpack('!I', hk_data[17:21]) rx_demod_n0 = struct.unpack('!I', hk_data[21:25]) rx_data_rate = hk_data[25] hk_content = [rx_status, rx_sensitivity, rx_frequency_shift, rx_iq_power, rx_agc_value, rx_demod_eb, rx_demod_n0, rx_data_rate] validity_buffer.append(hk_data[26:]) return hk_header, hk_content, validity_buffer, 8