QSerialPort write more than one time, only the first writing can be response



  • when click button, then write at to mobile, can get response "ok"

    void MainWindow::on_show_clicked()
    {
    inputdata="at\r\n";
    WriteData();
    ui->Output->append(str);

    }
    but if click button, then write more than one string to mobile, only can get response "ok" for first "at

    void MainWindow::on_show_clicked()
    {
    inputdata="at\r\n";
    WriteData();
    millisleep(50);
    str =inputdata;
    ui->Output->append(str);
    inputdata="at+cops?\r\n";
    WriteData();
    millisleep(50);
    str =inputdata;
    ui->Output->append(str);
    inputdata="at\r\n";
    WriteData();
    millisleep(50);
    str =inputdata;
    ui->Output->append(str);
    }

    so check the debug info, the cmd "at\r\n", "at+cops?\r\n","at\r\n" should be sent to mobile, but only first "at" can get response "ok", why?


  • Qt Champions 2017

    @Samyang dont use sleep in event driven programs. use QTimer instead, otherwise signals&slots are not working.

    have a look at Qts Terminal example, e.g.



  • ok, thank, i will check.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.