PDA

View Full Version : Collect data from different Serial Port Threads "simultaneously"



CqpUHkc
1st August 2018, 13:56
Hello everyone! I have some problems with the concept for synchronized data collection. I have 3 Serial Ports (sensors are connected over usb cdc-acm. it's a development kit with Linux on board). Each QSerialPort is in separate Thread (over moveToThread). I send Data to these ports from gui-thread simultaneously (doing with connect one Signal to 3 SerialPort Slots) and become Data from each sensor, Request–Response method. Additionaly i have placed parser in each Serial Port Thread. Now i want to collect received, parsed data from each SerialPort Thread simultaneously (synchronize?). After all data are collected i want process/compare data and send result to the Gui thread (Showing data in qTableWidget etc.).

Is there a standard procedure or does someone have a suggestion how to do that?

12909

Thank you very much!

wysota
20th August 2018, 10:30
The whole point of creating separate threads for each port is to make them asynchronous relative to each other. Seems that this is not what you want. Thus you should handle all three ports in a single thread (which is what you should be doing anyway). Signals such as readyRead() are emitted when there is anything to be read on the port so you can connect to those and do the reading from all the ports in the main thread.