1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

SDRdaemon plugin: fixes

This commit is contained in:
f4exb 2016-02-20 23:02:34 +01:00
parent 952a32172d
commit 48d858ce5d
6 changed files with 64 additions and 25 deletions

View File

@ -34,9 +34,9 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t rateDivider) :
m_lz4InSize(0),
m_lz4OutBuffer(0),
m_frameSize(0),
m_nbDecodes(0),
m_nbSuccessfulDecodes(0),
m_nbCRCOK(0),
m_nbLz4Decodes(0),
m_nbLz4SuccessfulDecodes(0),
m_nbLz4CRCOK(0),
m_dataCRC(0),
m_sampleRate(1000000),
m_sampleBytes(2),
@ -161,32 +161,32 @@ void SDRdaemonBuffer::writeDataLZ4(const char *array, uint32_t length)
if (m_lz4InCount >= m_lz4InSize) // full input compressed block retrieved
{
if (m_nbDecodes == 100)
if (m_nbLz4Decodes == 100)
{
std::cerr << "SDRdaemonBuffer::writeAndReadLZ4:"
<< " decoding: " << m_nbCRCOK
<< ":" << m_nbSuccessfulDecodes
<< "/" << m_nbDecodes
<< " decoding: " << m_nbLz4CRCOK
<< ":" << m_nbLz4SuccessfulDecodes
<< "/" << m_nbLz4Decodes
<< std::endl;
m_nbDecodes = 0;
m_nbSuccessfulDecodes = 0;
m_nbCRCOK = 0;
m_nbLz4Decodes = 0;
m_nbLz4SuccessfulDecodes = 0;
m_nbLz4CRCOK = 0;
}
uint64_t crc64 = m_crc64.calculate_crc(m_lz4InBuffer, m_lz4InSize);
if (memcmp(&crc64, &m_dataCRC, 8) == 0)
{
m_nbCRCOK++;
m_nbLz4CRCOK++;
}
int compressedSize = LZ4_decompress_fast((const char*) m_lz4InBuffer, (char*) &m_rawBuffer[m_writeIndex], m_frameSize);
m_nbDecodes++;
m_nbLz4Decodes++;
if (compressedSize == m_lz4InSize)
{
m_nbSuccessfulDecodes++;
m_nbLz4SuccessfulDecodes++;
}
writeToRawBufferLZ4((const char *) m_lz4InBuffer, m_frameSize);
@ -214,11 +214,11 @@ void SDRdaemonBuffer::writeToRawBufferUncompressed(const char *array, uint32_t l
void SDRdaemonBuffer::writeToRawBufferLZ4(const char *array, uint32_t length)
{
int compressedSize = LZ4_decompress_fast((const char*) m_lz4InBuffer, (char*) m_lz4OutBuffer, m_frameSize);
m_nbDecodes++;
m_nbLz4Decodes++;
if (compressedSize == m_lz4InSize)
{
m_nbSuccessfulDecodes++;
m_nbLz4SuccessfulDecodes++;
}
writeToRawBufferUncompressed((const char *) m_lz4OutBuffer, m_frameSize);

View File

@ -94,9 +94,9 @@ private:
uint32_t m_lz4InSize; //!< Size in bytes of the LZ4 input data
uint8_t *m_lz4OutBuffer; //!< Buffer for LZ4 uncompressed output
uint32_t m_frameSize; //!< Size in bytes of one uncompressed frame
uint32_t m_nbDecodes;
uint32_t m_nbSuccessfulDecodes;
uint32_t m_nbCRCOK;
uint32_t m_nbLz4Decodes;
uint32_t m_nbLz4SuccessfulDecodes;
uint32_t m_nbLz4CRCOK;
uint64_t m_dataCRC;
uint32_t m_sampleRate; //!< Current sample rate in Hz

View File

@ -234,12 +234,18 @@
</item>
<item>
<widget class="QLineEdit" name="address">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Data connection IP address</string>
</property>
<property name="text">
<string>127.0.0.1</string>
</property>
@ -254,12 +260,18 @@
</item>
<item>
<widget class="QLineEdit" name="port">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Data connection port</string>
</property>
<property name="text">
<string>9090</string>
</property>
@ -267,6 +279,9 @@
</item>
<item>
<widget class="QPushButton" name="applyButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>30</width>

View File

@ -47,7 +47,7 @@ SDRdaemonInput::SDRdaemonInput(const QTimer& masterTimer) :
{
m_sampleFifo.setSize(96000 * 4);
m_SDRdaemonUDPHandler = new SDRdaemonUDPHandler(&m_sampleFifo, getOutputMessageQueueToGUI());
m_SDRdaemonUDPHandler->connectTimer(m_masterTimer);
m_SDRdaemonUDPHandler->connectTimer(&m_masterTimer);
}
SDRdaemonInput::~SDRdaemonInput()
@ -101,7 +101,8 @@ bool SDRdaemonInput::handleMessage(const Message& message)
{
if (MsgConfigureSDRdaemonUDPLink::match(message))
{
// TODO: change UDP settings
MsgConfigureSDRdaemonUDPLink& conf = (MsgConfigureSDRdaemonUDPLink&) message;
m_SDRdaemonUDPHandler->configureUDPLink(conf.getAddress(), conf.getPort());
return true;
}
else if (MsgConfigureSDRdaemonAutoCorr::match(message))

View File

@ -16,6 +16,7 @@
#include <QUdpSocket>
#include <QDebug>
#include <QTimer>
#include <unistd.h>
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
@ -40,7 +41,8 @@ SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *o
m_tv_usec(0),
m_outputMessageQueueToGUI(outputMessageQueueToGUI),
m_tickCount(0),
m_samplesCount(0)
m_samplesCount(0),
m_timer(0)
{
m_udpBuf = new char[SDRdaemonBuffer::m_udpPayloadSize];
}
@ -53,6 +55,8 @@ SDRdaemonUDPHandler::~SDRdaemonUDPHandler()
void SDRdaemonUDPHandler::start()
{
qDebug("SDRdaemonUDPHandler::start");
if (!m_dataSocket)
{
m_dataSocket = new QUdpSocket(this);
@ -62,7 +66,7 @@ void SDRdaemonUDPHandler::start()
{
if (m_dataSocket->bind(m_dataAddress, m_dataPort))
{
qDebug("SDRdaemonUDPHandler::start: bind data socket to port %d", m_dataPort);
qDebug("SDRdaemonUDPHandler::start: bind data socket to %s:%d", m_dataAddress.toString().toStdString().c_str(), m_dataPort);
connect(m_dataSocket, SIGNAL(readyRead()), this, SLOT(dataReadyRead()), Qt::QueuedConnection); // , Qt::QueuedConnection
m_dataConnected = true;
}
@ -90,6 +94,22 @@ void SDRdaemonUDPHandler::stop()
}
}
void SDRdaemonUDPHandler::configureUDPLink(const QString& address, quint16 port)
{
qDebug("SDRdaemonUDPHandler::configureUDPLink: %s:%d", address.toStdString().c_str(), port);
bool addressOK = m_dataAddress.setAddress(address);
if (!addressOK)
{
qWarning("SDRdaemonUDPHandler::configureUDPLink: invalid address %s. Set to localhost.", address.toStdString().c_str());
m_dataAddress = QHostAddress::LocalHost;
}
stop();
m_dataPort = port;
start();
}
void SDRdaemonUDPHandler::dataReadyRead()
{
while (m_dataSocket->hasPendingDatagrams())
@ -163,10 +183,11 @@ void SDRdaemonUDPHandler::setSamplerate(uint32_t samplerate)
<< " #samples per chunk: " << (m_chunksize/SDRdaemonBuffer::m_iqSampleSize);
}
void SDRdaemonUDPHandler::connectTimer(const QTimer& timer)
void SDRdaemonUDPHandler::connectTimer(const QTimer* timer)
{
qDebug() << "SDRdaemonUDPHandler::connectTimer";
connect(&timer, SIGNAL(timeout()), this, SLOT(tick()));
m_timer = timer;
connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
}
void SDRdaemonUDPHandler::tick()

View File

@ -35,9 +35,10 @@ class SDRdaemonUDPHandler : public QObject
public:
SDRdaemonUDPHandler(SampleFifo* sampleFifo, MessageQueue *outputMessageQueueToGUI);
~SDRdaemonUDPHandler();
void connectTimer(const QTimer& timer);
void connectTimer(const QTimer* timer);
void start();
void stop();
void configureUDPLink(const QString& address, quint16 port);
public slots:
void dataReadyRead();
@ -59,6 +60,7 @@ private:
MessageQueue *m_outputMessageQueueToGUI;
uint32_t m_tickCount;
std::size_t m_samplesCount;
const QTimer *m_timer;
static const int m_rateDivider;