mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 08:46:34 +00:00
Changed directory structure and renamed applications
- autopilot -> drone_controller - rtsp_ai_player -> ai_controller - added top level qmake project file - updated documentation - moved small demo applications from tmp/ to misc/
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QUdpSocket>
|
||||
#include <QHostAddress>
|
||||
#include <QThread>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
if (argc != 2) {
|
||||
qDebug() << "Give port number of server as only parameter";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QUdpSocket udpSocket;
|
||||
quint16 receiverPort = atoi(argv[1]);
|
||||
|
||||
for (int i = 0; i < 10000000 ; i++) {
|
||||
QJsonObject json;
|
||||
json["value"] = i;
|
||||
QJsonDocument jsonDoc(json);
|
||||
QByteArray datagram = jsonDoc.toJson();
|
||||
|
||||
qint64 bytesSent = udpSocket.writeDatagram(datagram, QHostAddress("127.0.0.1"), receiverPort);
|
||||
|
||||
if (bytesSent == -1) {
|
||||
qWarning("Failed to send the datagram: %s", qPrintable(udpSocket.errorString()));
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
qDebug("Datagram sent successfully");
|
||||
}
|
||||
|
||||
QThread::msleep(100);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user