问题描述
有没有一些方法,我的串行设备已准备好接收更多的数据被通知?
我使用的。该项目工程,但似乎我遇到拥堵。
I am implementing a program that feeds commands to a servo controller over serial using the asynchronous API of QSerialPort. The program works, but it seems that I am experiencing congestion.
在我的应用程序保持最新伺服位置的注册,我希望与低延迟尽量控制器同步。我在尽可能快地时间让我推新数据的串行端口作法会导致什么,我认为是使通信打破完全数据的积累。
In my application I keep a registry of most updated servo position that I wish to synchronize with the controller with as low latency as possible. My attempt at pushing new data to the serial port as quickly as time lets me leads to what I think is a buildup of data that makes the communication break down altogether.
我的问题是,我可以得到通知时,串行接口已准备好以某种方式接收新的数据,而使用 QSerialPort
中的异步的模式?
My question is, can I be notified when the serial interface is ready to receive new data somehow while using QSerialPort
in asynchronous mode?
唯一的其他选择我看到的是使用的同步的模式和调用的但我真的不想这样做。
The only other option I see is to use synchronous mode and call waitForBytesWritten() But I really don't want to do that.
请注意:我研究href=\"http://doc.qt.io/qt-5/qtserialport-examples.html\" rel=\"nofollow\">串口例子QT5文档
NOTE: I have studied the serial port examples in the Qt5 documentation carefully, but the example for asynchronous write does not provide the information I need, as it perform a one-shot send before quitting.
推荐答案
您可以监听信号 bytesWritten
和检查 bytesToWrite
来确定该写缓冲区是空的。无论是从的QIODevice
继承。
You could listen to the signal bytesWritten
and check bytesToWrite
to determine if the write buffer is empty. Both are inherited from QIODevice
.
这篇关于如何知道什么时候QSerialPort准备在QT5更多的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!