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. Qt Modbus RTU timeout
Forum Updated to NodeBB v4.3 + New Features

Qt Modbus RTU timeout

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 4.2k 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
    szergejbubka
    wrote on last edited by
    #1

    Hi,

    I have a PLC communicating with Modbus RTU. I compiled and run the Modbus master example in Qt 5.11, and it throws timeout errors, when I try to read the holding registers. I set all parameters correctly and the PLC works well too. I know it, because if I compile the same Qt example with Qt 5.8 instead of 5.7, 5.9, 5.10 or 5.11, it works well and responses correctly. The debug messages show that the response arrives correctly on all versions, but somehow not processed by the Qt Modbus module, instead throws error after the timeout period elapsed. I use Ubuntu Linux 64bit, and previously already deployed an industrial project using modbus with Qt 5.8 successfully. Can this false behaviour somehow changed? Maybe a new parameter somewhere?

    Thanks.
    Best,
    Andras

    Pablo J. RoginaP 1 Reply Last reply
    0
    • Cleiton BuenoC Offline
      Cleiton BuenoC Offline
      Cleiton Bueno
      wrote on last edited by
      #2

      Hi, @szergejbubka

      What register value are you trying to read?
      Could you please attach the error here?


      Cleiton Bueno

      Blog | Linkedin | B2Open

      S 1 Reply Last reply
      0
      • Cleiton BuenoC Cleiton Bueno

        Hi, @szergejbubka

        What register value are you trying to read?
        Could you please attach the error here?


        Cleiton Bueno

        Blog | Linkedin | B2Open

        S Offline
        S Offline
        szergejbubka
        wrote on last edited by
        #3

        Hi @Cleiton-Bueno,

        I tried multiple holding register read starting from 0 and reading 1 register (but I even tried other parameters, more registers, starting from 1, etc.). The connection parameters are 115200,8,N,1, it is a virtual com port on /dev/ttyACM0. The device address is 2. The timeout is 1000ms and the retries are 3 attempts. With Qt 5.11 I get this output:

        qt.modbus: (RTU client) Sent Serial PDU: 0x0300000001
        qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x0203000000018439
        qt.modbus.lowlevel: (RTU client) Response buffer: "0203020000fc44"
        qt.modbus: (RTU client) Received ADU: "0203020000fc44"
        qt.modbus: (RTU client) Send successful: 0x0300000001
        qt.modbus: (RTU client) Receive timeout: 0x0300000001
        qt.modbus: (RTU client) Sent Serial PDU: 0x0300000001
        qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x0203000000018439
        qt.modbus.lowlevel: (RTU client) Response buffer: "0203020000fc44"
        qt.modbus: (RTU client) Received ADU: "0203020000fc44"
        qt.modbus: (RTU client) Send successful: 0x0300000001
        qt.modbus: (RTU client) Receive timeout: 0x0300000001
        qt.modbus: (RTU client) Sent Serial PDU: 0x0300000001
        qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x0203000000018439
        qt.modbus.lowlevel: (RTU client) Response buffer: "0203020000fc44"
        qt.modbus: (RTU client) Received ADU: "0203020000fc44"
        qt.modbus: (RTU client) Send successful: 0x0300000001
        qt.modbus: (RTU client) Receive timeout: 0x0300000001
        qt.modbus: (RTU client) Sent Serial PDU: 0x0300000001
        qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x0203000000018439
        qt.modbus.lowlevel: (RTU client) Response buffer: "0203020000fc44"
        qt.modbus: (RTU client) Received ADU: "0203020000fc44"
        qt.modbus: (RTU client) Send successful: 0x0300000001
        qt.modbus: (RTU client) Receive timeout: 0x0300000001
        

        Whereas with Qt 5.8 I get this one:

        qt.modbus: (RTU client) Sent Serial PDU: 0x0300000001
        qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x0203000000018439
        qt.modbus.lowlevel: (RTU client) Response buffer: "0203020000fc44"
        qt.modbus: (RTU client) Received ADU: "0203020000fc44"
        

        It really seems like the error is in the processing of the response.

        Thanks,
        András

        1 Reply Last reply
        0
        • S szergejbubka

          Hi,

          I have a PLC communicating with Modbus RTU. I compiled and run the Modbus master example in Qt 5.11, and it throws timeout errors, when I try to read the holding registers. I set all parameters correctly and the PLC works well too. I know it, because if I compile the same Qt example with Qt 5.8 instead of 5.7, 5.9, 5.10 or 5.11, it works well and responses correctly. The debug messages show that the response arrives correctly on all versions, but somehow not processed by the Qt Modbus module, instead throws error after the timeout period elapsed. I use Ubuntu Linux 64bit, and previously already deployed an industrial project using modbus with Qt 5.8 successfully. Can this false behaviour somehow changed? Maybe a new parameter somewhere?

          Thanks.
          Best,
          Andras

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @szergejbubka if you look at Qt SerialBus module source code, is this change maybe related to the behavior you mentioned?

          Due to the nature of our serial bus device, a frame could already
          be send completely, but the bytes written did not report that yet.
          Then we received an answer before we reached the receive state,
          messing up the whole state logic. Now we process incoming frames
          only if we are in receive state, otherwise drop full frames.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          S 1 Reply Last reply
          2
          • Pablo J. RoginaP Pablo J. Rogina

            @szergejbubka if you look at Qt SerialBus module source code, is this change maybe related to the behavior you mentioned?

            Due to the nature of our serial bus device, a frame could already
            be send completely, but the bytes written did not report that yet.
            Then we received an answer before we reached the receive state,
            messing up the whole state logic. Now we process incoming frames
            only if we are in receive state, otherwise drop full frames.

            S Offline
            S Offline
            szergejbubka
            wrote on last edited by
            #5

            @Pablo-J.-Rogina I do not know. How could I test it? Can this behaviour be changed by using parameters? For example by forcing a receive state? What was the reason of this change? This seems to be broken for me now.

            Thanks,
            András

            aha_1980A 1 Reply Last reply
            0
            • S szergejbubka

              @Pablo-J.-Rogina I do not know. How could I test it? Can this behaviour be changed by using parameters? For example by forcing a receive state? What was the reason of this change? This seems to be broken for me now.

              Thanks,
              András

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

              @szergejbubka said in Qt Modbus RTU timeout:

              I do not know. How could I test it?

              You could simply revert the patch and compile QtSerialBus again for testing.

              Can this behaviour be changed by using parameters?

              Not that I'm aware of.

              For example by forcing a receive state?

              That would be an awful hack... I think usually the module should be in receive state when data is received. Anything else sounds like a bug.

              What was the reason of this change?

              QTBUG-62144 and QTBUG-62299, as stated in the commit message.

              This seems to be broken for me now.

              Then please verify if its really this patch that causes your problems and then create your own bugreport, providing as much information as possible.

              Please also provide a link to your report here. Thanks.

              Qt has to stay free or it will die.

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

                It seems this is now tracked as QTBUG-69188.

                Qt has to stay free or it will die.

                1 Reply Last reply
                1
                • AlexBlascheA Offline
                  AlexBlascheA Offline
                  AlexBlasche
                  wrote on last edited by
                  #8

                  I believe this is fixed by https://codereview.qt-project.org/#/c/221549/ and was caused by the fix for bug https://bugreports.qt.io/browse/QTBUG-62299.

                  1 Reply Last reply
                  2

                  • Login

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