Hi Lawrance,
It is a buscoupler with an Ethernet port. It communicates over Modbus top. It's like wago 750-341.
But the problem is that I can only read and write registers. Not like common devices were I can read and write single coils or discrete inputs.
And now is my problem how to handle that register to get the boolean for each coil or input.
Marcus
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/N4uQ8eStTvE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.
You are right for example msg.payload = 65535 = 11 11 11 11 11 11 11 11 means all inputs or outputs are activated.
--
Yes one bit per coil simply packed to a 16 bit word.
--
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
My result is still 20...
The way you are using context whilst still currently supported has been deprecated in favour of the way documented here:
http://nodered.org/docs/writing-functions#storing-data
So as you are writing this now I'd suggest using the new way to future proof yourself.
Hey Mark,
Thank you for the hint. But I'm bad in English. But what seems interesting to me is the global variables.
Do I understand it right, that this let me read the buscoupler, store the data in global variables, I manipulate them to my needs and then write back to my buscoupler. If this works, then I have to find out how to do this.
Dave!! All Thumbs up!
Exactly what i want and ur code is much more lightweight than my horrible attempt.
line context.data[msg.bit] = msg.payload;
but I'm not sure you are setting "msg.bit" anywhere
You can check by
changing the output debug nodes e.g. "Task1" to Output "Complete msg object" so it will show you the complete msg object
or change the "join 16" so it reads...
node.warn("MSG.BIT"+msg.bit);
context.data[msg.bit] = msg.payload;
Here for u maybe helpful fopr others 2. And a backup for me!
[{"id":"5f2468d1.fce278","type":"mqtt-broker","z":"","broker":"192.168.0.127","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"true","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"true","birthPayload":""},{"id":"b0d1a6e8.26d948","type":"function","z":"3677a67d.31317a","name":"Join 16","func":"\ncontext.data = context.data || [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];\ncontext.data[msg.bit] = msg.payload;\n\n//if(context.data[0] !== undefined && context.data[1] !== undefined && context.data[2] !== undefined && context.data[3] !== undefined && context.data[4] !== undefined && context.data[5] !== undefined && context.data[6] !== undefined && context.data[7] !== undefined && context.data[8] !== undefined && context.data[9] !== undefined && context.data[10] !== undefined && context.data[11] !== undefined && context.data[12] !== undefined && context.data[13] !== undefined && context.data[14] !== undefined && context.data[15] !== undefined)\n//{\n\tvar msg2 = {};\n\tmsg2.payload = \"\"+ context.data[15]+ context.data[14]+ context.data[13]+ context.data[12]+ context.data[11]+ context.data[10]+ context.data[9] + context.data[8] + context.data[7] + context.data[6] + context.data[5] + context.data[4] + context.data[3] + context.data[2] + context.data[1] + context.data[0];\n msg2.payload = parseInt(msg2.payload,2);\n //context.data = new Array(16);\n return msg2;\n//}","outputs":1,"noerr":0,"x":700,"y":80,"wires":[["4411d1f3.58915"]]},{"id":"4411d1f3.58915","type":"debug","z":"3677a67d.31317a","name":"16 Outputs","active":true,"console":"false","complete":"payload","x":850,"y":180,"wires":[]},{"id":"a2fd8387.8e5ca","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Licht","topic":"Schlafzimmer/Output/Licht","broker":"5f2468d1.fce278","x":130,"y":760,"wires":[["d3867dd8.233ec"]]},{"id":"66f2902b.b2a36","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Heizung","topic":"Schlafzimmer/Output/Heizung","broker":"5f2468d1.fce278","x":140,"y":720,"wires":[["5eddec37.246b34"]]},{"id":"7d7d4fd.10824b","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Rollohoch","topic":"Schlafzimmer/Output/Rollohoch","broker":"5f2468d1.fce278","x":150,"y":680,"wires":[["d0d93528.95e338"]]},{"id":"92da12d7.4a794","type":"mqtt in","z":"3677a67d.31317a","name":"Schlafzimmer/Output/Rollorunter","topic":"Schlafzimmer/Output/Rollorunter","broker":"5f2468d1.fce278","x":150,"y":640,"wires":[["7e1c0625.70f1e8"]]},{"id":"fa4fea4.f2bef18","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Steckdosen","topic":"Leon/Output/Steckdosen","broker":"5f2468d1.fce278","x":130,"y":360,"wires":[["3fa1f5ba.5998aa"]]},{"id":"f9521d90.db35b","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Licht","topic":"Leon/Output/Licht","broker":"5f2468d1.fce278","x":110,"y":520,"wires":[["889aa5e3.b9bea8"]]},{"id":"7cc9b390.b2906c","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Heizung","topic":"Leon/Output/Heizung","broker":"5f2468d1.fce278","x":120,"y":480,"wires":[["7204b9e8.aebe88"]]},{"id":"cc711c5c.337bc","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Rollohoch","topic":"Leon/Output/Rollohoch","broker":"5f2468d1.fce278","x":120,"y":440,"wires":[["fd38fa58.ed9df8"]]},{"id":"19fb9c49.72fb94","type":"mqtt in","z":"3677a67d.31317a","name":"Leon/Output/Rollorunter","topic":"Leon/Output/Rollorunter","broker":"5f2468d1.fce278","x":130,"y":400,"wires":[["91342ed9.eac2d"]]},{"id":"16e1f54.93d1b0b","type":"mqtt in","z":"3677a67d.31317a","name":"Ankleidezimmer/Output/Licht","topic":"Ankleidezimmer/Output/Licht","broker":"5f2468d1.fce278","x":140,"y":580,"wires":[["82077ae0.5a7c48"]]},{"id":"c13689c4.fe31a8","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Licht","topic":"Basti/Output/Licht","broker":"5f2468d1.fce278","x":110,"y":300,"wires":[["3f8ba80f.fad938"]]},{"id":"9740fca4.98802","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Heizung","topic":"Basti/Output/Heizung","broker":"5f2468d1.fce278","x":120,"y":260,"wires":[["a457609b.0347"]]},{"id":"f7d30df0.1d6","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Rollohoch","topic":"Basti/Output/Rollohoch","broker":"5f2468d1.fce278","x":120,"y":220,"wires":[["5b659b23.724c54"]]},{"id":"3339057b.12557a","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Rollorunter","topic":"Basti/Output/Rollorunter","broker":"5f2468d1.fce278","x":120,"y":180,"wires":[["7f45c916.6d7018"]]},{"id":"3e13feb3.71c252","type":"mqtt in","z":"3677a67d.31317a","name":"Basti/Output/Steckdosen","topic":"Basti/Output/Steckdosen","broker":"5f2468d1.fce278","x":130,"y":140,"wires":[["94feaa2b.ae83f8"]]},{"id":"ca5f0283.fb097","type":"mqtt in","z":"3677a67d.31317a","name":"Fluroben/Output/Licht","topic":"Fluroben/Output/Licht","broker":"5f2468d1.fce278","x":120,"y":80,"wires":[["83f80f02.877b4"]]},{"id":"d3867dd8.233ec","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 1","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 0;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":760,"wires":[["b0d1a6e8.26d948"]]},{"id":"5eddec37.246b34","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 2","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 1;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":720,"wires":[["b0d1a6e8.26d948"]]},{"id":"d0d93528.95e338","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 3","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 2;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":680,"wires":[["b0d1a6e8.26d948"]]},{"id":"7e1c0625.70f1e8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 4","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 3;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":640,"wires":[["b0d1a6e8.26d948"]]},{"id":"82077ae0.5a7c48","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 5","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 4;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":580,"wires":[["b0d1a6e8.26d948"]]},{"id":"889aa5e3.b9bea8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 6","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 5;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":520,"wires":[["b0d1a6e8.26d948"]]},{"id":"7204b9e8.aebe88","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 7","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 6;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":480,"wires":[["b0d1a6e8.26d948"]]},{"id":"fd38fa58.ed9df8","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 8","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 7;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":440,"wires":[["b0d1a6e8.26d948"]]},{"id":"91342ed9.eac2d","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 9","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 8;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":400,"wires":[["b0d1a6e8.26d948"]]},{"id":"3fa1f5ba.5998aa","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 10","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 9;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":360,"wires":[["b0d1a6e8.26d948"]]},{"id":"3f8ba80f.fad938","type":"function","z":"3677a67d.31317a","name":"Adress 385 Output 11","func":"if (typeof msg.payload !== 'number') \n{\n msg.payload = Number(msg.payload);\n}\n\nif (!msg.payload) \n{\n msg.payload = 0;\n}\n\nmsg.bit = 10;\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":300,"wires":[["b0d1a6e8.26d948"]]},{"id":"<wbr style="font-family: tahoma, sans-serif; font-s
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/N4uQ8eStTvE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/0852dbfa-e1ef-47c0-8306-fdf3600eee8d%40googlegroups.com.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.