lijinliang 3 жил өмнө
parent
commit
3341351599

+ 2 - 1
src/driver/driver_ota_client/driver_ota_client.xml

@@ -1,6 +1,7 @@
 <xml>	
 	<node name="driver_ota_client">
-		<param name="ServerIP" value="0.0.0.0" />
+		<param name="ServerIP" value="192.168.1.70" />
 		<param name="ServerPort" value="60051" />
+		<param name="WaitNetTime" value="1000" />
 	</node>
 </xml>

+ 3 - 3
src/driver/driver_ota_client/vin.xml

@@ -1,6 +1,6 @@
 <xml>	
-	<node name="VIN">
-		<param name="VIN" value="AAAAAAAAAABBBBBBB" />
-		<param name="VehicleType" value="GE3" />
+	<node name="driver_ota_client">
+		<param name="VIN" value="1234567890" />
+		<param name="VehicleType" value="Car" />
 	</node>
 </xml>

+ 73 - 0
src/v2x/obuUdpClient/obuUdpClient/.gitignore

@@ -0,0 +1,73 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 18 - 0
src/v2x/obuUdpClient/obuUdpClient/main.cpp

@@ -0,0 +1,18 @@
+#include <QByteArray>
+#include <QCoreApplication>
+#include <QHostAddress>
+#include <QUdpSocket>
+#include <udpreciver.h>
+#include <udpsender.h>
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication a(argc, argv);
+    UdpReciver mUdpReciver(NULL,"192.168.1.70",5901);
+    UdpSender mUdpSender;
+    QByteArray byteArray;
+    QString strings="hello";
+    byteArray = strings.toUtf8();
+    mUdpSender.recMsg(byteArray);
+    return a.exec();
+}

+ 23 - 0
src/v2x/obuUdpClient/obuUdpClient/obuUdpClient.pro

@@ -0,0 +1,23 @@
+QT -= gui
+QT += network
+CONFIG += c++11 console
+CONFIG -= app_bundle
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += main.cpp \
+    udpsender.cpp \
+    udpreciver.cpp
+
+HEADERS += \
+    udpsender.h \
+    udpreciver.h

+ 40 - 0
src/v2x/obuUdpClient/obuUdpClient/udpreciver.cpp

@@ -0,0 +1,40 @@
+#include "udpreciver.h"
+
+UdpReciver::UdpReciver(QObject *parent, QString localhost, int port) : QObject(parent)
+{
+    m_thread = new QThread();
+    m_udpSocket = new QUdpSocket();
+//    localhost = "";
+    init_port(localhost, port);
+    connect(m_udpSocket, SIGNAL(readyRead()), this, SLOT(readDatagrams()), Qt::DirectConnection);
+    this->moveToThread(m_thread);
+    m_udpSocket->moveToThread(m_thread);
+    m_thread->start();
+}
+UdpReciver::~UdpReciver()
+{
+    m_thread->quit();
+    m_thread->wait();
+    m_thread->deleteLater();
+    m_udpSocket->close();
+    m_udpSocket->deleteLater();
+}
+void UdpReciver::init_port(QString tmphost, int tmport)
+{
+    m_port = tmport;
+    m_localhost = tmphost;
+    m_udpSocket->bind(QHostAddress(m_localhost), m_port);
+}
+void UdpReciver::readDatagrams()
+{
+    QHostAddress client_address; //client ip addr
+    m_data.clear();
+    while(m_udpSocket->hasPendingDatagrams())
+    {
+        m_data.resize(m_udpSocket->pendingDatagramSize());
+        m_udpSocket->readDatagram(m_data.data(), m_data.size(), &client_address);
+        QString strclient_address = client_address.toString();
+        deliverInfo(m_data, strclient_address);
+        qDebug() << "receive UDP data: " << m_data;
+    }
+}

+ 26 - 0
src/v2x/obuUdpClient/obuUdpClient/udpreciver.h

@@ -0,0 +1,26 @@
+#ifndef UDPRECIVER_H
+#define UDPRECIVER_H
+
+#include <QUdpSocket>
+#include <QThread>
+class UdpReciver : public QObject
+{
+    Q_OBJECT
+public:
+    UdpReciver(QObject *parent = NULL, QString localhost = NULL, int port = 0);
+    ~UdpReciver();
+    void init_port(QString tmphost, int tmport);
+signals:
+    void deliverInfo(QByteArray info, QString clientip);
+public slots:
+    void readDatagrams(); //listen UDP data
+private:
+    QUdpSocket *m_udpSocket;
+    QString m_localhost;
+    int m_port;
+    QByteArray m_data;
+    QThread *m_thread;
+};
+
+
+#endif // UDPRECIVER_H

+ 30 - 0
src/v2x/obuUdpClient/obuUdpClient/udpsender.cpp

@@ -0,0 +1,30 @@
+#include "udpsender.h"
+
+UdpSender::UdpSender()
+{
+    m_Socket = new QUdpSocket();
+    initSender("192.168.1.70", 5901);
+}
+UdpSender::~UdpSender()
+{
+    if (m_Socket != NULL)
+    {
+        delete m_Socket;
+        m_Socket = NULL;
+    }
+}
+void UdpSender::initSender(QString desHost, int port)
+{
+    m_address = desHost;
+    m_port = port;
+}
+void UdpSender::send(QByteArray msg)
+{
+    m_Socket->writeDatagram(msg, QHostAddress(m_address), m_port);
+}
+void UdpSender::recMsg(QByteArray msgInfo)
+{
+    send(msgInfo);
+    qDebug()<<"send data" <<msgInfo;
+}
+

+ 23 - 0
src/v2x/obuUdpClient/obuUdpClient/udpsender.h

@@ -0,0 +1,23 @@
+#ifndef UDPSENDER_H
+#define UDPSENDER_H
+
+//UdpSend.h
+#include <QUdpSocket>
+#include <QThread>
+class UdpSender : public QObject
+{
+    Q_OBJECT
+public:
+    UdpSender();
+    ~UdpSender();
+    void initSender(QString desHost, int port);
+    void send(QByteArray msg);
+public slots:
+    void recMsg(QByteArray msgInfo);
+private:
+    QUdpSocket *m_Socket = NULL;
+    QString m_address;
+    int m_port;
+};
+
+#endif // UDPSENDER_H