Modbus Test Tool
During writing a flow to control my Battery (https://flows.nodered.org/flow/3ab454d11d2a327aec6f092f30dbe7fc) with modbus TCP I found that testing the registers write and read Often requires the flow to be restarted. To prevent this I made this tool and can now write and read different registers without restarting the flow. Just fill in the correct values in the UI and press write and/or read to test the register values.
The flow makes use of the "node-red-contrib-modbus" nodes.
[{"id":"a01a6ad43ae20262","type":"tab","label":"Modbus Test Tool","disabled":false,"info":"","env":[]},{"id":"878dccbe61442ac8","type":"group","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","name":"","style":{"fill":"#bfdbef","label":true},"nodes":["0dd7041848a984bc","6d226c2b34164c7d","90707b2196df987a"],"x":534,"y":169,"w":252,"h":212},{"id":"5d69c190c353e51a","type":"group","z":"a01a6ad43ae20262","name":"","style":{"fill":"#e3f3d3","label":true},"nodes":["182d4d960b405847","5086b6eae1ccacc4","b6a8eccaf337f147","29a01819eceaa285","95b4acecc6e9cff9","b7d0091b14c7ded2","733d3778f5c99241","765415e47a1224e7","878dccbe61442ac8"],"x":94,"y":99,"w":932,"h":308},{"id":"182d4d960b405847","type":"function","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","name":"store values","func":"flow.set(\"Address\",msg.payload.address) ;\nflow.set(\"Value\",msg.payload.value) ;\nflow.set(\"Unitid\",msg.payload.unitid) ;\nflow.set(\"Quantity\",msg.payload.quantity) ;\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":140,"wires":[[]]},{"id":"5086b6eae1ccacc4","type":"function","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","name":"prepare read","func":"var Address = flow.get(\"Address\") ;\nvar Unitid = flow.get(\"Unitid\") ;\nvar Quantity = flow.get(\"Quantity\") ;\nvar fc = 3 ; //read =3 write is 6 \n\n\n\nvar msg1 = {};\n\nmsg1.payload = { \"fc\": fc, \"unitid\": Unitid, \"address\": Address, \"quantity\": Quantity } //read\n\n\nreturn [[msg1]];\n\n\n\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":260,"wires":[["0dd7041848a984bc"]]},{"id":"b6a8eccaf337f147","type":"ui_form","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","name":"","label":"","group":"bbc7c21fa70f301e","order":1,"width":"0","height":"0","options":[{"label":"address","value":"address","type":"number","required":false,"rows":null},{"label":"quantity","value":"quantity","type":"number","required":false,"rows":null},{"label":"unitid","value":"unitid","type":"number","required":false,"rows":null},{"label":"value","value":"value","type":"number","required":false,"rows":null}],"formValue":{"address":"","quantity":"","unitid":"","value":""},"payload":"","submit":"submit","cancel":"cancel","topic":"topic","topicType":"msg","splitLayout":false,"className":"","x":370,"y":140,"wires":[["182d4d960b405847","765415e47a1224e7"]]},{"id":"0dd7041848a984bc","type":"modbus-flex-getter","z":"a01a6ad43ae20262","g":"878dccbe61442ac8","name":"Read modbus register","showStatusActivities":false,"showErrors":false,"showWarnings":true,"logIOActivities":false,"server":"f821200b3de634c4","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"delayOnStart":false,"enableDeformedMessages":false,"startDelayTime":"","x":660,"y":260,"wires":[["29a01819eceaa285"],[]]},{"id":"29a01819eceaa285","type":"ui_text","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","group":"bbc7c21fa70f301e","order":7,"width":6,"height":1,"name":"","label":"Register value","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":920,"y":260,"wires":[]},{"id":"95b4acecc6e9cff9","type":"ui_button","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","name":"","group":"bbc7c21fa70f301e","order":9,"width":3,"height":1,"passthru":false,"label":"Read register","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":200,"y":260,"wires":[["5086b6eae1ccacc4"]]},{"id":"6d226c2b34164c7d","type":"modbus-flex-write","z":"a01a6ad43ae20262","g":"878dccbe61442ac8","name":"Write modbus register","showStatusActivities":false,"showErrors":false,"showWarnings":true,"server":"f821200b3de634c4","emptyMsgOnFail":false,"keepMsgProperties":false,"delayOnStart":false,"startDelayTime":"","x":660,"y":340,"wires":[[],[]]},{"id":"b7d0091b14c7ded2","type":"function","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","name":"prepare write","func":"var Address = flow.get(\"Address\") ;\nvar Value = flow.get(\"Value\") ;\nvar Unitid = flow.get(\"Unitid\") ;\nvar Quantity = flow.get(\"Quantity\") ;\nvar fc = 6 ; //read =3 write is 6 \n\n\n\nvar msg1 = {};\nmsg1.payload = {\"value\": Value, \"fc\": fc, \"unitid\": Unitid, \"address\": Address, \"quantity\": Quantity } //write\n\n\n\nreturn [[msg1]];\n\n\n\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":340,"wires":[["6d226c2b34164c7d"]]},{"id":"733d3778f5c99241","type":"ui_button","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","name":"","group":"bbc7c21fa70f301e","order":8,"width":3,"height":1,"passthru":false,"label":"Write register","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":200,"y":340,"wires":[["b7d0091b14c7ded2"]]},{"id":"765415e47a1224e7","type":"change","z":"a01a6ad43ae20262","g":"5d69c190c353e51a","name":"last","rules":[{"t":"set","p":"form","pt":"flow","to":"payload.form","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":170,"wires":[["b6a8eccaf337f147"]]},{"id":"90707b2196df987a","type":"comment","z":"a01a6ad43ae20262","g":"878dccbe61442ac8","name":"readme","info":"Select a modbus server:\nip nummer of the device and add port number 502\nexample: 192.168.178.55:502\n\nDo this for the modbus read node and for the \nmodbus write node.\n\nAlso change in the prepare nodes if necessary\nthe fc value for special registers.","x":640,"y":210,"wires":[]},{"id":"1aca8192ed33680e","type":"ui_spacer","z":"a01a6ad43ae20262","name":"spacer","group":"bbc7c21fa70f301e","order":6,"width":6,"height":1},{"id":"bbc7c21fa70f301e","type":"ui_group","name":"Modbus test tool","tab":"ba2cf45331ca6172","order":1,"disp":true,"width":6,"collapse":false,"className":""},{"id":"f821200b3de634c4","type":"modbus-client","name":"Marstek 2","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"failureLogEnabled":true,"tcpHost":"192.168.178.8","tcpPort":502,"tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":9600,"serialDatabits":8,"serialStopbits":1,"serialParity":"none","serialConnectionDelay":100,"serialAsciiResponseStartDelimiter":"0x3A","unit_id":2,"commandDelay":1,"clientTimeout":1000,"reconnectOnTimeout":true,"reconnectTimeout":2000,"parallelUnitIdsAllowed":true,"showErrors":false,"showWarnings":true,"showLogs":true},{"id":"ba2cf45331ca6172","type":"ui_tab","name":"Tools","icon":"dashboard","order":3,"disabled":false,"hidden":false},{"id":"2568634e40acb0d2","type":"global-config","env":[],"modules":{"node-red-dashboard":"3.6.6","node-red-contrib-modbus":"5.45.2"}}]