Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt serial communication using UART
Forum Updated to NodeBB v4.3 + New Features

Qt serial communication using UART

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
21 Posts 6 Posters 13.5k Views 2 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 segtteee

    @sierdzio

    Thaky you for your reply.

    i add
    //void MainWindow::on_pushButton_send_clicked()
    {
    port->open(QSerialPort::ReadWrite);
    port->write(ui->lineEdit_command->text().toLatin1());

    }// in my code and enter the command at lineEdit , but device can't conduct command..

    Is there something else i have to anything for device's behavior?

    sierdzioS Offline
    sierdzioS Offline
    sierdzio
    Moderators
    wrote on last edited by
    #12

    @segtteee said in Qt serial communication using UART:

    in my code and enter the command at lineEdit , but device can't conduct command..

    Well, I can't guess what error codes are you getting, right? I don't even know if you connected to the device correctly. Did it get the command? Did it reply with anything? Have you connected the readyRead() to some slot, or used waitForReadyRead() to wait for the reply?

    I don't give you whole solution for your problem, I'm not here to write the code for you. I'm happy to help you overcome problems and learn.

    (Z(:^

    S 1 Reply Last reply
    3
    • sierdzioS sierdzio

      @segtteee said in Qt serial communication using UART:

      in my code and enter the command at lineEdit , but device can't conduct command..

      Well, I can't guess what error codes are you getting, right? I don't even know if you connected to the device correctly. Did it get the command? Did it reply with anything? Have you connected the readyRead() to some slot, or used waitForReadyRead() to wait for the reply?

      I don't give you whole solution for your problem, I'm not here to write the code for you. I'm happy to help you overcome problems and learn.

      S Offline
      S Offline
      segtteee
      wrote on last edited by
      #13

      @sierdzio

      okay thank you for your reply .

      i have question , how to check connected device with qt ? only i enter the command and device conduct command?

      when i debuging the code there is no error message and no problem i think . hot to check in qt ?

      1 Reply Last reply
      0
      • aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by aha_1980
        #14

        @segtteee: I can only recommend you to have a look at the examples (there are a lot of them):

        http://doc.qt.io/qt-5/qtserialport-examples.html

        Take, e.g. the Terminal example http://doc.qt.io/qt-5/qtserialport-terminal-example.html and try to understand how it works. It should be very near to what you want to achive.

        PS: This example also shows how to check for some errors. Depending on the communication protocol, you may have to add more error checks.

        Qt has to stay free or it will die.

        S 1 Reply Last reply
        0
        • aha_1980A aha_1980

          @segtteee: I can only recommend you to have a look at the examples (there are a lot of them):

          http://doc.qt.io/qt-5/qtserialport-examples.html

          Take, e.g. the Terminal example http://doc.qt.io/qt-5/qtserialport-terminal-example.html and try to understand how it works. It should be very near to what you want to achive.

          PS: This example also shows how to check for some errors. Depending on the communication protocol, you may have to add more error checks.

          S Offline
          S Offline
          segtteee
          wrote on last edited by
          #15

          @aha_1980

          I also saw an example when I wrote this project.

          But they did not come out in detail and I could not understand.

          so i search everyday and raise a question here ....

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #16

            @segtteee said in Qt serial communication using UART:

            i have question , how to check connected device with qt ? only i enter the command and device conduct command?

            First step is to check if port->open() returned true.
            When calling port->write() you can check if the amount of bytes written is the same you sent. If not, something went wrong. Then you can check QSerialPort::error and see what was the problem.

            Another clue might be whether readyRead() is emitted in response to your command. If there is no reply, then again - something might be wrong (or not - that depends on what the command is and which device you connect to).

            (Z(:^

            S 1 Reply Last reply
            0
            • sierdzioS sierdzio

              @segtteee said in Qt serial communication using UART:

              i have question , how to check connected device with qt ? only i enter the command and device conduct command?

              First step is to check if port->open() returned true.
              When calling port->write() you can check if the amount of bytes written is the same you sent. If not, something went wrong. Then you can check QSerialPort::error and see what was the problem.

              Another clue might be whether readyRead() is emitted in response to your command. If there is no reply, then again - something might be wrong (or not - that depends on what the command is and which device you connect to).

              S Offline
              S Offline
              segtteee
              wrote on last edited by
              #17

              @sierdzio

              Thank you for your answer during long time.

              i try but i can't solve this situation. but i learn many thing thank to your reply.

              i'm really thank you .

              1 Reply Last reply
              1
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #18

                Hi
                For a pretty good example, please see
                http://doc.qt.io/qt-5/qtserialport-terminal-example.html
                It has dialog to select comport properties and allows to send text out of the box.
                Its also pretty good explained.~

                aha_1980A 1 Reply Last reply
                0
                • mrjjM mrjj

                  Hi
                  For a pretty good example, please see
                  http://doc.qt.io/qt-5/qtserialport-terminal-example.html
                  It has dialog to select comport properties and allows to send text out of the box.
                  Its also pretty good explained.~

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

                  @mrjj Thats what I wrote three days ago...

                  Qt has to stay free or it will die.

                  mrjjM 1 Reply Last reply
                  2
                  • aha_1980A aha_1980

                    @mrjj Thats what I wrote three days ago...

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #20

                    @aha_1980
                    Oh yes. sorry. i did miss. Clicked from locked thread. Should have read it all :)

                    1 Reply Last reply
                    0
                    • aha_1980A Offline
                      aha_1980A Offline
                      aha_1980
                      Lifetime Qt Champion
                      wrote on last edited by
                      #21

                      @mrjj said in Qt serial communication using UART:

                      @aha_1980
                      Oh yes. sorry. i did miss. Clicked from locked thread. Should have read it all :)

                      No problem :) (And no need to delete your post)

                      Qt has to stay free or it will die.

                      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