Fixed bug, that made the timeout look like an empty response
This commit is contained in:
parent
2849dc0e3b
commit
19acffbe11
1 changed files with 8 additions and 6 deletions
|
@ -51,13 +51,14 @@ bool BuzzerConn::connect()
|
||||||
|
|
||||||
//wait for the connection to finish
|
//wait for the connection to finish
|
||||||
loop.exec();
|
loop.exec();
|
||||||
timer.stop();
|
|
||||||
|
|
||||||
if(timer.remainingTime() == 0){
|
//loop finished
|
||||||
|
if(timer.remainingTime() == -1){
|
||||||
//the time has been triggered -> timeout
|
//the time has been triggered -> timeout
|
||||||
setState("disconnected");
|
setState("disconnected");
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
timer.stop();
|
||||||
|
|
||||||
|
|
||||||
QList<double> times = gettimes(2000, true);
|
QList<double> times = gettimes(2000, true);
|
||||||
|
@ -115,7 +116,6 @@ QList<double> BuzzerConn::gettimes(int timeout, bool bothTimes)
|
||||||
QList<double> times;
|
QList<double> times;
|
||||||
signed long ret;
|
signed long ret;
|
||||||
ret = this->sendCommand("GET_TIMESTAMP", timeout);
|
ret = this->sendCommand("GET_TIMESTAMP", timeout);
|
||||||
qDebug() << timeout << bothTimes;
|
|
||||||
if(ret >= 0){
|
if(ret >= 0){
|
||||||
|
|
||||||
times.append(double(200));
|
times.append(double(200));
|
||||||
|
@ -262,15 +262,17 @@ signed long BuzzerConn::sendCommand(QString command, int timeout){
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
||||||
//loop finished
|
//loop finished
|
||||||
timer.stop();
|
if(timer.remainingTime() == -1){
|
||||||
if(timer.remainingTime() == 0){
|
|
||||||
//the time has been triggered -> timeout
|
//the time has been triggered -> timeout
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer.stop();
|
||||||
|
|
||||||
|
|
||||||
//if the data is not 4 bytes long it is invalid -> clear and terminate
|
//if the data is not 4 bytes long it is invalid -> clear and terminate
|
||||||
if(this->socket->bytesAvailable() != 4){
|
if(this->socket->bytesAvailable() != 4){
|
||||||
qDebug() << this->socket->readAll();
|
this->socket->readAll();
|
||||||
return(-2);
|
return(-2);
|
||||||
}
|
}
|
||||||
long data = 0;
|
long data = 0;
|
||||||
|
|
Reference in a new issue