mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-10-05 19:31:13 -04:00
SDRdaemon: write UDP socket
This commit is contained in:
parent
75b505d012
commit
4697b13e60
@ -20,6 +20,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QUdpSocket>
|
||||||
|
|
||||||
#include "channel/sdrdaemondataqueue.h"
|
#include "channel/sdrdaemondataqueue.h"
|
||||||
#include "channel/sdrdaemondatablock.h"
|
#include "channel/sdrdaemondatablock.h"
|
||||||
@ -31,14 +32,18 @@ SDRDaemonChannelSinkThread::SDRDaemonChannelSinkThread(SDRDaemonDataQueue *dataQ
|
|||||||
QThread(parent),
|
QThread(parent),
|
||||||
m_running(false),
|
m_running(false),
|
||||||
m_dataQueue(dataQueue),
|
m_dataQueue(dataQueue),
|
||||||
m_cm256(cm256)
|
m_cm256(cm256),
|
||||||
|
m_address(QHostAddress::LocalHost),
|
||||||
|
m_port(9090)
|
||||||
{
|
{
|
||||||
|
m_socket = new QUdpSocket(this);
|
||||||
connect(m_dataQueue, SIGNAL(dataBlockEnqueued()), this, SLOT(handleData()));
|
connect(m_dataQueue, SIGNAL(dataBlockEnqueued()), this, SLOT(handleData()));
|
||||||
}
|
}
|
||||||
|
|
||||||
SDRDaemonChannelSinkThread::~SDRDaemonChannelSinkThread()
|
SDRDaemonChannelSinkThread::~SDRDaemonChannelSinkThread()
|
||||||
{
|
{
|
||||||
stopWork();
|
stopWork();
|
||||||
|
delete m_socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRDaemonChannelSinkThread::startWork()
|
void SDRDaemonChannelSinkThread::startWork()
|
||||||
@ -88,7 +93,8 @@ bool SDRDaemonChannelSinkThread::handleDataBlock(SDRDaemonDataBlock& dataBlock)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < SDRDaemonNbOrginalBlocks; i++)
|
for (int i = 0; i < SDRDaemonNbOrginalBlocks; i++)
|
||||||
{
|
{
|
||||||
// TODO: send block via UDP here
|
// send block via UDP
|
||||||
|
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, m_port);
|
||||||
usleep(txDelay);
|
usleep(txDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,7 +134,8 @@ bool SDRDaemonChannelSinkThread::handleDataBlock(SDRDaemonDataBlock& dataBlock)
|
|||||||
// Transmit all blocks
|
// Transmit all blocks
|
||||||
for (int i = 0; i < cm256Params.OriginalCount + cm256Params.RecoveryCount; i++)
|
for (int i = 0; i < cm256Params.OriginalCount + cm256Params.RecoveryCount; i++)
|
||||||
{
|
{
|
||||||
// TODO: send block via UDP here
|
// send block via UDP
|
||||||
|
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, m_port);
|
||||||
usleep(txDelay);
|
usleep(txDelay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,12 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
|
#include <QHostAddress>
|
||||||
|
|
||||||
class SDRDaemonDataQueue;
|
class SDRDaemonDataQueue;
|
||||||
class SDRDaemonDataBlock;
|
class SDRDaemonDataBlock;
|
||||||
class CM256;
|
class CM256;
|
||||||
|
class QUdpSocket;
|
||||||
|
|
||||||
class SDRDaemonChannelSinkThread : public QThread {
|
class SDRDaemonChannelSinkThread : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -38,15 +40,21 @@ public:
|
|||||||
void startWork();
|
void startWork();
|
||||||
void stopWork();
|
void stopWork();
|
||||||
|
|
||||||
|
void setAddress(QString& address) { m_address.setAddress(address); }
|
||||||
|
void setPort(unsigned int port) { m_port = port; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex m_startWaitMutex;
|
QMutex m_startWaitMutex;
|
||||||
QWaitCondition m_startWaiter;
|
QWaitCondition m_startWaiter;
|
||||||
bool m_running;
|
bool m_running;
|
||||||
|
|
||||||
SDRDaemonDataQueue *m_dataQueue;
|
SDRDaemonDataQueue *m_dataQueue;
|
||||||
|
|
||||||
CM256 *m_cm256; //!< CM256 library object
|
CM256 *m_cm256; //!< CM256 library object
|
||||||
|
|
||||||
|
QHostAddress m_address;
|
||||||
|
unsigned int m_port;
|
||||||
|
QUdpSocket *m_socket;
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
bool handleDataBlock(SDRDaemonDataBlock& dataBlock);
|
bool handleDataBlock(SDRDaemonDataBlock& dataBlock);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user