Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSerialPort write more than one time, only the first writing can be response
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 834 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Samyang
    wrote on last edited by
    #1

    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?

    aha_1980A 1 Reply Last reply
    0
    • S Samyang

      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?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by aha_1980
      #2

      @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.

      Qt has to stay free or it will die.

      1 Reply Last reply
      5
      • S Offline
        S Offline
        Samyang
        wrote on last edited by
        #3

        ok, thank, i will check.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved