dlink
This commit is contained in:
+17
-3
@@ -13,7 +13,11 @@ DLink::DLink(QObject *parent) : QObject(parent)
|
||||
//mavlink协议节点
|
||||
mavlinknode = new MavLinkNode();//不允许带参数,因为这是单独的线程
|
||||
connect(mavlinknode,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),
|
||||
this,SLOT(SendMessageTo(quint8,quint8*,quint16)),Qt::DirectConnection);//采用直连的方式,因为是多线程
|
||||
this,SLOT(SendMessageTo(quint8,quint8*,quint16)),Qt::DirectConnection);//采用直连的方式,因为是多线程
|
||||
|
||||
//connect(mavlinknode,&MavLinkNode::SendMessageTo,
|
||||
// this,&DLink::SendMessageTo);
|
||||
|
||||
|
||||
connect(mavlinknode,SIGNAL(showMessage(QString,int)),
|
||||
this,SIGNAL(showMessage(QString,int)),Qt::DirectConnection);
|
||||
@@ -33,13 +37,15 @@ int DLink::SendMessageTo(quint8 ch, quint8 *msg, quint16 len)
|
||||
{
|
||||
Q_UNUSED(ch);
|
||||
|
||||
qDebug() << "发送数据";
|
||||
|
||||
if (DLink::Clientsock)
|
||||
{
|
||||
foreach(Node node,clientSockets)
|
||||
{
|
||||
DLink::Clientsock->writeDatagram((const char *)msg, len,
|
||||
node.addr, node.port);
|
||||
//qDebug() << "Client Send Msg";
|
||||
qDebug() << "Client Send Msg";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +69,8 @@ int DLink::SendMessageTo(quint8 ch, quint8 *msg, quint16 len)
|
||||
qDebug() << flag;
|
||||
//serialPort->write()
|
||||
|
||||
qDebug() << QThread::currentThread();
|
||||
|
||||
//qDebug() << "serialPort Send Msg" << msg;
|
||||
|
||||
}
|
||||
@@ -94,7 +102,11 @@ bool DLink::setupPort(const QString port, qint32 baudrate, QSerialPort::Parity p
|
||||
serialPort->setDataBits(QSerialPort::Data8);
|
||||
serialPort->setStopBits(QSerialPort::OneStop);
|
||||
|
||||
mavlinknode->start();
|
||||
DLink::serialPort->write("serial connet ok",16);
|
||||
|
||||
qDebug() << QThread::currentThread();
|
||||
|
||||
mavlinknode->start();//启动之后串口就找不到了
|
||||
|
||||
connect(serialPort, SIGNAL(readyRead()), this, SLOT(readPendingDatagramsSerialPort()));
|
||||
|
||||
@@ -204,6 +216,8 @@ bool DLink::setupClient(const QHostAddress &remote_addr, int remote_port, int lo
|
||||
Clientsock = new QUdpSocket(this);
|
||||
if (Clientsock->bind(QHostAddress::Any, local_port))
|
||||
{
|
||||
Clientsock->joinMulticastGroup(remote_addr);//加入组播
|
||||
|
||||
if(Clientsock->open(QIODevice::ReadWrite))
|
||||
{
|
||||
connect(Clientsock, SIGNAL(readyRead()),
|
||||
|
||||
Reference in New Issue
Block a user