Hi,

I am working on an application which communicates with an appliance attached to the serial port. The application send commands and waits for the appliance's reply, or until timeout. Currently I am doing the waiting using an instance of QEventLoop, however I read that using QEventLoop leads to subtle bugs. So now I need to redesign my application logic, which currently depends on a method which sends data out of the port and waits for a response of certain length.

What I want to achieve is (pseudocode):
Qt Code:
  1. response = connection.sendQuery(query, responseLength, timeout)
  2. if (response.length() == responseLength) {
  3. // valid response
  4. } else {
  5. //invalid response
  6. }
To copy to clipboard, switch view to plain text mode 

Can you please suggest a strategy for creating that logic?

Thanks