add code to send mgm data

This commit is contained in:
Robin Müller 2022-08-17 11:19:23 +02:00
parent ca9f85de1b
commit d2144aab26
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
6 changed files with 50 additions and 6 deletions

2
deps/tmtccmd vendored

@ -1 +1 @@
Subproject commit 403c5fd2b1cd28af8de2b39f308b633892e660e5 Subproject commit d042315e4cc0b5d0b13ceaaf5e3f36e8ad455740

View File

@ -1 +1 @@
from . import acs_ctrl

View File

@ -1,5 +1,5 @@
"""HK Handling for EIVE OBSW""" """HK Handling for EIVE OBSW"""
from pus_tc.system.acs_ctrl import handle_acs_ctrl_mgm_data from tmtc.acs_ctrl import handle_acs_ctrl_mgm_data
from pus_tm.devs.plpcdu import handle_plpcdu_hk from pus_tm.devs.plpcdu import handle_plpcdu_hk
from pus_tm.devs.rad_sensor import handle_rad_sensor_data from pus_tm.devs.rad_sensor import handle_rad_sensor_data
from pus_tm.devs.sus import handle_sus_hk from pus_tm.devs.sus import handle_sus_hk

0
tmtc/__init__.py Normal file
View File

View File

@ -1,5 +1,8 @@
import enum import enum
import socket
import struct import struct
from socket import AF_INET
from typing import Tuple
from config.definitions import CustomServiceList from config.definitions import CustomServiceList
from config.object_ids import ACS_CONTROLLER from config.object_ids import ACS_CONTROLLER
@ -11,8 +14,12 @@ from tmtccmd.config.tmtc import (
OpCodeEntry, OpCodeEntry,
) )
from tmtccmd.tc import DefaultPusQueueHelper, service_provider from tmtccmd.tc import DefaultPusQueueHelper, service_provider
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid, \ from tmtccmd.tc.pus_3_fsfw_hk import (
enable_periodic_hk_command_with_interval, disable_periodic_hk_command generate_one_hk_command,
make_sid,
enable_periodic_hk_command_with_interval,
disable_periodic_hk_command,
)
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
LOGGER = get_console_logger() LOGGER = get_console_logger()
@ -34,6 +41,12 @@ class Info:
DISABLE_MGM_HK = "Disable MGM HK data generation" DISABLE_MGM_HK = "Disable MGM HK data generation"
PERFORM_MGM_CALIBRATION = False
CALIBRATION_SOCKET_HOST = "localhost"
CALIBRATION_SOCKET_PORT = 6677
CALIBRATION_ADDR = (CALIBRATION_SOCKET_HOST, CALIBRATION_SOCKET_PORT)
@tmtc_definitions_provider @tmtc_definitions_provider
def acs_cmd_defs(defs: TmtcDefinitionWrapper): def acs_cmd_defs(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry() oce = OpCodeEntry()
@ -122,4 +135,35 @@ def handle_acs_ctrl_mgm_data(printer: FsfwTmTcPrinter, hk_data: bytes):
for entry in zip(print_str_list, formatted_list): for entry in zip(print_str_list, formatted_list):
pw.dlog(f"{entry[0].ljust(28)}: {entry[1]}") pw.dlog(f"{entry[0].ljust(28)}: {entry[1]}")
current_idx += 1 current_idx += 1
if PERFORM_MGM_CALIBRATION:
perform_mgm_calibration(pw, mgm_0_lis3_floats_ut)
assert current_idx == 61 assert current_idx == 61
def perform_mgm_calibration(pw: PrintWrapper, mgm_tuple: Tuple):
calibr_socket = socket.socket(AF_INET, socket.SOCK_STREAM)
try:
declare_api_cmd = "declare_api_version 2"
calibr_socket.connect(CALIBRATION_ADDR)
calibr_socket.sendall(f"{declare_api_cmd}\n".encode())
calibr_socket.settimeout(0.2)
calibr_socket.setblocking(False)
reply = calibr_socket.recv(1024)
pw.dlog(
f"Received reply {reply} from Helmholtz Socket for command {declare_api_cmd}"
)
if len(mgm_tuple) != 3:
pw.dlog(f"MGM tuple has invalid length {len(mgm_tuple)}")
mgm_list = [mgm / 10e6 for mgm in mgm_tuple]
command = (
f"magnetometer_field {mgm_list[0]} {mgm_list[1]} {mgm_list[2]}\n".encode()
)
calibr_socket.sendall(command)
reply = calibr_socket.recv(1024)
pw.dlog(
f"Received reply {reply} from Helmholtz Socket for command magnetometer_field"
)
except socket.timeout:
pw.dlog("Socket timeout")
except ConnectionRefusedError or OSError:
pw.dlog("Connecting to Calibration Socket on addrss {} failed")

View File

@ -205,7 +205,7 @@ def main():
printer = FsfwTmTcPrinter(tmtc_logger.logger) printer = FsfwTmTcPrinter(tmtc_logger.logger)
raw_logger = RawTmtcTimedLogWrapper( raw_logger = RawTmtcTimedLogWrapper(
when=ROTATING_TIMED_LOGGER_INTERVAL_WHEN, when=ROTATING_TIMED_LOGGER_INTERVAL_WHEN,
interval=ROTATING_TIMED_LOGGER_INTERVAL interval=ROTATING_TIMED_LOGGER_INTERVAL,
) )
pus_verificator = PusVerificator() pus_verificator = PusVerificator()
ccsds_handler, tc_handler = setup_tmtc( ccsds_handler, tc_handler = setup_tmtc(