当前位置:   article > 正文

QT串口通信_串口通信编程教程step by step

串口通信编程教程step by step

1、准备工作
.pro添加

QT += serialport
  • 1

头文件

#include <QSerialPort>
#include <QSerialPortInfo>
  • 1
  • 2

2、寻找空闲串口

void MainWindow::findFreePorts(){
    QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();

    for (int i = 0; i < ports.size(); ++i){
        if (ports.at(i).isBusy()){
            ports.removeAt(i);
            continue;
        }
//添加到COMBOX
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/979389
推荐阅读
相关标签
  

闽ICP备14008679号