update gps hk parsing
This commit is contained in:
parent
51bbeaa693
commit
9fc90ba487
@ -34,8 +34,7 @@ class CustomServiceList(enum.Enum):
|
||||
REACTION_WHEEL_4 = "rw-4"
|
||||
RW_ASSEMBLY = "rw-ass"
|
||||
RAD_SENSOR = "rad_sensor"
|
||||
GPS_0 = "gps0"
|
||||
GPS_1 = "gps1"
|
||||
GPS_CTRL = "gnss-ctrl"
|
||||
PLOC_MEMORY_DUMPER = "ploc_memory_dumper"
|
||||
CORE = "core"
|
||||
STAR_TRACKER = "star_tracker"
|
||||
|
@ -1,4 +1,4 @@
|
||||
from pus_tc.devs.gps import GpsOpCodes
|
||||
from pus_tc.devs.gps import OpCodes
|
||||
from pus_tc.devs.pcdu import add_pcdu_cmds
|
||||
from pus_tc.devs.rad_sensor import add_rad_sens_cmds
|
||||
from tmtccmd.config import (
|
||||
@ -89,15 +89,6 @@ def add_ccsds_cmds(cmd_dict: ServiceOpCodeDictT):
|
||||
cmd_dict[CustomServiceList.CCSDS_HANDLER.value] = service_ccsds_handler_tuple
|
||||
|
||||
|
||||
def add_gps_cmds(cmd_dict: ServiceOpCodeDictT):
|
||||
op_code_dict = {
|
||||
GpsOpCodes.RESET_GNSS.value: ("Reset GPS", {OpCodeDictKeys.TIMEOUT: 2.0})
|
||||
}
|
||||
service_tuple = ("GPS 0", op_code_dict)
|
||||
cmd_dict[CustomServiceList.GPS_0.value] = service_tuple
|
||||
cmd_dict[CustomServiceList.GPS_1.value] = service_tuple
|
||||
|
||||
|
||||
def add_str_cmds(cmd_dict: ServiceOpCodeDictT):
|
||||
op_code_dict_srv_star_tracker = {
|
||||
"0": (
|
||||
|
@ -1,22 +1,63 @@
|
||||
import enum
|
||||
|
||||
from tmtccmd.config.definitions import QueueCommands
|
||||
from config.definitions import CustomServiceList
|
||||
from tmtccmd.config import add_op_code_entry, add_service_op_code_entry
|
||||
from tmtccmd.tc.pus_3_fsfw_hk import make_sid, generate_one_hk_command
|
||||
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT
|
||||
from tmtccmd.logging import get_console_logger
|
||||
from tmtccmd.tc.definitions import TcQueueT
|
||||
from tmtccmd.tc.pus_8_funccmd import generate_action_command
|
||||
|
||||
|
||||
from config.object_ids import GPS_HANDLER_1_ID, GPS_HANDLER_0_ID
|
||||
|
||||
LOGGER = get_console_logger()
|
||||
|
||||
class GpsOpCodes(enum.Enum):
|
||||
RESET_GNSS = "5"
|
||||
|
||||
class OpCodes:
|
||||
REQ_OS_HK = ["0", "hk-os"]
|
||||
RESET_GNSS = ["5", "reset"]
|
||||
|
||||
|
||||
class Info:
|
||||
REQ_OS_HK = "Request One-Shot HK"
|
||||
RESET_GNSS = "Reset GNSS using reset pin"
|
||||
|
||||
|
||||
class SetIds:
|
||||
HK = 0
|
||||
|
||||
|
||||
def add_gps_cmds(cmd_dict: ServiceOpCodeDictT):
|
||||
op_code_dict = dict()
|
||||
add_op_code_entry(
|
||||
op_code_dict=op_code_dict, keys=OpCodes.RESET_GNSS, info=Info.RESET_GNSS
|
||||
)
|
||||
add_op_code_entry(
|
||||
op_code_dict=op_code_dict, keys=OpCodes.REQ_OS_HK, info=Info.REQ_OS_HK
|
||||
)
|
||||
add_service_op_code_entry(
|
||||
srv_op_code_dict=cmd_dict,
|
||||
op_code_entry=op_code_dict,
|
||||
name=CustomServiceList.GPS_CTRL.value,
|
||||
info="GPS/GNSS Controller"
|
||||
)
|
||||
|
||||
|
||||
def pack_gps_command(object_id: bytes, tc_queue: TcQueueT, op_code: str):
|
||||
if op_code == GpsOpCodes.RESET_GNSS.value:
|
||||
if op_code in OpCodes.RESET_GNSS:
|
||||
if object_id == GPS_HANDLER_0_ID:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Resetting GPS device 0"))
|
||||
# TODO: This needs to be re-implemented
|
||||
LOGGER.warning("Reset pin handling needs to be re-implemented")
|
||||
return
|
||||
# tc_queue.appendleft((QueueCommands.PRINT, "Resetting GPS device 0"))
|
||||
elif object_id == GPS_HANDLER_1_ID:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, "Resetting GPS device 1"))
|
||||
LOGGER.warning("Reset pin handling needs to be re-implemented")
|
||||
return
|
||||
# tc_queue.appendleft((QueueCommands.PRINT, "Resetting GPS device 1"))
|
||||
cmd = generate_action_command(object_id=object_id, action_id=int(op_code))
|
||||
tc_queue.appendleft(cmd.pack_command_tuple())
|
||||
if op_code in OpCodes.REQ_OS_HK:
|
||||
tc_queue.appendleft((QueueCommands.PRINT, f"GMSS: {Info.REQ_OS_HK}"))
|
||||
cmd = generate_one_hk_command(sid=make_sid(object_id=object_id, set_id=SetIds.HK), ssc=0)
|
||||
tc_queue.appendleft(cmd.pack_command_tuple())
|
||||
|
@ -1,6 +1,4 @@
|
||||
import os
|
||||
import struct
|
||||
from datetime import datetime
|
||||
|
||||
from pus_tm.defs import PrintWrapper
|
||||
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
|
||||
@ -9,51 +7,31 @@ from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
|
||||
def handle_gps_data(printer: FsfwTmTcPrinter, hk_data: bytes):
|
||||
pw = PrintWrapper(printer)
|
||||
pw.dlog(f"Received GPS data, HK data length {len(hk_data)}")
|
||||
var_index = 0
|
||||
header_list = [
|
||||
"Latitude",
|
||||
"Longitude",
|
||||
"Altitude",
|
||||
"Fix Mode",
|
||||
"Sats in Use",
|
||||
"Date",
|
||||
"Unix Seconds",
|
||||
]
|
||||
latitude = struct.unpack("!d", hk_data[0:8])[0]
|
||||
longitude = struct.unpack("!d", hk_data[8:16])[0]
|
||||
altitude = struct.unpack("!d", hk_data[16:24])[0]
|
||||
fix_mode = hk_data[24]
|
||||
sat_in_use = hk_data[25]
|
||||
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]
|
||||
current_idx = 0
|
||||
fmt_str = "!ddddBBBHBBBBBI"
|
||||
inc_len = struct.calcsize(fmt_str)
|
||||
(
|
||||
lat,
|
||||
long,
|
||||
alt,
|
||||
speed,
|
||||
fix,
|
||||
sats_in_use,
|
||||
sats_in_view,
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hours,
|
||||
minutes,
|
||||
seconds,
|
||||
unix_seconds
|
||||
) = struct.unpack(fmt_str, hk_data[current_idx: current_idx + inc_len])
|
||||
current_idx += inc_len
|
||||
date_string = f"{day}.{month}.{year} {hours}:{minutes}:{seconds}"
|
||||
unix_seconds = struct.unpack("!I", hk_data[33:37])[0]
|
||||
content_list = [
|
||||
latitude,
|
||||
longitude,
|
||||
altitude,
|
||||
fix_mode,
|
||||
sat_in_use,
|
||||
date_string,
|
||||
unix_seconds,
|
||||
]
|
||||
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.now()}, {latitude}, {longitude}, {altitude}, "
|
||||
f"{fix_mode}, {sat_in_use}, {date_string}, {unix_seconds}\n"
|
||||
)
|
||||
validity_buffer = hk_data[37:39]
|
||||
pw.dlog(str(header_list))
|
||||
pw.dlog(str(content_list))
|
||||
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)
|
||||
pw.dlog(f"Lat: {lat} deg")
|
||||
pw.dlog(f"Long: {long} deg")
|
||||
pw.dlog(f"Altitude: {alt} m | Speed: {speed} m/s")
|
||||
pw.dlog(f"Fix Type: {fix} | Sats in View {sats_in_view} | Sats in Use {sats_in_use}")
|
||||
pw.dlog(f"GNSS Date: {date_string}")
|
||||
pw.dlog(f"Unix seconds {unix_seconds}")
|
||||
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=14)
|
||||
|
Loading…
Reference in New Issue
Block a user