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. Mock (imitation) for Modbus device
Forum Updated to NodeBB v4.3 + New Features

Mock (imitation) for Modbus device

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.3k 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.
  • U Offline
    U Offline
    UlrichRekkenin
    wrote on last edited by
    #1

    Good day,

    I am using the serialbus packages with QmodbusClient instance over TCP.
    Upgrading master example code I got my working solution. My modbus device read and write about 170 tags (coil, registers etc): something like QModbusDataUnit.

    In order to test my code I have to connect to a real programming logical controller (PLC) with the proper modbus tags configuration. But now I want to mock them.

    The question is what I should use for this?
    It seems to me that QModbusServer with QModbusDevice::setConnectionParameter() function to set url (ip and port).

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      One possibility could be to implement a custom mock QModbusClient subclass that you'd set in place of your standard QModbusClient object.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      U 1 Reply Last reply
      2
      • SGaistS SGaist

        Hi,

        One possibility could be to implement a custom mock QModbusClient subclass that you'd set in place of your standard QModbusClient object.

        Hope it helps

        U Offline
        U Offline
        UlrichRekkenin
        wrote on last edited by
        #3

        @SGaist I mean that I want some code which I can run in same or another machine (in a local network) and its code gives me the correct answer with a given (stored values for the RegisterType an address) value.

        J.HilkJ 1 Reply Last reply
        0
        • U UlrichRekkenin

          @SGaist I mean that I want some code which I can run in same or another machine (in a local network) and its code gives me the correct answer with a given (stored values for the RegisterType an address) value.

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

          @UlrichRekkenin
          you found th eModbus master example but not the slave one?

          Or am I missing something here!?


          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.

          U 1 Reply Last reply
          4
          • J.HilkJ J.Hilk

            @UlrichRekkenin
            you found th eModbus master example but not the slave one?

            Or am I missing something here!?

            U Offline
            U Offline
            UlrichRekkenin
            wrote on last edited by UlrichRekkenin
            #5

            @J.Hilk
            Oh, I saw it when was explored library.
            Yep, it can solve my problem.

            Note, that your should set localhost 127.0.0.1 with port 8080 instead of 502 in the both examples. Then you can easy connect.

            PS
            Maybe in example code you should change default gate from 502 to 8080 to work from the box?

            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