2021-02-27 13:09:55 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
2021-05-17 18:08:43 +02:00
|
|
|
@file syrlinks_hk_handler.py
|
2021-02-27 13:42:41 +01:00
|
|
|
@brief Syrlinks Hk Handler tests
|
2021-02-27 13:09:55 +01:00
|
|
|
@author J. Meier
|
|
|
|
@date 13.12.2020
|
|
|
|
"""
|
2022-10-31 18:44:48 +01:00
|
|
|
from config.definitions import CustomServiceList
|
|
|
|
from tmtccmd.config.tmtc import (
|
|
|
|
tmtc_definitions_provider,
|
|
|
|
TmtcDefinitionWrapper,
|
|
|
|
OpCodeEntry,
|
|
|
|
)
|
2022-08-08 16:32:18 +02:00
|
|
|
from tmtccmd.tc import DefaultPusQueueHelper
|
2022-05-05 16:15:53 +02:00
|
|
|
from tmtccmd.tc.pus_3_fsfw_hk import make_sid, generate_one_hk_command
|
2021-12-02 09:25:31 +01:00
|
|
|
from spacepackets.ecss.tc import PusTelecommand
|
2022-05-05 16:15:53 +02:00
|
|
|
from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes
|
2022-03-31 11:36:50 +02:00
|
|
|
import struct
|
2021-02-27 13:09:55 +01:00
|
|
|
|
2022-07-08 16:25:46 +02:00
|
|
|
from tmtccmd.util import ObjectIdU32
|
2022-07-04 17:59:09 +02:00
|
|
|
|
2021-02-27 13:09:55 +01:00
|
|
|
|
|
|
|
class SetIds:
|
2021-03-01 12:14:04 +01:00
|
|
|
RX_REGISTERS_DATASET = 1
|
|
|
|
TX_REGISTERS_DATASET = 2
|
2021-02-27 13:09:55 +01:00
|
|
|
|
|
|
|
|
2022-05-27 14:29:56 +02:00
|
|
|
class OpCodes:
|
2022-10-31 18:44:48 +01:00
|
|
|
OFF = "off"
|
|
|
|
ON = "on"
|
|
|
|
NORMAL = "nml"
|
|
|
|
STANDBY = "standby"
|
|
|
|
MODULATION = "modulation"
|
2022-05-27 14:29:56 +02:00
|
|
|
|
|
|
|
|
2021-12-02 09:25:31 +01:00
|
|
|
class CommandIds:
|
2022-04-04 15:05:38 +02:00
|
|
|
READ_RX_STATUS_REGISTERS = 2
|
|
|
|
SET_TX_MODE_STANDBY = 3
|
|
|
|
SET_TX_MODE_MODULATION = 4
|
|
|
|
SET_TX_MODE_CW = 5
|
|
|
|
READ_TX_STATUS = 7
|
|
|
|
READ_TX_WAVEFORM = 8
|
|
|
|
READ_TX_AGC_VALUE_HIGH_BYTE = 9
|
|
|
|
READ_TX_AGC_VALUE_LOW_BYTE = 10
|
2022-03-31 11:36:50 +02:00
|
|
|
WRITE_LCL_CONFIG = 11
|
|
|
|
READ_LCL_CONFIG_REGISTER = 12
|
2022-04-04 15:05:38 +02:00
|
|
|
SET_WAVEFORM_OQPSK = 17
|
|
|
|
SET_WAVEFORM_BPSK = 18
|
|
|
|
SET_SECOND_CONFIG = 19
|
|
|
|
ENABLE_DEBUG = 20
|
2022-04-05 08:42:38 +02:00
|
|
|
DISABLE_DEBUG = 21
|
2021-02-27 13:09:55 +01:00
|
|
|
|
2021-12-02 09:25:31 +01:00
|
|
|
|
2022-10-31 18:44:48 +01:00
|
|
|
@tmtc_definitions_provider
|
|
|
|
def add_syrlinks_cmds(defs: TmtcDefinitionWrapper):
|
|
|
|
oce = OpCodeEntry()
|
|
|
|
oce.add(OpCodes.OFF, "Syrlinks Handler: Set mode off")
|
|
|
|
oce.add(OpCodes.ON, "Syrlinks Handler: Set mode on")
|
|
|
|
oce.add(OpCodes.NORMAL, "Syrlinks Handler: Set mode normal")
|
|
|
|
oce.add(OpCodes.STANDBY, "Syrlinks Handler: Set TX standby")
|
|
|
|
oce.add(OpCodes.MODULATION, "Syrlinks Handler: Set TX modulation")
|
|
|
|
oce.add("5", "Syrlinks Handler: Set TX carrier wave")
|
|
|
|
oce.add("6", "Syrlinks Handler: Read TX status")
|
|
|
|
oce.add("7", "Syrlinks Handler: Read TX waveform")
|
|
|
|
oce.add("8", "Syrlinks Handler: Read TX AGC value high byte")
|
|
|
|
oce.add("9", "Syrlinks Handler: Read TX AGC value low byte")
|
|
|
|
oce.add("12", "Syrlinks Handler: Write LCL config")
|
|
|
|
oce.add("13", "Syrlinks Handler: Read RX status registers")
|
|
|
|
oce.add("14", "Syrlinks Handler: Read LCL config register")
|
|
|
|
oce.add("15", "Syrlinks Handler: Set waveform OQPSK")
|
|
|
|
oce.add("16", "Syrlinks Handler: Set waveform BPSK")
|
|
|
|
oce.add("17", "Syrlinks Handler: Set second config")
|
|
|
|
oce.add("18", "Syrlinks Handler: Enable debug output")
|
|
|
|
oce.add("19", "Syrlinks Handler: Disable debug output")
|
|
|
|
defs.add_service(CustomServiceList.SYRLINKS.value, "Syrlinks Handler", oce)
|
|
|
|
|
|
|
|
|
2022-08-08 16:32:18 +02:00
|
|
|
def pack_syrlinks_command(
|
|
|
|
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
|
|
|
|
):
|
2022-07-04 17:59:09 +02:00
|
|
|
obyt = object_id.as_bytes
|
|
|
|
q.add_log_cmd(f"Testing Syrlinks with object id: {object_id.as_hex_string}")
|
2022-10-31 18:44:48 +01:00
|
|
|
if op_code == OpCodes.OFF:
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Set mode off")
|
|
|
|
data = pack_mode_data(obyt, Modes.OFF, 0)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
|
2022-10-31 18:44:48 +01:00
|
|
|
if op_code == OpCodes.ON:
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Set mode on")
|
|
|
|
data = pack_mode_data(obyt, Modes.ON, 0)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
|
2022-10-31 18:44:48 +01:00
|
|
|
if op_code == OpCodes.NORMAL:
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Mode Normal")
|
|
|
|
data = pack_mode_data(obyt, Modes.NORMAL, 0)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
|
2022-10-31 18:44:48 +01:00
|
|
|
if op_code == OpCodes.STANDBY:
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("syrlinks: Set TX mode standby")
|
|
|
|
data = obyt + struct.pack("!I", CommandIds.SET_TX_MODE_STANDBY)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
|
2022-10-31 18:44:48 +01:00
|
|
|
if op_code == OpCodes.MODULATION:
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("syrlinks: Set TX mode modulation")
|
|
|
|
data = obyt + struct.pack("!I", CommandIds.SET_TX_MODE_MODULATION)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "5":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("syrlinks: Set TX mode CW")
|
|
|
|
data = obyt + struct.pack("!I", CommandIds.SET_TX_MODE_CW)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "6":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Get RX Registers")
|
|
|
|
sid = make_sid(obyt, SetIds.RX_REGISTERS_DATASET)
|
|
|
|
q.add_pus_tc(generate_one_hk_command(sid))
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "7":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Get TX Registers")
|
|
|
|
sid = make_sid(obyt, SetIds.TX_REGISTERS_DATASET)
|
|
|
|
q.add_pus_tc(generate_one_hk_command(sid))
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "8":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Read TX status")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.READ_TX_STATUS)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "9":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Read TX waveform")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.READ_TX_WAVEFORM)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "10":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Read TX AGC value high byte")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.READ_TX_AGC_VALUE_HIGH_BYTE)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "11":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Read TX AGC value low byte")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.READ_TX_AGC_VALUE_LOW_BYTE)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-03-31 11:36:50 +02:00
|
|
|
if op_code == "12":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Write LCL config")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.WRITE_LCL_CONFIG)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-03-31 11:36:50 +02:00
|
|
|
if op_code == "13":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Read RX status registers")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.READ_RX_STATUS_REGISTERS)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-03-31 11:36:50 +02:00
|
|
|
if op_code == "14":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Read LCL config register")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.READ_LCL_CONFIG_REGISTER)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-04-04 15:05:38 +02:00
|
|
|
if op_code == "15":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Set waveform OQPSK")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.SET_WAVEFORM_OQPSK)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-04-04 15:05:38 +02:00
|
|
|
if op_code == "16":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Set waveform BPSK")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.SET_WAVEFORM_BPSK)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-04-04 15:05:38 +02:00
|
|
|
if op_code == "17":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Set second config")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.SET_SECOND_CONFIG)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-04-04 15:05:38 +02:00
|
|
|
if op_code == "18":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Enable debug printout")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.ENABLE_DEBUG)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
2022-04-04 15:05:38 +02:00
|
|
|
if op_code == "19":
|
2022-07-04 17:59:09 +02:00
|
|
|
q.add_log_cmd("Syrlinks: Disable debug printout")
|
|
|
|
command = obyt + struct.pack("!I", CommandIds.DISABLE_DEBUG)
|
|
|
|
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|