Modbus tcp node dynamic change of ip address and portnr

I wonder, is it possible to dynamicly change the ip address and port number fields of a config node that is used in the modbus getter node?

1 Like

Here is a flow with some tests i was doing recently experimenting with Modbus Flex Connector

[{"id":"c312db7a02c1f4dd","type":"modbus-flex-sequencer","z":"5847b7aa62131d37","name":"","sequences":[{"name":"1","unitid":"1","fc":"FC1","address":"1","quantity":"1"}],"server":"ebeab3422d31a778","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":540,"y":80,"wires":[["552a9e388d7eda29"],[]]},{"id":"99da7dfd84cbd186","type":"inject","z":"5847b7aa62131d37","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":160,"y":80,"wires":[["6c8c4aeace8044d9"]]},{"id":"6c8c4aeace8044d9","type":"function","z":"5847b7aa62131d37","name":"","func":"msg.sequences = [\n    {\n        name: \"Foo\",\n        unitid: 1,\n        fc: 3,\n        address: 1,\n        quantity: 1\n    },\n    {\n        name: \"Bar\",\n        unitid: 1,\n        fc: 3,\n        address: 10,\n        quantity: 2\n    },\n    {\n        name: \"Baz\",\n        unitid: 1,\n        fc: 'FC3',\n        address: 20,\n        quantity: 3\n    }]\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":80,"wires":[["c312db7a02c1f4dd"]]},{"id":"e387b5cf3a56528a","type":"debug","z":"5847b7aa62131d37","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":80,"wires":[]},{"id":"552a9e388d7eda29","type":"join","z":"5847b7aa62131d37","name":"","mode":"custom","build":"object","property":"responseBuffer.buffer","propertyType":"msg","key":"modbusRequest.name","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":770,"y":80,"wires":[["0cd883411cc554c7"]]},{"id":"0cd883411cc554c7","type":"change","z":"5847b7aa62131d37","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"responseBuffer.buffer","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":80,"wires":[["e387b5cf3a56528a"]]},{"id":"602c2fb9189b3c62","type":"modbus-flex-getter","z":"5847b7aa62131d37","d":true,"name":"","showStatusActivities":true,"showErrors":true,"logIOActivities":false,"server":"ebeab3422d31a778","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":620,"y":200,"wires":[["167f353c05c28461"],[]]},{"id":"9eb2b47107b96ed8","type":"inject","z":"5847b7aa62131d37","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":200,"wires":[["2996681554f2e749"]]},{"id":"2996681554f2e749","type":"function","z":"5847b7aa62131d37","name":"","func":"msg.payload = {\n    name: \"Foo\",\n    fc: 3,\n    address: 1,\n    unitid: 1,\n    quantity: 10,\n}\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":200,"wires":[["602c2fb9189b3c62"]]},{"id":"167f353c05c28461","type":"debug","z":"5847b7aa62131d37","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":180,"wires":[]},{"id":"5e8844296c95858c","type":"modbus-flex-connector","z":"5847b7aa62131d37","name":"","maxReconnectsPerMinute":4,"emptyQueue":false,"showStatusActivities":false,"showErrors":false,"server":"ebeab3422d31a778","x":650,"y":360,"wires":[[]]},{"id":"de343ff69f1f4da3","type":"inject","z":"5847b7aa62131d37","name":"Device port 502","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":260,"y":320,"wires":[["b8f8914c9d5d69ae"]]},{"id":"cd1baf7d357f6329","type":"inject","z":"5847b7aa62131d37","name":"Device port 503","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":260,"y":400,"wires":[["a46d180a4664a236"]]},{"id":"b8f8914c9d5d69ae","type":"function","z":"5847b7aa62131d37","name":"","func":"msg.payload = {\n    'connectorType': 'TCP',\n    'tcpHost': '192.168.0.66',\n    'tcpPort': '502',\n    'unitId': 1\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":320,"wires":[["5e8844296c95858c"]]},{"id":"a46d180a4664a236","type":"function","z":"5847b7aa62131d37","name":"","func":"msg.payload = {\n    'connectorType': 'TCP',\n    'tcpHost': '192.168.0.66',\n    'tcpPort': '503',\n    'unitId': 1\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":400,"wires":[["5e8844296c95858c"]]},{"id":"b90d7f7951814165","type":"comment","z":"5847b7aa62131d37","name":"Change Mod. Config Settings","info":"","x":680,"y":300,"wires":[]},{"id":"ebeab3422d31a778","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.0.66","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","serialAsciiResponseStartDelimiter":"","unit_id":"0","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":false,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]
1 Like

@ubornn, thanks AGAIN, that's seems to be working very well.!!!

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