实验环境:Ubuntu14.04,qt5.5.0,dsp板。
实验描述:dsp板会不断发送udp数据包,数据包是float类型的数据。
#ifndef UDPRECEIVER
#define UDPRECEIVER
#include<QObject>
#include"radardata.h"
class QUdpSocket;
class UdpReceiver:public QObject
{
Q_OBJECT
public:
UdpReceiver(QObject *parent = 0);
~UdpReceiver();
private slots:
void processPendingDatagrams();
private:
QUdpSocket* udpSocket;
QByteArray udppak1;
int pNum;
RadarData rd;
RadarData::Trace tra;
};
#endif // UDPRECEIVER
#include"udpreceiver.h"
#include<QDataStream>
#include<QUdpSocket>
#include<QTime>
UdpReceiver::UdpReceiver(QObject* parent)
:QObject(parent)
{
pNum = 1;
udpSocket = new QUdpSocket(this);
udpSocket->bind(50000);
connect(udpSocket,SIGNAL(readyRead()),
this,SLOT(pro