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 RTS
Qt 6.11 is out! See what's new in the release blog

Qt Modbus RTS

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 1.3k 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.
  • Marco PellinM Offline
    Marco PellinM Offline
    Marco Pellin
    wrote on last edited by Marco Pellin
    #1

    Hi,
    I'm working on an hardware that needs RTS software active on TX while working with Modbus RTU.
    Is there a way to set it with Qt Modbus libraries?

    The answer will be useful both for Master and Slave devices, but right now I need it in particular for the Slave/Server case.

    Thanks a lot,
    Marco

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      see QModbusDevice::setConnectionParameter(int parameter, const QVariant &value) and set the RTU comm device to be a comm port that has flow control properly set for your requirements.

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      3
      • Marco PellinM Offline
        Marco PellinM Offline
        Marco Pellin
        wrote on last edited by
        #3

        Thanks for the answer.
        Actually QModbusDevice::setConnectionParameter handles only a limited set of parameters (https://doc.qt.io/archives/qt-5.11/qmodbusdevice.html) none of them related to the flow control.
        It seems to me that only the QSerialPort class manages the flow control (https://doc.qt.io/qt-5/qserialport.html).
        Unfortunately I cannot find anything linking the port to the modbus device, so that the serial port settings may be used with the modbus communication.
        Am I missing something?

        Kent-DorfmanK aha_1980A 2 Replies Last reply
        0
        • A Offline
          A Offline
          Astrinus
          wrote on last edited by
          #4

          You can set up the port with QSerialPort (setting the port up works only if it is closed) and then use QModbusDevice (code written as it is, but currently untested):

          QString mySerialPort{QStringLiteral("portname")}; // "portname" == "COM1" or "/dev/ttyS0"
          {
              QSerialPort sp(mySerialPort);
              sp.setFlowControl(QSerialPort::HardwareControl);
          } // ensure sp is not usable anymore
          QModbusServer ms;
          ms.setConnectionParameter(QModbusDevice::SerialPortNameParameter, mySerialPort);
          ms.connectDevice();
          
          1 Reply Last reply
          2
          • Marco PellinM Marco Pellin

            Thanks for the answer.
            Actually QModbusDevice::setConnectionParameter handles only a limited set of parameters (https://doc.qt.io/archives/qt-5.11/qmodbusdevice.html) none of them related to the flow control.
            It seems to me that only the QSerialPort class manages the flow control (https://doc.qt.io/qt-5/qserialport.html).
            Unfortunately I cannot find anything linking the port to the modbus device, so that the serial port settings may be used with the modbus communication.
            Am I missing something?

            Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #5

            @marco-pellin See @Astrinus example. That's what I was getting at.

            The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

            1 Reply Last reply
            0
            • Marco PellinM Marco Pellin

              Thanks for the answer.
              Actually QModbusDevice::setConnectionParameter handles only a limited set of parameters (https://doc.qt.io/archives/qt-5.11/qmodbusdevice.html) none of them related to the flow control.
              It seems to me that only the QSerialPort class manages the flow control (https://doc.qt.io/qt-5/qserialport.html).
              Unfortunately I cannot find anything linking the port to the modbus device, so that the serial port settings may be used with the modbus communication.
              Am I missing something?

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

              @marco-pellin

              Qt 5.14 will allow you to access the QSerialPort to configure special parameters QTBUG-76232. That will probably allow you to set the handshake parameters.

              Meanwhile you can try @Astrinus example.

              Regards

              Qt has to stay free or it will die.

              J.HilkJ 1 Reply Last reply
              3
              • aha_1980A aha_1980

                @marco-pellin

                Qt 5.14 will allow you to access the QSerialPort to configure special parameters QTBUG-76232. That will probably allow you to set the handshake parameters.

                Meanwhile you can try @Astrinus example.

                Regards

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @aha_1980
                yes! thanks for the heads up.

                With 5.14 I‘ll be able to ditch my hackaround to send raw data!


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                1

                • Login

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