SDRdaemon plugin: works with bugs

pull/6/head
f4exb 2016-02-19 08:48:14 +01:00
rodzic d267d56de5
commit 6b16222792
4 zmienionych plików z 19 dodań i 1 usunięć

Wyświetl plik

@ -109,7 +109,7 @@ Note that this plugin does not require any of the hardware support libraries nor
<h2>SDRdaemon input</h2> <h2>SDRdaemon input</h2>
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. 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.

Wyświetl plik

@ -233,9 +233,14 @@ uint8_t *SDRdaemonBuffer::readData(uint32_t length)
m_readCount += length; m_readCount += length;
return &m_rawBuffer[readCount]; return &m_rawBuffer[readCount];
} }
//else if (m_readCount > 0)
else else
{ {
if (length > m_chunkSize) {
qDebug("SDRdaemonBuffer::readData: length: %d", length);
}
uint32_t retLength = std::min(length, m_chunkSize); 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 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); 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 std::memcpy((void *) &m_chunkBuffer[m_rawSize - m_readCount], (const void *) m_rawBuffer, m_readCount); // read the rest at start of raw buffer

Wyświetl plik

@ -26,6 +26,7 @@ const int SDRdaemonUDPHandler::m_rateDivider = 1000/SDRDAEMON_THROTTLE_MS;
const int SDRdaemonUDPHandler::m_udpPayloadSize = 512; const int SDRdaemonUDPHandler::m_udpPayloadSize = 512;
SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *outputMessageQueueToGUI) : SDRdaemonUDPHandler::SDRdaemonUDPHandler(SampleFifo *sampleFifo, MessageQueue *outputMessageQueueToGUI) :
//m_mutex(QMutex::Recursive),
m_sdrDaemonBuffer(m_udpPayloadSize, m_rateDivider), m_sdrDaemonBuffer(m_udpPayloadSize, m_rateDivider),
m_dataSocket(0), m_dataSocket(0),
m_dataAddress(QHostAddress::LocalHost), m_dataAddress(QHostAddress::LocalHost),
@ -66,6 +67,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 port %d", m_dataPort);
//connect(this, SIGNAL(dataReady()), this, SLOT(processData()));
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;
} }
@ -83,6 +85,7 @@ void SDRdaemonUDPHandler::stop()
if (m_dataConnected) { if (m_dataConnected) {
disconnect(m_dataSocket, SIGNAL(readyRead()), this, SLOT(dataReadyRead())); disconnect(m_dataSocket, SIGNAL(readyRead()), this, SLOT(dataReadyRead()));
//disconnect(this, SIGNAL(dataReady()), this, SLOT(processData));
m_dataConnected = false; m_dataConnected = false;
} }
@ -101,6 +104,7 @@ void SDRdaemonUDPHandler::dataReadyRead()
{ {
qint64 pendingDataSize = m_dataSocket->pendingDatagramSize(); qint64 pendingDataSize = m_dataSocket->pendingDatagramSize();
m_udpReadBytes = m_dataSocket->readDatagram(m_udpBuf, pendingDataSize, 0, 0); m_udpReadBytes = m_dataSocket->readDatagram(m_udpBuf, pendingDataSize, 0, 0);
//emit dataReady();
processData(); processData();
} }
} }
@ -113,6 +117,8 @@ void SDRdaemonUDPHandler::processData()
} }
else if (m_udpReadBytes > 0) else if (m_udpReadBytes > 0)
{ {
//QMutexLocker ml(&m_mutex);
m_sdrDaemonBuffer.updateBlockCounts(m_udpReadBytes); m_sdrDaemonBuffer.updateBlockCounts(m_udpReadBytes);
if (m_sdrDaemonBuffer.readMeta(m_udpBuf, m_udpReadBytes)) if (m_sdrDaemonBuffer.readMeta(m_udpBuf, m_udpReadBytes))
@ -160,6 +166,8 @@ void SDRdaemonUDPHandler::setSamplerate(uint32_t samplerate)
<< " new:" << samplerate << " new:" << samplerate
<< " old:" << m_samplerate; << " old:" << m_samplerate;
//QMutexLocker ml(&m_mutex);
m_samplerate = samplerate; 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_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; m_bufsize = m_chunksize;

Wyświetl plik

@ -41,8 +41,13 @@ public:
public slots: public slots:
void dataReadyRead(); void dataReadyRead();
// void processData();
//signals:
// void dataReady();
private: private:
//QMutex m_mutex;
SDRdaemonBuffer m_sdrDaemonBuffer; SDRdaemonBuffer m_sdrDaemonBuffer;
QUdpSocket *m_dataSocket; QUdpSocket *m_dataSocket;
QHostAddress m_dataAddress; QHostAddress m_dataAddress;