|
@@ -178,12 +178,12 @@ void MainWindow::on_pushButton_Param_Get_clicked()
|
|
|
ui->lineEdit_Param_IPSrc->setText(strsrcip);
|
|
|
char strdstip[256];
|
|
|
snprintf(strdstip,256,"%d.%d.%d.%d",ethparam[4],ethparam[5],ethparam[6],ethparam[7]);
|
|
|
- ui->lineEdit_Param_IPSrc->setText(strdstip);
|
|
|
+ ui->lineEdit_Param_IPDest->setText(strdstip);
|
|
|
int nDataPort = ethparam[14]*256 + ethparam[15];
|
|
|
- ui->lineEdit_DataPort->setText(QString::number(nDataPort));
|
|
|
+ ui->lineEdit_Param_DataPort->setText(QString::number(nDataPort));
|
|
|
int nDevPort = ethparam[16]*256 + ethparam[17];
|
|
|
- mnDevPort = nDevPort;
|
|
|
- ui->lineEdit_DevPort->setText(QString::number(nDevPort));
|
|
|
+// mnDevPort = nDevPort;
|
|
|
+ ui->lineEdit_Param_DevPort->setText(QString::number(nDevPort));
|
|
|
mbParam_Get = true;
|
|
|
ui->pushButton_Param_Set->setEnabled(true);
|
|
|
}
|
|
@@ -278,7 +278,25 @@ void MainWindow::on_pushButton_Param_Set_clicked()
|
|
|
memcpy(pdata + 10 + 14,strDataPort,2);
|
|
|
memcpy(pdata + 10 + 16,strDevPort,2);
|
|
|
|
|
|
-// mpUDPSocket_Dev->writeDatagram(basend.data(),basend.size(),QHostAddress(mstrDevIP),mnDevPort);
|
|
|
+ int motorhz = 10;
|
|
|
+ if(ui->comboBox_MotorSpeed->currentIndex() == 0)motorhz = 5;
|
|
|
+ if(ui->comboBox_MotorSpeed->currentIndex() == 2)motorhz = 20;
|
|
|
+
|
|
|
+ motorhz = motorhz * 60;
|
|
|
+ unsigned short nMotorhz_High = motorhz/256;
|
|
|
+ unsigned short nMotorhz_Low = motorhz - nMotorhz_High*256;
|
|
|
+ unsigned char strmotor[2];
|
|
|
+ strmotor[0] = static_cast<unsigned char>(nMotorhz_High);
|
|
|
+ strmotor[1] = static_cast<unsigned char>(nMotorhz_Low);
|
|
|
+ memcpy(pdata+8,strmotor,2);
|
|
|
+
|
|
|
+ pdata[0] = 0xAA; pdata[1] = 0x00; pdata[2] = 0xFF; pdata[3] = 0x11;
|
|
|
+ pdata[4] = 0x22; pdata[5] = 0x22; pdata[6] = 0xAA; pdata[7] = 0xAA;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ mpUDPSocket_Dev->writeDatagram(basend.data(),basend.size(),QHostAddress(mstrDevIP),mnDevPort);
|
|
|
+ mpUDPSocket_Dev->flush();
|
|
|
QMessageBox::information(this,tr("Info"),tr("设置成功"),QMessageBox::YesAll);
|
|
|
}
|
|
|
|
|
@@ -309,6 +327,8 @@ void MainWindow::onSocketDevRead()
|
|
|
xUDPPac.mba = datagram.data();
|
|
|
xUDPPac.mhost = datagram.senderAddress();
|
|
|
xUDPPac.mnPort = static_cast<unsigned short>(datagram.senderPort()) ;
|
|
|
+ std::cout<<" dev send port : "<<xUDPPac.mnPort<<std::endl;
|
|
|
+ mnDevPort = xUDPPac.mnPort;
|
|
|
if(mvectorUDPPac_Dev.size()>=10)
|
|
|
{
|
|
|
mvectorUDPPac_Dev.erase(mvectorUDPPac_Dev.begin());
|
|
@@ -335,6 +355,7 @@ void MainWindow::onSocketDataRead()
|
|
|
xUDPPac.mba = datagram.data();
|
|
|
xUDPPac.mhost = datagram.senderAddress();
|
|
|
xUDPPac.mnPort = static_cast<unsigned short>(datagram.senderPort()) ;
|
|
|
+
|
|
|
if(mvectorUDPPac_Data.size()>=100)
|
|
|
{
|
|
|
mvectorUDPPac_Data.erase(mvectorUDPPac_Data.begin());
|
|
@@ -351,7 +372,8 @@ void MainWindow::onTimer()
|
|
|
if(mbListenning)
|
|
|
{
|
|
|
char strout[1000];
|
|
|
- snprintf(strout,1000,"Data Packet:%d Device Packete:%d",mnDataPacCount,mnDevPacCount);
|
|
|
+ snprintf(strout,1000,"%s | Last Second Recv | Data Packet:%d Device Packet:%d",QDateTime::currentDateTime().toString("hh:mm::ss:zzz").toLatin1().data(),
|
|
|
+ mnDataPacCount,mnDevPacCount);
|
|
|
ui->plainTextEdit->setPlainText(strout);
|
|
|
|
|
|
}
|
|
@@ -370,7 +392,7 @@ bool MainWindow::CheckMacSame()
|
|
|
if(nsize<=1)return true;
|
|
|
for(i=1;i<nsize;i++)
|
|
|
{
|
|
|
- QByteArray ba = mvectorUDPPac_Dev[i].mba.data();
|
|
|
+ QByteArray ba = mvectorUDPPac_Dev[i].mba;
|
|
|
char * pdata = ba.data();
|
|
|
if(ba.size() != 1206)
|
|
|
{
|