Blocking Master Example QT 自带 的 serial 即 串口 例子

1、官方解释文档:http://doc.qt.io/qt-5/qtserialport-blockingmaster-example.html

 

  Blocking Master shows how to create an application for a serial interface using the synchronous API of QSerialPort in a worker thread.

  阻塞主程序显示了如何使用QSerialPort的同步API在同个工作线程中为串行接口创建应用程序。

  

QSerialPort supports two programming alternatives:

QSerialPort支持两种编程方法:

  

  • The asynchronous (non-blocking) alternative. Operations are scheduled and performed when the control returns to the Qt event loop. TheQSerialPort class emits a signal when the operation is finished. For example, the write() method returns immediately. When the data is sent to the serial port, the QSerialPort class emits the bytesWritten() signal.
  • The synchronous (blocking) alternative. In headless and multithreaded applications, the wait method can be called (in this case,waitForReadyRead()) to suspend the calling thread until the operation has completed.
  •   异步(不阻塞)二者选择一种。当控制返回到Qt事件循环时,调度并执行操作。QSerialPort类在操作完成时发出一个信号。例如,write()方法立即返回。当数据被发送到串行端口时,QSerialPort类会发出bytes笔试()信号。
  •   同步(阻塞)的选择。在无头的和多线程的应用程序中,可以调用wait方法(在本例中,waitForReadyRead())暂停呼叫线程,直到操作完成。

 

posted on 2018-03-23 10:14  所长  阅读(746)  评论(0)    收藏  举报

导航