HK handling for GPS packet added

This commit is contained in:
Robin Müller 2021-09-06 14:52:41 +02:00
parent b04a3361e7
commit 0f09809d21
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -10,8 +10,10 @@ from config.object_ids import SYRLINKS_HANDLER, IMTQ_HANDLER_ID, GPS_HANDLER_0_I
LOGGER = get_console_logger() LOGGER = get_console_logger()
def handle_user_hk_packet(object_id: bytes, set_id: int, hk_data: bytearray, def handle_user_hk_packet(
service3_packet: Service3Base) -> Tuple[list, list, bytearray, int]: object_id: bytes, set_id: int, hk_data: bytearray,
service3_packet: Service3Base
) -> Tuple[list, list, bytearray, int]:
"""This function is called when a Service 3 Housekeeping packet is received. """This function is called when a Service 3 Housekeeping packet is received.
""" """
if object_id == SYRLINKS_HANDLER: if object_id == SYRLINKS_HANDLER:
@ -148,4 +150,36 @@ def handle_self_test_data(hk_data: bytearray) -> Tuple[list, list, bytearray, in
def handle_gps_data(hk_data: bytearray) -> Tuple[list, list, bytearray, int]: def handle_gps_data(hk_data: bytearray) -> Tuple[list, list, bytearray, int]:
LOGGER.info(f'Received GPS data, HK data length {len(hk_data)}') LOGGER.info(f'Received GPS data, HK data length {len(hk_data)}')
return [], [], bytearray(), 0 var_index = 0
header_array = []
content_array = []
latitude = struct.unpack('!d', hk_data[0:8])[0]
header_array.append('Latitude')
content_array.append(latitude)
longitude = struct.unpack('!d', hk_data[8:16])[0]
header_array.append('Longitude')
content_array.append(longitude)
altitude = struct.unpack('!d', hk_data[16:24])[0]
header_array.append('Altitude')
content_array.append(altitude)
fix_mode = hk_data[24]
header_array.append('Fix Mode')
content_array.append(fix_mode)
sat_in_use = hk_data[25]
header_array.append('Sats in Use')
content_array.append(sat_in_use)
year = struct.unpack('!H', hk_data[26:28])[0]
month = hk_data[28]
day = hk_data[29]
hours = hk_data[30]
minutes = hk_data[31]
seconds = hk_data[32]
header_array.append('Date')
content_array.append(f'{day}.{month}.{year} {hours}:{minutes}:{seconds}')
unix_seconds = struct.unpack('!I', hk_data[33:37])[0]
header_array.append('Unix Seconds')
content_array.append(unix_seconds)
var_index += 13
validity_buffer = hk_data[37:39]
return header_array, content_array, validity_buffer, var_index