簡體   English   中英

Qt串行端口,當我寫時,我看不到我寫的內容

[英]Qt serial port, when i write, i can not read what i write

我可以看到我在寫緩沖區中寫的內容,但是沒有准備就緒的信號,即使我使用讀功能,讀緩沖區中也沒有任何內容。 這是我的代碼:

    void Widget::ouvrir_port_com()
{
    struct PortSettings myComSetting = {BAUD57600,DATA_8,PAR_NONE,STOP_1,FLOW_OFF,100};

    myCom = new Win_QextSerialPort(port_com,myComSetting,QextSerialBase::EventDriven);

    if(myCom ->open(QIODevice::ReadWrite))// si il est ouvert
    {
        //QMessageBox::information(this, tr("Ouvert reussi"), tr("Ce port est ouvert") + port_com, QMessageBox::Ok);
    }else// si il est pas ouvert
    {
        QMessageBox::critical(this, tr("Echec de l'ouverture"), tr("Ce port de com ne peut pas être ouvrire ") + port_com + tr("\n Ce port de com n'est pas dipnible"), QMessageBox::Ok);
         return;
    }

    connect(myCom,SIGNAL(readyRead()),this,SLOT(readCom()));

    send_command();
}

void Widget::readCom()

{
    QByteArray temp = myCom->readAll();

    ui->textBrowser->insertPlainText(temp);
}

void Widget::send_command()
{
    QString x="OK ou pas?";
    myCom->write(x.toLatin1());
    myCom->flush();

    myCom->readyRead();
}

請幫我!!!!

您可以閱讀源,posix_qextserialport.cpp第147行:“ POSIX尚未實現事件驅動機制”,因此您可以新建一個計時器並在100毫秒處輪詢。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM