Skip to content

Instantly share code, notes, and snippets.

@robertsLando
Last active June 16, 2022 10:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertsLando/bc19aff2598d6a214bbfbe0e6f66ee64 to your computer and use it in GitHub Desktop.
Save robertsLando/bc19aff2598d6a214bbfbe0e6f66ee64 to your computer and use it in GitHub Desktop.
Simple Modscan like UI for Modbus testing

This flow creates a Tab "Modscan" in Node-Red UI that allows to:

  • Manual SERIAL and TCP connection (NEW FEATURE)
  • Read Modscan Registers And Coils in real time (FC3 and FC1)
  • Convert 2*16bit registers in 32 bit
  • Convert values in HEX rappresentation
  • Convert values in Float IEEE-754 rappresentation
  • Write Registers and Coils (FC5 FC6)
  • Write Hex values (The hex value will be converted to int than sent to Modbus Write Node)

THIS FLOW HAS BEEN EDITED TO WORK WITH LAST NODE-RED-CONTRIB-MODBUS VERSION AT THIS DATE (2.3.2). TO MAKE IT WORK WITH OLDER/FUTURE VERSIONS OF MODBUS CHECK THE OUTPUT OF MODBUS FLEX READ AND USE THE CHANGE NODE TO MOVE READED DATA INTO msg.payload. ATM the payload of modbus-flex-read has 2 fileds: 'buffer' and 'data' so the change node is used to move msg.payload.data into msg.payload.

Buy Me A Coffee

Modscan

[{"id":"3007b84d.585828","type":"tab","label":"MODSCAN ","disabled":false,"info":""},{"id":"32802fb2.df634","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"","payloadType":"date","repeat":"0.5","crontab":"","once":false,"onceDelay":"","x":127.1429443359375,"y":683.8571310043335,"wires":[["9dcffcba.11e58"]]},{"id":"9dcffcba.11e58","type":"function","z":"3007b84d.585828","name":"enable","func":"if(flow.get(\"enabled\")){\n flow.set(\"count\", flow.get(\"count\") + 1);\n msg.payload = {'fc': flow.get(\"FC\"), 'unitid': flow.get(\"unitid\"), 'address': flow.get(\"address\") , 'quantity': flow.get(\"length\"), 'conversion': flow.get(\"conversion\") };\n}else\n msg = null;\n \nreturn msg;","outputs":1,"noerr":0,"x":309.1429443359375,"y":683.8571310043335,"wires":[["85dd1b59.3dac48"]]},{"id":"fc92b2a7.bdd9a","type":"ui_button","z":"3007b84d.585828","name":"","group":"426c6703.2c1038","order":8,"width":"3","height":"1","passthru":false,"label":"Start","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"num","topic":"","x":429.6429443359375,"y":861.8571310043335,"wires":[["7cc0168.d03e0e8"]]},{"id":"7cc0168.d03e0e8","type":"function","z":"3007b84d.585828","name":"enable","func":"flow.set(\"enabled\", true);\nflow.set(\"count\", 0);","outputs":"0","noerr":0,"x":598.1429443359375,"y":861.8571310043335,"wires":[]},{"id":"4d70ca37.fe1dc4","type":"ui_button","z":"3007b84d.585828","name":"","group":"426c6703.2c1038","order":9,"width":"3","height":"1","passthru":false,"label":"Stop","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"num","topic":"","x":429.1429443359375,"y":912.8571310043335,"wires":[["7196f276.e2a1dc"]]},{"id":"7196f276.e2a1dc","type":"function","z":"3007b84d.585828","name":"disable","func":"flow.set(\"enabled\", false);","outputs":"0","noerr":0,"x":605.6429443359375,"y":912.8571310043335,"wires":[]},{"id":"5250a8de.1acd38","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"address\", msg.payload);","outputs":"0","noerr":0,"x":595.1429443359375,"y":955.8571310043335,"wires":[]},{"id":"dd349bfe.086ca8","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"length\", msg.payload);","outputs":"0","noerr":0,"x":596.1429443359375,"y":1000.8571310043335,"wires":[]},{"id":"f48850f7.e3c05","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"FC\", msg.payload);","outputs":"0","noerr":0,"x":593.1429443359375,"y":1043.8571310043335,"wires":[]},{"id":"85dd1b59.3dac48","type":"modbus-flex-getter","z":"3007b84d.585828","name":"read","showStatusActivities":false,"showErrors":false,"server":"5876d9d3.3456c8","x":460.1429443359375,"y":682.8571310043335,"wires":[["8d6a2f85.239ab","93e2b691.2d2f78"],[]]},{"id":"bddb7999.5e39f8","type":"ui_template","z":"3007b84d.585828","group":"55e082a0.9e821c","name":"","order":5,"width":"6","height":"10","format":"<div style=\"width:100%;\">\n <div style=\"display:inline-block; width:25%;\" ng-repeat=\"x in msg.payload track by $index\">\n {{!msg.input.payload.conversion ? \n ($index + msg.input.payload.address) : \n (($index*2 + msg.input.payload.address)+'-'+($index*2 + msg.input.payload.address+1))}} : {{ x }}\n </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":1485.14306640625,"y":692.8571166992188,"wires":[[]]},{"id":"63a764b7.de8d4c","type":"inject","z":"3007b84d.585828","name":"init","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":160.1429443359375,"y":862.8571310043335,"wires":[["f31e0c5a.d1de9"]]},{"id":"f31e0c5a.d1de9","type":"function","z":"3007b84d.585828","name":"init","func":"flow.set(\"FC\", 3);\nflow.set(\"address\", 1);\nflow.set(\"length\", 1);\nflow.set(\"enabled\", false);\nflow.set(\"count\", 0);\nflow.set(\"conversion\", 0);\nflow.set(\"hex\", 0);\nflow.set(\"conversion_float\", 0);","outputs":"0","noerr":0,"x":289.1429443359375,"y":862.8571310043335,"wires":[]},{"id":"ad93667a.a6fa78","type":"inject","z":"3007b84d.585828","name":"init","topic":"","payload":"count","payloadType":"flow","repeat":"0.5","crontab":"","once":false,"onceDelay":"","x":482.1429443359375,"y":623.8571310043335,"wires":[["67a50272.e8e96c"]]},{"id":"67a50272.e8e96c","type":"ui_text","z":"3007b84d.585828","group":"55e082a0.9e821c","order":1,"width":"5","height":"1","name":"read count","label":"Total reads: ","format":"{{msg.payload}}","layout":"row-spread","x":637.6429748535156,"y":623.8571329116821,"wires":[]},{"id":"d19ca237.83a9d","type":"status","z":"3007b84d.585828","name":"","scope":["85dd1b59.3dac48"],"x":113.6429443359375,"y":623.8571310043335,"wires":[["9136d04e.8d1f7"]]},{"id":"9136d04e.8d1f7","type":"ui_text","z":"3007b84d.585828","group":"55e082a0.9e821c","order":2,"width":"5","height":"1","name":"Modbus status","label":"Status:","format":"{{msg.status.text}}","layout":"row-spread","x":294.1429443359375,"y":623.8571310043335,"wires":[]},{"id":"4ab48214.f2ebac","type":"function","z":"3007b84d.585828","name":"16To32Bit","func":"var values32bit = [];\n\nfor(var i=0;i<msg.payload.length;i++){\n var tmp = msg.payload[i].toString(2);\n tmp = tmp.length < 16 ? '0'.repeat(16-tmp.length) + tmp : tmp;\n i++;\n var tmp1 = i < msg.payload.length ? msg.payload[i].toString(2) : '0000000000000000';\n tmp1 = tmp1.length < 16 ? '0'.repeat(16-tmp1.length) + tmp1 : tmp1;\n var value = parseInt(tmp1+tmp,2);\n if(flow.get('hex')) value = '0x'+value.toString(16).toUpperCase();\n \n values32bit.push(value);\n}\n\nmsg.payload = values32bit;\n\nreturn msg;","outputs":1,"noerr":0,"x":885.1429977416992,"y":707.8571300506592,"wires":[["ea3e65dc.00f918"]]},{"id":"93e2b691.2d2f78","type":"switch","z":"3007b84d.585828","name":"","property":"conversion","propertyType":"flow","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":670.6429443359375,"y":675.8571166992188,"wires":[["f93f41eb.2fa72"],["8e82685d.ac14a8","cba46076.4678e"]]},{"id":"526c1517.222e1c","type":"ui_switch","z":"3007b84d.585828","name":"","label":"32 bit","group":"426c6703.2c1038","order":5,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":429.6429443359375,"y":1083.8571310043335,"wires":[["91ac90a0.b2fb5"]]},{"id":"91ac90a0.b2fb5","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"conversion\", msg.payload);\nif(!flow.get(\"conversion\") && flow.get(\"conversion_float\"))\n flow.set(\"conversion_float\", 0);","outputs":"0","noerr":0,"x":592.1429443359375,"y":1083.8571310043335,"wires":[]},{"id":"c1dfb404.7cc128","type":"ui_dropdown","z":"3007b84d.585828","name":"","label":"FC","place":"FC","group":"426c6703.2c1038","order":3,"width":0,"height":0,"passthru":false,"options":[{"label":"Read Coil Status FC 1","value":1,"type":"num"},{"label":"Read Holding Register FC 3","value":3,"type":"num"},{"label":"Read Status Register FC 4","value":4,"type":"num"}],"payload":"","topic":"","x":429.1429443359375,"y":1043.8571310043335,"wires":[["f48850f7.e3c05"]]},{"id":"360c92cd.c9302e","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"address","payloadType":"flow","repeat":"","crontab":"","once":true,"x":214.1429443359375,"y":955.8571310043335,"wires":[["f947b91c.fa0988"]]},{"id":"db5eca59.3fd018","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"length","payloadType":"flow","repeat":"","crontab":"","once":true,"x":213.1429443359375,"y":1000.8571310043335,"wires":[["cc40dff8.48c9e"]]},{"id":"8304bcdd.2a20e","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"FC","payloadType":"flow","repeat":"","crontab":"","once":true,"x":202.1429443359375,"y":1043.8571310043335,"wires":[["c1dfb404.7cc128"]]},{"id":"b4eeaa7.1e11658","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"conversion","payloadType":"flow","repeat":"0.1","crontab":"","once":true,"x":230.1429443359375,"y":1083.8571310043335,"wires":[["526c1517.222e1c"]]},{"id":"db20baa6.fa3138","type":"modbus-flex-write","z":"3007b84d.585828","name":"write","showStatusActivities":false,"showErrors":false,"server":"5876d9d3.3456c8","x":1173.1429443359375,"y":862.8571310043335,"wires":[[],[]]},{"id":"3568f7ca.d83698","type":"ui_button","z":"3007b84d.585828","name":"write","group":"4a263e90.169ff","order":5,"width":"6","height":"1","passthru":false,"label":"WRITE","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":868.1429443359375,"y":862.8571310043335,"wires":[["9b8a12eb.e8c74"]]},{"id":"9b8a12eb.e8c74","type":"function","z":"3007b84d.585828","name":"enable","func":"var value = flow.get(\"value\");\n\nif(flow.get(\"conversion_write\"))\n value = parseInt(value, 16);\nelse value = parseInt(value);\n\nmsg.payload = {'value': value, 'fc': flow.get(\"FC_WRITE\"), 'unitid': flow.get(\"unitid\"), 'address': flow.get(\"address_write\") , 'quantity': 1 };\n\nreturn msg;","outputs":1,"noerr":0,"x":1018.1429443359375,"y":862.8571310043335,"wires":[["db20baa6.fa3138"]]},{"id":"cf92cac3.115e98","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"address_write\", msg.payload);","outputs":"0","noerr":0,"x":1287.6429443359375,"y":977.8571310043335,"wires":[]},{"id":"210dfeeb.090bf2","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"FC_WRITE\", msg.payload);","outputs":"0","noerr":0,"x":1288.6429443359375,"y":1018.8571310043335,"wires":[]},{"id":"76ad1330.edf39c","type":"inject","z":"3007b84d.585828","name":"init","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":883.6429443359375,"y":923.8571310043335,"wires":[["ce74fd33.da014"]]},{"id":"ce74fd33.da014","type":"function","z":"3007b84d.585828","name":"init","func":"flow.set(\"FC_WRITE\", 6);\nflow.set(\"address_write\", 1);\nflow.set(\"conversion_write\", 0);","outputs":"0","noerr":0,"x":1012.6429443359375,"y":923.8571310043335,"wires":[]},{"id":"690e91a4.45396","type":"ui_switch","z":"3007b84d.585828","name":"","label":"Hex to Int","group":"4a263e90.169ff","order":4,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":1133.1429443359375,"y":1058.8571310043335,"wires":[["a028380f.03e638"]]},{"id":"a028380f.03e638","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"conversion_write\", msg.payload);","outputs":"0","noerr":0,"x":1289.6429443359375,"y":1058.8571310043335,"wires":[]},{"id":"6d4a2b49.6c8284","type":"ui_dropdown","z":"3007b84d.585828","name":"","label":"FC","place":"FC","group":"4a263e90.169ff","order":3,"width":"0","height":"0","passthru":false,"options":[{"label":"Force Single Coil FC 5","value":"5","type":"str"},{"label":"Force Single Register FC 6","value":6,"type":"num"}],"payload":"","topic":"","x":1124.6429443359375,"y":1018.8571310043335,"wires":[["210dfeeb.090bf2"]]},{"id":"bef26ae7.614ba8","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"address_write","payloadType":"flow","repeat":"","crontab":"","once":true,"x":924.6429443359375,"y":977.8571310043335,"wires":[["c90dfb95.6bdc38"]]},{"id":"730f0b41.fb3724","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"FC_WRITE","payloadType":"flow","repeat":"","crontab":"","once":true,"x":915.6429443359375,"y":1018.8571310043335,"wires":[["6d4a2b49.6c8284"]]},{"id":"512a8b3a.5dee64","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"conversion_write","payloadType":"flow","repeat":"0.1","crontab":"","once":true,"onceDelay":"","x":933.6429443359375,"y":1058.8571310043335,"wires":[["690e91a4.45396"]]},{"id":"56b9b0e9.e1897","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Value","group":"4a263e90.169ff","order":2,"width":"3","height":"1","passthru":false,"mode":"text","delay":"100","topic":"","x":1122.1429443359375,"y":1098.8571310043335,"wires":[["6e9920d2.a5989"]]},{"id":"6e9920d2.a5989","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"value\", msg.payload);","outputs":"0","noerr":0,"x":1288.6429443359375,"y":1098.8571310043335,"wires":[]},{"id":"90069d50.bc1c2","type":"comment","z":"3007b84d.585828","name":"READ","info":"","x":74.6429443359375,"y":809.8571310043335,"wires":[]},{"id":"b747e293.f8f91","type":"comment","z":"3007b84d.585828","name":"WRITE","info":"","x":804.1429443359375,"y":810.8571310043335,"wires":[]},{"id":"770472a1.13395c","type":"comment","z":"3007b84d.585828","name":"OUTPUT","info":"","x":86.1429443359375,"y":570.8571310043335,"wires":[]},{"id":"47aa8310.8b3b7c","type":"ui_switch","z":"3007b84d.585828","name":"","label":"Hex Values","group":"426c6703.2c1038","order":7,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":435.9085693359375,"y":1130.6071310043335,"wires":[["3b016e18.240e82"]]},{"id":"3b016e18.240e82","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"hex\", msg.payload);\n\nif(flow.get(\"hex\") && flow.get(\"conversion_float\"))\n flow.set(\"conversion_float\", 0);","outputs":"0","noerr":0,"x":589.4085693359375,"y":1130.6071310043335,"wires":[]},{"id":"37aa5a96.cb6946","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"hex","payloadType":"flow","repeat":"0.1","crontab":"","once":true,"onceDelay":"","x":200.4085693359375,"y":1130.6071310043335,"wires":[["47aa8310.8b3b7c"]]},{"id":"f93f41eb.2fa72","type":"switch","z":"3007b84d.585828","name":"","property":"hex","propertyType":"flow","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","outputs":2,"x":878.9086074829102,"y":669.6071166992188,"wires":[["9c5eeca5.fac26"],["bddb7999.5e39f8","be6e63a4.9997e"]]},{"id":"9c5eeca5.fac26","type":"function","z":"3007b84d.585828","name":"toHex","func":"for(var i=0;i<msg.payload.length;i++)\n msg.payload[i] = '0x'+msg.payload[i].toString(16).toUpperCase();\n\nreturn msg;","outputs":1,"noerr":0,"x":1032.9085693359375,"y":615.6071166992188,"wires":[["bddb7999.5e39f8","be6e63a4.9997e"]]},{"id":"a05c178a.dab488","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"conversion_float","payloadType":"flow","repeat":"0.1","crontab":"","once":true,"onceDelay":"","x":221.1429443359375,"y":1176.8571310043335,"wires":[["697fbeab.91379"]]},{"id":"697fbeab.91379","type":"ui_switch","z":"3007b84d.585828","name":"","label":"Float","group":"426c6703.2c1038","order":6,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":410.6429443359375,"y":1176.8571310043335,"wires":[["6eb4434f.c0697c"]]},{"id":"6eb4434f.c0697c","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"conversion_float\", msg.payload);\nif(!flow.get(\"conversion\") && flow.get(\"conversion_float\"))\n flow.set(\"conversion\", 1);\n\nif(flow.get(\"conversion_float\"))\n flow.set(\"hex\", 0);","outputs":"0","noerr":0,"x":587.1429443359375,"y":1176.8571310043335,"wires":[]},{"id":"ea3e65dc.00f918","type":"switch","z":"3007b84d.585828","name":"","property":"conversion_float","propertyType":"flow","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","outputs":2,"x":1031.1429443359375,"y":737.8571166992188,"wires":[["bddb7999.5e39f8","be6e63a4.9997e"],["e1287907.03a0d8","aca9bf8c.b3ba"]]},{"id":"518d47aa.bcb938","type":"comment","z":"3007b84d.585828","name":"CONNECTION","info":"","x":118.46179962158203,"y":41.56597328186035,"wires":[]},{"id":"d8bd00c6.4441f","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Address","group":"b079e2a.7753f2","order":3,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":546.4617919921875,"y":131.01041412353516,"wires":[["606bf156.41c3"]]},{"id":"3e658f6f.6cb3c","type":"modbus-flex-connector","z":"3007b84d.585828","name":"connection","maxReconnectsPerMinute":4,"emptyQueue":false,"showStatusActivities":false,"showErrors":false,"server":"5876d9d3.3456c8","x":450.46185302734375,"y":385.01045298576355,"wires":[]},{"id":"f4df0c24.1b02c","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Port","group":"b079e2a.7753f2","order":4,"width":"3","height":"1","passthru":true,"mode":"text","delay":300,"topic":"","x":536.4791259765625,"y":175.01040649414062,"wires":[["ad832272.c1a76"]]},{"id":"606bf156.41c3","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"TCP_Connection\") || {};\n\noptions.tcpHost = msg.payload;\n\nflow.set(\"TCP_Connection\", options);","outputs":"0","noerr":0,"x":700.017333984375,"y":131.23263549804688,"wires":[]},{"id":"ad832272.c1a76","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"TCP_Connection\") || {};\n\noptions.tcpPort = msg.payload;\n\nflow.set(\"TCP_Connection\", options);","outputs":"0","noerr":0,"x":698.017333984375,"y":175.23263549804688,"wires":[]},{"id":"17332db6.9ffd62","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Unit ID","group":"b079e2a.7753f2","order":5,"width":"3","height":"1","passthru":true,"mode":"text","delay":300,"topic":"","x":535.4791412353516,"y":225.23263549804688,"wires":[["ed279caf.4274c"]]},{"id":"ed279caf.4274c","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"TCP_Connection\") || {};\n\noptions.unitId = msg.payload;\n\nflow.set(\"TCP_Connection\", options);","outputs":"0","noerr":0,"x":697.0173492431641,"y":225.45486450195312,"wires":[]},{"id":"6fff632c.675e9c","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"TCP_Connection","payloadType":"flow","repeat":"","crontab":"","once":true,"x":136,"y":147.23263549804688,"wires":[["387c8f76.0fe67","7246ca2.4831f34","a4883537.fd0a58","df543765.66fc68"]]},{"id":"387c8f76.0fe67","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.tcpHost","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":385.0173645019531,"y":131.23263549804688,"wires":[["d8bd00c6.4441f"]]},{"id":"7246ca2.4831f34","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.tcpPort","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":383.0173645019531,"y":175.23263549804688,"wires":[["f4df0c24.1b02c"]]},{"id":"a4883537.fd0a58","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.unitId","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380.0173645019531,"y":225.23263549804688,"wires":[["17332db6.9ffd62"]]},{"id":"c23376c3.7cc9d8","type":"ui_button","z":"3007b84d.585828","name":"connectTCP","group":"b079e2a.7753f2","order":6,"width":0,"height":0,"passthru":false,"label":"Connect","color":"","bgcolor":"","icon":"compare_arrows","payload":"TCP_Connection","payloadType":"flow","topic":"","x":109.01741790771484,"y":357.2326593399048,"wires":[["81514fd0.532d5"]]},{"id":"81514fd0.532d5","type":"function","z":"3007b84d.585828","name":"connect","func":"var options = msg.payload;\nvar error = {topic: \"TCP Connect\"};\nvar configs = flow.get('configs_TCP') || [];\n\noptions.connectorType = \"TCP\";\n\nif(!options.name || options.name === \"\"){\n options.name = \"No name\";\n}\n\nif(!options.tcpPort)\n options.tcpPort = 502;\n\nif(!options.tcpHost){\n error.payload = \"TCP Host address not Valid\";\n node.error(\"Error\",error);\n return;\n}\n\nvar index = configs.findIndex(function(conf) {\n return conf.name == options.name;\n});\n\nif(index < 0)\n configs.push(options);\nelse\n configs[index] = options;\n \nflow.set('configs_TCP', configs);\n\nnode.send([msg, {payload:configs, topic:\"init\"}]);","outputs":"2","noerr":0,"x":288.0174217224121,"y":357.23265838623047,"wires":[["3e658f6f.6cb3c","8dee1c7f.d8241"],["518c79c8.bf0d98"]]},{"id":"bac3fbb6.bea3e8","type":"ui_text_input","z":"3007b84d.585828","name":"custom port","label":"or choose a custom Port","group":"4fe0301e.33802","order":4,"width":"6","height":"1","passthru":true,"mode":"text","delay":300,"topic":"","x":1330.03466796875,"y":157.23262786865234,"wires":[["bd0c13b8.18979"]]},{"id":"6d01ef58.de6eb","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Unit ID","group":"4fe0301e.33802","order":5,"width":"3","height":"1","passthru":true,"mode":"text","delay":300,"topic":"","x":1308.034683227539,"y":200.4548568725586,"wires":[["b9883b89.d7b0f8"]]},{"id":"f0258c4f.dfc12","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"SERIAL_Connection","payloadType":"flow","repeat":"","crontab":"","once":true,"x":926.5555419921875,"y":152.4548568725586,"wires":[["32b2795f.f9f746","52822920.d8f8b8","a6aa7b0b.bc7cb8","743b34e2.0a022c","88c6cbfe.471658"]]},{"id":"32b2795f.f9f746","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.serialPort","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1162.5729064941406,"y":157.4548568725586,"wires":[["bac3fbb6.bea3e8"]]},{"id":"52822920.d8f8b8","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.unitId","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160.5729064941406,"y":200.4548568725586,"wires":[["6d01ef58.de6eb"]]},{"id":"7199d023.e1c6d","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"SERIAL_Connection\") || {};\n\nif(msg.payload)\n options.serialPort = msg.payload;\n\nflow.set(\"SERIAL_Connection\", options);","outputs":"0","noerr":0,"x":1479.5728759765625,"y":111.4548568725586,"wires":[]},{"id":"a6aa7b0b.bc7cb8","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.serialPort","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1164.5729064941406,"y":111.4548568725586,"wires":[["c04c8a2f.3e48d8"]]},{"id":"c04c8a2f.3e48d8","type":"ui_dropdown","z":"3007b84d.585828","name":"port","label":"Port","place":"Choose a serial port","group":"4fe0301e.33802","order":3,"width":"6","height":"1","passthru":true,"options":[{"label":"/dev/ttyUSB0","value":"/dev/ttyUSB0","type":"str"},{"label":"/dev/ttyUSB1","value":"/dev/ttyUSB1","type":"str"},{"label":"/dev/ttyAMA0","value":"/dev/ttyAMA0","type":"str"}],"payload":"","topic":"","x":1311.5729064941406,"y":111.78819942474365,"wires":[["7199d023.e1c6d"]]},{"id":"bd0c13b8.18979","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"SERIAL_Connection\") || {};\n\noptions.serialPort = msg.payload;\n\nflow.set(\"SERIAL_Connection\", options);","outputs":"0","noerr":0,"x":1480.5728759765625,"y":156.78819274902344,"wires":[]},{"id":"b9883b89.d7b0f8","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"SERIAL_Connection\") || {};\n\noptions.unitId = msg.payload;\n\nflow.set(\"SERIAL_Connection\", options);","outputs":"0","noerr":0,"x":1480.5728759765625,"y":199.78819274902344,"wires":[]},{"id":"743b34e2.0a022c","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.serialBaudrate","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1161.111099243164,"y":245.78817749023438,"wires":[["6a1aeb9f.420e24"]]},{"id":"c95e660a.10c0d8","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"SERIAL_Connection\") || {};\n\noptions.serialBaudrate = msg.payload;\n\nflow.set(\"SERIAL_Connection\", options);","outputs":"0","noerr":0,"x":1481.111068725586,"y":246.12151336669922,"wires":[]},{"id":"6c12cba3.837cc4","type":"ui_button","z":"3007b84d.585828","name":"connectSERIAL","group":"4fe0301e.33802","order":7,"width":0,"height":0,"passthru":false,"label":"Connect","color":"","bgcolor":"","icon":"compare_arrows","payload":"SERIAL_Connection","payloadType":"flow","topic":"","x":120.0173568725586,"y":409.7881774902344,"wires":[["7f6bcf05.18398"]]},{"id":"6a1aeb9f.420e24","type":"ui_dropdown","z":"3007b84d.585828","name":"BaudRate","label":"Baud Rate","place":"Select a Boud Rate","group":"4fe0301e.33802","order":6,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":115200,"type":"num"},{"label":"","value":57600,"type":"num"},{"label":"","value":38400,"type":"num"},{"label":"","value":19200,"type":"num"},{"label":"","value":9600,"type":"num"},{"label":"","value":4800,"type":"num"},{"label":"","value":2400,"type":"num"},{"label":"","value":1200,"type":"num"},{"label":"","value":300,"type":"num"},{"label":"","value":110,"type":"num"},{"label":"","value":75,"type":"num"}],"payload":"","topic":"","x":1315.239501953125,"y":245.78817749023438,"wires":[["c95e660a.10c0d8"]]},{"id":"d52565a6.856798","type":"ui_dropdown","z":"3007b84d.585828","name":"configurations","label":"Configurations","place":"Choose a conf...","group":"b079e2a.7753f2","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":1119.731704711914,"y":334.5819034576416,"wires":[["692f58b9.918a78"]]},{"id":"60a10bbf.dd1344","type":"inject","z":"3007b84d.585828","name":"","topic":"init","payload":"configs_TCP","payloadType":"flow","repeat":"","crontab":"","once":true,"x":749.0174331665039,"y":385.01042461395264,"wires":[["518c79c8.bf0d98"]]},{"id":"518c79c8.bf0d98","type":"function","z":"3007b84d.585828","name":"options","func":"var options = [];\n\n\n(msg.payload || []).forEach(function(opt) {\n var tmp = {};\n tmp[opt.name] = opt;\n options.push(tmp);\n});\n\nmsg.options = options;\n\nreturn msg;","outputs":1,"noerr":0,"x":935.0173721313477,"y":364.01040267944336,"wires":[["d52565a6.856798"]]},{"id":"fb2f0f94.099bb","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Name","group":"b079e2a.7753f2","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":536.017333984375,"y":84.01041412353516,"wires":[["96d82679.5f3268"]]},{"id":"96d82679.5f3268","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"TCP_Connection\") || {};\n\noptions.name = msg.payload;\n\nflow.set(\"TCP_Connection\", options);","outputs":"0","noerr":0,"x":699.5728759765625,"y":84.23263549804688,"wires":[]},{"id":"df543765.66fc68","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":384.5729064941406,"y":84.23263549804688,"wires":[["fb2f0f94.099bb"]]},{"id":"c8092503.4218a8","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Name","group":"4fe0301e.33802","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":1313.4617919921875,"y":67.01041412353516,"wires":[["be283b53.2c1d18"]]},{"id":"be283b53.2c1d18","type":"function","z":"3007b84d.585828","name":"save","func":"var options = flow.get(\"SERIAL_Connection\") || {};\n\noptions.name = msg.payload;\n\nflow.set(\"SERIAL_Connection\", options);","outputs":"0","noerr":0,"x":1481.017333984375,"y":67.23263549804688,"wires":[]},{"id":"88c6cbfe.471658","type":"change","z":"3007b84d.585828","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1166.0173645019531,"y":67.23263549804688,"wires":[["c8092503.4218a8"]]},{"id":"25b7c027.8c9ff","type":"ui_dropdown","z":"3007b84d.585828","name":"configurations","label":"Configurations","place":"Choose a conf...","group":"4fe0301e.33802","order":1,"width":0,"height":0,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":1117.4460067749023,"y":464.5977191925049,"wires":[["7bb61422.078f2c"]]},{"id":"ea6eba8e.556108","type":"inject","z":"3007b84d.585828","name":"","topic":"init","payload":"configs_SERIAL","payloadType":"flow","repeat":"","crontab":"","once":true,"x":744.017391204834,"y":437.4548463821411,"wires":[["174ed9b2.183ab6"]]},{"id":"174ed9b2.183ab6","type":"function","z":"3007b84d.585828","name":"options","func":"var options = [];\n\n(msg.payload || []).forEach(function(opt) {\n var tmp = {};\n tmp[opt.name] = opt;\n options.push(tmp);\n});\n\nmsg.options = options;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":933.0174179077148,"y":416.4548511505127,"wires":[["25b7c027.8c9ff"]]},{"id":"7f6bcf05.18398","type":"function","z":"3007b84d.585828","name":"connect","func":"var options = msg.payload;\nvar error = {topic: \"SERIAL Connect\"};\nvar configs = flow.get('configs_SERIAL') || [];\n\noptions.connectorType = \"SERIAL\";\n\nif(!options.name || options.name === \"\"){\n options.name = \"No name\";\n}\n\nif(!options.serialPort){\n error.payload = \"Serial port not valid\";\n node.error(\"Error\",error);\n return;\n}\n\nif(!options.serialBaudrate){\n error.payload = \"Select a Baud Rate\";\n node.error(\"Error\",error);\n return;\n}\n\nif(!options.unitId){\n error.payload = \"Unit ID not Valid\";\n node.error(\"Error\",error);\n return;\n}\n\nvar index = configs.findIndex(function(conf) {\n return conf.name == options.name;\n});\n\nif(index < 0)\n configs.push(options);\nelse\n configs[index] = options;\n \nflow.set('configs_SERIAL', configs);\n\nnode.send([msg, {payload:configs, topic:\"init\"}]);","outputs":"2","noerr":0,"x":290.0173645019531,"y":409.8992919921875,"wires":[["3e658f6f.6cb3c","fad03663.4dbfe8"],["174ed9b2.183ab6"]]},{"id":"ea932305.81705","type":"change","z":"3007b84d.585828","name":"","rules":[{"t":"set","p":"TCP_Connection","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1458.0652198791504,"y":334.9152021408081,"wires":[["e89e1758.ef8648"]]},{"id":"ae4b6077.b942","type":"change","z":"3007b84d.585828","name":"","rules":[{"t":"set","p":"SERIAL_Connection","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1467.9221725463867,"y":464.4865942001343,"wires":[["fbd5ccd8.b8237"]]},{"id":"eab9475c.d79388","type":"link in","z":"3007b84d.585828","name":"set_tcp","links":["e89e1758.ef8648","8dee1c7f.d8241"],"x":220.46198081970215,"y":84.89933586120605,"wires":[["df543765.66fc68","387c8f76.0fe67","7246ca2.4831f34","a4883537.fd0a58"]]},{"id":"e89e1758.ef8648","type":"link out","z":"3007b84d.585828","name":"set_tcp","links":["eab9475c.d79388"],"x":1620.60462474823,"y":335.47075176239014,"wires":[]},{"id":"7f126cfa.eb6934","type":"link in","z":"3007b84d.585828","name":"set_serial","links":["fbd5ccd8.b8237","fad03663.4dbfe8"],"x":992.4618768692017,"y":66.89929580688477,"wires":[["88c6cbfe.471658","a6aa7b0b.bc7cb8","32b2795f.f9f746","52822920.d8f8b8","743b34e2.0a022c"]]},{"id":"fbd5ccd8.b8237","type":"link out","z":"3007b84d.585828","name":"set_serial","links":["7f126cfa.eb6934"],"x":1630.175989151001,"y":464.0420923233032,"wires":[]},{"id":"370ac568.63436a","type":"inject","z":"3007b84d.585828","name":"init","topic":"","payload":"{\"options\":[]}","payloadType":"json","repeat":"","crontab":"","once":false,"x":728.9999771118164,"y":505.57143783569336,"wires":[["258db9e.0d0fa46","d52565a6.856798","25b7c027.8c9ff"]]},{"id":"258db9e.0d0fa46","type":"function","z":"3007b84d.585828","name":"init confs","func":"flow.set(\"configs_TCP\", null);\nflow.set(\"configs_SERIAL\", null);","outputs":"0","noerr":0,"x":886.7143058776855,"y":506.00001430511475,"wires":[]},{"id":"692f58b9.918a78","type":"switch","z":"3007b84d.585828","name":"check","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"init","vt":"str"}],"checkall":"true","outputs":1,"x":1277.8570747375488,"y":335.14288997650146,"wires":[["ea932305.81705"]]},{"id":"7bb61422.078f2c","type":"switch","z":"3007b84d.585828","name":"check","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"init","vt":"str"}],"checkall":"true","outputs":1,"x":1277.0000076293945,"y":464.42857837677,"wires":[["ae4b6077.b942"]]},{"id":"f4c74bcc.c754b8","type":"catch","z":"3007b84d.585828","name":"","scope":["7f6bcf05.18398","81514fd0.532d5"],"x":160.00000762939453,"y":496.42858505249023,"wires":[["469a0794.8fa5e8"]]},{"id":"469a0794.8fa5e8","type":"ui_toast","z":"3007b84d.585828","position":"top right","displayTime":"3","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"Error","name":"error","x":320,"y":496.4285774230957,"wires":[]},{"id":"8dee1c7f.d8241","type":"link out","z":"3007b84d.585828","name":"init_tcp","links":["eab9475c.d79388"],"x":431.42858600616455,"y":330.2857265472412,"wires":[]},{"id":"fad03663.4dbfe8","type":"link out","z":"3007b84d.585828","name":"init_serial","links":["7f126cfa.eb6934"],"x":426.42856788635254,"y":453.1428499221802,"wires":[]},{"id":"f947b91c.fa0988","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Address","group":"426c6703.2c1038","order":1,"width":"3","height":"1","passthru":true,"mode":"text","delay":300,"topic":"","x":438.2857360839844,"y":955.4285888671875,"wires":[["5250a8de.1acd38"]]},{"id":"c90dfb95.6bdc38","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Address","group":"4a263e90.169ff","order":1,"width":"2","height":"1","passthru":true,"mode":"text","delay":300,"topic":"","x":1124.2857666015625,"y":977.7142944335938,"wires":[["cf92cac3.115e98"]]},{"id":"cc40dff8.48c9e","type":"ui_text_input","z":"3007b84d.585828","name":"","label":"Length","group":"426c6703.2c1038","order":2,"width":"3","height":"1","passthru":true,"mode":"text","delay":300,"topic":"","x":427.1428527832031,"y":1001.1428833007812,"wires":[["dd349bfe.086ca8"]]},{"id":"ae1af357.01906","type":"inject","z":"3007b84d.585828","name":"","topic":"init","payload":"{\"payload\":null}","payloadType":"json","repeat":"1","crontab":"","once":false,"x":838.5714492797852,"y":307.1428499221802,"wires":[["d52565a6.856798","25b7c027.8c9ff"]]},{"id":"e1287907.03a0d8","type":"toFloat","z":"3007b84d.585828","name":"","toFixed":"4","x":1287.6429443359375,"y":761.8571166992188,"wires":[["bddb7999.5e39f8","be6e63a4.9997e"]]},{"id":"8d6a2f85.239ab","type":"ui_text","z":"3007b84d.585828","group":"55e082a0.9e821c","order":3,"width":"0","height":"0","name":"","label":"Received Data: ","format":"{{msg.payload}}","layout":"row-spread","x":449.00000762939453,"y":768.0000534057617,"wires":[]},{"id":"be6e63a4.9997e","type":"ui_text","z":"3007b84d.585828","group":"55e082a0.9e821c","order":4,"width":0,"height":0,"name":"","label":"Converted Data: ","format":"{{msg.payload}}","layout":"row-spread","x":1401,"y":629,"wires":[]},{"id":"cc26bbfe.79b628","type":"function","z":"3007b84d.585828","name":"16To32Bit_Inverse","func":"var values32bit = [];\n\nfor(var i=0;i<msg.payload.length;i++){\n var tmp = msg.payload[i].toString(2);\n tmp = tmp.length < 16 ? '0'.repeat(16-tmp.length) + tmp : tmp;\n i++;\n var tmp1 = i < msg.payload.length ? msg.payload[i].toString(2) : '0000000000000000';\n tmp1 = tmp1.length < 16 ? '0'.repeat(16-tmp1.length) + tmp1 : tmp1;\n var value = parseInt(tmp+tmp1,2);\n if(flow.get('hex')) value = '0x'+value.toString(16).toUpperCase();\n \n values32bit.push(value);\n}\n\nmsg.payload = values32bit;\n\nreturn msg;","outputs":1,"noerr":0,"x":860.7695465087891,"y":758.0039596557617,"wires":[["ea3e65dc.00f918"]]},{"id":"6c39c83d.761918","type":"ui_switch","z":"3007b84d.585828","name":"","label":"Invert","group":"426c6703.2c1038","order":4,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":415.01953887939453,"y":1226.003960609436,"wires":[["67f8390b.1fd7e8"]]},{"id":"8e82685d.ac14a8","type":"switch","z":"3007b84d.585828","name":"Inv","property":"inverse","propertyType":"flow","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":671.0195350646973,"y":738.0040216445923,"wires":[["4ab48214.f2ebac"],["cc26bbfe.79b628"]]},{"id":"67f8390b.1fd7e8","type":"function","z":"3007b84d.585828","name":"save","func":"flow.set(\"inverse\", msg.payload);","outputs":"0","noerr":0,"x":585.0195960998535,"y":1226.0039138793945,"wires":[]},{"id":"d5eb6b2e.d43268","type":"inject","z":"3007b84d.585828","name":"","topic":"","payload":"inverse","payloadType":"flow","repeat":"0.1","crontab":"","once":true,"onceDelay":"","x":206.01953125,"y":1226.0039463043213,"wires":[["6c39c83d.761918"]]},{"id":"cba46076.4678e","type":"function","z":"3007b84d.585828","name":"64Bit_Int","func":"// 13.04.2019 Ben ekledim, kodu asagidan aldim\n// 16to32bit ornegine bakarak 4 registeri birlestirdim 64 Bit integer yaptim\n\nvar values64bit = [];\n\nfor(var i=0;i<msg.payload.length;i++){\n var tmp = msg.payload[i].toString(4);\n tmp = tmp.length < 16 ? '0'.repeat(16-tmp.length) + tmp : tmp;\n i++;\n var tmp1 = i < msg.payload.length ? msg.payload[i].toString(4) : '0000000000000000';\n tmp1 = tmp1.length < 16 ? '0'.repeat(16-tmp1.length) + tmp1 : tmp1;\n i++;\n var tmp2 = i < msg.payload.length ? msg.payload[i].toString(4) : '0000000000000000';\n tmp2 = tmp2.length < 16 ? '0'.repeat(16-tmp2.length) + tmp2 : tmp2;\n i++;\n var tmp3 = i < msg.payload.length ? msg.payload[i].toString(4) : '0000000000000000';\n tmp3 = tmp3.length < 16 ? '0'.repeat(16-tmp3.length) + tmp3 : tmp3;\n \n var value = parseInt(tmp+tmp1+tmp2+tmp3,4); // 64 Bit int olarak birlestiriyor\n\n if(flow.get('hex')) value = '0x'+value.toString(16).toUpperCase();\n \n values64bit.push(value);\n}\n\nmsg.payload = values64bit;\n\nreturn msg;","outputs":1,"noerr":0,"x":653.8867263793945,"y":796.6328649520874,"wires":[["a13ddb7f.448088"]]},{"id":"a13ddb7f.448088","type":"debug","z":"3007b84d.585828","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1029.6445770263672,"y":797.9023342132568,"wires":[]},{"id":"aca9bf8c.b3ba","type":"debug","z":"3007b84d.585828","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1279.6328125,"y":826.8984375,"wires":[]},{"id":"426c6703.2c1038","type":"ui_group","z":"","name":"Read (0 Based)","tab":"1810c2ba.d68d0d","order":3,"disp":true,"width":"6","collapse":false},{"id":"5876d9d3.3456c8","type":"modbus-client","z":"","name":"MODSCAN","clienttype":"serial","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"2000"},{"id":"55e082a0.9e821c","type":"ui_group","z":"","name":"Output","tab":"1810c2ba.d68d0d","order":5,"disp":true,"width":"6","collapse":false},{"id":"4a263e90.169ff","type":"ui_group","z":"","name":"Write (0 Based)","tab":"1810c2ba.d68d0d","order":4,"disp":true,"width":"6","collapse":false},{"id":"b079e2a.7753f2","type":"ui_group","z":"","name":"TCP","tab":"1810c2ba.d68d0d","order":2,"disp":true,"width":"6"},{"id":"4fe0301e.33802","type":"ui_group","z":"","name":"Serial","tab":"1810c2ba.d68d0d","order":1,"disp":true,"width":"6"},{"id":"1810c2ba.d68d0d","type":"ui_tab","z":"","name":"Modscan (C.Iskender 26.12.2018)","icon":"dashboard","order":2}]
Copy link

ghost commented Aug 24, 2018

Hi Roberts i would like to inform you that i have succesfully tested also the usb device COM4540 !!

@OldFartingPhysicist
Copy link

Hi Daniel,
Thank you very much for sharing your marvelous work!
I have tested it with a USB-RS485 converter plugged it directly on a Raspberry Pi Zero W.
I made small modifications to run the flow as follows. It may help others or it may give new ideas.

  1. Reviewing the flow, I thought TCP or Serial connection was selected automatically. I do not know why but the flow did not work until I selected Modbus Serial (or Modbus Serial Expert) in the connection node. Then it worked like a charm. I have tested it with a RS485 slave device
  2. In both Read and Write nodes, Slave ID is fixed as "1", I have corrected it and it works for any slave ID now. From GUI you can select Slave ID as intended.
  3. I have deleted first switch in Output section. It was not passing any message to its outputs. Now I can see some of the conversion outputs on the GUI but not all of them. (I will detail them when I find my notes and share my version with you.)
  4. Since I could not see all conversion outputs on the GUI table (template), I have added a dashboard text (ui_text), to see the received response from slave and also see the conversion outputs. Now I can see float, long integer, hex conversions on this ui_text.
  5. I have added function code 4 (FC 4), Read Status Registers and tested successfully.

I have used some Modbus slave simulators to test Modbus serial and below are my findings;
a. I have discovered that Read and Write Addresses are 0 Based.
b. Both long integer and float conversion is represented as inverse. In other words some Modbus serial simulators named same conversions as "Float Inverse" and "Long Integer Inverse"

Thank you very much once more for such an exiting work!

@brentdbell
Copy link

Hi Daniel,
Thank you very much for sharing your marvelous work!
I have tested it with a USB-RS485 converter plugged it directly on a Raspberry Pi Zero W.
I made small modifications to run the flow as follows. It may help others or it may give new ideas.

  1. Reviewing the flow, I thought TCP or Serial connection was selected automatically. I do not know why but the flow did not work until I selected Modbus Serial (or Modbus Serial Expert) in the connection node. Then it worked like a charm. I have tested it with a RS485 slave device
  2. In both Read and Write nodes, Slave ID is fixed as "1", I have corrected it and it works for any slave ID now. From GUI you can select Slave ID as intended.
  3. I have deleted first switch in Output section. It was not passing any message to its outputs. Now I can see some of the conversion outputs on the GUI but not all of them. (I will detail them when I find my notes and share my version with you.)
  4. Since I could not see all conversion outputs on the GUI table (template), I have added a dashboard text (ui_text), to see the received response from slave and also see the conversion outputs. Now I can see float, long integer, hex conversions on this ui_text.
  5. I have added function code 4 (FC 4), Read Status Registers and tested successfully.

I have used some Modbus slave simulators to test Modbus serial and below are my findings;
a. I have discovered that Read and Write Addresses are 0 Based.
b. Both long integer and float conversion is represented as inverse. In other words some Modbus serial simulators named same conversions as "Float Inverse" and "Long Integer Inverse"

Thank you very much once more for such an exiting work!

@OldFartingPhysicist - I know your post is a little old....I am trying to get this working - using TCP which I have working with the device I am controlling in some other flows I have done myself. Can you please let me know if you have an update flow with your modifications, or a little more detail in exactly what you did to make it work for you?

Sorry, but I am a bit of a noob with Node-red, I have tried making some of the changes you mention but still unable to get anything in the output of the Dashboard UI.

Thanks

@OldFartingPhysicist
Copy link

OldFartingPhysicist commented Jan 20, 2020 via email

@robertsLando
Copy link
Author

@OldFartingPhysicist Please share it here so I can update the flow.

@OldFartingPhysicist
Copy link

OldFartingPhysicist commented Jan 20, 2020 via email

@robertsLando
Copy link
Author

robertsLando commented Jan 21, 2020

Updated, Thanks 😄

@OldFartingPhysicist
Copy link

Dear Daniel, Thank you very much again for your marvelous work. I have learned a lot about Node-Red when investigating your flows.
You may want to delete, my name on the GUI tab.
Since I am not a software engineer I could not understand some parts and make GUI table (template) work properly.

@robertsLando
Copy link
Author

I have already editet the flow and removed some comments you added :) thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment