1
votes

I am using Qserialport to receive a 7 byte data on every 10 ms. the baud rate is 115200. and i use signal(readyread) and slot(readLine in a separate function) method. the ready read signal is only emitted on every 16ms. but my device sends data at 10 ms interval. How to receive the samples at 10ms interval. how to make the readyread signal to emit at 10ms interval. Thanks

1

1 Answers

2
votes

In general readyread signal would be emitted even if one byte is received. But the response time depends on many factors like the driver, CPU load or how much the Qt event-loop is busy.

When a receive is detected in the serial port, all data in the driver buffer will be read and then the signal readyRead() will be emitted. It is possible that some more bytes arrive to the port from the moment the driver detects the receive until it tries to read all buffer.

If you want to read the data at certain intervals, you don't need to use the readyRead signal. You can have QTimer with 10 ms intervals, and connect it's timeout signal to some slot in which you read data by calling readAll().