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 with arduino problem
QtWS25 Last Chance

QSerialport with arduino problem

Scheduled Pinned Locked Moved General and Desktop
qserialportarduino
3 Posts 2 Posters 2.0k Views
  • 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.
  • L Offline
    L Offline
    lotin
    wrote on 25 Aug 2015, 14:34 last edited by
    #1

    Hi,
    i have a problem with comunication between pc and arduino uno.
    I have this code for communicating:
    <code>

    serial->write(data_char);    
    int waitTimeout = 1000;
    if (serial->waitForBytesWritten(waitTimeout)) {      
        if (serial->waitForReadyRead(waitTimeout)){
            QByteArray response =  serial->readAll();
            qDebug() << "response" << response;
        } else {
            qDebug() <<"Wait read response timeout %1";
        }
    } else {
        qDebug() << "Wait write request timeout %1";
    }
    

    </code>
    I want to send data and wait until arduino answers.
    Ok, it send data and waiting for response, but i getting the actual response and the previous response to.

    For example:
    I will connect the program with serial port and send first "message" , for example 12, and the first response is ok, i get 12.
    But when now i send, for example 78, the response is "1278".
    And then when i send for example 3, the response is "783".
    .
    .
    .

    I´ve tried lots of possibilities, but nothing were good. Can you help me please. Thank you.

    Program in arduino works fine in terminal.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 25 Aug 2015, 14:47 last edited by
      #2

      You can try to check it with the Terminal example which comes with the QSerialPort

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lotin
        wrote on 26 Aug 2015, 16:31 last edited by
        #3

        Yes, i made this program by the terminal example.

        I solve it. I use QStringList to delete the first response.

        But, i thank you for for answer.

        1 Reply Last reply
        0

        1/3

        25 Aug 2015, 14:34

        • Login

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