Browse Source

Real Test

trurl 5 years ago
parent
commit
81021cde9c
2 changed files with 15 additions and 7 deletions
  1. 13 6
      mainwindow.cpp
  2. 2 1
      mainwindow.ui

+ 13 - 6
mainwindow.cpp

@@ -94,7 +94,7 @@ void MainWindow::openRemote()
     qDebug("openRemote(): %s", this->ui->ttyPathEdit->toPlainText().toStdString().c_str());
     //SettingsDialog::Settings p = settings->settings();
     this->remote->setPortName(this->ui->ttyPathEdit->toPlainText());
-    this->remote->setBaudRate(115200);
+    this->remote->setBaudRate(9600);
     this->remote->setDataBits(QSerialPort::Data8);
     this->remote->setParity(QSerialPort::NoParity);
     this->remote->setStopBits(QSerialPort::OneStop);
@@ -253,10 +253,17 @@ void MainWindow::redrawGraphics()
 
 void MainWindow::recvData()
 {
-    QByteArray data = remote->readAll();
+    if (!remote->canReadLine())
+        return;
+
+    QByteArray data = remote->readLine();
     QString string = QTextCodec::codecForMib(106)->toUnicode(data);
-    //qDebug("received data: %s", string.toStdString().c_str());
-    QStringList arguments = string.split(" ");
+    QRegExp rx("[ ]+");
+    QStringList arguments = string.split(rx);
+    qDebug("received data (%i: %s): %s", arguments.size(), arguments.at(0).toStdString().c_str(), string.toStdString().c_str());
+
+    if(arguments.size() < 6)
+        return;
 
     this->curState.m[0].direction = arguments.at(0).at(0).toLatin1();
     this->curState.m[0].speed     = arguments.at(1).toInt();
@@ -366,13 +373,13 @@ void MainWindow::sendDesiredState(int motorId)
 
 void MainWindow::on_speedM0Slider_valueChanged(int value)
 {
-    this->desiredState.m[0].speed = value;
+    this->desiredState.m[0].speed = sqrt(209-value+0.1);
     this->sendDesiredState(0);
 }
 
 void MainWindow::on_speedM1Slider_valueChanged(int value)
 {
-    this->desiredState.m[1].speed = value;
+    this->desiredState.m[1].speed = sqrt(209-value+0.1);
     this->sendDesiredState(0);
 }
 

+ 2 - 1
mainwindow.ui

@@ -71,6 +71,7 @@
            <height>150</height>
           </size>
          </property>
+         <zorder>ADC1Plot</zorder>
         </widget>
        </item>
        <item>
@@ -412,7 +413,7 @@
          <enum>Qt::ScrollBarAlwaysOff</enum>
         </property>
         <property name="plainText">
-         <string>/dev/ttyV0</string>
+         <string>/dev/ttyUSB2</string>
         </property>
         <property name="backgroundVisible">
          <bool>false</bool>