export gps to logger
This commit is contained in:
parent
0f09809d21
commit
4e4d69f6d6
@ -1,5 +1,7 @@
|
|||||||
"""HK Handling for EIVE OBSW"""
|
"""HK Handling for EIVE OBSW"""
|
||||||
import struct
|
import struct
|
||||||
|
import os
|
||||||
|
import datetime
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from tmtccmd.tm.service_3_housekeeping import Service3Base
|
from tmtccmd.tm.service_3_housekeeping import Service3Base
|
||||||
@ -175,11 +177,22 @@ def handle_gps_data(hk_data: bytearray) -> Tuple[list, list, bytearray, int]:
|
|||||||
minutes = hk_data[31]
|
minutes = hk_data[31]
|
||||||
seconds = hk_data[32]
|
seconds = hk_data[32]
|
||||||
header_array.append('Date')
|
header_array.append('Date')
|
||||||
content_array.append(f'{day}.{month}.{year} {hours}:{minutes}:{seconds}')
|
date_string = f'{day}.{month}.{year} {hours}:{minutes}:{seconds}'
|
||||||
|
content_array.append(date_string)
|
||||||
unix_seconds = struct.unpack('!I', hk_data[33:37])[0]
|
unix_seconds = struct.unpack('!I', hk_data[33:37])[0]
|
||||||
header_array.append('Unix Seconds')
|
header_array.append('Unix Seconds')
|
||||||
content_array.append(unix_seconds)
|
content_array.append(unix_seconds)
|
||||||
var_index += 13
|
var_index += 13
|
||||||
|
if not os.path.isfile('gps_log.txt'):
|
||||||
|
with open("gps_log.txt", "w") as gps_file:
|
||||||
|
gps_file.write(
|
||||||
|
'Time, Latitude [deg], Longitude [deg], Altitude [m], Fix Mode, Sats in Use, '
|
||||||
|
'Date, Unix Seconds\n'
|
||||||
|
)
|
||||||
|
with open("gps_log.txt", "a") as gps_file:
|
||||||
|
gps_file.write(
|
||||||
|
f'{datetime.datetime.now()}, {latitude}, {longitude}, {altitude}, '
|
||||||
|
f'{fix_mode}, {sat_in_use}, {date_string}, {unix_seconds}\n'
|
||||||
|
)
|
||||||
validity_buffer = hk_data[37:39]
|
validity_buffer = hk_data[37:39]
|
||||||
|
|
||||||
return header_array, content_array, validity_buffer, var_index
|
return header_array, content_array, validity_buffer, var_index
|
||||||
|
Loading…
Reference in New Issue
Block a user