#include "txthread.h" txThread::txThread() { lineCounter = 0; watchdogTimer = new QTimer(); watchdogTimer->setInterval(1000); //because of sudden stops during sending a file } //I use a watchdogTimer to force sending the next //command if there is a too long pause of communication //This is only a workaround!! //EDIT: I found out that this sometimes happens because of timing issues in the firmware. txThread::~txThread() { } QString removeComments(QString intext) { ////////////////////////////////////////////////remove comments QString outTmp1,outTmp2; bool state=1; //1= send, 0 = ignore for(int i=0;istart(); #endif sendNext(); } void txThread::sendNext() { QString tmp; if(lineCounter <= lineMax) { tmp = textfile.section("\n",lineCounter,lineCounter); tmp.append("\n"); bot->send(tmp); double progress= (double) lineCounter/(double)lineMax; emit progressChanged(progress*100); lineCounter++; } else { watchdogTimer->stop(); emit fileTransmitted(); return; } #ifdef Watchdog watchdogTimer->start(); #endif if(tmp.contains("G4")) { msleep(300); } } void txThread::watchdogTimeout() { qDebug()<<"watchdogTimeout"; sendNext(); } int txThread::getLineCounter() { return lineCounter; }