How to use the Modbus-Flex-Connector?

I am trying to understand what the Modbus-Flex-Connector Node is doing - whether it will connect to Modbus and Read values or whether it should be use in conjunction with another ModBus node.

Sending data in like this:

msg.payload = {
    'fc': 4,
    'unitid': 1,
    'address': 0x100C,
    'quantity': 29,
    'connectorType': 'TCP',
    'tcpHost': global.get("MODBUS_IP"),
    'tcpPort': 503,
    'tcpType': "DEFAULT"
}

Is not resulting in any error, but nothing is being returned from Modbus - so I think this need to used in conjunction with another node, but I am not sure what role the Modbus-Flex-Connector Node is playing. Any help and insight in to understand how to use the Modbus-Flex-Connector Node will be appreciated. As it sound it is what I want to use to provide dynamux Modbus config information.

I assume you have something (a debug node) attached to the output?

Are you certain there is nothing coming out of it?

Exactly this .. its used to change the Modbus config dynamically
In the Help tab of the node it shows some examples of how that msg should be

msg.payload = { 'connectorType': 'TCP', 'tcpHost': '192.168.0.100', 'tcpPort': '502', 'unitId': 1 } 
return msg

The thing is the Modbus Flex Connector will not trigger a modbus Read / Write itself .. it will just change the config. You still need to use a Modbus-Flex-Getter node to do that.

Note that both the Connector and Getter are using the same config.

Sample Flow :

[{"id":"0617a95e616b94a7","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":170,"y":1720,"wires":[["898afaf3b661843f"]]},{"id":"898afaf3b661843f","type":"function","z":"54efb553244c241f","name":"192.168.0.100","func":"msg.payload = {\n    'connectorType': 'TCP',\n    'tcpHost': '192.168.0.100',\n    'unitId': 1\n}\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":1720,"wires":[["678bbb6347399e7b"]]},{"id":"678bbb6347399e7b","type":"modbus-flex-connector","z":"54efb553244c241f","name":"","maxReconnectsPerMinute":4,"emptyQueue":false,"showStatusActivities":true,"showErrors":true,"server":"464f5fed7e44856a","x":590,"y":1800,"wires":[["71a1c0cb1c397b23"]]},{"id":"71a1c0cb1c397b23","type":"debug","z":"54efb553244c241f","name":"debug 30","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":820,"y":1800,"wires":[]},{"id":"51cededc559f5cf6","type":"function","z":"54efb553244c241f","name":"192.168.0.101","func":"msg.payload = {\n    'connectorType': 'TCP',\n    'tcpHost': '192.168.0.101',\n    'unitId': 1\n}\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":1800,"wires":[["678bbb6347399e7b"]]},{"id":"61d2e5849bb550d8","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":170,"y":1800,"wires":[["51cededc559f5cf6"]]},{"id":"c271b2e90284c677","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":170,"y":2060,"wires":[["4819d151c4601f3b"]]},{"id":"4819d151c4601f3b","type":"function","z":"54efb553244c241f","name":"Modbus msg","func":"msg.payload = {\n    'value': msg.payload,\n    'fc': 3,\n    'unitid': 1,\n    'address': 3072,\n    'quantity': 14\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":2060,"wires":[["8aa3796a635e873c","25a516684b9ffaf4"]]},{"id":"8aa3796a635e873c","type":"modbus-flex-getter","z":"54efb553244c241f","name":"","showStatusActivities":true,"showErrors":true,"showWarnings":true,"logIOActivities":false,"server":"464f5fed7e44856a","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":true,"keepMsgProperties":false,"delayOnStart":false,"startDelayTime":"","x":590,"y":2060,"wires":[["4ee1b336b2b08fc1"],[]]},{"id":"4ee1b336b2b08fc1","type":"debug","z":"54efb553244c241f","name":"debug 39","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":2040,"wires":[]},{"id":"469c4452f8da61b6","type":"function","z":"54efb553244c241f","name":"192.168.0.102","func":"msg.payload = {\n    'connectorType': 'TCP',\n    'tcpHost': '192.168.0.102',\n    'unitId': 1\n}\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":1880,"wires":[["678bbb6347399e7b"]]},{"id":"45940cfa17d819f6","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":170,"y":1880,"wires":[["469c4452f8da61b6"]]},{"id":"25a516684b9ffaf4","type":"debug","z":"54efb553244c241f","name":"debug 52","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":1980,"wires":[]},{"id":"464f5fed7e44856a","type":"modbus-client","name":"Modbus Config","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"0x3A","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true,"showWarnings":true,"showLogs":true}]
1 Like

I do have a debug node - this is what coming out of it.

Screenshot 2024-01-08 203042

I see that inside the Modbus-Flex-Connector Node one has to select a Server config from a drop down. Is that the server config instance that is being changed by the Modbus-Flex-Connector Node and which can then be used with the new dynamically updated config in a Modbus-Flex-Getter Node that is referencing the same server config? Is my understanding correct?

And what do you see if you expand the payload?

This makes a lot of sense.

The problem with the Modbus-Flex-Connector node is that, when you send a msg to it for a new (dynamic) configuration .. it immediately produces a msg on its output (the one you shared) without actually waiting for the new connection to be applied .. this new configuration may take a second to actually be established, which makes it little difficult to use the Connector output msg to trigger a Read (because the connection is not ready.)

So keeping that in mind, you may need to introduce a small Delay between the Connector and the Getter

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.