Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. QtSerialPort sending data
Qt 6.11 is out! See what's new in the release blog

QtSerialPort sending data

Scheduled Pinned Locked Moved 3rd Party Software
5 Posts 3 Posters 3.8k 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.
  • E Offline
    E Offline
    Erni35
    wrote on last edited by
    #1

    Hi and hello,

    short problem. I try to send 3 commands with QtSerialPort to a device. If I send them in 3 different routines triggered by 3 buttons it works perfect. If I call these 3 routines from one additional routine it fails. The fourth routine includes the correct timing (sleep(2000)) on a windows system. A port sniffer shows the right commands, a break of 2000 ms from the first one to the second, but the third one comes together with the second one.
    @
    button1-click -> command1
    button2-click -> command2
    button3-click -> command3
    @
    the other way
    @
    button4-click -> command1 -> sleep(2000)->command2->sleep(2000)->command3
    @
    Why there is no break between command2 and command3 in the second way?

    Thanks,
    Erni35

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2

      Please do not use sleep() call, because it is freeze event-loop.
      Instead use QTimer with command interval 2000 msec to send.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Erni35
        wrote on last edited by
        #3

        OK.
        But then I have to use signal - slot more...
        My little problem I solved this way. Now I wait for the response from the first command in a signal - slot loop, and it helps

        Erni35

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          IMHO, if you're going to use Qt, then you really need to lose the idea that using signals and slots are bad or cumbersome or something to avoid having to use. They're a fundamental part of the tool kit.

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • E Offline
            E Offline
            Erni35
            wrote on last edited by
            #5

            I know. And now, with using these tools it loks pretty good. And it works! Thanks you.

            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