add remaining parsing for syrlinks HK

This commit is contained in:
Robin Müller 2023-02-10 15:51:03 +01:00
parent d7c30ba406
commit 9178251ed7
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -6,6 +6,8 @@
@date 13.12.2020
"""
import enum
import logging
import math
from eive_tmtc.pus_tm.defs import PrintWrapper
@ -269,21 +271,41 @@ def handle_syrlinks_rx_registers_dataset(printer: FsfwTmTcPrinter, hk_data: byte
"RX Sensitivity",
"RX Frequency Shift",
"RX IQ Power",
"RX AGC Value",
"RX AGC Value (Raw)",
"RX Demod Eb",
"RX Demod N0",
"RX Datarate",
"RX Datarate [kbps]",
]
rx_status = hk_data[0]
carrier_detect = rx_status & 0b1
carrier_lock = (rx_status >> 1) & 0b1
data_lock = (rx_status >> 2) & 0b1
data_valid = (rx_status >> 3) & 0b1
rx_sensitivity = struct.unpack("!I", hk_data[1:5])[0]
rx_frequency_shift = struct.unpack("!i", hk_data[5:9])[0]
freq_shift_hz = rx_frequency_shift / 8.0
freq_shift_printout = f"Raw: {rx_frequency_shift}, Eng: {freq_shift_hz} Hz"
rx_iq_power = struct.unpack("!H", hk_data[9:11])[0]
rx_agc_value = struct.unpack("!H", hk_data[11:13])[0]
rx_demod_eb = struct.unpack("!I", hk_data[13:17])[0]
rx_demod_n0 = struct.unpack("!I", hk_data[17:21])[0]
rx_data_rate = hk_data[21]
rx_agc_inhibit = (rx_agc_value >> 15) & 0b1
rx_agc = rx_agc_value & 0xFFF
rx_demod_eb = struct.unpack("!I", hk_data[13:17])[0] & 0xFFFFFF
rx_demod_n0 = struct.unpack("!I", hk_data[17:21])[0] & 0xFFFFFF
eb_to_n0 = 20 * math.log10(rx_demod_eb / rx_demod_n0) - 3
rx_data_rate_raw = hk_data[21]
rx_data_rate = -1
if rx_data_rate_raw == 0:
rx_data_rate = 256
elif rx_data_rate_raw == 1:
rx_data_rate = 128
elif rx_data_rate_raw == 3:
rx_data_rate = 64
elif rx_data_rate_raw == 7:
rx_data_rate = 32
elif rx_data_rate_raw == 15:
rx_data_rate = 16
elif rx_data_rate_raw == 31:
rx_data_rate = 8
content_list = [
rx_status,
rx_sensitivity,
@ -297,20 +319,60 @@ def handle_syrlinks_rx_registers_dataset(printer: FsfwTmTcPrinter, hk_data: byte
validity_buffer = hk_data[22:]
for header, content in zip(header_list, content_list):
pw.dlog(f"{header}: {content}")
pw.dlog(f"Carrier Detect: {carrier_detect}")
pw.dlog(f"Carrier Lock: {carrier_lock}")
pw.dlog(f"Data Lock (data clock recovery loop lock status): {data_lock}")
pw.dlog(f"Data Valid (valid if TEB < 10e-5): {data_valid}")
pw.dlog(f"Data Lock (data clock recovery loop lock status): {data_lock}")
pw.dlog(f"RX AGC Inhibit: {rx_agc_inhibit}")
pw.dlog(f"RX AGC: {rx_agc}")
pw.dlog(f"Eb / E0RX [dB]: {eb_to_n0}")
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=8)
class TxConv(enum.IntEnum):
NO_CODING = 0b000
VITERBI_HALF_G1G2INV = 0b010
VITERBI_HALF = 0b111
WAVEFORM_STRINGS = ["OFF", "CW", "QPSK", "0QPSK", "PCM/PM", "PSK/PM", "BPSK"]
def handle_syrlinks_tx_registers_dataset(
printer: FsfwTmTcPrinter,
hk_data: bytes,
):
pw = PrintWrapper(printer)
header_list = ["TX Status", "TX Waveform", "TX AGC value"]
header_list = ["TX Status Raw", "TX Waveform", "TX AGC value"]
tx_status = hk_data[0]
try:
tx_conv = TxConv(tx_status & 0b111)
except IndexError:
logging.getLogger(__name__).warning(
f"invalid TX conv value {tx_status & 0b111}"
)
tx_conv = -1
tx_diff_encoder_enable = (tx_status >> 3) & 0b1
tx_waveform = hk_data[1]
waveform = tx_waveform & 0b1111
try:
waveform_str = WAVEFORM_STRINGS[waveform]
except IndexError:
logging.getLogger(__name__).warning(f"Unknown waveform value {waveform}")
waveform_str = "Unknown"
pcm_mode = (tx_waveform >> 4) & 0b1
tx_agc_value = struct.unpack("!H", hk_data[2:4])[0]
tx_agc_inhibit = (tx_agc_value >> 15) & 0b1
tx_agc = tx_agc_value & 0xFFF
content_list = [tx_status, tx_waveform, tx_agc_value]
validity_buffer = hk_data[4:]
for header, content in zip(header_list, content_list):
pw.dlog(f"{header}: {content}")
pw.dlog(f"TX CONV: {tx_conv!r}")
pw.dlog(f"TX DIFF (differential encoder enable): {tx_diff_encoder_enable}")
pw.dlog(f"Waveform: {waveform_str}")
pw.dlog(f"PCM Mode: {pcm_mode}")
pw.dlog(f"TX AGC Inhibit: {tx_agc_inhibit}")
pw.dlog(f"TX AGC: {tx_agc}")
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=3)