diff --git a/Readme.md b/Readme.md index b3d437675..6bd609853 100644 --- a/Readme.md +++ b/Readme.md @@ -109,7 +109,7 @@ Note that this plugin does not require any of the hardware support libraries nor

SDRdaemon input

-Warning: this is experimental is buggy (algorithm to retrieve samples is flawed). +Warning: this is experimental and not fulle debugged yet. This is the client side of the SDRdaemon server. See the [SDRdaemon](https://github.com/f4exb/sdrdaemon) project in this Github repository. You must specify the address and UDP port to which the server connects and samples will flow into the SDRangel application (default is `127.0.0.1`port `9090`). It uses the meta data to retrieve the sample flow characteristics such as sample rate and receiveng center frequency. diff --git a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp index 7fa12bbf5..f8afe5e8d 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp +++ b/plugins/samplesource/sdrdaemon/sdrdaemonbuffer.cpp @@ -233,9 +233,14 @@ uint8_t *SDRdaemonBuffer::readData(uint32_t length) m_readCount += length; return &m_rawBuffer[readCount]; } + //else if (m_readCount > 0) else { + if (length > m_chunkSize) { + qDebug("SDRdaemonBuffer::readData: length: %d", length); + } uint32_t retLength = std::min(length, m_chunkSize); + //uint32_t retLength = length; std::memcpy((void *) m_chunkBuffer, (const void *) &m_rawBuffer[m_readCount], m_rawSize - m_readCount); // read last bit from raw buffer m_readCount = retLength - (m_rawSize - m_readCount); std::memcpy((void *) &m_chunkBuffer[m_rawSize - m_readCount], (const void *) m_rawBuffer, m_readCount); // read the rest at start of raw buffer diff --git a/plugins/samplesource/sdrdaemon/sdrdaemonudphandler.cpp b/plugins/samplesource/sdrdaemon/sdrdaemonudphandler.cpp index cf08f181e..9a1c4618a 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemonudphandler.cpp +++ b/plugins/samplesource/sdrdaemon/sdrdaemonudphandler.cpp @@ -26,6 +26,7 @@ const int SDRdaemonUDPHandler::m_rateDivider = 1000/SDRDAEMON_THROTTLE_MS; const int SDRdaemonUDPHandler::m_udpPayloadSize = 512; SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *outputMessageQueueToGUI) : + //m_mutex(QMutex::Recursive), m_sdrDaemonBuffer(m_udpPayloadSize, m_rateDivider), m_dataSocket(0), m_dataAddress(QHostAddress::LocalHost), @@ -66,6 +67,7 @@ void SDRdaemonUDPHandler::start() if (m_dataSocket->bind(m_dataAddress, m_dataPort)) { qDebug("SDRdaemonUDPHandler::start: bind data socket to port %d", m_dataPort); + //connect(this, SIGNAL(dataReady()), this, SLOT(processData())); connect(m_dataSocket, SIGNAL(readyRead()), this, SLOT(dataReadyRead()), Qt::QueuedConnection); // , Qt::QueuedConnection m_dataConnected = true; } @@ -83,6 +85,7 @@ void SDRdaemonUDPHandler::stop() if (m_dataConnected) { disconnect(m_dataSocket, SIGNAL(readyRead()), this, SLOT(dataReadyRead())); + //disconnect(this, SIGNAL(dataReady()), this, SLOT(processData)); m_dataConnected = false; } @@ -101,6 +104,7 @@ void SDRdaemonUDPHandler::dataReadyRead() { qint64 pendingDataSize = m_dataSocket->pendingDatagramSize(); m_udpReadBytes = m_dataSocket->readDatagram(m_udpBuf, pendingDataSize, 0, 0); + //emit dataReady(); processData(); } } @@ -113,6 +117,8 @@ void SDRdaemonUDPHandler::processData() } else if (m_udpReadBytes > 0) { + //QMutexLocker ml(&m_mutex); + m_sdrDaemonBuffer.updateBlockCounts(m_udpReadBytes); if (m_sdrDaemonBuffer.readMeta(m_udpBuf, m_udpReadBytes)) @@ -160,6 +166,8 @@ void SDRdaemonUDPHandler::setSamplerate(uint32_t samplerate) << " new:" << samplerate << " old:" << m_samplerate; + //QMutexLocker ml(&m_mutex); + m_samplerate = samplerate; m_chunksize = (m_samplerate / m_rateDivider)*4; // TODO: implement FF and slow motion here. 4 corresponds to live. 2 is half speed, 8 is doulbe speed m_bufsize = m_chunksize; diff --git a/plugins/samplesource/sdrdaemon/sdrdaemonudphandler.h b/plugins/samplesource/sdrdaemon/sdrdaemonudphandler.h index c056f4cfc..66becc1a5 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemonudphandler.h +++ b/plugins/samplesource/sdrdaemon/sdrdaemonudphandler.h @@ -41,8 +41,13 @@ public: public slots: void dataReadyRead(); +// void processData(); + +//signals: +// void dataReady(); private: + //QMutex m_mutex; SDRdaemonBuffer m_sdrDaemonBuffer; QUdpSocket *m_dataSocket; QHostAddress m_dataAddress;