mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 21:56:35 +00:00
45c19baa45
- autopilot -> drone_controller - rtsp_ai_player -> ai_controller - added top level qmake project file - updated documentation - moved small demo applications from tmp/ to misc/
40 lines
968 B
C++
40 lines
968 B
C++
#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;
|
|
}
|