Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

solved but if the whole line is not set in one recieved in one package.

  • Loading branch information...
commit cfa8da5a683c48b2abb298c0275deca0fc03b74f 1 parent 4a6b740
@bkubicek authored
Showing with 24 additions and 12 deletions.
  1. +19 −12 mainwindow.cpp
  2. +4 −0 mainwindow.h
  3. +1 −0  tab_pid.cpp
View
31 mainwindow.cpp
@@ -95,7 +95,18 @@ MainWindow::MainWindow(QWidget *parent): QWidget(parent)
connect(port, SIGNAL(readyRead()), this, SLOT(slotRead()));
connect(tabRaw->sendText,SIGNAL(returnPressed()),this, SLOT(manualSend()));
-
+
+
+ connect(tabPID,SIGNAL(pidChanged()),this, SLOT(sendPID()));
+ connect(tabPID->pids[0],SIGNAL(returnPressed()),this, SLOT(sendPID()));
+ connect(tabPID->pids[1],SIGNAL(returnPressed()),this, SLOT(sendPID()));
+ connect(tabPID->pids[2],SIGNAL(returnPressed()),this, SLOT(sendPID()));
+ connect(tabPID->pids[3],SIGNAL(returnPressed()),this, SLOT(sendPID()));
+ connect(tabPID->btLoad,SIGNAL(clicked()),this, SLOT(getPID()));
+
+ connect(tabPID->temp[hotend1],SIGNAL(returnPressed()),this, SLOT(setHotend1Temp()));
+
+ timer = new QTimer(this);
}
MainWindow::~MainWindow()
{
@@ -167,19 +178,13 @@ void MainWindow::clickedConnect()
}
tabPID->startTime();
- connect(tabPID->temp[hotend1],SIGNAL(returnPressed()),this, SLOT(setHotend1Temp()));
- QTimer *timer = new QTimer(this);
+
connect(timer, SIGNAL(timeout()), this, SLOT(measure()));
timer->start(1000);
send("M301\n");
- connect(tabPID,SIGNAL(pidChanged()),this, SLOT(sendPID()));
- connect(tabPID->pids[0],SIGNAL(returnPressed()),this, SLOT(sendPID()));
- connect(tabPID->pids[1],SIGNAL(returnPressed()),this, SLOT(sendPID()));
- connect(tabPID->pids[2],SIGNAL(returnPressed()),this, SLOT(sendPID()));
- connect(tabPID->pids[3],SIGNAL(returnPressed()),this, SLOT(sendPID()));
- connect(tabPID->btLoad,SIGNAL(clicked()),this, SLOT(getPID()));
-
+
+ serialBuffer="";
}
void MainWindow::clickedDisconnect()
@@ -247,8 +252,10 @@ void MainWindow::slotRead()
//qDebug() << "Readed is : " << ba.size() << " bytes";
//qDebug()<<QString( ba);
tabRaw->edit->insertPlainText(ba);
-
- QStringList lines = QString( ba).split("\n");
+ serialBuffer=serialBuffer+QString(ba);
+ int n=serialBuffer.lastIndexOf("\n");
+ QStringList lines = serialBuffer.mid(0,n).split("\n");
+ serialBuffer=serialBuffer.mid(n,sizeof(serialBuffer)-n);
foreach(QString s, lines)
{
if(s.startsWith("ok"))
View
4 mainwindow.h
@@ -21,6 +21,7 @@ class TabEEPROM;
//class QextSerialPort;
class SerialDeviceEnumerator;
class AbstractSerial;
+class QTimer;
#include <QMap>
@@ -70,5 +71,8 @@ public slots:
SerialDeviceEnumerator *m_sde;
AbstractSerial *port;
+ QString serialBuffer; //so only full lines are handed to the next stuff.
+ QTimer *timer;
+
};
View
1  tab_pid.cpp
@@ -226,6 +226,7 @@ void TabPID::clearClicked()
target_hotend1.resize(0);
target_hotend2.resize(0);
target_bed.resize(0);
+ startTime();
}
Please sign in to comment.
Something went wrong with that request. Please try again.