Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED]How to implement serial communication with a GUI
adgova last edited by adgova
I am not sure if this should be posted here, but I'll give it a try. Let me know if it should be posted somewhere else and I'll try to me move it, till then bare with me as I don't know my way around here.
I am trying to develop an application that will constantly receive and send data over a serial protocol (RS-232). It will need to update the GUI to show the changes occurring in the other device (temperature changes) almost instantly and it will need to do some calculations based on received data and send commands to the device to order the next actions to be taken by the device (increase heater power or cooler power). My question how important is it to implement these communication and calculation codes in a separate thread? or is there even better alternative to threading?
Hi and welcome to devnet,
You can benefit from Qt's asynchronous architecture. Unless you are doing very intensive calculation there's no need to start thinking about thread for serial communication.
Just implement your classes using Qt's signals and slots, and only then if you really have a performance bottleneck, start thinking about threads.
adgova last edited by
Hi and thank you for your reply.
The calculation might be intensive, I am not sure of that yet. I will need to implement some sort of PID control and auto tune algorithm. I am thinking I can start of without threading and then switch if it becomes important.
one more question though, when you say asynchronous architecture, are you referring to the signal-slot mechanism or other classes and namespaces like QRunable and QT Concurent?
Signal Slots and events. QRunnable and QtConcurrent are high level threading related classes
adgova last edited by
Thanks for your help.
You're welcome !
If that answers your questions then please update the thread title prepending [solved] so other forum users may know a solution has been found :)
Also, consider up voting the answer(s) that you find useful, it will help others to find them more easily :)