2023-01-27 15:42:00 +01:00
|
|
|
import enum
|
|
|
|
|
|
|
|
from eive_tmtc.config.definitions import CustomServiceList
|
|
|
|
from eive_tmtc.config.object_ids import COM_SUBSYSTEM_ID
|
2023-01-28 14:30:51 +01:00
|
|
|
from eive_tmtc.tmtc.com.syrlinks_handler import Datarate
|
2023-01-27 15:42:00 +01:00
|
|
|
from tmtccmd.config.tmtc import (
|
|
|
|
tmtc_definitions_provider,
|
|
|
|
TmtcDefinitionWrapper,
|
|
|
|
OpCodeEntry,
|
|
|
|
)
|
|
|
|
from tmtccmd.tc import service_provider
|
|
|
|
from tmtccmd.tc.decorator import ServiceProviderParams
|
2023-01-31 12:56:13 +01:00
|
|
|
from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command
|
|
|
|
from tmtccmd.tc.pus_20_fsfw_param import (
|
2023-01-28 14:30:51 +01:00
|
|
|
create_load_param_cmd,
|
|
|
|
pack_scalar_u8_parameter_app_data,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class ParameterId(enum.IntEnum):
|
|
|
|
DATARATE = 0
|
2023-01-27 15:42:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Submode(enum.IntEnum):
|
|
|
|
RX_ONLY = 0
|
|
|
|
RX_AND_TX_DEF_DATARATE = 1
|
|
|
|
RX_AND_TX_LOW_DATARATE = 2
|
|
|
|
RX_AND_TX_HIGH_DATARATE = 3
|
|
|
|
RX_AND_TX_CARRIER_WAVE = 4
|
|
|
|
|
|
|
|
|
|
|
|
class OpCode:
|
|
|
|
RX_ONLY = "rx_only"
|
2023-01-27 20:23:41 +01:00
|
|
|
TX_AND_RX_DEF_RATE = "rx_and_tx_default_rate"
|
2023-01-27 15:42:00 +01:00
|
|
|
TX_AND_RX_LOW_RATE = "rx_and_tx_low_rate"
|
|
|
|
TX_AND_RX_HIGH_RATE = "rx_and_tx_high_rate"
|
|
|
|
TX_AND_RX_CARRIER_WAVE = "rx_and_tx_carrier_wave"
|
2023-01-28 14:30:51 +01:00
|
|
|
UPDATE_DEFAULT_DATARATE_LOW = "update_default_rate_low"
|
|
|
|
UPDATE_DEFAULT_DATARATE_HIGH = "update_default_rate_high"
|
2023-01-27 15:42:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Info:
|
|
|
|
RX_ONLY = "Syrlinks RX Only"
|
2023-01-27 20:23:41 +01:00
|
|
|
TX_AND_RX_DEF_DATARATE = "Syrlinks with TX default datarate"
|
2023-01-27 15:42:00 +01:00
|
|
|
TX_AND_RX_LOW_DATARATE = "Syrlinks with TX low datarate (BPSK modulation)"
|
|
|
|
TX_AND_RX_HIGH_DATARATE = "Syrlinks with TX high datarate (0QPSK modulation)"
|
|
|
|
TX_AND_RX_CARRIER_WAVE = "Syrlinks with TX carrier wave"
|
2023-01-28 14:30:51 +01:00
|
|
|
UPDATE_DEFAULT_DATARATE_LOW = "Configure default low datarate (BPSK modulation)"
|
|
|
|
UPDATE_DEFAULT_DATARATE_HIGH = "Configure default high datarate (0QPSK modulation)"
|
2023-01-27 15:42:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
@service_provider(CustomServiceList.COM_SS)
|
|
|
|
def build_com_subsystem_cmd(p: ServiceProviderParams):
|
|
|
|
q = p.queue_helper
|
|
|
|
o = p.op_code
|
2023-01-28 14:30:51 +01:00
|
|
|
prefix = "COM Subsystem"
|
2023-01-27 15:42:00 +01:00
|
|
|
if o == OpCode.RX_ONLY:
|
|
|
|
q.add_log_cmd(Info.RX_ONLY)
|
|
|
|
q.add_pus_tc(create_mode_command(COM_SUBSYSTEM_ID, Submode.RX_ONLY, 0))
|
2023-01-27 20:23:41 +01:00
|
|
|
elif o == OpCode.TX_AND_RX_DEF_RATE:
|
|
|
|
q.add_log_cmd(Info.TX_AND_RX_DEF_DATARATE)
|
|
|
|
q.add_pus_tc(
|
|
|
|
create_mode_command(COM_SUBSYSTEM_ID, Submode.RX_AND_TX_DEF_DATARATE, 0)
|
|
|
|
)
|
2023-01-27 15:42:00 +01:00
|
|
|
elif o == OpCode.TX_AND_RX_LOW_RATE:
|
|
|
|
q.add_log_cmd(Info.TX_AND_RX_LOW_DATARATE)
|
|
|
|
q.add_pus_tc(
|
|
|
|
create_mode_command(COM_SUBSYSTEM_ID, Submode.RX_AND_TX_LOW_DATARATE, 0)
|
|
|
|
)
|
|
|
|
elif o == OpCode.TX_AND_RX_HIGH_RATE:
|
|
|
|
q.add_log_cmd(Info.TX_AND_RX_HIGH_DATARATE)
|
|
|
|
q.add_pus_tc(
|
|
|
|
create_mode_command(COM_SUBSYSTEM_ID, Submode.RX_AND_TX_HIGH_DATARATE, 0)
|
|
|
|
)
|
2023-01-28 14:30:51 +01:00
|
|
|
if o == OpCode.UPDATE_DEFAULT_DATARATE_LOW:
|
|
|
|
q.add_log_cmd(f"{prefix}: {Info.UPDATE_DEFAULT_DATARATE_LOW}")
|
|
|
|
q.add_pus_tc(
|
|
|
|
create_load_param_cmd(
|
|
|
|
pack_scalar_u8_parameter_app_data(
|
|
|
|
COM_SUBSYSTEM_ID,
|
|
|
|
0,
|
|
|
|
ParameterId.DATARATE,
|
|
|
|
Datarate.LOW_RATE_MODULATION_BPSK,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if o == OpCode.UPDATE_DEFAULT_DATARATE_HIGH:
|
|
|
|
q.add_log_cmd(f"{prefix}: {Info.UPDATE_DEFAULT_DATARATE_HIGH}")
|
|
|
|
q.add_pus_tc(
|
|
|
|
create_load_param_cmd(
|
|
|
|
pack_scalar_u8_parameter_app_data(
|
|
|
|
COM_SUBSYSTEM_ID,
|
|
|
|
0,
|
|
|
|
ParameterId.DATARATE,
|
|
|
|
Datarate.HIGH_RATE_MODULATION_0QPSK,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2023-01-27 15:42:00 +01:00
|
|
|
elif o == OpCode.TX_AND_RX_CARRIER_WAVE:
|
|
|
|
q.add_log_cmd(Info.TX_AND_RX_CARRIER_WAVE)
|
|
|
|
q.add_pus_tc(
|
|
|
|
create_mode_command(COM_SUBSYSTEM_ID, Submode.RX_AND_TX_CARRIER_WAVE, 0)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@tmtc_definitions_provider
|
|
|
|
def add_com_subsystem_cmds(defs: TmtcDefinitionWrapper):
|
|
|
|
oce = OpCodeEntry()
|
|
|
|
oce.add(OpCode.RX_ONLY, Info.RX_ONLY)
|
|
|
|
oce.add(OpCode.TX_AND_RX_LOW_RATE, Info.TX_AND_RX_LOW_DATARATE)
|
|
|
|
oce.add(OpCode.TX_AND_RX_HIGH_RATE, Info.TX_AND_RX_HIGH_DATARATE)
|
2023-01-27 20:23:41 +01:00
|
|
|
oce.add(OpCode.TX_AND_RX_DEF_RATE, Info.TX_AND_RX_DEF_DATARATE)
|
2023-01-28 14:30:51 +01:00
|
|
|
oce.add(OpCode.UPDATE_DEFAULT_DATARATE_LOW, Info.UPDATE_DEFAULT_DATARATE_LOW)
|
|
|
|
oce.add(OpCode.UPDATE_DEFAULT_DATARATE_HIGH, Info.UPDATE_DEFAULT_DATARATE_HIGH)
|
2023-01-27 15:42:00 +01:00
|
|
|
defs.add_service(CustomServiceList.COM_SS, "COM Subsystem", oce)
|