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())暫停呼叫線程,直到操做完成。
相關文章
相關標籤/搜索