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
|
|
|
|
"""
|
|
|
|
|
2021-05-17 18:08:43 +02:00
|
|
|
from tmtccmd.config.definitions import QueueCommands
|
2021-07-24 14:58:47 +02:00
|
|
|
from tmtccmd.tc.definitions import TcQueueT
|
|
|
|
from tmtccmd.tc.service_3_housekeeping import make_sid, generate_one_hk_command
|
2021-12-02 09:25:31 +01:00
|
|
|
from spacepackets.ecss.tc import PusTelecommand
|
2022-03-29 07:57:39 +02:00
|
|
|
from tmtccmd.tc.service_200_mode import pack_mode_data, Modes
|
2022-03-31 11:36:50 +02:00
|
|
|
import struct
|
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
|
|
|
|
|
|
|
|
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-01-18 14:03:56 +01:00
|
|
|
def pack_syrlinks_command(
|
|
|
|
object_id: bytearray, tc_queue: TcQueueT, op_code: str
|
|
|
|
) -> TcQueueT:
|
2021-12-02 09:25:31 +01:00
|
|
|
tc_queue.appendleft(
|
2022-01-18 14:03:56 +01:00
|
|
|
(
|
|
|
|
QueueCommands.PRINT,
|
2022-03-30 09:22:10 +02:00
|
|
|
"Testing Syrlinks with object id: 0x" + object_id.hex(),
|
2022-01-18 14:03:56 +01:00
|
|
|
)
|
2021-12-02 09:25:31 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
if op_code == "0":
|
2022-04-04 13:53:26 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Set mode off"))
|
2022-03-29 07:03:13 +02:00
|
|
|
command = pack_mode_data(object_id, Modes.OFF, 0)
|
|
|
|
command = PusTelecommand(service=200, subservice=1, ssc=9, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "1":
|
2022-04-04 13:53:26 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Set mode on"))
|
2022-03-29 07:03:13 +02:00
|
|
|
command = pack_mode_data(object_id, Modes.ON, 0)
|
|
|
|
command = PusTelecommand(service=200, subservice=1, ssc=10, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "2":
|
2022-03-29 07:57:39 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Mode Normal"))
|
2022-03-29 07:03:13 +02:00
|
|
|
command = pack_mode_data(object_id, Modes.NORMAL, 0)
|
|
|
|
command = PusTelecommand(service=200, subservice=1, ssc=11, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "3":
|
2021-12-02 09:25:31 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "syrlinks: Set TX mode standby"))
|
|
|
|
command = object_id + CommandIds.SET_TX_MODE_STANDBY
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=10, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "4":
|
2021-12-02 09:25:31 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "syrlinks: Set TX mode modulation"))
|
|
|
|
command = object_id + CommandIds.SET_TX_MODE_MODULATION
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=11, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "5":
|
2021-12-02 09:25:31 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "syrlinks: Set TX mode CW"))
|
|
|
|
command = object_id + CommandIds.SET_TX_MODE_CW
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=12, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "6":
|
2021-12-02 09:25:31 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Get RX Registers"))
|
|
|
|
sid = make_sid(object_id, SetIds.RX_REGISTERS_DATASET)
|
|
|
|
command = generate_one_hk_command(sid, 200)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "7":
|
2021-12-02 09:25:31 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Get TX Registers"))
|
|
|
|
sid = make_sid(object_id, SetIds.TX_REGISTERS_DATASET)
|
|
|
|
command = generate_one_hk_command(sid, 201)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "8":
|
2021-12-02 09:25:31 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Read TX status"))
|
|
|
|
command = object_id + CommandIds.READ_TX_STATUS
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=13, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "9":
|
2021-12-02 09:25:31 +01:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Read TX waveform"))
|
|
|
|
command = object_id + CommandIds.READ_TX_WAVEFORM
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=14, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "10":
|
2022-01-18 14:03:56 +01:00
|
|
|
tc_queue.appendleft(
|
|
|
|
(QueueCommands.PRINT, "Syrlinks: Read TX AGC value high byte")
|
|
|
|
)
|
2021-12-02 09:25:31 +01:00
|
|
|
command = object_id + CommandIds.READ_TX_AGC_VALUE_HIGH_BYTE
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=15, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-29 07:03:13 +02:00
|
|
|
if op_code == "11":
|
2022-01-18 14:03:56 +01:00
|
|
|
tc_queue.appendleft(
|
|
|
|
(QueueCommands.PRINT, "Syrlinks: Read TX AGC value low byte")
|
|
|
|
)
|
2021-12-02 09:25:31 +01:00
|
|
|
command = object_id + CommandIds.READ_TX_AGC_VALUE_LOW_BYTE
|
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=16, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-03-31 11:36:50 +02:00
|
|
|
if op_code == "12":
|
2022-04-04 13:53:26 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Write LCL config"))
|
|
|
|
command = object_id + struct.pack("!I", CommandIds.WRITE_LCL_CONFIG)
|
2022-03-31 11:36:50 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=17, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "13":
|
2022-04-04 13:53:26 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Read RX status registers"))
|
|
|
|
command = object_id + struct.pack("!I", CommandIds.READ_RX_STATUS_REGISTERS)
|
2022-03-31 11:36:50 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=18, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "14":
|
2022-04-04 13:53:26 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Read LCL config register"))
|
|
|
|
command = object_id + struct.pack("!I", CommandIds.READ_LCL_CONFIG_REGISTER)
|
2022-03-31 11:36:50 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=19, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
2022-04-04 15:05:38 +02:00
|
|
|
if op_code == "15":
|
2022-04-05 19:49:42 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Set waveform OQPSK"))
|
|
|
|
command = object_id + struct.pack("!I", CommandIds.SET_WAVEFORM_OQPSK)
|
2022-04-04 15:05:38 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "16":
|
2022-04-05 19:49:42 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Set waveform BPSK"))
|
|
|
|
command = object_id + struct.pack("!I", CommandIds.SET_WAVEFORM_BPSK)
|
2022-04-04 15:05:38 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "17":
|
2022-04-05 19:49:42 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Set second config"))
|
|
|
|
command = object_id + struct.pack("!I", CommandIds.SET_SECOND_CONFIG)
|
2022-04-04 15:05:38 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "18":
|
2022-04-05 19:49:42 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Enable debug printout"))
|
|
|
|
command = object_id + struct.pack("!I", CommandIds.ENABLE_DEBUG)
|
2022-04-04 15:05:38 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|
|
|
|
if op_code == "19":
|
2022-04-05 19:49:42 +02:00
|
|
|
tc_queue.appendleft((QueueCommands.PRINT, "Syrlinks: Disable debug printout"))
|
|
|
|
command = object_id + struct.pack("!I", CommandIds.DISABLE_DEBUG)
|
2022-04-04 15:05:38 +02:00
|
|
|
command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command)
|
|
|
|
tc_queue.appendleft(command.pack_command_tuple())
|