mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-04 06:07:49 -04:00
SDRdaemon plugin: fixes
This commit is contained in:
parent
952a32172d
commit
48d858ce5d
@ -34,9 +34,9 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t rateDivider) :
|
|||||||
m_lz4InSize(0),
|
m_lz4InSize(0),
|
||||||
m_lz4OutBuffer(0),
|
m_lz4OutBuffer(0),
|
||||||
m_frameSize(0),
|
m_frameSize(0),
|
||||||
m_nbDecodes(0),
|
m_nbLz4Decodes(0),
|
||||||
m_nbSuccessfulDecodes(0),
|
m_nbLz4SuccessfulDecodes(0),
|
||||||
m_nbCRCOK(0),
|
m_nbLz4CRCOK(0),
|
||||||
m_dataCRC(0),
|
m_dataCRC(0),
|
||||||
m_sampleRate(1000000),
|
m_sampleRate(1000000),
|
||||||
m_sampleBytes(2),
|
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_lz4InCount >= m_lz4InSize) // full input compressed block retrieved
|
||||||
{
|
{
|
||||||
if (m_nbDecodes == 100)
|
if (m_nbLz4Decodes == 100)
|
||||||
{
|
{
|
||||||
std::cerr << "SDRdaemonBuffer::writeAndReadLZ4:"
|
std::cerr << "SDRdaemonBuffer::writeAndReadLZ4:"
|
||||||
<< " decoding: " << m_nbCRCOK
|
<< " decoding: " << m_nbLz4CRCOK
|
||||||
<< ":" << m_nbSuccessfulDecodes
|
<< ":" << m_nbLz4SuccessfulDecodes
|
||||||
<< "/" << m_nbDecodes
|
<< "/" << m_nbLz4Decodes
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
m_nbDecodes = 0;
|
m_nbLz4Decodes = 0;
|
||||||
m_nbSuccessfulDecodes = 0;
|
m_nbLz4SuccessfulDecodes = 0;
|
||||||
m_nbCRCOK = 0;
|
m_nbLz4CRCOK = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t crc64 = m_crc64.calculate_crc(m_lz4InBuffer, m_lz4InSize);
|
uint64_t crc64 = m_crc64.calculate_crc(m_lz4InBuffer, m_lz4InSize);
|
||||||
|
|
||||||
if (memcmp(&crc64, &m_dataCRC, 8) == 0)
|
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);
|
int compressedSize = LZ4_decompress_fast((const char*) m_lz4InBuffer, (char*) &m_rawBuffer[m_writeIndex], m_frameSize);
|
||||||
m_nbDecodes++;
|
m_nbLz4Decodes++;
|
||||||
|
|
||||||
if (compressedSize == m_lz4InSize)
|
if (compressedSize == m_lz4InSize)
|
||||||
{
|
{
|
||||||
m_nbSuccessfulDecodes++;
|
m_nbLz4SuccessfulDecodes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeToRawBufferLZ4((const char *) m_lz4InBuffer, m_frameSize);
|
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)
|
void SDRdaemonBuffer::writeToRawBufferLZ4(const char *array, uint32_t length)
|
||||||
{
|
{
|
||||||
int compressedSize = LZ4_decompress_fast((const char*) m_lz4InBuffer, (char*) m_lz4OutBuffer, m_frameSize);
|
int compressedSize = LZ4_decompress_fast((const char*) m_lz4InBuffer, (char*) m_lz4OutBuffer, m_frameSize);
|
||||||
m_nbDecodes++;
|
m_nbLz4Decodes++;
|
||||||
|
|
||||||
if (compressedSize == m_lz4InSize)
|
if (compressedSize == m_lz4InSize)
|
||||||
{
|
{
|
||||||
m_nbSuccessfulDecodes++;
|
m_nbLz4SuccessfulDecodes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeToRawBufferUncompressed((const char *) m_lz4OutBuffer, m_frameSize);
|
writeToRawBufferUncompressed((const char *) m_lz4OutBuffer, m_frameSize);
|
||||||
|
@ -94,9 +94,9 @@ private:
|
|||||||
uint32_t m_lz4InSize; //!< Size in bytes of the LZ4 input data
|
uint32_t m_lz4InSize; //!< Size in bytes of the LZ4 input data
|
||||||
uint8_t *m_lz4OutBuffer; //!< Buffer for LZ4 uncompressed output
|
uint8_t *m_lz4OutBuffer; //!< Buffer for LZ4 uncompressed output
|
||||||
uint32_t m_frameSize; //!< Size in bytes of one uncompressed frame
|
uint32_t m_frameSize; //!< Size in bytes of one uncompressed frame
|
||||||
uint32_t m_nbDecodes;
|
uint32_t m_nbLz4Decodes;
|
||||||
uint32_t m_nbSuccessfulDecodes;
|
uint32_t m_nbLz4SuccessfulDecodes;
|
||||||
uint32_t m_nbCRCOK;
|
uint32_t m_nbLz4CRCOK;
|
||||||
uint64_t m_dataCRC;
|
uint64_t m_dataCRC;
|
||||||
|
|
||||||
uint32_t m_sampleRate; //!< Current sample rate in Hz
|
uint32_t m_sampleRate; //!< Current sample rate in Hz
|
||||||
|
@ -234,12 +234,18 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="address">
|
<widget class="QLineEdit" name="address">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>120</width>
|
<width>120</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Data connection IP address</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>127.0.0.1</string>
|
<string>127.0.0.1</string>
|
||||||
</property>
|
</property>
|
||||||
@ -254,12 +260,18 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="port">
|
<widget class="QLineEdit" name="port">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>50</width>
|
<width>50</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Data connection port</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>9090</string>
|
<string>9090</string>
|
||||||
</property>
|
</property>
|
||||||
@ -267,6 +279,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="applyButton">
|
<widget class="QPushButton" name="applyButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>30</width>
|
<width>30</width>
|
||||||
|
@ -47,7 +47,7 @@ SDRdaemonInput::SDRdaemonInput(const QTimer& masterTimer) :
|
|||||||
{
|
{
|
||||||
m_sampleFifo.setSize(96000 * 4);
|
m_sampleFifo.setSize(96000 * 4);
|
||||||
m_SDRdaemonUDPHandler = new SDRdaemonUDPHandler(&m_sampleFifo, getOutputMessageQueueToGUI());
|
m_SDRdaemonUDPHandler = new SDRdaemonUDPHandler(&m_sampleFifo, getOutputMessageQueueToGUI());
|
||||||
m_SDRdaemonUDPHandler->connectTimer(m_masterTimer);
|
m_SDRdaemonUDPHandler->connectTimer(&m_masterTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDRdaemonInput::~SDRdaemonInput()
|
SDRdaemonInput::~SDRdaemonInput()
|
||||||
@ -101,7 +101,8 @@ bool SDRdaemonInput::handleMessage(const Message& message)
|
|||||||
{
|
{
|
||||||
if (MsgConfigureSDRdaemonUDPLink::match(message))
|
if (MsgConfigureSDRdaemonUDPLink::match(message))
|
||||||
{
|
{
|
||||||
// TODO: change UDP settings
|
MsgConfigureSDRdaemonUDPLink& conf = (MsgConfigureSDRdaemonUDPLink&) message;
|
||||||
|
m_SDRdaemonUDPHandler->configureUDPLink(conf.getAddress(), conf.getPort());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (MsgConfigureSDRdaemonAutoCorr::match(message))
|
else if (MsgConfigureSDRdaemonAutoCorr::match(message))
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTimer>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "dsp/dspcommands.h"
|
#include "dsp/dspcommands.h"
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
@ -40,7 +41,8 @@ SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *o
|
|||||||
m_tv_usec(0),
|
m_tv_usec(0),
|
||||||
m_outputMessageQueueToGUI(outputMessageQueueToGUI),
|
m_outputMessageQueueToGUI(outputMessageQueueToGUI),
|
||||||
m_tickCount(0),
|
m_tickCount(0),
|
||||||
m_samplesCount(0)
|
m_samplesCount(0),
|
||||||
|
m_timer(0)
|
||||||
{
|
{
|
||||||
m_udpBuf = new char[SDRdaemonBuffer::m_udpPayloadSize];
|
m_udpBuf = new char[SDRdaemonBuffer::m_udpPayloadSize];
|
||||||
}
|
}
|
||||||
@ -53,6 +55,8 @@ SDRdaemonUDPHandler::~SDRdaemonUDPHandler()
|
|||||||
|
|
||||||
void SDRdaemonUDPHandler::start()
|
void SDRdaemonUDPHandler::start()
|
||||||
{
|
{
|
||||||
|
qDebug("SDRdaemonUDPHandler::start");
|
||||||
|
|
||||||
if (!m_dataSocket)
|
if (!m_dataSocket)
|
||||||
{
|
{
|
||||||
m_dataSocket = new QUdpSocket(this);
|
m_dataSocket = new QUdpSocket(this);
|
||||||
@ -62,7 +66,7 @@ void SDRdaemonUDPHandler::start()
|
|||||||
{
|
{
|
||||||
if (m_dataSocket->bind(m_dataAddress, m_dataPort))
|
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
|
connect(m_dataSocket, SIGNAL(readyRead()), this, SLOT(dataReadyRead()), Qt::QueuedConnection); // , Qt::QueuedConnection
|
||||||
m_dataConnected = true;
|
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()
|
void SDRdaemonUDPHandler::dataReadyRead()
|
||||||
{
|
{
|
||||||
while (m_dataSocket->hasPendingDatagrams())
|
while (m_dataSocket->hasPendingDatagrams())
|
||||||
@ -163,10 +183,11 @@ void SDRdaemonUDPHandler::setSamplerate(uint32_t samplerate)
|
|||||||
<< " #samples per chunk: " << (m_chunksize/SDRdaemonBuffer::m_iqSampleSize);
|
<< " #samples per chunk: " << (m_chunksize/SDRdaemonBuffer::m_iqSampleSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRdaemonUDPHandler::connectTimer(const QTimer& timer)
|
void SDRdaemonUDPHandler::connectTimer(const QTimer* timer)
|
||||||
{
|
{
|
||||||
qDebug() << "SDRdaemonUDPHandler::connectTimer";
|
qDebug() << "SDRdaemonUDPHandler::connectTimer";
|
||||||
connect(&timer, SIGNAL(timeout()), this, SLOT(tick()));
|
m_timer = timer;
|
||||||
|
connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRdaemonUDPHandler::tick()
|
void SDRdaemonUDPHandler::tick()
|
||||||
|
@ -35,9 +35,10 @@ class SDRdaemonUDPHandler : public QObject
|
|||||||
public:
|
public:
|
||||||
SDRdaemonUDPHandler(SampleFifo* sampleFifo, MessageQueue *outputMessageQueueToGUI);
|
SDRdaemonUDPHandler(SampleFifo* sampleFifo, MessageQueue *outputMessageQueueToGUI);
|
||||||
~SDRdaemonUDPHandler();
|
~SDRdaemonUDPHandler();
|
||||||
void connectTimer(const QTimer& timer);
|
void connectTimer(const QTimer* timer);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
void configureUDPLink(const QString& address, quint16 port);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void dataReadyRead();
|
void dataReadyRead();
|
||||||
@ -59,6 +60,7 @@ private:
|
|||||||
MessageQueue *m_outputMessageQueueToGUI;
|
MessageQueue *m_outputMessageQueueToGUI;
|
||||||
uint32_t m_tickCount;
|
uint32_t m_tickCount;
|
||||||
std::size_t m_samplesCount;
|
std::size_t m_samplesCount;
|
||||||
|
const QTimer *m_timer;
|
||||||
|
|
||||||
static const int m_rateDivider;
|
static const int m_rateDivider;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user