eive-tmtc/pus_tm/service_8_hook.py

45 lines
1.6 KiB
Python
Raw Normal View History

2021-02-09 12:35:10 +01:00
from typing import Tuple
2021-03-19 18:03:41 +01:00
from config.object_ids import ObjIdIds
from pus_tc.imtq import ImtqActionIds
2021-02-09 12:35:10 +01:00
def user_analyze_service_8_data(
2021-03-19 17:39:52 +01:00
object_id: int, action_id: int, custom_data: bytearray) -> Tuple[list, list]:
2021-02-09 12:35:10 +01:00
"""
This function is called by the TMTC core if a Service 8 data reply (subservice 130)
is received. The user can return a tuple of two lists, where the first list
is a list of header strings to print and the second list is a list of values to print.
The TMTC core will take care of printing both lists and logging them.
@param object_id:
@param action_id:
@param custom_data:
@return:
"""
2021-03-19 18:03:41 +01:00
if object_id == ObjIdIds.PDU2_HANDLER_ID.value:
2021-02-11 08:18:42 +01:00
header_list = ['PDU2 Service 8 Reply']
data_string = str()
for index in range(len(custom_data)):
data_string += str(hex(custom_data[index])) + " , "
data_string = data_string.rstrip()
data_string = data_string.rstrip(',')
data_string = data_string.rstrip()
content_list = [data_string]
elif object_id == ObjIdIds.IMTQ_HANDLER_ID:
return handle_imtq_replies(action_id, custom_data)
2021-02-09 12:35:10 +01:00
else:
header_list = []
content_list = []
return header_list, content_list
def handle_imtq_replies(action_id: int, custom_data: bytearray) -> Tuple[list, list]:
header_list = []
content_list = []
if action_id == ImtqActionIds.get_commanded_dipole:
header_list = ['Commanded X-Dipole', 'Commanded Y-Dipole', 'Commanded Z-Dipole']
x_dipole =
content_list = [custom_data[:4], custom_data[4:6], custom_data[6:10]]
return header_list, content_list