Okay so I connected the Signal to the Slot
This is my handlePortReadyRead Slot:
for(int charCount = 0; charCount < temp.count(); charCount++){
char singleInChar = temp.at(charCount);
validationFlag = handleResponse(&response, deviceAddr, FID, singleInChar, false);
if(validationFlag){
if(response.at(0) != 0){ // device sent error code
displayErrorMessage(response.at(0));
}
emit readCompleteFrame();
break;
}
}
byteReceived = true;
QByteArray temp = RS485port.readAll();
for(int charCount = 0; charCount < temp.count(); charCount++){
char singleInChar = temp.at(charCount);
validationFlag = handleResponse(&response, deviceAddr, FID, singleInChar, false);
if(validationFlag){
if(response.at(0) != 0){ // device sent error code
displayErrorMessage(response.at(0));
}
emit readCompleteFrame();
break;
}
}
byteReceived = true;
To copy to clipboard, switch view to plain text mode
I'm having a process, where I write many times to the port and then want to analyse the response. At the moment it looks like this:
RS485Port.write(dataToSend);
timer->start(100);
do{
if(validationFlag){
...
//do something with the response
response.clear();
}
else if(timer->remainingTime() == 0){
... //check if no connection or no valid Frame
}
}
while(!validationFlag);
RS485Port.write(dataToSend);
timer->start(100);
do{
QApplication::processEvents();
if(validationFlag){
...
//do something with the response
response.clear();
}
else if(timer->remainingTime() == 0){
... //check if no connection or no valid Frame
}
}
while(!validationFlag);
To copy to clipboard, switch view to plain text mode
So this process is a very long process. Sometimes it get stucked in the middle of the code, I think it is because of the QApplication:
rocessEvents().
Is there any better way?
Bookmarks