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

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

 

  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支持两种编程方法:app

  

  • 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())暂停呼叫线程,直到操做完成。
相关文章
相关标签/搜索