dlink
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#include "CommandUI.h"
|
#include "CommandUI.h"
|
||||||
#include "ui_CommandUI.h"
|
#include "ui_CommandUI.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -214,8 +214,8 @@ void CommandUI::on_commandClicked()
|
|||||||
command = info.toObject().find(_commandJsonKey).value().toInt();
|
command = info.toObject().find(_commandJsonKey).value().toInt();
|
||||||
confirm = info.toObject().find(_confirmJsonKey).value().toInt();
|
confirm = info.toObject().find(_confirmJsonKey).value().toInt();
|
||||||
|
|
||||||
//如果confirm == 1,那么弹出确认对话框
|
//如果confirm 不为0,那么弹出确认对话框
|
||||||
if(confirm == 1)
|
if(confirm != 0)
|
||||||
{
|
{
|
||||||
Confirm *confirmor = new Confirm(this);
|
Confirm *confirmor = new Confirm(this);
|
||||||
confirmor->setGeometry(0,0,this->width(),this->height());
|
confirmor->setGeometry(0,0,this->width(),this->height());
|
||||||
|
|||||||
Binary file not shown.
+1
-1
@@ -370,7 +370,7 @@
|
|||||||
<location filename="ComponentUI/Confirm/Confirm.cpp" line="41"/>
|
<location filename="ComponentUI/Confirm/Confirm.cpp" line="41"/>
|
||||||
<source>Notice:<byte value="xd"/>
|
<source>Notice:<byte value="xd"/>
|
||||||
</source>
|
</source>
|
||||||
<translation>注意:
|
<translation>注意:
|
||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
|||||||
+16
-2
@@ -15,6 +15,10 @@ DLink::DLink(QObject *parent) : QObject(parent)
|
|||||||
connect(mavlinknode,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),
|
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)),
|
connect(mavlinknode,SIGNAL(showMessage(QString,int)),
|
||||||
this,SIGNAL(showMessage(QString,int)),Qt::DirectConnection);
|
this,SIGNAL(showMessage(QString,int)),Qt::DirectConnection);
|
||||||
|
|
||||||
@@ -33,13 +37,15 @@ int DLink::SendMessageTo(quint8 ch, quint8 *msg, quint16 len)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(ch);
|
Q_UNUSED(ch);
|
||||||
|
|
||||||
|
qDebug() << "发送数据";
|
||||||
|
|
||||||
if (DLink::Clientsock)
|
if (DLink::Clientsock)
|
||||||
{
|
{
|
||||||
foreach(Node node,clientSockets)
|
foreach(Node node,clientSockets)
|
||||||
{
|
{
|
||||||
DLink::Clientsock->writeDatagram((const char *)msg, len,
|
DLink::Clientsock->writeDatagram((const char *)msg, len,
|
||||||
node.addr, node.port);
|
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;
|
qDebug() << flag;
|
||||||
//serialPort->write()
|
//serialPort->write()
|
||||||
|
|
||||||
|
qDebug() << QThread::currentThread();
|
||||||
|
|
||||||
//qDebug() << "serialPort Send Msg" << msg;
|
//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->setDataBits(QSerialPort::Data8);
|
||||||
serialPort->setStopBits(QSerialPort::OneStop);
|
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()));
|
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);
|
Clientsock = new QUdpSocket(this);
|
||||||
if (Clientsock->bind(QHostAddress::Any, local_port))
|
if (Clientsock->bind(QHostAddress::Any, local_port))
|
||||||
{
|
{
|
||||||
|
Clientsock->joinMulticastGroup(remote_addr);//加入组播
|
||||||
|
|
||||||
if(Clientsock->open(QIODevice::ReadWrite))
|
if(Clientsock->open(QIODevice::ReadWrite))
|
||||||
{
|
{
|
||||||
connect(Clientsock, SIGNAL(readyRead()),
|
connect(Clientsock, SIGNAL(readyRead()),
|
||||||
|
|||||||
+3
-1
@@ -42,6 +42,8 @@ public:
|
|||||||
|
|
||||||
MavLinkNode *mavlinknode = nullptr;
|
MavLinkNode *mavlinknode = nullptr;
|
||||||
|
|
||||||
|
int SendMessageTo(quint8 ch, quint8 *msg, quint16 len);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void showMessage(const QString &message,int TimeOut = 0);
|
void showMessage(const QString &message,int TimeOut = 0);
|
||||||
|
|
||||||
@@ -65,7 +67,7 @@ public slots:
|
|||||||
|
|
||||||
void readPendingDatagramsClient(void);
|
void readPendingDatagramsClient(void);
|
||||||
|
|
||||||
int SendMessageTo(quint8 ch, quint8 *msg, quint16 len);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user