diff --git a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.cpp b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.cpp index 6f15f8613..53e81aad3 100644 --- a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.cpp +++ b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.cpp @@ -84,7 +84,6 @@ SDRdaemonFECGui::SDRdaemonFECGui(DeviceSourceAPI *deviceAPI, QWidget* parent) : ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->centerFrequency->setValueRange(7, 0, pow(10,7)); - //connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); does not exist in this class connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); m_statusTimer.start(500); connect(&(deviceAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick())); @@ -148,46 +147,6 @@ void SDRdaemonFECGui::resetToDefaults() QByteArray SDRdaemonFECGui::serialize() const { return m_settings.serialize(); -// bool ok; -// SimpleSerializer s(1); -// -// s.writeString(1, ui->address->text()); -// uint32_t uintval = ui->dataPort->text().toInt(&ok); -// -// if((!ok) || (uintval < 1024) || (uintval > 65535)) { -// uintval = 9090; -// } -// -// s.writeU32(2, uintval); -// s.writeBool(3, m_dcBlock); -// s.writeBool(4, m_iqCorrection); -// -// uintval = ui->controlPort->text().toInt(&ok); -// -// if((!ok) || (uintval < 1024) || (uintval > 65535)) { -// uintval = 9091; -// } -// -// s.writeU32(5, uintval); -// -// uint32_t confFrequency = ui->freq->text().toInt(&ok); -// -// if (ok) { -// s.writeU32(6, confFrequency); -// } -// -// s.writeU32(7, ui->decim->currentIndex()); -// s.writeU32(8, ui->fcPos->currentIndex()); -// -// uint32_t sampleRate = ui->sampleRate->text().toInt(&ok); -// -// if (ok) { -// s.writeU32(9, sampleRate); -// } -// -// s.writeString(10, ui->specificParms->text()); -// -// return s.final(); } bool SDRdaemonFECGui::deserialize(const QByteArray& data) @@ -209,80 +168,6 @@ bool SDRdaemonFECGui::deserialize(const QByteArray& data) blockApplySettings(false); return false; } -// SimpleDeserializer d(data); -// QString address; -// quint16 dataPort; -// bool dcBlock; -// bool iqCorrection; -// uint32_t confFrequency; -// uint32_t confSampleRate; -// uint32_t confDecim; -// uint32_t confFcPos; -// QString confSpecificParms; -// -// if (!d.isValid()) -// { -// resetToDefaults(); -// displaySettings(); -// return false; -// } -// -// if (d.getVersion() == 1) -// { -// uint32_t uintval; -// d.readString(1, &address, "127.0.0.1"); -// d.readU32(2, &uintval, 9090); -// -// if ((uintval > 1024) && (uintval < 65536)) { -// dataPort = uintval; -// } else { -// dataPort = 9090; -// } -// -// d.readBool(3, &dcBlock, false); -// d.readBool(4, &iqCorrection, false); -// d.readU32(5, &uintval, 9091); -// -// if ((uintval > 1024) && (uintval < 65536)) { -// m_controlPort = uintval; -// } else { -// m_controlPort = 9091; -// } -// -// d.readU32(6, &confFrequency, 435000); -// d.readU32(7, &confDecim, 3); -// d.readU32(8, &confFcPos, 2); -// d.readU32(9, &confSampleRate, 1000); -// d.readString(10, &confSpecificParms, ""); -// -// if ((address != m_address) || (dataPort != m_dataPort)) -// { -// m_address = address; -// m_dataPort = dataPort; -// configureUDPLink(); -// } -// -// if ((dcBlock != m_dcBlock) || (iqCorrection != m_iqCorrection)) -// { -// m_dcBlock = dcBlock; -// m_iqCorrection = iqCorrection; -// configureAutoCorrections(); -// } -// -// displaySettings(); -// displayConfigurationParameters(confFrequency, confDecim, confFcPos, confSampleRate, confSpecificParms); -// m_initSendConfiguration = true; -// return true; -// } -// else -// { -// resetToDefaults(); -// displaySettings(); -// QString defaultSpecificParameters(""); -// displayConfigurationParameters(435000, 3, 2, 1000, defaultSpecificParameters); -// m_initSendConfiguration = true; -// return false; -// } } qint64 SDRdaemonFECGui::getCenterFrequency() const @@ -388,11 +273,7 @@ void SDRdaemonFECGui::updateSampleRateAndFrequency() void SDRdaemonFECGui::displaySettings() { ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); -// ui->sampleRate->setValue(m_settings.m_sampleRate); ui->deviceRateText->setText(tr("%1k").arg(m_sampleRate / 1000.0)); -// ui->txDelay->setValue(m_settings.m_txDelay*100); -// ui->txDelayText->setText(tr("%1").arg(m_settings.m_txDelay*100)); -// ui->nbFECBlocks->setValue(m_settings.m_nbFECBlocks); ui->freq->setText(QString::number(m_settings.m_centerFrequency / 1000)); ui->decim->setCurrentIndex(m_settings.m_log2Decim); @@ -411,9 +292,6 @@ void SDRdaemonFECGui::displaySettings() ui->controlPort->setText(tr("%1").arg(m_settings.m_controlPort)); ui->specificParms->setText(m_settings.m_specificParameters); -// ui->address->setText(m_address); -// ui->dataPort->setText(QString::number(m_dataPort)); -// ui->controlPort->setText(QString::number(m_controlPort)); ui->dcOffset->setChecked(m_settings.m_dcBlock); ui->iqImbalance->setChecked(m_settings.m_iqCorrection); @@ -527,20 +405,6 @@ void SDRdaemonFECGui::sendSettings() m_updateTimer.start(100); } -//void SDRdaemonFECGui::displayConfigurationParameters(uint32_t freq, -// uint32_t log2Decim, -// uint32_t fcPos, -// uint32_t sampleRate, -// QString& specParms) -//{ -// ui->freq->setText(QString::number(freq)); -// ui->decim->setCurrentIndex(log2Decim); -// ui->fcPos->setCurrentIndex(fcPos); -// ui->sampleRate->setText(QString::number(sampleRate)); -// ui->specificParms->setText(specParms); -// ui->specificParms->setCursorPosition(0); -//} - void SDRdaemonFECGui::on_applyButton_clicked(bool checked __attribute__((unused))) { m_settings.m_address = ui->address->text(); @@ -562,103 +426,14 @@ void SDRdaemonFECGui::on_applyButton_clicked(bool checked __attribute__((unused) } configureUDPLink(); - -// bool dataOk, ctlOk; -// QString udpAddress = ui->address->text(); -// int udpDataPort = ui->dataPort->text().toInt(&dataOk); -// int tcpCtlPort = ui->controlPort->text().toInt(&ctlOk); -// -// if((!dataOk) || (udpDataPort < 1024) || (udpDataPort > 65535)) -// { -// udpDataPort = 9090; -// } -// -// if((!ctlOk) || (tcpCtlPort < 1024) || (tcpCtlPort > 65535)) -// { -// tcpCtlPort = 9091; -// } -// -// m_address = udpAddress; -// m_dataPort = udpDataPort; -// m_controlPort = tcpCtlPort; -// -// if (m_addressEdited || m_dataPortEdited) -// { -// configureUDPLink(); -// m_addressEdited = false; -// m_dataPortEdited = false; -// } } void SDRdaemonFECGui::on_sendButton_clicked(bool checked __attribute__((unused))) { sendControl(true); -// sendConfiguration(); ui->specificParms->setCursorPosition(0); } -//void SDRdaemonFECGui::sendConfiguration() -//{ -// QString remoteAddress; -// ((SDRdaemonFECInput *) m_sampleSource)->getRemoteAddress(remoteAddress); -// -// if (remoteAddress != m_remoteAddress) -// { -// m_remoteAddress = remoteAddress; -// std::ostringstream os; -// os << "tcp://" << m_remoteAddress.toStdString() << ":" << m_controlPort; -// std::string addrstrng = os.str(); -// int rc = nn_connect(m_sender, addrstrng.c_str()); -// -// if (rc < 0) { -// qDebug() << "SDRdaemonGui::sendConfiguration: connexion to " << addrstrng.c_str() << " failed"; -// QMessageBox::information(this, tr("Message"), tr("Cannot connect to remote control port")); -// } else { -// qDebug() << "SDRdaemonGui::sendConfiguration: connexion to " << addrstrng.c_str() << " successful"; -// } -// } -// -// std::ostringstream os; -// bool ok; -// -// os << "decim=" << ui->decim->currentIndex() -// << ",fcpos=" << ui->fcPos->currentIndex(); -// -// uint64_t freq = ui->freq->text().toInt(&ok); -// -// if (ok) { -// os << ",freq=" << freq*1000LL; -// } else { -// QMessageBox::information(this, tr("Message"), tr("Invalid frequency")); -// } -// -// uint32_t srate = ui->sampleRate->text().toInt(&ok); -// -// if (ok) { -// os << ",srate=" << srate*1000; -// } else { -// QMessageBox::information(this, tr("Message"), tr("invalid sample rate")); -// } -// -// if ((ui->specificParms->text()).size() > 0) { -// os << "," << ui->specificParms->text().toStdString(); -// } -// -// int config_size = os.str().size(); -// int rc = nn_send(m_sender, (void *) os.str().c_str(), config_size, 0); -// -// if (rc != config_size) -// { -// QMessageBox::information(this, tr("Message"), tr("Cannot send message to remote control port")); -// } -// else -// { -// qDebug() << "SDRdaemonGui::sendConfiguration:" -// << " remoteAddress: " << remoteAddress -// << " message: " << os.str().c_str(); -// } -//} - void SDRdaemonFECGui::on_address_returnPressed() { m_settings.m_address = ui->address->text(); @@ -819,12 +594,6 @@ void SDRdaemonFECGui::updateWithStreamData() void SDRdaemonFECGui::updateWithStreamTime() { -// if (m_initSendConfiguration) -// { -// sendConfiguration(); -// m_initSendConfiguration = false; -// } - quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL); QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec); QString s_date = dt.toString("yyyy-MM-dd hh:mm:ss.zzz"); @@ -833,9 +602,9 @@ void SDRdaemonFECGui::updateWithStreamTime() if (m_framesDecodingStatus == 2) { ui->allFramesDecoded->setStyleSheet("QToolButton { background-color : green; }"); } else if (m_framesDecodingStatus == 1) { - ui->allFramesDecoded->setStyleSheet("QToolButton { background-color : magenta; }"); - } else { ui->allFramesDecoded->setStyleSheet("QToolButton { background:rgb(56,56,56); }"); + } else { + ui->allFramesDecoded->setStyleSheet("QToolButton { background-color : red; }"); } QString s = QString::number(m_bufferLengthInSecs, 'f', 1); @@ -856,18 +625,9 @@ void SDRdaemonFECGui::updateWithStreamTime() ui->minNbBlocksText->setPalette(m_paletteWhiteText); } - s = QString::number(m_avgNbBlocks, 'f', 1); - ui->avgNbBlocksText->setText(tr("%1").arg(s)); - - s = QString::number(m_minNbOriginalBlocks, 'f', 0); - ui->minNbOriginalText->setText(tr("%1").arg(s)); - s = QString::number(m_maxNbRecovery, 'f', 0); ui->maxNbRecoveryText->setText(tr("%1").arg(s)); - s = QString::number(m_avgNbRecovery, 'f', 1); - ui->avgNbRecoveryText->setText(tr("%1").arg(s)); - s = QString::number(m_nbOriginalBlocks + m_nbFECBlocks, 'f', 0); QString s1 = QString::number(m_nbFECBlocks, 'f', 0); ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1)); diff --git a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.h b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.h index 79ad8edcd..6b0fadaa9 100644 --- a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.h +++ b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.h @@ -101,13 +101,6 @@ private: void blockApplySettings(bool block); void displaySettings(); - -// void displayConfigurationParameters(uint32_t freq, -// uint32_t log2Decim, -// uint32_t fcPos, -// uint32_t sampleRate, -// QString& specParms); - void displayTime(); void sendControl(bool force = false); void sendSettings(); @@ -116,7 +109,6 @@ private: void updateWithAcquisition(); void updateWithStreamData(); void updateWithStreamTime(); -// void sendConfiguration(); void updateSampleRateAndFrequency(); private slots: diff --git a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.ui b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.ui index cadf5a5c1..52d3dea1b 100644 --- a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.ui +++ b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecgui.ui @@ -366,6 +366,42 @@ + + + + + 52 + 0 + + + + Nominal number of blocks per frame: Total/FEC + + + 000/000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + Frames status: green = all original received, none = some recovered by FEC, red = some lost + + + ... + + + + :/locked.png:/locked.png + + + @@ -385,68 +421,6 @@ - - - - - 35 - 0 - - - - Average number of blocks retrieved per frame - - - 000.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - false - - - Frames status: green = all original received, pink = some recovered by FEC, none = some lost - - - ... - - - - :/locked.png:/locked.png - - - - - - - - 24 - 0 - - - - Minimum number of original blocks retrieved per frame - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Vertical - - - @@ -467,47 +441,67 @@ - - - - 35 - 0 - - - - Average number of recovery blocks used per frame - - - 000.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - + Qt::Vertical - + + + + 22 + 16777215 + + + + Event counts reset + + + 0 + + + + + - 52 + 25 0 - Nominal number of blocks per frame: Total/FEC + Number of uncrecoverable errors since event counts reset - 000/000 + 000 - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 25 + 0 + + + + Number of correctable errors since event counts reset + + + 000 + + + + + + + Time since last event counts reset + + + 00:00:00 diff --git a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecinput.cpp b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecinput.cpp index 5cdb1b4c2..ba1caf562 100644 --- a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecinput.cpp +++ b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecinput.cpp @@ -107,7 +107,14 @@ void SDRdaemonFECInput::getRemoteAddress(QString &s) bool SDRdaemonFECInput::handleMessage(const Message& message) { - if (MsgConfigureSDRdaemonUDPLink::match(message)) + if (MsgConfigureSDRdaemonFEC::match(message)) + { + qDebug() << "SDRdaemonFECInput::handleMessage:" << message.getIdentifier(); + //MsgConfigureSDRdaemonFEC& conf = (MsgConfigureSDRdaemonFEC&) message; + //applySettings(conf.getSettings(), conf.getForce()); + return true; + } + else if (MsgConfigureSDRdaemonUDPLink::match(message)) { MsgConfigureSDRdaemonUDPLink& conf = (MsgConfigureSDRdaemonUDPLink&) message; m_SDRdaemonUDPHandler->configureUDPLink(conf.getAddress(), conf.getPort()); diff --git a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecsettings.cpp b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecsettings.cpp new file mode 100644 index 000000000..b5b2ea307 --- /dev/null +++ b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecsettings.cpp @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// 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 // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "util/simpleserializer.h" +#include "sdrdaemonfecsettings.h" + +SDRdaemonFECSettings::SDRdaemonFECSettings() +{ + resetToDefaults(); +} + +void SDRdaemonFECSettings::resetToDefaults() +{ + m_centerFrequency = 435000*1000; + m_sampleRate = 256000; + m_log2Decim = 4; + m_txDelay = 0.5; + m_nbFECBlocks = 0; + m_address = "127.0.0.1"; + m_dataPort = 9092; + m_controlPort = 9093; + m_specificParameters = ""; + m_dcBlock = false; + m_iqCorrection = false; + m_fcPos = 2; // center +} + +QByteArray SDRdaemonFECSettings::serialize() const +{ + SimpleSerializer s(1); + + s.writeU64(1, m_sampleRate); + s.writeU32(2, m_log2Decim); + s.writeFloat(3, m_txDelay); + s.writeU32(4, m_nbFECBlocks); + s.writeString(5, m_address); + s.writeU32(6, m_dataPort); + s.writeU32(7, m_controlPort); + s.writeString(8, m_specificParameters); + s.writeBool(9, m_dcBlock); + s.writeBool(10, m_iqCorrection); + s.writeU32(11, m_fcPos); + + return s.final(); +} + +bool SDRdaemonFECSettings::deserialize(const QByteArray& data) +{ + SimpleDeserializer d(data); + + if (!d.isValid()) + { + resetToDefaults(); + return false; + } + + if (d.getVersion() == 1) + { + quint32 uintval; + d.readU64(1, &m_sampleRate, 48000); + d.readU32(2, &m_log2Decim, 0); + d.readFloat(3, &m_txDelay, 0.5); + d.readU32(4, &m_nbFECBlocks, 0); + d.readString(5, &m_address, "127.0.0.1"); + d.readU32(6, &uintval, 9090); + m_dataPort = uintval % (1<<16); + d.readU32(7, &uintval, 9090); + m_controlPort = uintval % (1<<16); + d.readString(8, &m_specificParameters, ""); + d.readBool(9, &m_dcBlock, false); + d.readBool(10, &m_iqCorrection, false); + d.readU32(11, &m_fcPos, 2); + return true; + } + else + { + resetToDefaults(); + return false; + } +} + + + diff --git a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecsettings.h b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecsettings.h new file mode 100644 index 000000000..9acd6d293 --- /dev/null +++ b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecsettings.h @@ -0,0 +1,42 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// 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 // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef PLUGINS_SAMPLESOURCE_SDRDAEMONFEC_SDRDAEMONFECSETTINGS_H_ +#define PLUGINS_SAMPLESOURCE_SDRDAEMONFEC_SDRDAEMONFECSETTINGS_H_ + +#include + +struct SDRdaemonFECSettings { + quint64 m_centerFrequency; + quint64 m_sampleRate; + quint32 m_log2Decim; + float m_txDelay; + quint32 m_nbFECBlocks; + QString m_address; + quint16 m_dataPort; + quint16 m_controlPort; + QString m_specificParameters; + bool m_dcBlock; + bool m_iqCorrection; + quint32 m_fcPos; + + SDRdaemonFECSettings(); + void resetToDefaults(); + QByteArray serialize() const; + bool deserialize(const QByteArray& data); +}; + +#endif /* PLUGINS_SAMPLESOURCE_SDRDAEMONFEC_SDRDAEMONFECSETTINGS_H_ */ diff --git a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecudphandler.cpp b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecudphandler.cpp index 5360de83a..8f3df27d6 100644 --- a/plugins/samplesource/sdrdaemonfec/sdrdaemonfecudphandler.cpp +++ b/plugins/samplesource/sdrdaemonfec/sdrdaemonfecudphandler.cpp @@ -233,7 +233,8 @@ void SDRdaemonFECUDPHandler::tick() int nbFECblocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbFECBlocks; m_tickCount = 0; - framesDecodingStatus = (minNbOriginalBlocks == nbOriginalBlocks ? 2 : (minNbOriginalBlocks < nbOriginalBlocks - nbFECblocks ? 0 : 1)); + //framesDecodingStatus = (minNbOriginalBlocks == nbOriginalBlocks ? 2 : (minNbOriginalBlocks < nbOriginalBlocks - nbFECblocks ? 0 : 1)); + framesDecodingStatus = (minNbBlocks == 128 + nbFECblocks ? 2 : (minNbBlocks < 128 ? 0 : 1)); SDRdaemonFECInput::MsgReportSDRdaemonFECStreamTiming *report = SDRdaemonFECInput::MsgReportSDRdaemonFECStreamTiming::create( m_tv_sec,