当前位置: 首页>>代码示例>>C++>>正文


C++ QSerialPortInfo::portName方法代码示例

本文整理汇总了C++中QSerialPortInfo::portName方法的典型用法代码示例。如果您正苦于以下问题:C++ QSerialPortInfo::portName方法的具体用法?C++ QSerialPortInfo::portName怎么用?C++ QSerialPortInfo::portName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSerialPortInfo的用法示例。


在下文中一共展示了QSerialPortInfo::portName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: open

bool SerialCommandQueue::open(QSerialPortInfo info)
{
    if (isConnected()) {
        qCritical("Already connected to serial device");
        return false;
    }

    qDebug() << "connecting to " << info.portName();

#if defined(Q_OS_OSX)
    // Note: This should be info.portName(). Changed here as a workaround for:
    // https://bugreports.qt.io/browse/QTBUG-45127
    serial->setPortName(info.systemLocation());
#else
    serial->setPortName(info.portName());
#endif
    serial->setBaudRate(QSerialPort::Baud115200);

    if (!serial->open(QIODevice::ReadWrite)) {
        qDebug() << "Could not connect to serial device. Error: " << serial->error()
                 << serial->errorString();
        return false;
    }

    return true;
}
开发者ID:dunk8888,项目名称:PatternPaint,代码行数:26,代码来源:serialcommandqueue.cpp

示例2: foreach

 foreach (const QSerialPortInfo &info, BlinkyTape::findBlinkyTapeBootloaders()) {
     report.append("  " + info.portName() + "\r");
     report.append("    Manufacturer: " + info.manufacturer() + "\r");
     report.append("    Description: " + info.description() + "\r");
     report.append("    VID: 0x" + QString::number(info.vendorIdentifier(),16) + "\r");
     report.append("    PID: 0x" + QString::number(info.productIdentifier(),16) + "\r");
 }
开发者ID:invariant,项目名称:PatternPaint,代码行数:7,代码来源:systeminformation.cpp

示例3: QSerialPort

/*!
 * \brief Rs232DevicePrivate::Rs232DevicePrivate - CTor
 * \param info
 * \param parent
 */
Rs232DevicePrivate::Rs232DevicePrivate(const QSerialPortInfo &info, QObject *parent) :
    QSerialPort(info, parent)
{
    m_debug = false;

    qDebug() << headDebug << "CTor" << info.portName();

    // Faccio partire un timer: se entro il suo timeout non ho trovato il converter mi autodistruggo
    connect (&m_timerAutodelete, SIGNAL(timeout()), this, SLOT(deleteLater()));
    m_timerAutodelete.start(2000);

    connect (&m_timerSendGetId, SIGNAL(timeout()), this, SLOT(sendMsgGetId()));

    // Sono riuscito a configurare la porta?
    if (configPort())
    {
        // Si, la porta e' fisica e non virtuale.
        m_statoParser = STATO_RS232_DLE_STX;
        m_checksum = 0;

        connect(this, SIGNAL(error(QSerialPort::SerialPortError)),
                this, SLOT(errorSlot(QSerialPort::SerialPortError)));
        connect(this, SIGNAL(readyRead()), this, SLOT(fromDeviceSlot()));

        // Spedisco il messaggio per sapere se e' collegato un converter
        sendMsgGetId();
    }
}
开发者ID:specialk74,项目名称:ComOven2,代码行数:33,代码来源:rs232deviceprivate.cpp

示例4: QMainWindow

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    ui->setupUi(this);

    ui->console->clear();

    timerMOTOR = new QTimer(this);


    ui->comboBox_baundrate->addItem("57600",QSerialPort::Baud57600);
    ui->comboBox_baundrate->addItem("9600",QSerialPort::Baud9600);


    for(QSerialPortInfo port : QSerialPortInfo::availablePorts())
        ui->comboBox_port->addItem(port.portName(),port.description());

    serialhandler = new SerialHandler(this);


    connect(serialhandler,SIGNAL(console(QString)),ui->console,SLOT(insertPlainText(QString)));

    connect(serialhandler,SIGNAL(motor1(int)),ui->bar_m1,SLOT(setValue(int)));
    connect(serialhandler,SIGNAL(motor2(int)),ui->bar_m2,SLOT(setValue(int)));
    connect(serialhandler,SIGNAL(motor3(int)),ui->bar_m3,SLOT(setValue(int)));
    connect(serialhandler,SIGNAL(motor4(int)),ui->bar_m4,SLOT(setValue(int)));

    ui->pushButton_connect->click();

}
开发者ID:SakkeS,项目名称:Quadcopter,代码行数:32,代码来源:mainwindow.cpp

示例5: foreach

    foreach (QSerialPortInfo info, QSerialPortInfo::availablePorts())
    {
        //QListWidgetItem * item = new QListWidgetItem( info.portName(),this->ui->list);
        QListWidgetItem * item = new QListWidgetItem( info.portName());
        this->ui->list->addItem(item);
        item->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
        item->setCheckState(Qt::Checked);

    }
开发者ID:alezz,项目名称:serialsurveyor,代码行数:9,代码来源:dlgsetup.cpp

示例6: foreach

 //  Found the available ports, associated vendor id and product id
 foreach(const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()){
     if(serialPortInfo.hasVendorIdentifier() && serialPortInfo.hasProductIdentifier()){
         if(serialPortInfo.vendorIdentifier() == found_vendorID){
             if(serialPortInfo.productIdentifier() == found_productID){
                 arm_portname = serialPortInfo.portName();
                 arm_port_is_available = true;
             }
         }
     }
 }
开发者ID:lamarts,项目名称:Tiva-TM4C-ARM-Coretex-M4-UART---Qt-C-GUI,代码行数:11,代码来源:mainwindowMac.cpp

示例7: PrintPortInfo

QT_USE_NAMESPACE

void CardReader::PrintPortInfo(const QSerialPortInfo &info)
{
    QTextStream cout(stdout);
    cout << "Name        : " << info.portName() << endl
         << "Description : " << info.description() << endl
         << "Manufacturer: " << info.manufacturer() << endl
         << "Is busy     : " << info.isBusy() << endl
         << endl;
}
开发者ID:SQReder,项目名称:com-mitm,代码行数:11,代码来源:cardreader.cpp

示例8: QWidget

serialportconnectioncontrols::serialportconnectioncontrols(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::serialportconnectioncontrols)
{
    ui->setupUi(this);
    connected = false;
    QList <QSerialPortInfo> ports = portInfo.availablePorts();
    QSerialPortInfo tmp;
    for(int i=0;i<ports.size();i++)
    {
        tmp = ports.at(i);
        ui->PortBox->addItem(tmp.portName());
    }
    autoconnect = true;
}
开发者ID:brucetsao,项目名称:Arduino_Communication,代码行数:15,代码来源:serialportconnectioncontrols.cpp

示例9: sortPorts

bool sortPorts(const QSerialPortInfo &s1, const QSerialPortInfo &s2)
{
    return s1.portName() < s2.portName();
}
开发者ID:CodeMining,项目名称:OpenPilot,代码行数:4,代码来源:serialplugin.cpp

示例10: main

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    // Get list of all serial ports
    QList<QSerialPortInfo> serialInfoList = QSerialPortInfo::availablePorts();
    qDebug();
    if (!serialInfoList.size() > 0)
    {
        qDebug() << "no serial ports found";
        return app.exec();
    }
    else
    {
        qDebug() << "List all serial ports";
        qDebug() << "---------------------";
        for (int i=0; i<serialInfoList.size(); i++)
        {
            QSerialPortInfo serialInfo = serialInfoList.at(i);
            qDebug() << "port: " << i;
            qDebug() << "  name:          " << serialInfo.portName();
            qDebug() << "  description:   " << serialInfo.description();
            qDebug() << "  manufacturer:  " << serialInfo.manufacturer();
            //qDebug() << "  serial Number: " << serialInfo.serialNumber();
            if (serialInfo.hasVendorIdentifier())
            {
                qDebug() << "  vendorId:     " << serialInfo.vendorIdentifier();
            }
            if (serialInfo.hasProductIdentifier())
            {
                qDebug() << "  producId:     " << serialInfo.productIdentifier();
            }
            qDebug();
        }
    }

    qDebug() << "opening panels controller";
    QSerialPortInfo serialInfo = serialInfoList.at(0);
    bias::PanelsController pcontrol(serialInfo);
    bool isOpen = pcontrol.open();
    if (!isOpen)
    {
        qDebug() << "  unable to open device";
        return app.exec();
    }
    qDebug() << "  device opened";

     if (true)
    {
        qDebug() << "  blink led";
        pcontrol.blinkLED();
        QThread::msleep(4000);
    }

    // Test allOn, allOff 
     if (true)
    {
        for (int i=0; i<5; i++)
        {
            qDebug() << "  all on";
            pcontrol.allOn();
            QThread::msleep(500);
            qDebug() << "  all off";
            pcontrol.allOff();
            QThread::msleep(500);
        }
    }

    // Test setToGrayLevel
     if (true)
    {
        for (int i=0; i<2; i++)
        {
            for (int j=1; j<bias::PanelsController::NUM_GRAY_LEVEL; j++)
            {
                qDebug() << "  set to gray level = " << j;
                pcontrol.setToGrayLevel(j);
                QThread::msleep(100);
            }
            for (int j=bias::PanelsController::NUM_GRAY_LEVEL-1; j>=0; j--) 
            {
                qDebug() << "  set to gray level = " << j;
                pcontrol.setToGrayLevel(j);
                QThread::msleep(100);
            }
        }
    }

    // Test setConfigID
     if (true)
    {
        int id = 1;
        qDebug() << "  set config id = " << id;
        pcontrol.setConfigID(id);
        QThread::msleep(1000);
    }


    // Test setPatternID 
    if (true)
//.........这里部分代码省略.........
开发者ID:janelia-idf,项目名称:bias,代码行数:101,代码来源:test_panels_controller.cpp

示例11: on

void Kompas::on()
{

    timer->stop();
    QSerialPortInfo *info = new QSerialPortInfo(*port);
    if(!(port->isOpen() && info->portName() == settings->m_name_COM))
    {
        if(port->isOpen())
            port->close();

        qDebug()<<settings->m_name_COM;
        port->setPortName(settings->m_name_COM);
        if (port->open(QIODevice::ReadWrite))
        {
            QFile file("dataRead.dat");
            if (file.open(QIODevice::ReadOnly | QIODevice::Text))
            {
               QTextStream stream(&file);
               m_skl = stream.readLine().toInt();
               m_coef_A = stream.readLine().toInt();
               file.close();
            }

            updateSettings();
            QSerialPortInfo *info = new QSerialPortInfo(*port);
            qDebug() << "Name        : " << info->portName();
            qDebug() << "Description : " << info->description();
            qDebug() << "Manufacturer: " << info->manufacturer();
            qDebug() << "BaudRate: " << port->baudRate();
            qDebug() << "Parity: " << port->parity();
            qDebug() << "Data bits: " << port->dataBits();
            qDebug() << "Stop Bits: " << port->stopBits();
            delete info;
            m_state=1;
            emit stateChanged();
            m_connect_state=1;
            emit connect_stateChanged();
            qDebug()<<"state = 1 ON";
            qDebug()<<settings->m_name_COM<<"opened";
        }
        else
        {
            if(port->isOpen())
                port->close();
            qDebug()<<"Error while opening";
        }
    }
    if(port->isOpen() && port->waitForReadyRead(1000))
    {
        QString data;
        QByteArray ByteArray;
        m_state = 1;
        while(m_state)
        {
            qint64 byteAvail = port->bytesAvailable();
            qApp->processEvents();
            if(byteAvail >=13)
            {
                ByteArray = port->readAll();
                data = data.fromLocal8Bit(ByteArray).trimmed();
                if(ByteArray[3]=='p')
                {
                    QBitArray bitdata(104),two_bytes(16);
                    for(int i = 0,j; i < 104; ++i)
                    {
                        j=i/8;
                        if(j<=13)
                            bitdata[i] = ByteArray[j] & (1 << i%8);
                        else
                            break;
                    }

                    for(int i=40,j=15;i<56&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Roll
                    setRoll(Round(toDec(two_bytes,1)*1.41,1));
                    for(int i=56,j=15;i<72&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Pitch
                    setPitch(Round(toDec(two_bytes,1)*1.41,1));
                    for(int i=72,j=15;i<88&&j>=0;i++,j--){two_bytes[j]=bitdata[i];} //Azimuth

                    setAngle(Round(toDec(two_bytes,0)*1.41,1));
                    m_state=0;
                    qApp->processEvents();
                }
            }
        }
    }
    else
    {
        qDebug()<<"WaitForReadyRead failed";
        qDebug()<<port->error();
    }
    kompasThread1->quit();
    timer->start(10);
}
开发者ID:Navi-Dals,项目名称:Compass,代码行数:93,代码来源:kompas.cpp

示例12: equalPredicat

bool Cooller_ModBusController::equalPredicat(QSerialPortInfo& first, QSerialPortInfo& second)
{
    return first.portName() == second.portName();
}
开发者ID:Pryadka,项目名称:AirCoolControll,代码行数:4,代码来源:Cooller_ModbusController.cpp

示例13: operator

 bool operator() (const QSerialPortInfo &serialPortInfo) const
 {
     return serialPortInfo.portName() == m_serialPortName;
 }
开发者ID:xjohncz,项目名称:qt5,代码行数:4,代码来源:qserialportinfo_win.cpp

示例14: setDeviceInfo

void StatusBar::setDeviceInfo(const QSerialPort *port)
{
    QSerialPortInfo info = QSerialPortInfo(*port);
    if (info.isValid()) {
        QString deviceInfo = QString("%1 %2 @%3").arg(info.manufacturer()).arg(info.description()).arg(info.portName());
        m_lb_deviceName->setText(deviceInfo);
    }
}
开发者ID:Arento,项目名称:CuteCom,代码行数:8,代码来源:statusbar.cpp

示例15: sortPorts

bool sortPorts(QSerialPortInfo const & s1, QSerialPortInfo const & s2)
{
    return s1.portName() < s2.portName();
}
开发者ID:nongxiaoming,项目名称:QGroundStation,代码行数:4,代码来源:gpsdisplaygadgetoptionspage.cpp


注:本文中的QSerialPortInfo::portName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。