Add initial RTTY Mod without API

This commit is contained in:
srcejon 2023-09-01 17:10:26 +01:00
parent f891bd681e
commit f5968816ef
31 changed files with 5533 additions and 27 deletions

View File

@ -107,6 +107,7 @@ option(ENABLE_CHANNELTX_MODATV "Enable channeltx modatv plugin" ON)
option(ENABLE_CHANNELTX_MOD802.15.4 "Enable channeltx mod802.15.4 plugin" ON)
option(ENABLE_CHANNELTX_REMOTESOURCE "Enable channeltx remotesource plugin" ON)
option(ENABLE_CHANNELTX_FILESOURCE "Enable channeltx filesource plugin" ON)
option(ENABLE_CHANNELTX_MODRTTY "Enable channeltx modrtty plugin" ON)
# Channel MIMO enablers
option(ENABLE_CHANNELMIMO "Enable channelmimo plugins" ON)

View File

@ -1,5 +1,9 @@
project(mod)
if (ENABLE_CHANNELTX_MODRTTY)
add_subdirectory(modrtty)
endif()
if (ENABLE_CHANNELTX_MODAIS)
add_subdirectory(modais)
endif()

View File

@ -0,0 +1,69 @@
project(modrtty)
set(modrtty_SOURCES
rttymod.cpp
rttymodbaseband.cpp
rttymodsource.cpp
rttymodplugin.cpp
rttymodsettings.cpp
rttymodwebapiadapter.cpp
)
set(modrtty_HEADERS
rttymod.h
rttymodbaseband.h
rttymodsource.h
rttymodplugin.h
rttymodsettings.h
rttymodwebapiadapter.h
)
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
)
if(NOT SERVER_MODE)
set(modrtty_SOURCES
${modrtty_SOURCES}
rttymodgui.cpp
rttymodgui.ui
rttymodrepeatdialog.cpp
rttymodrepeatdialog.ui
rttymodtxsettingsdialog.cpp
rttymodtxsettingsdialog.ui
)
set(modrtty_HEADERS
${modrtty_HEADERS}
rttymodgui.h
rttymodrepeatdialog.h
rttymodtxsettingsdialog.h
)
set(TARGET_NAME modrtty)
set(TARGET_LIB "Qt::Widgets")
set(TARGET_LIB_GUI "sdrgui")
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
else()
set(TARGET_NAME modrttysrv)
set(TARGET_LIB "")
set(TARGET_LIB_GUI "")
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
endif()
add_library(${TARGET_NAME} SHARED
${modrtty_SOURCES}
)
target_link_libraries(${TARGET_NAME}
Qt::Core
${TARGET_LIB}
sdrbase
${TARGET_LIB_GUI}
swagger
)
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
# Install debug symbols
if (WIN32)
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}> CONFIGURATIONS Debug RelWithDebInfo DESTINATION ${INSTALL_FOLDER} )
endif()

View File

@ -0,0 +1,113 @@
<h1>RTTY Modulator Plugin</h1>
<h2>Introduction</h2>
This plugin can be used to transmit RTTY encoded text.
<h2>Interface</h2>
The top and bottom bars of the channel window are described [here](../../../sdrgui/channel/readme.md)
![RTTY Modulator plugin GUI](../../../doc/img/RTTYMod_plugin.png)
<h3>1: Frequency shift from center frequency of transmission</h3>
Use the wheels to adjust the frequency shift in Hz from the center frequency of transmission. Left click on a digit sets the cursor position at this digit. Right click on a digit sets all digits on the right to zero. This effectively floors value at the digit position. Wheels are moved with the mousewheel while pointing at the wheel or by selecting the wheel with the left mouse click and using the keyboard arrows. Pressing shift simultaneously moves digit by 5 and pressing control moves it by 2.
<h3>2: Channel power</h3>
Average total power in dB relative to a +/- 1.0 amplitude signal generated in the pass band.
<h3>3: Channel mute</h3>
Use this button to toggle mute for this channel.
<h3>4: Mode</h3>
Contains a list of common baud rate and frequency shift settings. To specify your own, set this option to Custom.
45.45/170 is common for amateur RTTY.
<h3>5: Baud</h3>
Specifies the baud rate in symbols (bits) per second.
<h3>6: Frequency Shift</h3>
Adjusts the frequency shift (different between mark and space frequencies) in Hz.
<h3>7: RF Bandwidth</h3>
This specifies the bandwidth of a LPF that is applied to the output signal to limit the RF bandwidth.
<h3>8: Gain</h3>
Adjusts the gain in dB from -60 to 0dB.
<h3>9: Level meter in %</h3>
- top bar (beige): average value
- bottom bar (brown): instantaneous peak value
- tip vertical bar (bright red): peak hold value
<h3>10: UDP</h3>
When checked, a UDP port is opened to receive text from other features or applications that will be transmitted.
<h3>11: UDP address</h3>
IP address of the interface to open the UDP port on, to receive text to be transmitted.
<h3>12: UDP port</h3>
UDP port number to receive text to be transmitted on.
<h3>13: Baudot Character Set</h3>
Specifies the Baudot character set used to encode the text to transmit.
<h3>14: Bit Ordering</h3>
Specifies whether bits are transmitted least-significant-bit first (LSB) or most-significant-bit first (MSB).
<h3>15: Mark/Space Frequency</h3>
When unchecked, the mark frequency is the higher RF frequency, when checked the space frequency is higher.
<h3>16: Unshift on Space</h3>
When checked, the Baudot character set will shift to letters when a space character (' ') is transmitted.
<h3>17: Repeat</h3>
Check this button to repeatedly transmit a packet. Right click to open the dialog to adjust the number of times the packet should be repeated.
<h3>18: Clear Transmitted Text</h3>
Press to clear the transmitted text.
<h3>19: Text to Transmit</h3>
Enter text to transmit. Pressing return will transmit the text and clear this field. Press the arrow to display and select a list of pre-defined text or previously transmitted text to enter in to the field.
<h3>20: TX</h3>
Press to transmits the current text. The text field will not be cleared.
Right click to open a dialog to adjust additional transmitter settings.
<h2>API</h2>
Full details of the API can be found in the Swagger documentation. Below are a few examples.
To transmit the current text simply send a "tx" action:
curl -X POST "http://127.0.0.1:8091/sdrangel/deviceset/1/channel/0/actions" -d '{"channelType": "RttyMod", "direction": 1, "RttyModActions": { "tx": 1}}'
To transmit a packet from the command line:
curl -X POST "http://127.0.0.1:8091/sdrangel/deviceset/1/channel/0/actions" -d '{"channelType": "RttyMod", "direction": 1, "RttyModActions": { "tx": 1, "payload": {"text": "CQ CQ CQ anyone using SDRangel" }}}'
To set the baud rate and frequency shift:
curl -X PATCH "http://127.0.0.1:8091/sdrangel/deviceset/1/channel/0/settings" -d '{"channelType": "RttyMod", "direction": 1, "RttyModSettings": {"baud": 45.45; "frequencyShift": 170 }}'

View File

@ -0,0 +1,886 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QTime>
#include <QDebug>
#include <QMutexLocker>
#include <QNetworkAccessManager>
#include <QNetworkDatagram>
#include <QNetworkReply>
#include <QBuffer>
#include <QUdpSocket>
#include <QThread>
#include "SWGChannelSettings.h"
#include "SWGWorkspaceInfo.h"
#include "SWGChannelReport.h"
#include "SWGChannelActions.h"
/*#include "SWGRttyModReport.h"
#include "SWGRttyModActions.h"*/
#include <stdio.h>
#include <complex.h>
#include <algorithm>
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "device/deviceapi.h"
#include "feature/feature.h"
#include "util/db.h"
#include "util/crc.h"
#include "maincore.h"
#include "rttymodbaseband.h"
#include "rttymod.h"
MESSAGE_CLASS_DEFINITION(RttyMod::MsgConfigureRttyMod, Message)
MESSAGE_CLASS_DEFINITION(RttyMod::MsgTx, Message)
MESSAGE_CLASS_DEFINITION(RttyMod::MsgReportTx, Message)
MESSAGE_CLASS_DEFINITION(RttyMod::MsgTXPacketBytes, Message)
MESSAGE_CLASS_DEFINITION(RttyMod::MsgTXPacketData, Message)
const char* const RttyMod::m_channelIdURI = "sdrangel.channeltx.modrtty";
const char* const RttyMod::m_channelId = "RttyMod";
RttyMod::RttyMod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_TX_SCALEF),
m_sampleRate(48000),
m_udpSocket(nullptr)
{
setObjectName(m_channelId);
m_thread = new QThread(this);
m_basebandSource = new RttyModBaseband();
m_basebandSource->setSpectrumSampleSink(&m_spectrumVis);
m_basebandSource->setChannel(this);
m_basebandSource->moveToThread(m_thread);
applySettings(m_settings, true);
m_deviceAPI->addChannelSource(this);
m_deviceAPI->addChannelSourceAPI(this);
m_networkManager = new QNetworkAccessManager();
QObject::connect(
m_networkManager,
&QNetworkAccessManager::finished,
this,
&RttyMod::networkManagerFinished
);
}
RttyMod::~RttyMod()
{
closeUDP();
QObject::connect(
m_networkManager,
&QNetworkAccessManager::finished,
this,
&RttyMod::networkManagerFinished
);
delete m_networkManager;
m_deviceAPI->removeChannelSourceAPI(this);
m_deviceAPI->removeChannelSource(this);
delete m_basebandSource;
delete m_thread;
}
void RttyMod::setDeviceAPI(DeviceAPI *deviceAPI)
{
if (deviceAPI != m_deviceAPI)
{
m_deviceAPI->removeChannelSourceAPI(this);
m_deviceAPI->removeChannelSource(this);
m_deviceAPI = deviceAPI;
m_deviceAPI->addChannelSource(this);
m_deviceAPI->addChannelSinkAPI(this);
}
}
void RttyMod::start()
{
qDebug("RttyMod::start");
m_basebandSource->reset();
m_thread->start();
}
void RttyMod::stop()
{
qDebug("RttyMod::stop");
m_thread->exit();
m_thread->wait();
}
void RttyMod::pull(SampleVector::iterator& begin, unsigned int nbSamples)
{
m_basebandSource->pull(begin, nbSamples);
}
bool RttyMod::handleMessage(const Message& cmd)
{
if (MsgConfigureRttyMod::match(cmd))
{
MsgConfigureRttyMod& cfg = (MsgConfigureRttyMod&) cmd;
qDebug() << "RttyMod::handleMessage: MsgConfigureRttyMod";
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (MsgTx::match(cmd))
{
MsgTx* msg = new MsgTx((const MsgTx&)cmd);
m_basebandSource->getInputMessageQueue()->push(msg);
return true;
}
else if (MsgTXPacketData::match(cmd))
{
MsgTXPacketData* msg = new MsgTXPacketData((const MsgTXPacketData&)cmd);
m_basebandSource->getInputMessageQueue()->push(msg);
return true;
}
else if (DSPSignalNotification::match(cmd))
{
// Forward to the source
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy
qDebug() << "RttyMod::handleMessage: DSPSignalNotification";
m_basebandSource->getInputMessageQueue()->push(rep);
// Forward to GUI if any
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(new DSPSignalNotification(notif));
}
return true;
}
else if (MainCore::MsgChannelDemodQuery::match(cmd))
{
qDebug() << "RttyMod::handleMessage: MsgChannelDemodQuery";
sendSampleRateToDemodAnalyzer();
return true;
}
else
{
return false;
}
}
void RttyMod::setCenterFrequency(qint64 frequency)
{
RttyModSettings settings = m_settings;
settings.m_inputFrequencyOffset = frequency;
applySettings(settings, false);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureRttyMod *msgToGUI = MsgConfigureRttyMod::create(settings, false);
m_guiMessageQueue->push(msgToGUI);
}
}
void RttyMod::applySettings(const RttyModSettings& settings, bool force)
{
qDebug() << "RttyMod::applySettings:"
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_baud: " << settings.m_baud
<< " m_rfBandwidth: " << settings.m_rfBandwidth
<< " m_frequencyShift: " << settings.m_frequencyShift
<< " m_gain: " << settings.m_gain
<< " m_channelMute: " << settings.m_channelMute
<< " m_repeat: " << settings.m_repeat
<< " m_repeatCount: " << settings.m_repeatCount
<< " m_useReverseAPI: " << settings.m_useReverseAPI
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
<< " m_reverseAPIAddress: " << settings.m_reverseAPIPort
<< " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
<< " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
<< " force: " << force;
QList<QString> reverseAPIKeys;
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
reverseAPIKeys.append("inputFrequencyOffset");
}
if ((settings.m_baud != m_settings.m_baud) || force) {
reverseAPIKeys.append("baud");
}
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
reverseAPIKeys.append("rfBandwidth");
}
if ((settings.m_frequencyShift != m_settings.m_frequencyShift) || force) {
reverseAPIKeys.append("frequencyShift");
}
if ((settings.m_gain != m_settings.m_gain) || force) {
reverseAPIKeys.append("gain");
}
if ((settings.m_channelMute != m_settings.m_channelMute) || force) {
reverseAPIKeys.append("channelMute");
}
if ((settings.m_repeat != m_settings.m_repeat) || force) {
reverseAPIKeys.append("repeat");
}
if ((settings.m_repeatCount != m_settings.m_repeatCount) || force) {
reverseAPIKeys.append("repeatCount");
}
if ((settings.m_lpfTaps != m_settings.m_lpfTaps) || force) {
reverseAPIKeys.append("lpfTaps");
}
if ((settings.m_bbNoise != m_settings.m_bbNoise) || force) {
reverseAPIKeys.append("bbNoise");
}
if ((settings.m_rfNoise != m_settings.m_rfNoise) || force) {
reverseAPIKeys.append("rfNoise");
}
if ((settings.m_writeToFile != m_settings.m_writeToFile) || force) {
reverseAPIKeys.append("writeToFile");
}
if ((settings.m_data != m_settings.m_data) || force) {
reverseAPIKeys.append("data");
}
if ((settings.m_beta != m_settings.m_beta) || force) {
reverseAPIKeys.append("beta");
}
if ((settings.m_symbolSpan != m_settings.m_symbolSpan) || force) {
reverseAPIKeys.append("symbolSpan");
}
if ((settings.m_udpEnabled != m_settings.m_udpEnabled) || force) {
reverseAPIKeys.append("udpEnabled");
}
if ((settings.m_udpAddress != m_settings.m_udpAddress) || force) {
reverseAPIKeys.append("udpAddress");
}
if ((settings.m_udpPort != m_settings.m_udpPort) || force) {
reverseAPIKeys.append("udpPort");
}
if ( (settings.m_udpEnabled != m_settings.m_udpEnabled)
|| (settings.m_udpAddress != m_settings.m_udpAddress)
|| (settings.m_udpPort != m_settings.m_udpPort)
|| force)
{
if (settings.m_udpEnabled)
openUDP(settings);
else
closeUDP();
}
if (m_settings.m_streamIndex != settings.m_streamIndex)
{
if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
{
m_deviceAPI->removeChannelSourceAPI(this);
m_deviceAPI->removeChannelSource(this, m_settings.m_streamIndex);
m_deviceAPI->addChannelSource(this, settings.m_streamIndex);
m_deviceAPI->addChannelSourceAPI(this);
}
reverseAPIKeys.append("streamIndex");
}
RttyModBaseband::MsgConfigureRttyModBaseband *msg = RttyModBaseband::MsgConfigureRttyModBaseband::create(settings, force);
m_basebandSource->getInputMessageQueue()->push(msg);
if (settings.m_useReverseAPI)
{
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex) ||
(m_settings.m_reverseAPIChannelIndex != settings.m_reverseAPIChannelIndex);
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
}
QList<ObjectPipe*> pipes;
MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes);
if (pipes.size() > 0) {
sendChannelSettings(pipes, reverseAPIKeys, settings, force);
}
m_settings = settings;
}
QByteArray RttyMod::serialize() const
{
return m_settings.serialize();
}
bool RttyMod::deserialize(const QByteArray& data)
{
bool success = true;
if (!m_settings.deserialize(data))
{
m_settings.resetToDefaults();
success = false;
}
MsgConfigureRttyMod *msg = MsgConfigureRttyMod::create(m_settings, true);
m_inputMessageQueue.push(msg);
return success;
}
void RttyMod::sendSampleRateToDemodAnalyzer()
{
QList<ObjectPipe*> pipes;
MainCore::instance()->getMessagePipes().getMessagePipes(this, "reportdemod", pipes);
if (pipes.size() > 0)
{
for (const auto& pipe : pipes)
{
MessageQueue* messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
MainCore::MsgChannelDemodReport *msg = MainCore::MsgChannelDemodReport::create(
this,
getSourceChannelSampleRate()
);
messageQueue->push(msg);
}
}
}
int RttyMod::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
/*response.setRttyModSettings(new SWGSDRangel::SWGRttyModSettings());
response.getRttyModSettings()->init();
webapiFormatChannelSettings(response, m_settings);
*/
return 200;
}
int RttyMod::webapiWorkspaceGet(
SWGSDRangel::SWGWorkspaceInfo& response,
QString& errorMessage)
{
(void) errorMessage;
response.setIndex(m_settings.m_workspaceIndex);
return 200;
}
int RttyMod::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
RttyModSettings settings = m_settings;
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
MsgConfigureRttyMod *msg = MsgConfigureRttyMod::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureRttyMod *msgToGUI = MsgConfigureRttyMod::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatChannelSettings(response, settings);
return 200;
}
void RttyMod::webapiUpdateChannelSettings(
RttyModSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response)
{
/*if (channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = response.getRttyModSettings()->getInputFrequencyOffset();
}
if (channelSettingsKeys.contains("baud")) {
settings.m_baud = response.getRttyModSettings()->getBaud();
}
if (channelSettingsKeys.contains("rfBandwidth")) {
settings.m_rfBandwidth = response.getRttyModSettings()->getRfBandwidth();
}
if (channelSettingsKeys.contains("frequencyShift")) {
settings.m_frequencyShift = response.getRttyModSettings()->getFrequencyShift();
}
if (channelSettingsKeys.contains("gain")) {
settings.m_gain = response.getRttyModSettings()->getGain();
}
if (channelSettingsKeys.contains("channelMute")) {
settings.m_channelMute = response.getRttyModSettings()->getChannelMute() != 0;
}
if (channelSettingsKeys.contains("repeat")) {
settings.m_repeat = response.getRttyModSettings()->getRepeat() != 0;
}
if (channelSettingsKeys.contains("repeatDelay")) {
settings.m_repeatDelay = response.getRttyModSettings()->getRepeatDelay();
}
if (channelSettingsKeys.contains("repeatCount")) {
settings.m_repeatCount = response.getRttyModSettings()->getRepeatCount();
}
if (channelSettingsKeys.contains("lpfTaps")) {
settings.m_lpfTaps = response.getRttyModSettings()->getLpfTaps();
}
if (channelSettingsKeys.contains("bbNoise")) {
settings.m_bbNoise = response.getRttyModSettings()->getBbNoise() != 0;
}
if (channelSettingsKeys.contains("rfNoise")) {
settings.m_rfNoise = response.getRttyModSettings()->getRfNoise() != 0;
}
if (channelSettingsKeys.contains("writeToFile")) {
settings.m_writeToFile = response.getRttyModSettings()->getWriteToFile() != 0;
}
if (channelSettingsKeys.contains("data")) {
settings.m_data = *response.getRttyModSettings()->getData();
}
if (channelSettingsKeys.contains("beta")) {
settings.m_beta = response.getRttyModSettings()->getBeta();
}
if (channelSettingsKeys.contains("symbolSpan")) {
settings.m_symbolSpan = response.getRttyModSettings()->getSymbolSpan();
}
if (channelSettingsKeys.contains("rgbColor")) {
settings.m_rgbColor = response.getRttyModSettings()->getRgbColor();
}
if (channelSettingsKeys.contains("title")) {
settings.m_title = *response.getRttyModSettings()->getTitle();
}
if (channelSettingsKeys.contains("streamIndex")) {
settings.m_streamIndex = response.getRttyModSettings()->getStreamIndex();
}
if (channelSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = response.getRttyModSettings()->getUseReverseApi() != 0;
}
if (channelSettingsKeys.contains("reverseAPIAddress")) {
settings.m_reverseAPIAddress = *response.getRttyModSettings()->getReverseApiAddress();
}
if (channelSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getRttyModSettings()->getReverseApiPort();
}
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getRttyModSettings()->getReverseApiDeviceIndex();
}
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = response.getRttyModSettings()->getReverseApiChannelIndex();
}
if (channelSettingsKeys.contains("udpEnabled")) {
settings.m_udpEnabled = response.getRttyModSettings()->getUdpEnabled();
}
if (channelSettingsKeys.contains("udpAddress")) {
settings.m_udpAddress = *response.getRttyModSettings()->getUdpAddress();
}
if (channelSettingsKeys.contains("udpPort")) {
settings.m_udpPort = response.getRttyModSettings()->getUdpPort();
}
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) {
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getRttyModSettings()->getChannelMarker());
}
if (settings.m_rollupState && channelSettingsKeys.contains("rollupState")) {
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getRttyModSettings()->getRollupState());
}*/
}
int RttyMod::webapiReportGet(
SWGSDRangel::SWGChannelReport& response,
QString& errorMessage)
{
(void) errorMessage;
/*response.setRttyModReport(new SWGSDRangel::SWGRttyModReport());
response.getRttyModReport()->init();
webapiFormatChannelReport(response);*/
return 200;
}
int RttyMod::webapiActionsPost(
const QStringList& channelActionsKeys,
SWGSDRangel::SWGChannelActions& query,
QString& errorMessage)
{
/*SWGSDRangel::SWGRttyModActions *swgRttyModActions = query.getRttyModActions();
if (swgRttyModActions)
{
if (channelActionsKeys.contains("tx"))
{
if (swgRttyModActions->getTx() != 0)
{
if (channelActionsKeys.contains("payload")
&& (swgRttyModActions->getPayload()->getData()))
{
MsgTXPacketData *msg = MsgTXPacketData::create(
*swgRttyModActions->getPayload()->getData(
);
m_basebandSource->getInputMessageQueue()->push(msg);
}
else
{
MsgTx *msg = MsgTx::create();
m_basebandSource->getInputMessageQueue()->push(msg);
}
return 202;
}
else
{
errorMessage = "Packet must contain tx action";
return 400;
}
}
else
{
errorMessage = "Unknown action";
return 400;
}
}
else
{
errorMessage = "Missing RttyModActions in query";
return 400;
}*/
return 0;
}
void RttyMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const RttyModSettings& settings)
{
/*response.getRttyModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getRttyModSettings()->setBaud(settings.m_baud);
response.getRttyModSettings()->setRfBandwidth(settings.m_rfBandwidth);
response.getRttyModSettings()->setFrequencyShift(settings.m_frequencyShift);
response.getRttyModSettings()->setGain(settings.m_gain);
response.getRttyModSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
response.getRttyModSettings()->setRepeat(settings.m_repeat ? 1 : 0);
response.getRttyModSettings()->setRepeatDelay(settings.m_repeatDelay);
response.getRttyModSettings()->setRepeatCount(settings.m_repeatCount);
response.getRttyModSettings()->setLpfTaps(settings.m_lpfTaps);
response.getRttyModSettings()->setBbNoise(settings.m_bbNoise ? 1 : 0);
response.getRttyModSettings()->setRfNoise(settings.m_rfNoise ? 1 : 0);
response.getRttyModSettings()->setWriteToFile(settings.m_writeToFile ? 1 : 0);
if (response.getRttyModSettings()->getData()) {
*response.getRttyModSettings()->getData() = settings.m_data;
} else {
response.getRttyModSettings()->setData(new QString(settings.m_data));
}
response.getRttyModSettings()->setPulseShaping(settings.m_pulseShaping ? 1 : 0);
response.getRttyModSettings()->setBeta(settings.m_beta);
response.getRttyModSettings()->setSymbolSpan(settings.m_symbolSpan);
response.getRttyModSettings()->setUdpEnabled(settings.m_udpEnabled);
response.getRttyModSettings()->setUdpAddress(new QString(settings.m_udpAddress));
response.getRttyModSettings()->setUdpPort(settings.m_udpPort);
response.getRttyModSettings()->setRgbColor(settings.m_rgbColor);
if (response.getRttyModSettings()->getTitle()) {
*response.getRttyModSettings()->getTitle() = settings.m_title;
} else {
response.getRttyModSettings()->setTitle(new QString(settings.m_title));
}
response.getRttyModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
if (response.getRttyModSettings()->getReverseApiAddress()) {
*response.getRttyModSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
} else {
response.getRttyModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
}
response.getRttyModSettings()->setReverseApiPort(settings.m_reverseAPIPort);
response.getRttyModSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
response.getRttyModSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
if (settings.m_channelMarker)
{
if (response.getRttyModSettings()->getChannelMarker())
{
settings.m_channelMarker->formatTo(response.getRttyModSettings()->getChannelMarker());
}
else
{
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(swgChannelMarker);
response.getRttyModSettings()->setChannelMarker(swgChannelMarker);
}
}
if (settings.m_rollupState)
{
if (response.getRttyModSettings()->getRollupState())
{
settings.m_rollupState->formatTo(response.getRttyModSettings()->getRollupState());
}
else
{
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(swgRollupState);
response.getRttyModSettings()->setRollupState(swgRollupState);
}
}*/
}
void RttyMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{
/*response.getRttyModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));
response.getRttyModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate());*/
}
void RttyMod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RttyModSettings& settings, bool force)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
.arg(settings.m_reverseAPIAddress)
.arg(settings.m_reverseAPIPort)
.arg(settings.m_reverseAPIDeviceIndex)
.arg(settings.m_reverseAPIChannelIndex);
m_networkRequest.setUrl(QUrl(channelSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer = new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgChannelSettings->asJson().toUtf8());
buffer->seek(0);
// Always use PATCH to avoid passing reverse API settings
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
buffer->setParent(reply);
delete swgChannelSettings;
}
void RttyMod::sendChannelSettings(
const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys,
const RttyModSettings& settings,
bool force)
{
for (const auto& pipe : pipes)
{
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
if (messageQueue)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
this,
channelSettingsKeys,
swgChannelSettings,
force
);
messageQueue->push(msg);
}
}
}
void RttyMod::webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const RttyModSettings& settings,
bool force
)
{
/*swgChannelSettings->setDirection(1); // single source (Tx)
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
swgChannelSettings->setChannelType(new QString(m_channelId));
swgChannelSettings->setRttyModSettings(new SWGSDRangel::SWGRttyModSettings());
SWGSDRangel::SWGRttyModSettings *swgRttyModSettings = swgChannelSettings->getRttyModSettings();
// transfer data that has been modified. When force is on transfer all data except reverse API data
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
swgRttyModSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
}
if (channelSettingsKeys.contains("baud") || force) {
swgRttyModSettings->setBaud((int) settings.m_baud);
}
if (channelSettingsKeys.contains("rfBandwidth") || force) {
swgRttyModSettings->setRfBandwidth(settings.m_rfBandwidth);
}
if (channelSettingsKeys.contains("frequencyShift") || force) {
swgRttyModSettings->setFrequencyShift(settings.m_frequencyShift);
}
if (channelSettingsKeys.contains("gain") || force) {
swgRttyModSettings->setGain(settings.m_gain);
}
if (channelSettingsKeys.contains("channelMute") || force) {
swgRttyModSettings->setChannelMute(settings.m_channelMute ? 1 : 0);
}
if (channelSettingsKeys.contains("repeat") || force) {
swgRttyModSettings->setRepeat(settings.m_repeat ? 1 : 0);
}
if (channelSettingsKeys.contains("repeatDelay") || force) {
swgRttyModSettings->setRepeatDelay(settings.m_repeatDelay);
}
if (channelSettingsKeys.contains("repeatCount") || force) {
swgRttyModSettings->setRepeatCount(settings.m_repeatCount);
}
if (channelSettingsKeys.contains("lpfTaps")) {
swgRttyModSettings->setLpfTaps(settings.m_lpfTaps);
}
if (channelSettingsKeys.contains("bbNoise")) {
swgRttyModSettings->setBbNoise(settings.m_bbNoise ? 1 : 0);
}
if (channelSettingsKeys.contains("rfNoise")) {
swgRttyModSettings->setRfNoise(settings.m_rfNoise ? 1 : 0);
}
if (channelSettingsKeys.contains("writeToFile")) {
swgRttyModSettings->setWriteToFile(settings.m_writeToFile ? 1 : 0);
}
if (channelSettingsKeys.contains("data")) {
swgRttyModSettings->setData(new QString(settings.m_data));
}
if (channelSettingsKeys.contains("beta")) {
swgRttyModSettings->setBeta(settings.m_beta);
}
if (channelSettingsKeys.contains("symbolSpan")) {
swgRttyModSettings->setSymbolSpan(settings.m_symbolSpan);
}
if (channelSettingsKeys.contains("rgbColor") || force) {
swgRttyModSettings->setRgbColor(settings.m_rgbColor);
}
if (channelSettingsKeys.contains("title") || force) {
swgRttyModSettings->setTitle(new QString(settings.m_title));
}
if (channelSettingsKeys.contains("streamIndex") || force) {
swgRttyModSettings->setStreamIndex(settings.m_streamIndex);
}
if (channelSettingsKeys.contains("udpEnabled") || force) {
swgRttyModSettings->setUdpEnabled(settings.m_udpEnabled);
}
if (channelSettingsKeys.contains("udpAddress") || force) {
swgRttyModSettings->setUdpAddress(new QString(settings.m_udpAddress));
}
if (channelSettingsKeys.contains("udpPort") || force) {
swgRttyModSettings->setUdpPort(settings.m_udpPort);
}
if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force))
{
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(swgChannelMarker);
swgRttyModSettings->setChannelMarker(swgChannelMarker);
}
if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force))
{
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(swgRollupState);
swgRttyModSettings->setRollupState(swgRollupState);
}*/
}
void RttyMod::networkManagerFinished(QNetworkReply *reply)
{
QNetworkReply::NetworkError replyError = reply->error();
if (replyError)
{
qWarning() << "RttyMod::networkManagerFinished:"
<< " error(" << (int) replyError
<< "): " << replyError
<< ": " << reply->errorString();
}
else
{
QString answer = reply->readAll();
answer.chop(1); // remove last \n
qDebug("RttyMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
}
reply->deleteLater();
}
double RttyMod::getMagSq() const
{
return m_basebandSource->getMagSq();
}
void RttyMod::setLevelMeter(QObject *levelMeter)
{
connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), levelMeter, SLOT(levelChanged(qreal, qreal, int)));
}
uint32_t RttyMod::getNumberOfDeviceStreams() const
{
return m_deviceAPI->getNbSinkStreams();
}
int RttyMod::getSourceChannelSampleRate() const
{
return m_basebandSource->getSourceChannelSampleRate();
}
void RttyMod::openUDP(const RttyModSettings& settings)
{
closeUDP();
m_udpSocket = new QUdpSocket();
if (!m_udpSocket->bind(QHostAddress(settings.m_udpAddress), settings.m_udpPort))
qCritical() << "RttyMod::openUDP: Failed to bind to port " << settings.m_udpAddress << ":" << settings.m_udpPort << ". Error: " << m_udpSocket->error();
else
qDebug() << "RttyMod::openUDP: Listening for packets on " << settings.m_udpAddress << ":" << settings.m_udpPort;
connect(m_udpSocket, &QUdpSocket::readyRead, this, &RttyMod::udpRx);
}
void RttyMod::closeUDP()
{
if (m_udpSocket != nullptr)
{
disconnect(m_udpSocket, &QUdpSocket::readyRead, this, &RttyMod::udpRx);
delete m_udpSocket;
m_udpSocket = nullptr;
}
}
void RttyMod::udpRx()
{
while (m_udpSocket->hasPendingDatagrams())
{
QNetworkDatagram datagram = m_udpSocket->receiveDatagram();
MsgTXPacketBytes *msg = MsgTXPacketBytes::create(datagram.data());
m_basebandSource->getInputMessageQueue()->push(msg);
}
}
void RttyMod::setMessageQueueToGUI(MessageQueue* queue) {
ChannelAPI::setMessageQueueToGUI(queue);
m_basebandSource->setMessageQueueToGUI(queue);
}

View File

@ -0,0 +1,264 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016-2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_MODRTTY_RTTYMOD_H_
#define PLUGINS_CHANNELTX_MODRTTY_RTTYMOD_H_
#include <vector>
#include <iostream>
#include <fstream>
#include <QRecursiveMutex>
#include <QNetworkRequest>
#include "dsp/basebandsamplesource.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "util/message.h"
#include "rttymodsettings.h"
class QNetworkAccessManager;
class QNetworkReply;
class QThread;
class QUdpSocket;
class DeviceAPI;
class RttyModBaseband;
class ObjectPipe;
class RttyMod : public BasebandSampleSource, public ChannelAPI {
public:
class MsgConfigureRttyMod : public Message {
MESSAGE_CLASS_DECLARATION
public:
const RttyModSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureRttyMod* create(const RttyModSettings& settings, bool force)
{
return new MsgConfigureRttyMod(settings, force);
}
private:
RttyModSettings m_settings;
bool m_force;
MsgConfigureRttyMod(const RttyModSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
};
class MsgTx : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgTx* create() {
return new MsgTx();
}
private:
MsgTx() :
Message()
{ }
};
class MsgReportTx : public Message {
MESSAGE_CLASS_DECLARATION
public:
const QString& getText() const { return m_text; }
int getBufferedCharacters() const { return m_bufferedCharacters; }
static MsgReportTx* create(const QString& text, int bufferedCharacters) {
return new MsgReportTx(text, bufferedCharacters);
}
private:
QString m_text;
int m_bufferedCharacters;
MsgReportTx(const QString& text, int bufferedCharacters) :
Message(),
m_text(text),
m_bufferedCharacters(bufferedCharacters)
{ }
};
class MsgTXPacketBytes : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgTXPacketBytes* create(QByteArray data) {
return new MsgTXPacketBytes(data);
}
QByteArray m_data;
private:
MsgTXPacketBytes(QByteArray data) :
Message(),
m_data(data)
{ }
};
class MsgTXPacketData : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgTXPacketData* create(QString data)
{
return new MsgTXPacketData(data);
}
QString m_data;
private:
MsgTXPacketData(QString data) :
Message(),
m_data(data)
{ }
};
//=================================================================
RttyMod(DeviceAPI *deviceAPI);
virtual ~RttyMod();
virtual void destroy() { delete this; }
virtual void setDeviceAPI(DeviceAPI *deviceAPI);
virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; }
virtual void start();
virtual void stop();
virtual void pull(SampleVector::iterator& begin, unsigned int nbSamples);
virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); }
virtual QString getSourceName() { return objectName(); }
virtual void getIdentifier(QString& id) { id = objectName(); }
virtual QString getIdentifier() const { return objectName(); }
virtual void getTitle(QString& title) { title = m_settings.m_title; }
virtual qint64 getCenterFrequency() const { return m_settings.m_inputFrequencyOffset; }
virtual void setCenterFrequency(qint64 frequency);
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return m_settings.m_inputFrequencyOffset;
}
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiWorkspaceGet(
SWGSDRangel::SWGWorkspaceInfo& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiReportGet(
SWGSDRangel::SWGChannelReport& response,
QString& errorMessage);
virtual int webapiActionsPost(
const QStringList& channelActionsKeys,
SWGSDRangel::SWGChannelActions& query,
QString& errorMessage);
static void webapiFormatChannelSettings(
SWGSDRangel::SWGChannelSettings& response,
const RttyModSettings& settings);
static void webapiUpdateChannelSettings(
RttyModSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
double getMagSq() const;
void setLevelMeter(QObject *levelMeter);
uint32_t getNumberOfDeviceStreams() const;
int getSourceChannelSampleRate() const;
void setMessageQueueToGUI(MessageQueue* queue) override;
static const char* const m_channelIdURI;
static const char* const m_channelId;
private:
enum RateState {
RSInitialFill,
RSRunning
};
DeviceAPI* m_deviceAPI;
QThread *m_thread;
RttyModBaseband* m_basebandSource;
RttyModSettings m_settings;
SpectrumVis m_spectrumVis;
SampleVector m_sampleBuffer;
QRecursiveMutex m_settingsMutex;
int m_sampleRate;
QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest;
QUdpSocket *m_udpSocket;
virtual bool handleMessage(const Message& cmd);
void applySettings(const RttyModSettings& settings, bool force = false);
void sendSampleRateToDemodAnalyzer();
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RttyModSettings& settings, bool force);
void sendChannelSettings(
const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys,
const RttyModSettings& settings,
bool force
);
void webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const RttyModSettings& settings,
bool force
);
void openUDP(const RttyModSettings& settings);
void closeUDP();
private slots:
void networkManagerFinished(QNetworkReply *reply);
void udpRx();
};
#endif /* PLUGINS_CHANNELTX_MODRTTY_RTTYMOD_H_ */

View File

@ -0,0 +1,207 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include "dsp/upchannelizer.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "rttymodbaseband.h"
#include "rttymod.h"
MESSAGE_CLASS_DEFINITION(RttyModBaseband::MsgConfigureRttyModBaseband, Message)
RttyModBaseband::RttyModBaseband()
{
m_sampleFifo.resize(SampleSourceFifo::getSizePolicy(48000));
m_channelizer = new UpChannelizer(&m_source);
qDebug("RttyModBaseband::RttyModBaseband");
QObject::connect(
&m_sampleFifo,
&SampleSourceFifo::dataRead,
this,
&RttyModBaseband::handleData,
Qt::QueuedConnection
);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
RttyModBaseband::~RttyModBaseband()
{
delete m_channelizer;
}
void RttyModBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_sampleFifo.reset();
}
void RttyModBaseband::setChannel(ChannelAPI *channel)
{
m_source.setChannel(channel);
}
void RttyModBaseband::pull(const SampleVector::iterator& begin, unsigned int nbSamples)
{
unsigned int part1Begin, part1End, part2Begin, part2End;
m_sampleFifo.read(nbSamples, part1Begin, part1End, part2Begin, part2End);
SampleVector& data = m_sampleFifo.getData();
if (part1Begin != part1End)
{
std::copy(
data.begin() + part1Begin,
data.begin() + part1End,
begin
);
}
unsigned int shift = part1End - part1Begin;
if (part2Begin != part2End)
{
std::copy(
data.begin() + part2Begin,
data.begin() + part2End,
begin + shift
);
}
}
void RttyModBaseband::handleData()
{
QMutexLocker mutexLocker(&m_mutex);
SampleVector& data = m_sampleFifo.getData();
unsigned int ipart1begin;
unsigned int ipart1end;
unsigned int ipart2begin;
unsigned int ipart2end;
qreal rmsLevel, peakLevel;
int numSamples;
unsigned int remainder = m_sampleFifo.remainder();
while ((remainder > 0) && (m_inputMessageQueue.size() == 0))
{
m_sampleFifo.write(remainder, ipart1begin, ipart1end, ipart2begin, ipart2end);
if (ipart1begin != ipart1end) { // first part of FIFO data
processFifo(data, ipart1begin, ipart1end);
}
if (ipart2begin != ipart2end) { // second part of FIFO data (used when block wraps around)
processFifo(data, ipart2begin, ipart2end);
}
remainder = m_sampleFifo.remainder();
}
m_source.getLevels(rmsLevel, peakLevel, numSamples);
emit levelChanged(rmsLevel, peakLevel, numSamples);
}
void RttyModBaseband::processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd)
{
m_channelizer->prefetch(iEnd - iBegin);
m_channelizer->pull(data.begin() + iBegin, iEnd - iBegin);
}
void RttyModBaseband::handleInputMessages()
{
Message* message;
while ((message = m_inputMessageQueue.pop()) != nullptr)
{
if (handleMessage(*message)) {
delete message;
}
}
}
bool RttyModBaseband::handleMessage(const Message& cmd)
{
if (MsgConfigureRttyModBaseband::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
MsgConfigureRttyModBaseband& cfg = (MsgConfigureRttyModBaseband&) cmd;
qDebug() << "RttyModBaseband::handleMessage: MsgConfigureRttyModBaseband";
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (RttyMod::MsgTx::match(cmd))
{
qDebug() << "RttyModBaseband::handleMessage: MsgTx";
m_source.addTXPacket(m_settings.m_data);
return true;
}
else if (RttyMod::MsgTXPacketBytes::match(cmd))
{
RttyMod::MsgTXPacketBytes& tx = (RttyMod::MsgTXPacketBytes&) cmd;
m_source.addTXPacket(tx.m_data);
return true;
}
else if (RttyMod::MsgTXPacketData::match(cmd))
{
RttyMod::MsgTXPacketData& tx = (RttyMod::MsgTXPacketData&) cmd;
m_source.addTXPacket(tx.m_data);
return true;
}
else if (DSPSignalNotification::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
qDebug() << "RttyModBaseband::handleMessage: DSPSignalNotification: basebandSampleRate: " << notif.getSampleRate();
m_sampleFifo.resize(SampleSourceFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_source.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
return true;
}
else
{
qDebug() << "RttyModBaseband - Baseband got unknown message";
return false;
}
}
void RttyModBaseband::applySettings(const RttyModSettings& settings, bool force)
{
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force)
{
m_channelizer->setChannelization(m_channelizer->getChannelSampleRate(), settings.m_inputFrequencyOffset);
m_source.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
}
m_source.applySettings(settings, force);
m_settings = settings;
}
int RttyModBaseband::getChannelSampleRate() const
{
return m_channelizer->getChannelSampleRate();
}

View File

@ -0,0 +1,100 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_RTTYMODBASEBAND_H
#define INCLUDE_RTTYMODBASEBAND_H
#include <QObject>
#include <QRecursiveMutex>
#include "dsp/samplesourcefifo.h"
#include "util/message.h"
#include "util/messagequeue.h"
#include "rttymodsource.h"
class UpChannelizer;
class ChannelAPI;
class RttyModBaseband : public QObject
{
Q_OBJECT
public:
class MsgConfigureRttyModBaseband : public Message {
MESSAGE_CLASS_DECLARATION
public:
const RttyModSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureRttyModBaseband* create(const RttyModSettings& settings, bool force)
{
return new MsgConfigureRttyModBaseband(settings, force);
}
private:
RttyModSettings m_settings;
bool m_force;
MsgConfigureRttyModBaseband(const RttyModSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
};
RttyModBaseband();
~RttyModBaseband();
void reset();
void pull(const SampleVector::iterator& begin, unsigned int nbSamples);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
void setMessageQueueToGUI(MessageQueue* messageQueue) { m_source.setMessageQueueToGUI(messageQueue); }
double getMagSq() const { return m_source.getMagSq(); }
int getChannelSampleRate() const;
void setSpectrumSampleSink(BasebandSampleSink* sampleSink) { m_source.setSpectrumSink(sampleSink); }
void setChannel(ChannelAPI *channel);
int getSourceChannelSampleRate() const { return m_source.getChannelSampleRate(); }
signals:
/**
* Level changed
* \param rmsLevel RMS level in range 0.0 - 1.0
* \param peakLevel Peak level in range 0.0 - 1.0
* \param numSamples Number of audio samples analyzed
*/
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
private:
SampleSourceFifo m_sampleFifo;
UpChannelizer *m_channelizer;
RttyModSource m_source;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
RttyModSettings m_settings;
QRecursiveMutex m_mutex;
void processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd);
bool handleMessage(const Message& cmd);
void applySettings(const RttyModSettings& settings, bool force = false);
private slots:
void handleInputMessages();
void handleData(); //!< Handle data when samples have to be processed
};
#endif // INCLUDE_RTTYMODBASEBAND_H

View File

@ -0,0 +1,663 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDockWidget>
#include <QMainWindow>
#include <QFileDialog>
#include <QTime>
#include <QScrollBar>
#include <QDebug>
#include "dsp/spectrumvis.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "device/deviceuiset.h"
#include "plugin/pluginapi.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "util/maidenhead.h"
#include "gui/glspectrum.h"
#include "gui/crightclickenabler.h"
#include "gui/basicchannelsettingsdialog.h"
#include "gui/devicestreamselectiondialog.h"
#include "gui/fmpreemphasisdialog.h"
#include "gui/dialpopup.h"
#include "gui/dialogpositioner.h"
#include "maincore.h"
#include "ui_rttymodgui.h"
#include "rttymodgui.h"
#include "rttymodrepeatdialog.h"
#include "rttymodtxsettingsdialog.h"
RttyModGUI* RttyModGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx)
{
RttyModGUI* gui = new RttyModGUI(pluginAPI, deviceUISet, channelTx);
return gui;
}
void RttyModGUI::destroy()
{
delete this;
}
void RttyModGUI::resetToDefaults()
{
m_settings.resetToDefaults();
displaySettings();
applySettings(true);
}
QByteArray RttyModGUI::serialize() const
{
return m_settings.serialize();
}
bool RttyModGUI::deserialize(const QByteArray& data)
{
if(m_settings.deserialize(data)) {
displaySettings();
applySettings(true);
return true;
} else {
resetToDefaults();
return false;
}
}
bool RttyModGUI::handleMessage(const Message& message)
{
if (RttyMod::MsgConfigureRttyMod::match(message))
{
const RttyMod::MsgConfigureRttyMod& cfg = (RttyMod::MsgConfigureRttyMod&) message;
m_settings = cfg.getSettings();
blockApplySettings(true);
m_channelMarker.updateSettings(static_cast<const ChannelMarker*>(m_settings.m_channelMarker));
displaySettings();
blockApplySettings(false);
return true;
}
else if (RttyMod::MsgReportTx::match(message))
{
const RttyMod::MsgReportTx& report = (RttyMod::MsgReportTx&)message;
QString s = report.getText();
int bufferedCharacters = report.getBufferedCharacters();
// Turn TX button green when transmitting
QString tooltip = m_initialToolTip;
if (bufferedCharacters == 0)
{
ui->txButton->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
else
{
ui->txButton->setStyleSheet("QToolButton { background-color : green; }");
tooltip.append(QString("\n\n%1 characters in buffer").arg(bufferedCharacters));
}
ui->txButton->setToolTip(tooltip);
s = s.replace(">", ""); // Don't display LTRS
s = s.replace("\r", ""); // Don't display carriage returns
if (!s.isEmpty())
{
// Is the scroll bar at the bottom?
int scrollPos = ui->transmittedText->verticalScrollBar()->value();
bool atBottom = scrollPos >= ui->transmittedText->verticalScrollBar()->maximum();
// Move cursor to end where we want to append new text
// (user may have moved it by clicking / highlighting text)
ui->transmittedText->moveCursor(QTextCursor::End);
// Restore scroll position
ui->transmittedText->verticalScrollBar()->setValue(scrollPos);
// Insert text
ui->transmittedText->insertPlainText(s);
// Scroll to bottom, if we we're previously at the bottom
if (atBottom) {
ui->transmittedText->verticalScrollBar()->setValue(ui->transmittedText->verticalScrollBar()->maximum());
}
}
return true;
}
else if (DSPSignalNotification::match(message))
{
const DSPSignalNotification& notif = (const DSPSignalNotification&) message;
m_deviceCenterFrequency = notif.getCenterFrequency();
m_basebandSampleRate = notif.getSampleRate();
ui->deltaFrequency->setValueRange(false, 7, -m_basebandSampleRate/2, m_basebandSampleRate/2);
ui->deltaFrequencyLabel->setToolTip(tr("Range %1 %L2 Hz").arg(QChar(0xB1)).arg(m_basebandSampleRate/2));
updateAbsoluteCenterFrequency();
return true;
}
else
{
return false;
}
}
void RttyModGUI::channelMarkerChangedByCursor()
{
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
applySettings();
}
void RttyModGUI::handleSourceMessages()
{
Message* message;
while ((message = getInputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
delete message;
}
}
}
void RttyModGUI::on_deltaFrequency_changed(qint64 value)
{
m_channelMarker.setCenterFrequency(value);
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
updateAbsoluteCenterFrequency();
applySettings();
}
void RttyModGUI::on_mode_currentIndexChanged(int index)
{
(void)index;
QString mode = ui->mode->currentText();
bool custom = mode == "Custom";
if (!custom)
{
QStringList settings = mode.split("/");
int baudRate = settings[0].toInt();
int frequencyShift = settings[1].toInt();
int bandwidth = frequencyShift * 2 + baudRate;
ui->baudRate->setCurrentText(settings[0]);
ui->frequencyShift->setValue(frequencyShift);
ui->rfBW->setValue(bandwidth);
}
ui->baudRateLabel->setEnabled(custom);
ui->baudRate->setEnabled(custom);
ui->frequencyShiftLabel->setEnabled(custom);
ui->frequencyShift->setEnabled(custom);
ui->frequencyShiftText->setEnabled(custom);
ui->rfBWLabel->setEnabled(custom);
ui->rfBW->setEnabled(custom);
ui->rfBWText->setEnabled(custom);
applySettings();
}
void RttyModGUI::on_rfBW_valueChanged(int value)
{
int bw = value;
ui->rfBWText->setText(formatFrequency(bw));
m_channelMarker.setBandwidth(bw);
m_settings.m_rfBandwidth = bw;
applySettings();
}
void RttyModGUI::on_baudRate_currentIndexChanged(int index)
{
(void)index;
m_settings.m_baud = ui->baudRate->currentText().toFloat();
applySettings();
}
void RttyModGUI::on_frequencyShift_valueChanged(int value)
{
m_settings.m_frequencyShift = value;
ui->frequencyShiftText->setText(formatFrequency(m_settings.m_frequencyShift));
applySettings();
}
void RttyModGUI::on_characterSet_currentIndexChanged(int index)
{
m_settings.m_characterSet = (Baudot::CharacterSet)index;
applySettings();
}
void RttyModGUI::on_endian_clicked(bool checked)
{
m_settings.m_msbFirst = checked;
if (checked) {
ui->endian->setText("MSB");
}
else {
ui->endian->setText("LSB");
}
applySettings();
}
void RttyModGUI::on_spaceHigh_clicked(bool checked)
{
m_settings.m_spaceHigh = checked;
if (checked) {
ui->spaceHigh->setText("M-S");
}
else {
ui->spaceHigh->setText("S-M");
}
applySettings();
}
void RttyModGUI::on_clearTransmittedText_clicked()
{
ui->transmittedText->clear();
}
void RttyModGUI::on_gain_valueChanged(int value)
{
ui->gainText->setText(QString("%1dB").arg(value));
m_settings.m_gain = value;
applySettings();
}
void RttyModGUI::on_channelMute_toggled(bool checked)
{
m_settings.m_channelMute = checked;
applySettings();
}
void RttyModGUI::on_txButton_clicked()
{
transmit(ui->text->currentText());
}
void RttyModGUI::on_text_returnPressed()
{
transmit(ui->text->currentText());
ui->text->setCurrentText("");
}
void RttyModGUI::on_text_editingFinished()
{
m_settings.m_data = ui->text->currentText();
applySettings();
}
void RttyModGUI::on_repeat_toggled(bool checked)
{
m_settings.m_repeat = checked;
applySettings();
}
void RttyModGUI::repeatSelect(const QPoint& p)
{
RttyModRepeatDialog dialog(m_settings.m_repeatCount);
dialog.move(p);
new DialogPositioner(&dialog, false);
if (dialog.exec() == QDialog::Accepted)
{
m_settings.m_repeatCount = dialog.m_repeatCount;
applySettings();
}
}
void RttyModGUI::txSettingsSelect(const QPoint& p)
{
RttyModTXSettingsDialog dialog(&m_settings);
dialog.move(p);
new DialogPositioner(&dialog, false);
if (dialog.exec() == QDialog::Accepted)
{
displaySettings();
applySettings();
}
}
void RttyModGUI::on_udpEnabled_clicked(bool checked)
{
m_settings.m_udpEnabled = checked;
applySettings();
}
void RttyModGUI::on_udpAddress_editingFinished()
{
m_settings.m_udpAddress = ui->udpAddress->text();
applySettings();
}
void RttyModGUI::on_udpPort_editingFinished()
{
m_settings.m_udpPort = ui->udpPort->text().toInt();
applySettings();
}
void RttyModGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
(void) widget;
(void) rollDown;
getRollupContents()->saveState(m_rollupState);
applySettings();
}
void RttyModGUI::onMenuDialogCalled(const QPoint &p)
{
if (m_contextMenuType == ContextMenuChannelSettings)
{
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex);
dialog.setDefaultTitle(m_displayedName);
if (m_deviceUISet->m_deviceMIMOEngine)
{
dialog.setNumberOfStreams(m_rttyMod->getNumberOfDeviceStreams());
dialog.setStreamIndex(m_settings.m_streamIndex);
}
dialog.move(p);
new DialogPositioner(&dialog, false);
dialog.exec();
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
m_settings.m_title = m_channelMarker.getTitle();
m_settings.m_useReverseAPI = dialog.useReverseAPI();
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex();
setWindowTitle(m_settings.m_title);
setTitle(m_channelMarker.getTitle());
setTitleColor(m_settings.m_rgbColor);
if (m_deviceUISet->m_deviceMIMOEngine)
{
m_settings.m_streamIndex = dialog.getSelectedStreamIndex();
m_channelMarker.clearStreamIndexes();
m_channelMarker.addStreamIndex(m_settings.m_streamIndex);
updateIndexLabel();
}
applySettings();
}
resetContextMenuType();
}
RttyModGUI::RttyModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent) :
ChannelGUI(parent),
ui(new Ui::RttyModGUI),
m_pluginAPI(pluginAPI),
m_deviceUISet(deviceUISet),
m_channelMarker(this),
m_deviceCenterFrequency(0),
m_basebandSampleRate(1),
m_doApplySettings(true)
{
setAttribute(Qt::WA_DeleteOnClose, true);
m_helpURL = "plugins/channeltx/modrtty/readme.md";
RollupContents *rollupContents = getRollupContents();
ui->setupUi(rollupContents);
setSizePolicy(rollupContents->sizePolicy());
rollupContents->arrangeRollups();
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_rttyMod = (RttyMod*) channelTx;
m_rttyMod->setMessageQueueToGUI(getInputMessageQueue());
connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
m_spectrumVis = m_rttyMod->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
// Extra /2 here because SSB?
ui->glSpectrum->setCenterFrequency(8000/4);
ui->glSpectrum->setSampleRate(8000/2);
ui->glSpectrum->setLsbDisplay(true);
SpectrumSettings spectrumSettings = m_spectrumVis->getSettings();
spectrumSettings.m_ssb = false;
spectrumSettings.m_displayCurrent = true;
spectrumSettings.m_displayWaterfall = false;
spectrumSettings.m_displayMaxHold = false;
spectrumSettings.m_displayHistogram = false;
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
m_spectrumVis->getInputMessageQueue()->push(msg);
CRightClickEnabler *repeatRightClickEnabler = new CRightClickEnabler(ui->repeat);
connect(repeatRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(repeatSelect(const QPoint &)));
CRightClickEnabler *txRightClickEnabler = new CRightClickEnabler(ui->txButton);
connect(txRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(txSettingsSelect(const QPoint &)));
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
m_channelMarker.blockSignals(true);
m_channelMarker.setColor(Qt::red);
m_channelMarker.setBandwidth(12500);
m_channelMarker.setCenterFrequency(0);
m_channelMarker.setTitle("Packet Modulator");
m_channelMarker.setSourceOrSinkStream(false);
m_channelMarker.blockSignals(false);
m_channelMarker.setVisible(true); // activate signal on the last setting only
m_deviceUISet->addChannelMarker(&m_channelMarker);
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
m_rttyMod->setLevelMeter(ui->volumeMeter);
m_settings.setChannelMarker(&m_channelMarker);
m_settings.setRollupState(&m_rollupState);
ui->spectrumContainer->setVisible(false);
displaySettings();
makeUIConnections();
applySettings();
DialPopup::addPopupsToChildDials(this);
m_initialToolTip = ui->txButton->toolTip();
}
RttyModGUI::~RttyModGUI()
{
// If we don't disconnect, we can get this signal after this has been deleted!
QObject::disconnect(ui->text->lineEdit(), &QLineEdit::editingFinished, this, &RttyModGUI::on_text_editingFinished);
delete ui;
}
void RttyModGUI::transmit(const QString& str)
{
QString s = str;
if (m_settings.m_prefixCRLF) {
s.prepend("\r\r\n>"); // '>' switches to letters
}
if (m_settings.m_postfixCRLF) {
s.append("\r\r\n");
}
RttyMod::MsgTXPacketData *msg = RttyMod::MsgTXPacketData::create(s);
m_rttyMod->getInputMessageQueue()->push(msg);
}
void RttyModGUI::blockApplySettings(bool block)
{
m_doApplySettings = !block;
}
void RttyModGUI::applySettings(bool force)
{
if (m_doApplySettings)
{
RttyMod::MsgConfigureRttyMod *msg = RttyMod::MsgConfigureRttyMod::create(m_settings, force);
m_rttyMod->getInputMessageQueue()->push(msg);
}
}
QString RttyModGUI::formatFrequency(int frequency) const
{
QString suffix = "";
if (width() > 450) {
suffix = " Hz";
}
return QString("%1%2").arg(frequency).arg(suffix);
}
QString RttyModGUI::substitute(const QString& text)
{
const MainSettings& mainSettings = MainCore::instance()->getSettings();
QString location = Maidenhead::toMaidenhead(mainSettings.getLatitude(), mainSettings.getLongitude());
QString s = text;
s = s.replace("${callsign}", mainSettings.getStationName().toUpper());
s = s.replace("${location}", location);
return s;
}
void RttyModGUI::displaySettings()
{
m_channelMarker.blockSignals(true);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
m_channelMarker.setTitle(m_settings.m_title);
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
m_channelMarker.blockSignals(false);
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
setTitleColor(m_settings.m_rgbColor);
setWindowTitle(m_channelMarker.getTitle());
setTitle(m_channelMarker.getTitle());
updateIndexLabel();
blockApplySettings(true);
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
ui->mode->setCurrentText("Custom");
ui->rfBWText->setText(formatFrequency(m_settings.m_rfBandwidth));
ui->rfBW->setValue(m_settings.m_rfBandwidth / 100.0);
QString baudRate;
if (m_settings.m_baud < 46.0f && m_settings.m_baud > 45.0f) {
baudRate = "45.45";
}
else {
baudRate = QString("%1").arg(m_settings.m_baud);
}
ui->baudRate->setCurrentIndex(ui->baudRate->findText(baudRate));
ui->frequencyShiftText->setText(formatFrequency(m_settings.m_frequencyShift));
ui->frequencyShift->setValue(m_settings.m_frequencyShift);
ui->frequencyShift->setValue(m_settings.m_frequencyShift);
ui->characterSet->setCurrentIndex((int)m_settings.m_characterSet);
ui->endian->setChecked(m_settings.m_msbFirst);
if (m_settings.m_msbFirst) {
ui->endian->setText("MSB");
}
else {
ui->endian->setText("LSB");
}
ui->spaceHigh->setChecked(m_settings.m_spaceHigh);
if (m_settings.m_spaceHigh) {
ui->spaceHigh->setText("M-S");
}
else {
ui->spaceHigh->setText("S-M");
}
ui->udpEnabled->setChecked(m_settings.m_udpEnabled);
ui->udpAddress->setText(m_settings.m_udpAddress);
ui->udpPort->setText(QString::number(m_settings.m_udpPort));
ui->gainText->setText(QString("%1").arg((double)m_settings.m_gain, 0, 'f', 1));
ui->gain->setValue(m_settings.m_gain);
ui->channelMute->setChecked(m_settings.m_channelMute);
ui->repeat->setChecked(m_settings.m_repeat);
ui->text->clear();
for (const auto& text : m_settings.m_predefinedTexts) {
ui->text->addItem(substitute(text));
}
ui->text->setCurrentText(m_settings.m_data);
getRollupContents()->restoreState(m_rollupState);
updateAbsoluteCenterFrequency();
blockApplySettings(false);
}
void RttyModGUI::leaveEvent(QEvent* event)
{
m_channelMarker.setHighlighted(false);
ChannelGUI::leaveEvent(event);
}
void RttyModGUI::enterEvent(EnterEventType* event)
{
m_channelMarker.setHighlighted(true);
ChannelGUI::enterEvent(event);
}
void RttyModGUI::tick()
{
double powDb = CalcDb::dbPower(m_rttyMod->getMagSq());
m_channelPowerDbAvg(powDb);
ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.asDouble(), 0, 'f', 1));
}
void RttyModGUI::makeUIConnections()
{
QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &RttyModGUI::on_deltaFrequency_changed);
QObject::connect(ui->mode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RttyModGUI::on_mode_currentIndexChanged);
QObject::connect(ui->rfBW, &QSlider::valueChanged, this, &RttyModGUI::on_rfBW_valueChanged);
QObject::connect(ui->baudRate, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RttyModGUI::on_baudRate_currentIndexChanged);
QObject::connect(ui->frequencyShift, &QSlider::valueChanged, this, &RttyModGUI::on_frequencyShift_valueChanged);
QObject::connect(ui->characterSet, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RttyModGUI::on_characterSet_currentIndexChanged);
QObject::connect(ui->endian, &QCheckBox::clicked, this, &RttyModGUI::on_endian_clicked);
QObject::connect(ui->spaceHigh, &QCheckBox::clicked, this, &RttyModGUI::on_spaceHigh_clicked);
QObject::connect(ui->clearTransmittedText, &QToolButton::clicked, this, &RttyModGUI::on_clearTransmittedText_clicked);
QObject::connect(ui->gain, &QDial::valueChanged, this, &RttyModGUI::on_gain_valueChanged);
QObject::connect(ui->channelMute, &QToolButton::toggled, this, &RttyModGUI::on_channelMute_toggled);
QObject::connect(ui->txButton, &QToolButton::clicked, this, &RttyModGUI::on_txButton_clicked);
QObject::connect(ui->text->lineEdit(), &QLineEdit::editingFinished, this, &RttyModGUI::on_text_editingFinished);
QObject::connect(ui->text->lineEdit(), &QLineEdit::returnPressed, this, &RttyModGUI::on_text_returnPressed);
QObject::connect(ui->repeat, &ButtonSwitch::toggled, this, &RttyModGUI::on_repeat_toggled);
QObject::connect(ui->udpEnabled, &QCheckBox::clicked, this, &RttyModGUI::on_udpEnabled_clicked);
QObject::connect(ui->udpAddress, &QLineEdit::editingFinished, this, &RttyModGUI::on_udpAddress_editingFinished);
QObject::connect(ui->udpPort, &QLineEdit::editingFinished, this, &RttyModGUI::on_udpPort_editingFinished);
}
void RttyModGUI::updateAbsoluteCenterFrequency()
{
setStatusFrequency(m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset);
}

View File

@ -0,0 +1,130 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_MODRTTY_RTTYMODGUI_H_
#define PLUGINS_CHANNELTX_MODRTTY_RTTYMODGUI_H_
#include "channel/channelgui.h"
#include "dsp/channelmarker.h"
#include "util/movingaverage.h"
#include "util/messagequeue.h"
#include "settings/rollupstate.h"
#include "rttymod.h"
#include "rttymodsettings.h"
class PluginAPI;
class DeviceUISet;
class BasebandSampleSource;
class SpectrumVis;
namespace Ui {
class RttyModGUI;
}
class RttyModGUI : public ChannelGUI {
Q_OBJECT
public:
static RttyModGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx);
virtual void destroy();
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual void setWorkspaceIndex(int index) { m_settings.m_workspaceIndex = index; };
virtual int getWorkspaceIndex() const { return m_settings.m_workspaceIndex; };
virtual void setGeometryBytes(const QByteArray& blob) { m_settings.m_geometryBytes = blob; };
virtual QByteArray getGeometryBytes() const { return m_settings.m_geometryBytes; };
virtual QString getTitle() const { return m_settings.m_title; };
virtual QColor getTitleColor() const { return m_settings.m_rgbColor; };
virtual void zetHidden(bool hidden) { m_settings.m_hidden = hidden; }
virtual bool getHidden() const { return m_settings.m_hidden; }
virtual ChannelMarker& getChannelMarker() { return m_channelMarker; }
virtual int getStreamIndex() const { return m_settings.m_streamIndex; }
virtual void setStreamIndex(int streamIndex) { m_settings.m_streamIndex = streamIndex; }
public slots:
void channelMarkerChangedByCursor();
private:
Ui::RttyModGUI* ui;
PluginAPI* m_pluginAPI;
DeviceUISet* m_deviceUISet;
ChannelMarker m_channelMarker;
RollupState m_rollupState;
RttyModSettings m_settings;
qint64 m_deviceCenterFrequency;
int m_basebandSampleRate;
bool m_doApplySettings;
SpectrumVis* m_spectrumVis;
QString m_initialToolTip;
RttyMod* m_rttyMod;
MovingAverageUtil<double, double, 2> m_channelPowerDbAvg; // Less than other mods, as packets are short
MessageQueue m_inputMessageQueue;
explicit RttyModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = 0);
virtual ~RttyModGUI();
void transmit(const QString& str);
void blockApplySettings(bool block);
void applySettings(bool force = false);
void displaySettings();
QString formatFrequency(int frequency) const;
bool handleMessage(const Message& message);
void makeUIConnections();
void updateAbsoluteCenterFrequency();
QString substitute(const QString& text);
void leaveEvent(QEvent*);
void enterEvent(EnterEventType*);
private slots:
void handleSourceMessages();
void on_deltaFrequency_changed(qint64 value);
void on_mode_currentIndexChanged(int value);
void on_rfBW_valueChanged(int index);
void on_baudRate_currentIndexChanged(int index);
void on_frequencyShift_valueChanged(int value);
void on_gain_valueChanged(int value);
void on_channelMute_toggled(bool checked);
void on_characterSet_currentIndexChanged(int index);
void on_endian_clicked(bool checked);
void on_spaceHigh_clicked(bool checked);
void on_clearTransmittedText_clicked();
void on_txButton_clicked();
void on_text_editingFinished();
void on_text_returnPressed();
void on_repeat_toggled(bool checked);
void repeatSelect(const QPoint& p);
void txSettingsSelect(const QPoint& p);
void on_udpEnabled_clicked(bool checked);
void on_udpAddress_editingFinished();
void on_udpPort_editingFinished();
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void tick();
};
#endif /* PLUGINS_CHANNELTX_MODRTTY_RTTYMODGUI_H_ */

View File

@ -0,0 +1,975 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RttyModGUI</class>
<widget class="RollupContents" name="RttyModGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>702</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>390</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="windowTitle">
<string>RTTY Modulator</string>
</property>
<widget class="QWidget" name="settingsContainer" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>2</x>
<y>2</y>
<width>391</width>
<height>211</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>280</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QVBoxLayout" name="settingsLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="deltaFreqPowLayout">
<property name="topMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="deltaFrequencyLayout">
<item>
<widget class="QLabel" name="deltaFrequencyLabel">
<property name="minimumSize">
<size>
<width>16</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Df</string>
</property>
</widget>
</item>
<item>
<widget class="ValueDialZ" name="deltaFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Hz </string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>-100.0 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QToolButton" name="channelMute">
<property name="toolTip">
<string>Mute/Unmute channel</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/txon.png</normaloff>
<normalon>:/txoff.png</normalon>:/txon.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="rfBandwidthLayout">
<item>
<widget class="QComboBox" name="mode">
<property name="minimumSize">
<size>
<width>86</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>RTTY baud rate and frequency shift</string>
</property>
<item>
<property name="text">
<string>45.45/170</string>
</property>
</item>
<item>
<property name="text">
<string>50/170</string>
</property>
</item>
<item>
<property name="text">
<string>50/450</string>
</property>
</item>
<item>
<property name="text">
<string>75/170</string>
</property>
</item>
<item>
<property name="text">
<string>75/850</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="baudRateLabel">
<property name="text">
<string>Baud</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="baudRate">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Baud rate in symbols per second</string>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<item>
<property name="text">
<string>45</string>
</property>
</item>
<item>
<property name="text">
<string>45.45</string>
</property>
</item>
<item>
<property name="text">
<string>50</string>
</property>
</item>
<item>
<property name="text">
<string>75</string>
</property>
</item>
<item>
<property name="text">
<string>100</string>
</property>
</item>
<item>
<property name="text">
<string>110</string>
</property>
</item>
<item>
<property name="text">
<string>150</string>
</property>
</item>
<item>
<property name="text">
<string>200</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="Line" name="line_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="frequencyShiftLabel">
<property name="text">
<string>Shift</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="frequencyShift">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Frequency shift in Hertz</string>
</property>
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>10</number>
</property>
<property name="value">
<number>170</number>
</property>
<property name="sliderPosition">
<number>170</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="frequencyShiftText">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>850</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rfBWLabel">
<property name="text">
<string>BW</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="rfBW">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>RF bandwidth</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="pageStep">
<number>100</number>
</property>
<property name="value">
<number>340</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rfBWText">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>1700</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="volumeLayout">
<item>
<widget class="QDial" name="gain">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Gain</string>
</property>
<property name="minimum">
<number>-60</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="singleStep">
<number>5</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="gainLabel">
<property name="text">
<string>Gain</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="gainText">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Audio input gain value</string>
</property>
<property name="text">
<string>-80.0dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="LevelMeterVU" name="volumeMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>Level (% full range) top trace: average, bottom trace: instantaneous peak, tip: peak hold</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="udpLayout">
<item>
<widget class="QCheckBox" name="udpEnabled">
<property name="toolTip">
<string>Forward text received via UDP</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>UDP</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="udpAddress">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string>UDP address to listen for text to forward on</string>
</property>
<property name="inputMask">
<string>000.000.000.000</string>
</property>
<property name="text">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="udpSeparator">
<property name="text">
<string>:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="udpPort">
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string>UDP port to listen for text to forward on</string>
</property>
<property name="inputMask">
<string>00000</string>
</property>
<property name="text">
<string>9997</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="callsignLayout">
<item>
<widget class="QLabel" name="characterSetLabel">
<property name="text">
<string>Baudot</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="characterSet">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Baudot character set</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>ITA 2</string>
</property>
</item>
<item>
<property name="text">
<string>UK</string>
</property>
</item>
<item>
<property name="text">
<string>European</string>
</property>
</item>
<item>
<property name="text">
<string>US</string>
</property>
</item>
<item>
<property name="text">
<string>Russian</string>
</property>
</item>
<item>
<property name="text">
<string>Murray</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="endian">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Whether LSB (Least significant bit) or MSB (Most significant bit) is transmitted first</string>
</property>
<property name="text">
<string>LSB</string>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="spaceHigh">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Whether mark is high RF frequency (unchecked) or low RF frequency (checked)</string>
</property>
<property name="text">
<string>S-M</string>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="unshiftOnSpace">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Unshift on space - Set character set to letter when a space character is transmitted</string>
</property>
<property name="text">
<string>US</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="ButtonSwitch" name="repeat">
<property name="toolTip">
<string>Repeatedly transmit the text. Right click for additional settings.</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/playloop.png</normaloff>:/playloop.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="clearTransmittedText">
<property name="toolTip">
<string>Clear transmitted text</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/bin.png</normaloff>:/bin.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="packetDataLayout">
<item>
<widget class="QComboBox" name="text">
<property name="toolTip">
<string>Text to send</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="txButton">
<property name="toolTip">
<string>Press to transmit the text. Right click for additional settings.</string>
</property>
<property name="text">
<string>TX</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="logContainer" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>220</y>
<width>391</width>
<height>141</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Transmitted Text</string>
</property>
<layout class="QVBoxLayout" name="transmittedLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QPlainTextEdit" name="transmittedText">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="spectrumContainer" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>370</y>
<width>381</width>
<height>284</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Baseband Spectrum</string>
</property>
<layout class="QVBoxLayout" name="spectrumLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="GLSpectrum" name="glSpectrum" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>250</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>8</pointsize>
</font>
</property>
</widget>
</item>
<item>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>RollupContents</class>
<extends>QWidget</extends>
<header>gui/rollupcontents.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>LevelMeterVU</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>deltaFrequency</tabstop>
<tabstop>channelMute</tabstop>
<tabstop>rfBW</tabstop>
<tabstop>txButton</tabstop>
<tabstop>transmittedText</tabstop>
</tabstops>
<resources>
<include location="../../../sdrgui/resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,92 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QtPlugin>
#include "plugin/pluginapi.h"
#ifndef SERVER_MODE
#include "rttymodgui.h"
#endif
#include "rttymod.h"
#include "rttymodwebapiadapter.h"
#include "rttymodplugin.h"
const PluginDescriptor RttyModPlugin::m_pluginDescriptor = {
RttyMod::m_channelId,
QStringLiteral("RTTY Modulator"),
QStringLiteral("7.16.0"),
QStringLiteral("(c) Jon Beniston, M7RCE"),
QStringLiteral("https://github.com/f4exb/sdrangel"),
true,
QStringLiteral("https://github.com/f4exb/sdrangel")
};
RttyModPlugin::RttyModPlugin(QObject* parent) :
QObject(parent),
m_pluginAPI(0)
{
}
const PluginDescriptor& RttyModPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void RttyModPlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
m_pluginAPI->registerTxChannel(RttyMod::m_channelIdURI, RttyMod::m_channelId, this);
}
void RttyModPlugin::createTxChannel(DeviceAPI *deviceAPI, BasebandSampleSource **bs, ChannelAPI **cs) const
{
if (bs || cs)
{
RttyMod *instance = new RttyMod(deviceAPI);
if (bs) {
*bs = instance;
}
if (cs) {
*cs = instance;
}
}
}
#ifdef SERVER_MODE
ChannelGUI* RttyModPlugin::createTxChannelGUI(
DeviceUISet *deviceUISet,
BasebandSampleSource *txChannel) const
{
(void) deviceUISet;
(void) txChannel;
return nullptr;
}
#else
ChannelGUI* RttyModPlugin::createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const
{
return RttyModGUI::create(m_pluginAPI, deviceUISet, txChannel);
}
#endif
ChannelWebAPIAdapter* RttyModPlugin::createChannelWebAPIAdapter() const
{
return new RttyModWebAPIAdapter();
}

View File

@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_RTTYMODPLUGIN_H
#define INCLUDE_RTTYMODPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class DeviceUISet;
class BasebandSampleSource;
class RttyModPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "sdrangel.channeltx.rttymod")
public:
explicit RttyModPlugin(QObject* parent = 0);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
virtual void createTxChannel(DeviceAPI *deviceAPI, BasebandSampleSource **bs, ChannelAPI **cs) const;
virtual ChannelGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *rxChannel) const;
virtual ChannelWebAPIAdapter* createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
};
#endif // INCLUDE_RTTYMODPLUGIN_H

View File

@ -0,0 +1,43 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "rttymodrepeatdialog.h"
#include "rttymodsettings.h"
#include <QLineEdit>
RttyModRepeatDialog::RttyModRepeatDialog(int repeatCount, QWidget* parent) :
QDialog(parent),
ui(new Ui::RttyModRepeatDialog)
{
ui->setupUi(this);
QLineEdit *edit = ui->repeatCount->lineEdit();
if (edit) {
edit->setText(QString("%1").arg(repeatCount));
}
}
RttyModRepeatDialog::~RttyModRepeatDialog()
{
delete ui;
}
void RttyModRepeatDialog::accept()
{
QString text = ui->repeatCount->currentText();
m_repeatCount = text.toUInt();
QDialog::accept();
}

View File

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_RTTYMODREPEATDIALOG_H
#define INCLUDE_RTTYMODREPEATDIALOG_H
#include "ui_rttymodrepeatdialog.h"
class RttyModRepeatDialog : public QDialog {
Q_OBJECT
public:
explicit RttyModRepeatDialog(int repeatCount, QWidget* parent = 0);
~RttyModRepeatDialog();
int m_repeatCount; // Number of packets to transmit (-1 = infinite)
private slots:
void accept();
private:
Ui::RttyModRepeatDialog* ui;
};
#endif // INCLUDE_RTTYMODREPEATDIALOG_H

View File

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RttyModRepeatDialog</class>
<widget class="QDialog" name="RttyModRepeatDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>91</height>
</rect>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Packet Repeat Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="repeatCountLabel">
<property name="text">
<string>Times to transmit</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="repeatCount">
<property name="toolTip">
<string>Number of times to transmit</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>10</string>
</property>
</item>
<item>
<property name="text">
<string>100</string>
</property>
</item>
<item>
<property name="text">
<string>1000</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>repeatCount</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>RttyModRepeatDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>RttyModRepeatDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,236 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QColor>
#include <QDebug>
#include "dsp/dspengine.h"
#include "util/baudot.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "rttymodsettings.h"
RttyModSettings::RttyModSettings() :
m_channelMarker(nullptr),
m_rollupState(nullptr)
{
resetToDefaults();
}
void RttyModSettings::resetToDefaults()
{
m_inputFrequencyOffset = 0;
m_baud = 45.45;
m_rfBandwidth = 340;
m_frequencyShift = 170;
m_gain = 0.0f;
m_channelMute = false;
m_repeat = false;
m_repeatCount = 10;
m_lpfTaps = 301;
m_bbNoise = false;
m_rfNoise = false;
m_writeToFile = false;
m_data = "CQ CQ CQ DE SDRangel CQ";
m_characterSet = Baudot::ITA2;
m_msbFirst = false;
m_spaceHigh = false;
m_prefixCRLF = true;
m_postfixCRLF = true;
m_predefinedTexts = QStringList({
"CQ CQ CQ DE ${callsign} ${callsign} CQ",
"DE ${callsign} ${callsign} ${callsign}",
"UR 599 QTH IS ${location}",
"TU DE ${callsign} CQ"
});
m_rgbColor = QColor(0, 105, 2).rgb();
m_title = "RTTY Modulator";
m_streamIndex = 0;
m_useReverseAPI = false;
m_reverseAPIAddress = "127.0.0.1";
m_reverseAPIPort = 8888;
m_reverseAPIDeviceIndex = 0;
m_reverseAPIChannelIndex = 0;
m_pulseShaping = false;
m_beta = 0.5f;
m_symbolSpan = 6;
m_udpEnabled = false;
m_udpAddress = "127.0.0.1";
m_udpPort = 9998;
m_workspaceIndex = 0;
m_hidden = false;
}
QString RttyModSettings::getMode() const
{
return QString("%1/%2").arg(m_baud).arg(m_frequencyShift);
}
QByteArray RttyModSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_inputFrequencyOffset);
s.writeReal(2, m_baud);
s.writeS32(3, m_rfBandwidth);
s.writeS32(4, m_frequencyShift);
s.writeReal(5, m_gain);
s.writeBool(6, m_channelMute);
s.writeBool(7, m_repeat);
s.writeS32(9, m_repeatCount);
s.writeS32(23, m_lpfTaps);
s.writeBool(24, m_bbNoise);
s.writeBool(25, m_rfNoise);
s.writeBool(26, m_writeToFile);
s.writeString(30, m_data);
s.writeS32(60, (int)m_characterSet);
s.writeBool(61, m_unshiftOnSpace);
s.writeBool(62, m_msbFirst);
s.writeBool(63, m_spaceHigh);
s.writeBool(64, m_prefixCRLF);
s.writeBool(65, m_postfixCRLF);
s.writeList(66, m_predefinedTexts);
s.writeU32(31, m_rgbColor);
s.writeString(32, m_title);
if (m_channelMarker) {
s.writeBlob(33, m_channelMarker->serialize());
}
s.writeS32(34, m_streamIndex);
s.writeBool(35, m_useReverseAPI);
s.writeString(36, m_reverseAPIAddress);
s.writeU32(37, m_reverseAPIPort);
s.writeU32(38, m_reverseAPIDeviceIndex);
s.writeU32(39, m_reverseAPIChannelIndex);
s.writeBool(46, m_pulseShaping);
s.writeReal(47, m_beta);
s.writeS32(48, m_symbolSpan);
s.writeBool(51, m_udpEnabled);
s.writeString(52, m_udpAddress);
s.writeU32(53, m_udpPort);
if (m_rollupState) {
s.writeBlob(54, m_rollupState->serialize());
}
s.writeS32(55, m_workspaceIndex);
s.writeBlob(56, m_geometryBytes);
s.writeBool(57, m_hidden);
return s.final();
}
bool RttyModSettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
{
QByteArray bytetmp;
qint32 tmp;
uint32_t utmp;
d.readS32(1, &tmp, 0);
m_inputFrequencyOffset = tmp;
d.readReal(2, &m_baud, 45.45f);
d.readS32(3, &m_rfBandwidth, 340);
d.readS32(4, &m_frequencyShift, 170);
d.readReal(5, &m_gain, 0.0f);
d.readBool(6, &m_channelMute, false);
d.readBool(7, &m_repeat, false);
d.readS32(9, &m_repeatCount, -1);
d.readS32(23, &m_lpfTaps, 301);
d.readBool(24, &m_bbNoise, false);
d.readBool(25, &m_rfNoise, false);
d.readBool(26, &m_writeToFile, false);
d.readString(30, &m_data, "CQ CQ CQ anyone using SDRangel");
d.readS32(60, (int*)&m_characterSet, (int)Baudot::ITA2);
d.readBool(61, &m_unshiftOnSpace, false);
d.readBool(62, &m_msbFirst, false);
d.readBool(63, &m_spaceHigh, false);
d.readBool(64, &m_prefixCRLF, true);
d.readBool(65, &m_postfixCRLF, true);
d.readList(66, &m_predefinedTexts);
d.readU32(31, &m_rgbColor);
d.readString(32, &m_title, "RTTY Modulator");
if (m_channelMarker)
{
d.readBlob(33, &bytetmp);
m_channelMarker->deserialize(bytetmp);
}
d.readS32(34, &m_streamIndex, 0);
d.readBool(35, &m_useReverseAPI, false);
d.readString(36, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(37, &utmp, 0);
if ((utmp > 1023) && (utmp < 65535)) {
m_reverseAPIPort = utmp;
} else {
m_reverseAPIPort = 8888;
}
d.readU32(38, &utmp, 0);
m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
d.readU32(39, &utmp, 0);
m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
d.readBool(46, &m_pulseShaping, false);
d.readReal(47, &m_beta, 0.5f);
d.readS32(48, &m_symbolSpan, 6);
d.readBool(51, &m_udpEnabled);
d.readString(52, &m_udpAddress, "127.0.0.1");
d.readU32(53, &utmp);
if ((utmp > 1023) && (utmp < 65535)) {
m_udpPort = utmp;
} else {
m_udpPort = 9998;
}
if (m_rollupState)
{
d.readBlob(54, &bytetmp);
m_rollupState->deserialize(bytetmp);
}
d.readS32(55, &m_workspaceIndex, 0);
d.readBlob(56, &m_geometryBytes);
d.readBool(57, &m_hidden, false);
return true;
}
else
{
qDebug() << "RttyModSettings::deserialize: ERROR";
resetToDefaults();
return false;
}
}

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_MODRTTY_RTTYMODSETTINGS_H
#define PLUGINS_CHANNELTX_MODRTTY_RTTYMODSETTINGS_H
#include <QByteArray>
#include <stdint.h>
#include "dsp/dsptypes.h"
#include "util/baudot.h"
class Serializable;
struct RttyModSettings
{
qint64 m_inputFrequencyOffset;
float m_baud;
int m_rfBandwidth;
int m_frequencyShift;
Real m_gain;
bool m_channelMute;
bool m_repeat;
int m_repeatCount;
int m_lpfTaps;
bool m_bbNoise;
bool m_rfNoise;
bool m_writeToFile;
QString m_data; // Text to send
bool m_pulseShaping;
float m_beta;
int m_symbolSpan;
Baudot::CharacterSet m_characterSet;
bool m_unshiftOnSpace;
bool m_msbFirst; // false = LSB first, true = MSB first
bool m_spaceHigh; // false = mark high frequency, true = space high frequency
bool m_prefixCRLF;
bool m_postfixCRLF;
QStringList m_predefinedTexts;
quint32 m_rgbColor;
QString m_title;
Serializable *m_channelMarker;
int m_streamIndex;
bool m_useReverseAPI;
QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort;
uint16_t m_reverseAPIDeviceIndex;
uint16_t m_reverseAPIChannelIndex;
bool m_udpEnabled;
QString m_udpAddress;
uint16_t m_udpPort;
Serializable *m_rollupState;
int m_workspaceIndex;
QByteArray m_geometryBytes;
bool m_hidden;
RttyModSettings();
void resetToDefaults();
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
QString getMode() const;
};
#endif /* PLUGINS_CHANNELTX_MODRTTY_RTTYMODSETTINGS_H */

View File

@ -0,0 +1,438 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <cctype>
#include <QDebug>
#include "dsp/basebandsamplesink.h"
#include "dsp/datafifo.h"
#include "rttymod.h"
#include "rttymodsource.h"
#include "util/messagequeue.h"
#include "maincore.h"
RttyModSource::RttyModSource() :
m_channelSampleRate(48000),
m_channelFrequencyOffset(0),
m_spectrumRate(8000),
m_audioPhase(0.0f),
m_fmPhase(0.0),
m_spectrumSink(nullptr),
m_magsq(0.0),
m_levelCalcCount(0),
m_peakLevel(0.0f),
m_levelSum(0.0f),
m_byteIdx(0),
m_bitIdx(0),
m_bitCount(0)
{
m_bits.append(0);
m_lowpass.create(301, m_channelSampleRate, 400.0 / 2.0);
m_pulseShape.create(0.5, 6, m_channelSampleRate/45.45);
m_demodBuffer.resize(1<<12);
m_demodBufferFill = 0;
m_interpolatorDistanceRemain = 0;
m_interpolatorConsumed = false;
m_interpolatorDistance = (Real)m_channelSampleRate / (Real)m_spectrumRate;
m_interpolator.create(48, m_spectrumRate, m_spectrumRate / 2.2, 3.0);
applySettings(m_settings, true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
}
RttyModSource::~RttyModSource()
{
}
void RttyModSource::pull(SampleVector::iterator begin, unsigned int nbSamples)
{
std::for_each(
begin,
begin + nbSamples,
[this](Sample& s) {
pullOne(s);
}
);
}
void RttyModSource::pullOne(Sample& sample)
{
if (m_settings.m_channelMute)
{
sample.m_real = 0.0f;
sample.m_imag = 0.0f;
return;
}
// Calculate next sample
modulateSample();
// Shift to carrier frequency
Complex ci = m_modSample;
ci *= m_carrierNco.nextIQ();
// Calculate power
double magsq = ci.real() * ci.real() + ci.imag() * ci.imag();
m_movingAverage(magsq);
m_magsq = m_movingAverage.asDouble();
// Convert from float to fixed point
sample.m_real = (FixReal) (ci.real() * SDR_TX_SCALEF);
sample.m_imag = (FixReal) (ci.imag() * SDR_TX_SCALEF);
}
void RttyModSource::sampleToSpectrum(Real sample)
{
if (m_spectrumSink)
{
Complex out;
Complex in;
in.real(sample);
in.imag(0.0f);
if (m_interpolator.decimate(&m_interpolatorDistanceRemain, in, &out))
{
sample = std::real(out);
m_sampleBuffer.push_back(Sample(sample * 0.891235351562f * SDR_TX_SCALEF, 0.0f));
m_spectrumSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true);
m_sampleBuffer.clear();
m_interpolatorDistanceRemain += m_interpolatorDistance;
}
}
}
void RttyModSource::modulateSample()
{
Real audioMod;
if (m_sampleIdx == 0)
{
if (m_bitCount == 0)
{
if (!m_dataToTransmit.isEmpty())
{
// Encode a character at a time, so we get a TxReport after each character
QString s = m_dataToTransmit.left(1);
m_dataToTransmit = m_dataToTransmit.mid(1);
encodePacket(s);
}
else
{
// Transmit "diddle"
encodePacket(">");
}
initTX();
}
m_bit = getBit();
}
m_sampleIdx++;
if (m_sampleIdx >= m_samplesPerSymbol) {
m_sampleIdx = 0;
}
if (!m_settings.m_bbNoise)
{
// FSK
if (m_settings.m_pulseShaping)
{
if (m_sampleIdx == 1) {
audioMod = m_pulseShape.filter(m_bit ? 1.0f : -1.0f);
} else {
audioMod = m_pulseShape.filter(0.0f);
}
}
else
{
audioMod = m_bit ? 1.0f : -1.0f;
}
}
else
{
audioMod = (Real)rand() / ((Real)RAND_MAX) - 0.5; // Noise to test filter frequency response
}
// Display baseband audio in spectrum analyser
sampleToSpectrum(audioMod);
// FM
m_fmPhase += m_phaseSensitivity * audioMod * (m_settings.m_spaceHigh ? -1.0f : 1.0f);
// Keep phase in range -pi,pi
if (m_fmPhase > M_PI) {
m_fmPhase -= 2.0f * M_PI;
} else if (m_fmPhase < -M_PI) {
m_fmPhase += 2.0f * M_PI;
}
if (!m_settings.m_rfNoise)
{
m_modSample.real(m_linearGain * cos(m_fmPhase));
m_modSample.imag(m_linearGain * sin(m_fmPhase));
}
else
{
// Noise to test filter frequency response
m_modSample.real(m_linearGain * ((Real)rand()/((Real)RAND_MAX)-0.5f));
m_modSample.imag(m_linearGain * ((Real)rand()/((Real)RAND_MAX)-0.5f));
}
// Apply low pass filter to limit RF BW
m_modSample = m_lowpass.filter(m_modSample);
Real s = std::real(m_modSample);
calculateLevel(s);
m_demodBuffer[m_demodBufferFill] = audioMod * std::numeric_limits<int16_t>::max();
++m_demodBufferFill;
if (m_demodBufferFill >= m_demodBuffer.size())
{
QList<ObjectPipe*> dataPipes;
MainCore::instance()->getDataPipes().getDataPipes(m_channel, "demod", dataPipes);
if (dataPipes.size() > 0)
{
QList<ObjectPipe*>::iterator it = dataPipes.begin();
for (; it != dataPipes.end(); ++it)
{
DataFifo *fifo = qobject_cast<DataFifo*>((*it)->m_element);
if (fifo) {
fifo->write((quint8*) &m_demodBuffer[0], m_demodBuffer.size() * sizeof(qint16), DataFifo::DataTypeI16);
}
}
}
m_demodBufferFill = 0;
}
}
void RttyModSource::calculateLevel(Real& sample)
{
if (m_levelCalcCount < m_levelNbSamples)
{
m_peakLevel = std::max(std::fabs(m_peakLevel), sample);
m_levelSum += sample * sample;
m_levelCalcCount++;
}
else
{
m_rmsLevel = sqrt(m_levelSum / m_levelNbSamples);
m_peakLevelOut = m_peakLevel;
m_peakLevel = 0.0f;
m_levelSum = 0.0f;
m_levelCalcCount = 0;
}
}
void RttyModSource::applySettings(const RttyModSettings& settings, bool force)
{
// Only recreate filters if settings have changed
if ((settings.m_lpfTaps != m_settings.m_lpfTaps) || (settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force)
{
qDebug() << "RttyModSource::applySettings: Creating new lpf with taps " << settings.m_lpfTaps << " rfBW " << settings.m_rfBandwidth;
m_lowpass.create(settings.m_lpfTaps, m_channelSampleRate, settings.m_rfBandwidth / 2.0);
}
if ((settings.m_beta != m_settings.m_beta) || (settings.m_symbolSpan != m_settings.m_symbolSpan) || (settings.m_baud != m_settings.m_baud) || force)
{
qDebug() << "RttyModSource::applySettings: Recreating pulse shaping filter: "
<< " beta: " << settings.m_beta
<< " symbolSpan: " << settings.m_symbolSpan
<< " channelSampleRate:" << m_channelSampleRate
<< " baud:" << settings.m_baud;
m_pulseShape.create(settings.m_beta, m_settings.m_symbolSpan, m_channelSampleRate/settings.m_baud);
}
if ((settings.m_characterSet != m_settings.m_characterSet) || force) {
m_rttyEncoder.setCharacterSet(settings.m_characterSet);
}
if ((settings.m_unshiftOnSpace != m_settings.m_unshiftOnSpace) || force) {
m_rttyEncoder.setUnshiftOnSpace(settings.m_unshiftOnSpace);
}
if ((settings.m_msbFirst != m_settings.m_msbFirst) || force) {
m_rttyEncoder.setMsbFirst(settings.m_msbFirst);
}
m_settings = settings;
m_samplesPerSymbol = m_channelSampleRate / m_settings.m_baud;
qDebug() << "m_samplesPerSymbol: " << m_samplesPerSymbol << " (" << m_channelSampleRate << "/" << m_settings.m_baud << ")";
// Precalculate FM sensensity and linear gain to save doing it in the loop
m_phaseSensitivity = 2.0f * M_PI * (m_settings.m_frequencyShift/2.0f) / (double)m_channelSampleRate;
m_linearGain = powf(10.0f, m_settings.m_gain/20.0f);
}
void RttyModSource::applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force)
{
qDebug() << "RttyModSource::applyChannelSettings:"
<< " channelSampleRate: " << channelSampleRate
<< " channelFrequencyOffset: " << channelFrequencyOffset
<< " rfBandwidth: " << m_settings.m_rfBandwidth;
if ((channelFrequencyOffset != m_channelFrequencyOffset)
|| (channelSampleRate != m_channelSampleRate) || force)
{
m_carrierNco.setFreq(channelFrequencyOffset, channelSampleRate);
}
if ((m_channelSampleRate != channelSampleRate) || force)
{
qDebug() << "RttyModSource::applyChannelSettings: Recreating filters";
m_lowpass.create(m_settings.m_lpfTaps, channelSampleRate, m_settings.m_rfBandwidth / 2.0);
qDebug() << "RttyModSource::applyChannelSettings: Recreating bandpass filter: "
<< " channelSampleRate:" << channelSampleRate;
qDebug() << "RttyModSource::applyChannelSettings: Recreating pulse shaping filter: "
<< " beta: " << m_settings.m_beta
<< " symbolSpan: " << m_settings.m_symbolSpan
<< " channelSampleRate:" << m_channelSampleRate
<< " baud:" << m_settings.m_baud;
m_pulseShape.create(m_settings.m_beta, m_settings.m_symbolSpan, channelSampleRate/m_settings.m_baud);
}
if ((m_channelSampleRate != channelSampleRate) || force)
{
m_interpolatorDistanceRemain = 0;
m_interpolatorConsumed = false;
m_interpolatorDistance = (Real) channelSampleRate / (Real) m_spectrumRate;
m_interpolator.create(48, m_spectrumRate, m_spectrumRate / 2.2, 3.0);
}
m_channelSampleRate = channelSampleRate;
m_channelFrequencyOffset = channelFrequencyOffset;
m_samplesPerSymbol = m_channelSampleRate / m_settings.m_baud;
qDebug() << "m_samplesPerSymbol: " << m_samplesPerSymbol << " (" << m_channelSampleRate << "/" << m_settings.m_baud << ")";
// Precalculate FM sensensity to save doing it in the loop
m_phaseSensitivity = 2.0f * M_PI * (m_settings.m_frequencyShift/2.0f) / (double)m_channelSampleRate;
QList<ObjectPipe*> pipes;
MainCore::instance()->getMessagePipes().getMessagePipes(m_channel, "reportdemod", pipes);
if (pipes.size() > 0)
{
for (const auto& pipe : pipes)
{
MessageQueue* messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
MainCore::MsgChannelDemodReport *msg = MainCore::MsgChannelDemodReport::create(m_channel, m_channelSampleRate);
messageQueue->push(msg);
}
}
}
int RttyModSource::getBit()
{
int bit;
if (m_bitCount > 0)
{
bit = (m_bits[m_byteIdx] >> m_bitIdx) & 1;
m_bitIdx++;
m_bitCount--;
if (m_bitIdx == 8)
{
m_byteIdx++;
m_bitIdx = 0;
}
}
else
{
qDebug() << "RttyModSource::getBit: Called when empty";
bit = 1;
}
return bit;
}
void RttyModSource::addBit(int bit)
{
m_bits[m_byteIdx] |= bit << m_bitIdx;
m_bitIdx++;
m_bitCount++;
m_bitCountTotal++;
if (m_bitIdx == 8)
{
m_byteIdx++;
if (m_bits.size() <= m_byteIdx) {
m_bits.append(0);
}
m_bitIdx = 0;
}
}
void RttyModSource::initTX()
{
m_byteIdx = 0;
m_bitIdx = 0;
m_bitCount = m_bitCountTotal; // Reset to allow retransmission
m_bit = 0;
}
void RttyModSource::addTXPacket(QString data)
{
int count = m_settings.m_repeat ? m_settings.m_repeatCount : 1;
for (int i = 0; i < count; i++) {
m_dataToTransmit.append(data);
}
}
void RttyModSource::addTXPacket(QByteArray data)
{
int count = m_settings.m_repeat ? m_settings.m_repeatCount : 1;
for (int i = 0; i < count; i++) {
m_dataToTransmit.append(QString(data));
}
}
void RttyModSource::encodePacket(const QString& text)
{
// RTTY encoding
m_byteIdx = 0;
m_bitIdx = 0;
m_bitCount = 0;
m_bitCountTotal = 0;
for (int i = 0; i < m_bits.size(); i++) {
m_bits[i] = 0;
}
QString s = text.toUpper(); // RTTY only supports upper case
for (int i = 0; i < s.size(); i++)
{
unsigned bits;
unsigned bitCount;
bool error;
error = m_rttyEncoder.encode(s[i], bits, bitCount);
for (int j = 0; j < bitCount; j++)
{
int txBit = (bits >> j) & 1;
addBit(txBit);
}
}
if (getMessageQueueToGUI())
{
RttyMod::MsgReportTx* msg = RttyMod::MsgReportTx::create(s, m_dataToTransmit.size());
getMessageQueueToGUI()->push(msg);
}
}

View File

@ -0,0 +1,134 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_RTTYMODSOURCE_H
#define INCLUDE_RTTYMODSOURCE_H
#include <QMutex>
#include <QDebug>
#include <QVector>
#include "dsp/channelsamplesource.h"
#include "dsp/nco.h"
#include "dsp/ncof.h"
#include "dsp/interpolator.h"
#include "dsp/firfilter.h"
#include "dsp/raisedcosine.h"
#include "util/movingaverage.h"
#include "util/baudot.h"
#include "rttymodsettings.h"
class BasebandSampleSink;
class ChannelAPI;
class RttyModSource : public ChannelSampleSource
{
public:
RttyModSource();
virtual ~RttyModSource();
virtual void pull(SampleVector::iterator begin, unsigned int nbSamples);
virtual void pullOne(Sample& sample);
virtual void prefetch(unsigned int nbSamples) { (void) nbSamples; }
double getMagSq() const { return m_magsq; }
void getLevels(qreal& rmsLevel, qreal& peakLevel, int& numSamples) const
{
rmsLevel = m_rmsLevel;
peakLevel = m_peakLevelOut;
numSamples = m_levelNbSamples;
}
void setMessageQueueToGUI(MessageQueue* messageQueue) { m_messageQueueToGUI = messageQueue; }
void setSpectrumSink(BasebandSampleSink *sampleSink) { m_spectrumSink = sampleSink; }
void applySettings(const RttyModSettings& settings, bool force = false);
void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false);
void addTXPacket(QString data);
void addTXPacket(QByteArray data);
//void encodePacket(uint8_t *packet, int packet_length, uint8_t *packet_end);
void encodePacket(const QString& data);
void setChannel(ChannelAPI *channel) { m_channel = channel; }
int getChannelSampleRate() const { return m_channelSampleRate; }
private:
int m_channelSampleRate;
int m_channelFrequencyOffset;
int m_spectrumRate;
RttyModSettings m_settings;
ChannelAPI *m_channel;
NCO m_carrierNco;
Real m_audioPhase;
double m_fmPhase; // Double gives cleaner spectrum than Real
double m_phaseSensitivity;
Real m_linearGain;
Complex m_modSample;
int m_bit; // Current bit
RaisedCosine<Real> m_pulseShape; // Pulse shaping filter
Lowpass<Complex> m_lowpass; // Low pass filter to limit RF bandwidth
BasebandSampleSink* m_spectrumSink; // Spectrum GUI to display baseband waveform
SampleVector m_sampleBuffer;
Interpolator m_interpolator; // Interpolator to downsample to 4k in spectrum
Real m_interpolatorDistance;
Real m_interpolatorDistanceRemain;
bool m_interpolatorConsumed;
double m_magsq;
MovingAverageUtil<double, double, 16> m_movingAverage;
quint32 m_levelCalcCount;
qreal m_rmsLevel;
qreal m_peakLevelOut;
Real m_peakLevel;
Real m_levelSum;
static const int m_levelNbSamples = 480; // every 10ms assuming 48k Sa/s
int m_sampleIdx; // Sample index in to symbol
int m_samplesPerSymbol; // Number of samples per symbol
QString m_dataToTransmit; // Transmit data buffer (before RTTY encoding)
BaudotEncoder m_rttyEncoder;
QList<uint8_t> m_bits; // Bits to transmit
int m_byteIdx; // Index in to m_bits
int m_bitIdx; // Index in to current byte of m_bits
int m_bitCount; // Count of number of valid bits in m_bits
int m_bitCountTotal;
QVector<qint16> m_demodBuffer;
int m_demodBufferFill;
MessageQueue* m_messageQueueToGUI;
MessageQueue* getMessageQueueToGUI() { return m_messageQueueToGUI; }
int getBit(); // Get bit from m_bits
void addBit(int bit); // Add bit to m_bits, with zero stuffing
void initTX();
void calculateLevel(Real& sample);
void modulateSample();
void sampleToSpectrum(Real sample);
};
#endif // INCLUDE_RTTYMODSOURCE_H

View File

@ -0,0 +1,112 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "rttymodtxsettingsdialog.h"
static QListWidgetItem* newItem(const QString& text)
{
QListWidgetItem* item = new QListWidgetItem(text);
item->setFlags(item->flags() | Qt::ItemIsEditable);
return item;
}
RttyModTXSettingsDialog::RttyModTXSettingsDialog(RttyModSettings* settings, QWidget *parent) :
QDialog(parent),
ui(new Ui::RttyModTXSettingsDialog),
m_settings(settings)
{
ui->setupUi(this);
ui->prefixCRLF->setChecked(m_settings->m_prefixCRLF);
ui->postfixCRLF->setChecked(m_settings->m_postfixCRLF);
for (const auto& text : m_settings->m_predefinedTexts) {
ui->predefinedText->addItem(newItem(text));
}
ui->pulseShaping->setChecked(m_settings->m_pulseShaping);
ui->beta->setValue(m_settings->m_beta);
ui->symbolSpan->setValue(m_settings->m_symbolSpan);
ui->lpfTaps->setValue(m_settings->m_lpfTaps);
ui->bbNoise->setChecked(m_settings->m_bbNoise);
ui->rfNoise->setChecked(m_settings->m_rfNoise);
}
RttyModTXSettingsDialog::~RttyModTXSettingsDialog()
{
delete ui;
}
void RttyModTXSettingsDialog::accept()
{
m_settings->m_prefixCRLF = ui->prefixCRLF->isChecked();
m_settings->m_postfixCRLF = ui->postfixCRLF->isChecked();
m_settings->m_predefinedTexts.clear();
for (int i = 0; i < ui->predefinedText->count(); i++) {
m_settings->m_predefinedTexts.append(ui->predefinedText->item(i)->text());
}
m_settings->m_pulseShaping = ui->pulseShaping->isChecked();
m_settings->m_beta = ui->beta->value();
m_settings->m_symbolSpan = ui->symbolSpan->value();
m_settings->m_lpfTaps = ui->lpfTaps->value();
m_settings->m_bbNoise = ui->bbNoise->isChecked();
m_settings->m_rfNoise = ui->rfNoise->isChecked();
QDialog::accept();
}
void RttyModTXSettingsDialog::on_add_clicked()
{
QListWidgetItem* item = newItem("...");
ui->predefinedText->addItem(item);
ui->predefinedText->setCurrentItem(item);
}
void RttyModTXSettingsDialog::on_remove_clicked()
{
QList<QListWidgetItem*> items = ui->predefinedText->selectedItems();
for (auto item : items) {
delete ui->predefinedText->takeItem(ui->predefinedText->row(item));
}
}
void RttyModTXSettingsDialog::on_up_clicked()
{
QList<QListWidgetItem*> items = ui->predefinedText->selectedItems();
for (auto item : items)
{
int row = ui->predefinedText->row(item);
if (row > 0)
{
QListWidgetItem* item = ui->predefinedText->takeItem(row);
ui->predefinedText->insertItem(row - 1, item);
ui->predefinedText->setCurrentItem(item);
}
}
}
void RttyModTXSettingsDialog::on_down_clicked()
{
QList<QListWidgetItem*> items = ui->predefinedText->selectedItems();
for (auto item : items)
{
int row = ui->predefinedText->row(item);
if (row < ui->predefinedText->count() - 1)
{
QListWidgetItem* item = ui->predefinedText->takeItem(row);
ui->predefinedText->insertItem(row + 1, item);
ui->predefinedText->setCurrentItem(item);
}
}
}

View File

@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_RTTYMODTXSETTINGSDIALOG_H
#define INCLUDE_RTTYMODTXSETTINGSDIALOG_H
#include "ui_rttymodtxsettingsdialog.h"
#include "rttymodsettings.h"
class RttyModTXSettingsDialog : public QDialog {
Q_OBJECT
public:
explicit RttyModTXSettingsDialog(RttyModSettings *settings, QWidget *parent = nullptr);
~RttyModTXSettingsDialog();
RttyModSettings *m_settings;
private slots:
void accept();
void on_add_clicked();
void on_remove_clicked();
void on_up_clicked();
void on_down_clicked();
private:
Ui::RttyModTXSettingsDialog* ui;
};
#endif // INCLUDE_RTTYMODTXSETTINGSDIALOG_H

View File

@ -0,0 +1,294 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RttyModTXSettingsDialog</class>
<widget class="QDialog" name="RttyModTXSettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>546</height>
</rect>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="windowTitle">
<string>Packet TX Extra Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="listControls">
<property name="title">
<string>Text</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="prefixCRLF">
<property name="toolTip">
<string>Prefix text with carriage returns, line feed and switch to letters</string>
</property>
<property name="text">
<string>Prefix CR+CR+LF+LTRS</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Predefined text</string>
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="add">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Add item to list</string>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="remove">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Remove selected items from list</string>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="up">
<property name="toolTip">
<string>Move selected item up</string>
</property>
<property name="text">
<string>Up</string>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/arrow_up.png</normaloff>:/arrow_up.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="down">
<property name="toolTip">
<string>Move selected item down</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/arrow_down.png</normaloff>:/arrow_down.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="postfixCRLF">
<property name="toolTip">
<string>Postfix text with carriage returns and line feeds</string>
</property>
<property name="text">
<string>Postfix CR+CR+LF</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QListWidget" name="predefinedText">
<property name="toolTip">
<string>Predefined text messages
Substitutions:
${callsign}
${location}</string>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="fskGroup">
<property name="title">
<string>Modulation</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="lpfTapsLabel">
<property name="text">
<string>RF BW limit LPF taps</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="lpfTaps">
<property name="toolTip">
<string>Number of taps in LPF for RF BW filter.</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="pulseShaping">
<property name="toolTip">
<string>Enable raised cosine pulse shaping filter</string>
</property>
<property name="text">
<string>Raised cosine pulse shaping</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="betaLabel">
<property name="text">
<string>Filter rolloff (beta)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="beta">
<property name="toolTip">
<string>Roll-off of the filter</string>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.250000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="symbolSpanLabel">
<property name="text">
<string>Filter symbol span</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="symbolSpan">
<property name="toolTip">
<string>Number of symbols over which filter is applied</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>20</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="debugGroup">
<property name="title">
<string>Debug</string>
</property>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="bbNoise">
<property name="toolTip">
<string>Generate white noise as baseband signal.</string>
</property>
<property name="text">
<string>Generate BB noise</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="rfNoise">
<property name="toolTip">
<string>Generate white noise as RF signal.</string>
</property>
<property name="text">
<string>Generate RF noise</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../sdrgui/resources/res.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>RttyModTXSettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>RttyModTXSettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,53 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "SWGChannelSettings.h"
#include "rttymod.h"
#include "rttymodwebapiadapter.h"
RttyModWebAPIAdapter::RttyModWebAPIAdapter()
{}
RttyModWebAPIAdapter::~RttyModWebAPIAdapter()
{}
int RttyModWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
/*response.setRttyModSettings(new SWGSDRangel::SWGRttyModSettings());
response.getRttyModSettings()->init();
RttyMod::webapiFormatChannelSettings(response, m_settings);*/
return 200;
}
int RttyModWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) force; // no action
(void) errorMessage;
RttyMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
RttyMod::webapiFormatChannelSettings(response, m_settings);
return 200;
}

View File

@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// Copyright (C) 2023 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_RTTYMOD_WEBAPIADAPTER_H
#define INCLUDE_RTTYMOD_WEBAPIADAPTER_H
#include "channel/channelwebapiadapter.h"
#include "rttymodsettings.h"
/**
* Standalone API adapter only for the settings
*/
class RttyModWebAPIAdapter : public ChannelWebAPIAdapter {
public:
RttyModWebAPIAdapter();
virtual ~RttyModWebAPIAdapter();
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { return m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
private:
RttyModSettings m_settings;
};
#endif // INCLUDE_RTTYMOD_WEBAPIADAPTER_H

View File

@ -23,84 +23,84 @@
// We use < for FIGS and > for LTRS and ^ for Cyrillic
// Unicode used for source file encoding
const QString Baudot::m_ita2Letter[] = {
const QStringList Baudot::m_ita2Letter = {
"\0", "E", "\n", "A", " ", "S", "I", "U",
"\r", "D", "R", "J", "N", "F", "C", "K",
"T", "Z", "L", "W", "H", "Y", "P", "Q",
"O", "B", "G", "<", "M", "X", "V", ">"
};
const QString Baudot::m_ita2Figure[] = {
const QStringList Baudot::m_ita2Figure = {
"\0", "3", "\n", "-", " ", "\'", "8", "7",
"\r", "\x5", "4", "\a", ",", "!", ":", "(",
"5", "+", ")", "2", "£", "6", "0", "1",
"9", "?", "&", "<", ".", "/", "=", ">"
};
const QString Baudot::m_ukLetter[] = {
const QStringList Baudot::m_ukLetter = {
"\0", "A", "E", "/", "Y", "U", "I", "O",
"<", "J", "G", "H", "B", "C", "F", "D",
" ", "-", "X", "Z", "S", "T", "W", "V",
"\b", "K", "M", "L", "R", "Q", "N", "P"
};
const QString Baudot::m_ukFigure[] = {
const QStringList Baudot::m_ukFigure = {
"\0", "1", "2", "", "3", "4", "³⁄", "5",
" ", "6", "7", "¹", "8", "9", "⁵⁄", "0",
">", ".", "⁹⁄", ":", "⁷⁄", "²", "?", "\'",
"\b", "(", ")", "=", "-", "/", "£", "+"
};
const QString Baudot::m_europeanLetter[] = {
const QStringList Baudot::m_europeanLetter = {
"\0", "A", "E", "É", "Y", "U", "I", "O",
"<", "J", "G", "H", "B", "C", "F", "D",
" ", "t", "X", "Z", "S", "T", "W", "V",
"\b", "K", "M", "L", "R", "Q", "N", "P"
};
const QString Baudot::m_europeanFigure[] = {
const QStringList Baudot::m_europeanFigure = {
"\0", "1", "2", "&", "3", "4", "º", "5",
" ", "6", "7", "", "8", "9", "", "0",
">", ".", ",", ":", ";", "!", "?", "\'",
"\b", "(", ")", "=", "-", "/", "", "%"
};
const QString Baudot::m_usLetter[] = {
const QStringList Baudot::m_usLetter = {
"\0", "E", "\n", "A", " ", "S", "I", "U",
"\r", "D", "R", "J", "N", "F", "C", "K",
"T", "Z", "L", "W", "H", "Y", "P", "Q",
"O", "B", "G", "<", "M", "X", "V", ">"
};
const QString Baudot::m_usFigure[] = {
const QStringList Baudot::m_usFigure = {
"\0", "3", "\n", "-", " ", "\a", "8", "7",
"\r", "\x5", "4", "\'", ",", "!", ":", "(",
"5", "\"", ")", "2", "#", "6", "0", "1",
"9", "?", "&", "<", ".", "/", ";", ">"
};
const QString Baudot::m_russianLetter[] = {
const QStringList Baudot::m_russianLetter = {
"\0", "Е", "\n", "А", " ", "С", "И", "У",
"\r", "Д", "П", "Й", "Н", "Ф", "Ц", "К",
"Т", "З", "Л", "В", "Х", "Ы", "P", "Я",
"О", "Б", "Г", "<", "М", "Ь", "Ж", ">"
};
const QString Baudot::m_russianFigure[] = {
const QStringList Baudot::m_russianFigure = {
"\0", "3", "\n", "-", " ", "\'", "8", "7",
"\r", "Ч", "4", "Ю", ",", "Э", ":", "(",
"5", "+", ")", "2", "Щ", "6", "0", "1",
"9", "?", "Ш", "<", ".", "/", ";", ">"
};
const QString Baudot::m_murrayLetter[] = {
const QStringList Baudot::m_murrayLetter = {
" ", "E", "?", "A", ">", "S", "I", "U",
"\n", "D", "R", "J", "N", "F", "C", "K",
"T", "Z", "L", "W", "H", "Y", "P", "Q",
"O", "B", "G", "<", "M", "X", "V", "\b"
};
const QString Baudot::m_murrayFigure[] = {
const QStringList Baudot::m_murrayFigure = {
" ", "3", "?", " ", ">", "'", "8", "7",
"\n", "²", "4", "⁷⁄", "-", "", "(", "⁹⁄",
"5", ".", "/", "2", "⁵⁄", "6", "0", "1",
@ -190,3 +190,172 @@ QString BaudotDecoder::decode(char bits)
return c;
}
BaudotEncoder::BaudotEncoder()
{
setCharacterSet(Baudot::ITA2);
setUnshiftOnSpace(false);
setMsbFirst(false);
setStartBits(1);
setStopBits(1);
init();
}
void BaudotEncoder::setCharacterSet(Baudot::CharacterSet characterSet)
{
m_characterSet = characterSet;
switch (m_characterSet)
{
case Baudot::ITA2:
m_letters = Baudot::m_ita2Letter;
m_figures = Baudot::m_ita2Figure;
break;
case Baudot::UK:
m_letters = Baudot::m_ukLetter;
m_figures = Baudot::m_ukFigure;
break;
case Baudot::EUROPEAN:
m_letters = Baudot::m_europeanLetter;
m_figures = Baudot::m_europeanFigure;
break;
case Baudot::US:
m_letters = Baudot::m_usLetter;
m_figures = Baudot::m_usFigure;
break;
case Baudot::RUSSIAN:
m_letters = Baudot::m_russianLetter;
m_figures = Baudot::m_russianFigure;
break;
case Baudot::MURRAY:
m_letters = Baudot::m_murrayLetter;
m_figures = Baudot::m_murrayFigure;
break;
default:
qDebug() << "BaudotEncoder::BaudotEncoder: Unsupported character set " << m_characterSet;
m_letters = Baudot::m_ita2Letter;
m_figures = Baudot::m_ita2Figure;
m_characterSet = Baudot::ITA2;
break;
}
}
void BaudotEncoder::setUnshiftOnSpace(bool unshiftOnSpace)
{
m_unshiftOnSpace = unshiftOnSpace;
}
void BaudotEncoder::setMsbFirst(bool msbFirst)
{
m_msbFirst = msbFirst;
}
// startBits should be 0 or 1
void BaudotEncoder::setStartBits(int startBits)
{
m_startBits = startBits;
}
// stopBits should be 0, 1 or 2
void BaudotEncoder::setStopBits(int stopBits)
{
m_stopBits = stopBits;
}
void BaudotEncoder::init()
{
m_figure = false;
}
bool BaudotEncoder::encode(QChar c, unsigned &bits, unsigned int &bitCount)
{
unsigned int code;
const unsigned int codeLen = 5;
bits = 0;
bitCount = 0;
// Only upper case is supported
c = c.toUpper();
QString s(c);
// We could create reverse look-up tables to speed this up, but it's only 200 baud...
if (m_letters.contains(s))
{
if (m_figure)
{
// Switch to letters
addStartBits(bits, bitCount);
code = reverseBits(m_letters.indexOf(">"), codeLen);
addBits(bits, bitCount, code, codeLen);
addStopBits(bits, bitCount);
m_figure = false;
}
addStartBits(bits, bitCount);
code = reverseBits(m_letters.indexOf(s), codeLen);
addBits(bits, bitCount, code, codeLen);
addStopBits(bits, bitCount);
return true;
}
else if (m_figures.contains(s))
{
if (!m_figure)
{
// Switch to figures
addStartBits(bits, bitCount);
code = reverseBits(m_letters.indexOf("<"), codeLen);
addBits(bits, bitCount, code, codeLen);
addStopBits(bits, bitCount);
m_figure = true;
}
addStartBits(bits, bitCount);
code = reverseBits(m_figures.indexOf(s), codeLen);
addBits(bits, bitCount, code, codeLen);
addStopBits(bits, bitCount);
if ((s == " ") && m_unshiftOnSpace) {
m_figure = false;
}
}
else
{
qDebug() << "BaudotEncoder::encode: Can't encode" << c;
return false;
}
return true;
}
void BaudotEncoder::addStartBits(unsigned& bits, unsigned int& bitCount) const
{
// Start bit is 0
addBits(bits, bitCount, 0, m_startBits);
}
void BaudotEncoder::addStopBits(unsigned& bits, unsigned int& bitCount) const
{
// Stop bit is 1
addBits(bits, bitCount, ((1 << m_stopBits)) - 1, m_stopBits);
}
void BaudotEncoder::addBits(unsigned& bits, unsigned int& bitCount, int data, int count) const
{
bits |= data << bitCount;
bitCount += count;
}
unsigned BaudotEncoder::reverseBits(unsigned bits, unsigned int count) const
{
if (m_msbFirst) {
return BaudotEncoder::reverse(bits) >> (sizeof(unsigned int) * 8 - count);
} else {
return bits;
}
}
unsigned int BaudotEncoder::reverse(unsigned int x)
{
x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
return((x >> 16) | (x << 16));
}

View File

@ -38,18 +38,18 @@ public:
};
// QString used for fractions in figure set
static const QString m_ita2Letter[];
static const QString m_ita2Figure[];
static const QString m_ukLetter[];
static const QString m_ukFigure[];
static const QString m_europeanLetter[];
static const QString m_europeanFigure[];
static const QString m_usLetter[];
static const QString m_usFigure[];
static const QString m_russianLetter[];
static const QString m_russianFigure[];
static const QString m_murrayLetter[];
static const QString m_murrayFigure[];
static const QStringList m_ita2Letter;
static const QStringList m_ita2Figure;
static const QStringList m_ukLetter;
static const QStringList m_ukFigure;
static const QStringList m_europeanLetter;
static const QStringList m_europeanFigure;
static const QStringList m_usLetter;
static const QStringList m_usFigure;
static const QStringList m_russianLetter;
static const QStringList m_russianFigure;
static const QStringList m_murrayLetter;
static const QStringList m_murrayFigure;
};
@ -58,7 +58,7 @@ class SDRBASE_API BaudotDecoder {
public:
BaudotDecoder();
void setCharacterSet(Baudot::CharacterSet characterSet=Baudot::ITA2);
void setCharacterSet(Baudot::CharacterSet characterSet = Baudot::ITA2);
void setUnshiftOnSpace(bool unshiftOnSpace);
void init();
QString decode(char bits);
@ -67,11 +67,43 @@ private:
Baudot::CharacterSet m_characterSet;
bool m_unshiftOnSpace;
const QString *m_letters;
const QString *m_figures;
QStringList m_letters;
QStringList m_figures;
bool m_figure;
};
class SDRBASE_API BaudotEncoder {
public:
BaudotEncoder();
void setCharacterSet(Baudot::CharacterSet characterSet = Baudot::ITA2);
void setUnshiftOnSpace(bool unshiftOnSpace);
void setMsbFirst(bool msbFirst);
void setStartBits(int startBits);
void setStopBits(int stopBits);
void init();
bool encode(QChar c, unsigned& bits, unsigned int &bitCount);
private:
void addStartBits(unsigned int& bits, unsigned int& bitCount) const;
void addStopBits(unsigned int& bits, unsigned int& bitCount) const;
void addBits(unsigned int& bits, unsigned int& bitCount, int data, int count) const;
unsigned reverseBits(unsigned int bits, unsigned int count) const;
static unsigned reverse(unsigned int bits);
Baudot::CharacterSet m_characterSet;
bool m_unshiftOnSpace;
QStringList m_letters;
QStringList m_figures;
bool m_figure;
bool m_msbFirst;
int m_startBits;
int m_stopBits;
};
#endif // INCLUDE_UTIL_BAUDOT_H

View File

@ -31,5 +31,7 @@ ChannelActions:
$ref: "http://swgserver:8081/api/swagger/include/PacketMod.yaml#/PacketModActions"
RadioAstronomyActions:
$ref: "http://swgserver:8081/api/swagger/include/RadioAstronomy.yaml#/RadioAstronomyActions"
RTTYModActions:
$ref: "http://swgserver:8081/api/swagger/include/RTTYMod.yaml#/RTTYModActions"
SigMFFileSinkActions:
$ref: "http://swgserver:8081/api/swagger/include/SigMFFileSink.yaml#/SigMFFileSinkActions"

View File

@ -81,6 +81,8 @@ ChannelReport:
$ref: "http://swgserver:8081/api/swagger/include/RadiosondeDemod.yaml#/RadiosondeDemodReport"
RemoteSourceReport:
$ref: "http://swgserver:8081/api/swagger/include/RemoteSource.yaml#/RemoteSourceReport"
RTTYModReport:
$ref: "http://swgserver:8081/api/swagger/include/RTTYMod.yaml#/RTTYModReport"
PacketDemodReport:
$ref: "http://swgserver:8081/api/swagger/include/PacketDemod.yaml#/PacketDemodReport"
PacketModReport:

View File

@ -69,6 +69,8 @@ ChannelSettings:
$ref: "http://swgserver:8081/api/swagger/include/FT8Demod.yaml#/FT8DemodSettings"
RTTYDemodSettings:
$ref: "http://swgserver:8081/api/swagger/include/RTTYDemod.yaml#/RTTYDemodSettings"
RTTYModSettings:
$ref: "http://swgserver:8081/api/swagger/include/RTTYMod.yaml#/RTTYModSettings"
HeatMapSettings:
$ref: "http://swgserver:8081/api/swagger/include/HeatMap.yaml#/HeatMapSettings"
ILSDemodSettings:

View File

@ -0,0 +1,106 @@
RTTYModSettings:
description: RTTYMod
properties:
inputFrequencyOffset:
type: integer
format: int64
baud:
type: number
format: float
description: Baud rate
rfBandwidth:
type: integer
frequencyShift:
type: integer
gain:
type: number
format: float
channelMute:
type: integer
repeat:
type: integer
repeatCount:
type: integer
lpfTaps:
type: integer
bbNoise:
type: integer
description: >
Boolean
* 0 - off
* 1 - on
rfNoise:
type: integer
description: >
Boolean
* 0 - off
* 1 - on
data:
type: string
pulseShaping:
type: integer
description: >
Boolean
* 0 - off
* 1 - on
beta:
type: number
format: float
symbolSpan:
type: integer
udpEnabled:
description: "Whether to receive text to transmit on specified UDP port"
type: integer
udpAddress:
description: "UDP address to receive text to transmit via"
type: string
udpPort:
description: "UDP port to receive text to transmit via"
type: integer
rgbColor:
type: integer
title:
type: string
streamIndex:
description: MIMO channel. Not relevant when connected to SI (single Rx).
type: integer
useReverseAPI:
description: Synchronize with reverse API (1 for yes, 0 for no)
type: integer
reverseAPIAddress:
type: string
reverseAPIPort:
type: integer
reverseAPIDeviceIndex:
type: integer
reverseAPIChannelIndex:
type: integer
channelMarker:
$ref: "http://swgserver:8081/api/swagger/include/ChannelMarker.yaml#/ChannelMarker"
rollupState:
$ref: "http://swgserver:8081/api/swagger/include/RollupState.yaml#/RollupState"
RTTYModReport:
description: RTTYMod
properties:
channelPowerDB:
description: power transmitted in channel (dB)
type: number
format: float
channelSampleRate:
type: integer
RTTYModActions:
description: RTTYMod
properties:
tx:
type: integer
description: >
Transmit current text
* 0 - Do nothing
* 1 - Transmit
payload:
type: object
properties:
data:
type: string