Unsolved Issue in making GUI responsive
-
@Kira That example shows how to use SYNCHRONOUS API in GUI thread. But why do you want to use synchronous API instead of the asynchronous? If there is no valid reason to use synchronous API use the asynchronous - this is WAY easier compared to dealing with threads.
-
@Kira and just to add to @jsulm:
I doubt the serial port handling is your problem. Serial ports are slow and handling them with signals and slots is most often no problem.
I think your problem is handling the data you received through serial port. If that takes a bit longer, you'll block your GUI.
Regards
-
@jsulm said in Issue in making GUI responsive:
That example shows how to use SYNCHRONOUS API in GUI thread.
Will this approach cause my GUI to hang if i don't get a timely response??
Can you please suggest how can i implement the following requirement using asynchronous approch?
->Send serial data
->Read the data
->If data read successfully than allow another serial request. -
@aha_1980 said in Issue in making GUI responsive:
I think your problem is handling the data you received through serial port. If that takes a bit longer, you'll block your GUI.
I have used the standard example to get data from the serial port. Still sometimes i don't get response on my serialPort.
Will look again into the issue and see to it that the data handling is done properly.If the above asynchronous approach will cause my GUI to hang i will have to use the second appoach.
-
@Kira said in Issue in making GUI responsive:
Will this approach cause my GUI to hang if i don't get a timely response??
Not in that example. But again: why not simply use asynchronous API? Why do you make things unnecessary complex?
-
@jsulm said in Issue in making GUI responsive:
Not in that example. But again: why not simply use asynchronous API? Why do you make things unnecessary complex?
@jsulm : Actually i am writing program for system which is completely based on feedback mechanism.
As an example: If i give the my device command to move 15 steps in an axis i will have wait for feedback from my controller device after than i can allow user to give next command.
Feedback is generated by after the device have moved. It is also observed that if i continuously request the device without getting the feedback, serial port hangs most of the time.For different command there are different feedback. I will have to analyse the feedback generated
and allow for controller to move.If the feedback mechanism can be implemented in asynchronous approch i would be happy to implement.Can you please help with an example if already available?
I have checked the terminal example in qt creator but it does not have feedback mechanism -
@Kira You can take a look at this: https://doc.qt.io/qt-5/qstatemachine.html
-
@jsulm said in Issue in making GUI responsive:
You can take a look at this: https://doc.qt.io/qt-5/qstatemachine.html
@jsulm : Hi, just a last clarfication. I went through the documentation of statemachine.
And i have following signal and slots:
connect(serial, &QSerialPort::readyRead, this, &MainWindow::readData);connect(console, &Console::getData, this, &MainWindow::writeData);
How can i apply the state machine logic to this
Thanks and regards -
The idea would be that you will drive the state machine based on the feedback your receive from the device.
One controller object that will send command and parse answers and will emit something that will allow the state machine to go to the next state.
-
@SGaist : Thanks for the reply just one thing i need to clarify.
Just couple of doubts .
How can i handle the situation if there is no response for the serial input? -
In what case would that happen ?
Do you have some times guarantees with regard to answer from the device ?