Solved Mock (imitation) for Modbus device
-
Good day,
I am using the
serialbus
packages withQmodbusClient
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 likeQModbusDataUnit
.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 withQModbusDevice::setConnectionParameter()
function to set url (ip and port). -
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
-
@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.
-
@UlrichRekkenin
you found th eModbus master example but not the slave one?Or am I missing something here!?
-
@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?