Reading different registers in the same device +help reading some datas
See original GitHub issueGood day!
Great tools for Modbus! It’s working perfectly!
Is it possible to read different registers using the same function for reading in flex getter? I’m trying to read different registers with a different address on the same device here 50521, 50528 and 50770
I’ve tried msg.payload = {'fc': 3, 'unitid': 69, 'address': [50521,50528,50770] , 'quantity': 3 }
but seems to read 50521 and 50522 and 50523.
For now, I’m doing like this :
[{"id":"dfab6cca.74f9c","type":"tab","label":"Test read buffer"},{"id":"5b09b1a.b5e725","type":"function","z":"dfab6cca.74f9c","name":"extract buffer","func":"msg.payload = msg.payload.buffer.readUInt32BE(0);\nreturn msg","outputs":"1","noerr":0,"x":800,"y":180,"wires":[["68fa93ee.cb764c"]]},{"id":"68fa93ee.cb764c","type":"debug","z":"dfab6cca.74f9c","name":"","active":true,"console":"false","complete":"payload","x":990,"y":160,"wires":[]},{"id":"2f0694da.fdc7fc","type":"function","z":"dfab6cca.74f9c","name":"buff to string","func":"msg.payload = msg.payload.buffer.toString('utf8',0,8)\n +'_'+ msg.payload.buffer.toString('utf8',9);\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":340,"wires":[["1beb007.056dc"]]},{"id":"4aab90d1.62e9e","type":"modbus-read","z":"dfab6cca.74f9c","name":"Automatic Read FC3","showStatusActivities":true,"showErrors":true,"unitid":"69","dataType":"HoldingRegister","adr":"50042","quantity":"16","rate":"5","rateUnit":"s","server":"8f02b0be.180e6","x":130,"y":340,"wires":[[],["2f0694da.fdc7fc"]]},{"id":"1beb007.056dc","type":"debug","z":"dfab6cca.74f9c","name":"","active":false,"console":"false","complete":"false","x":610,"y":340,"wires":[]},{"id":"2ea584ae.afc47c","type":"comment","z":"dfab6cca.74f9c","name":"Lire le Buffer 2x16 (U32 BE)","info":"","x":160,"y":60,"wires":[]},{"id":"554db64f.5e6e98","type":"comment","z":"dfab6cca.74f9c","name":"Lire un biffer Buffer 8x16 et mettre en UTF8 - Ici marque + modèle","info":"","x":280,"y":300,"wires":[]},{"id":"59774ec.ee77fb","type":"modbus-flex-getter","z":"dfab6cca.74f9c","name":"","showStatusActivities":false,"showErrors":false,"server":"8f02b0be.180e6","x":580,"y":160,"wires":[[],["5b09b1a.b5e725"]]},{"id":"92decbe2.624bb8","type":"inject","z":"dfab6cca.74f9c","name":"Voltage","topic":"Voltage","payload":"50520","payloadType":"str","repeat":"5","crontab":"","once":false,"x":120,"y":120,"wires":[["ceb5d6e0.bbff78","68fa93ee.cb764c"]]},{"id":"ceb5d6e0.bbff78","type":"function","z":"dfab6cca.74f9c","name":"Ask to modbus","func":"msg.payload = {'fc': 3, 'unitid': 69, 'address': msg.payload , 'quantity': 2 , 'Topic' : msg.topic}\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":160,"wires":[["59774ec.ee77fb"]]},{"id":"98a72a48.563c88","type":"inject","z":"dfab6cca.74f9c","name":"Courrant","topic":"Courrant","payload":"50528","payloadType":"str","repeat":"5","crontab":"","once":false,"x":120,"y":160,"wires":[["ceb5d6e0.bbff78"]]},{"id":"ee7cdab.274e828","type":"inject","z":"dfab6cca.74f9c","name":"Wh","topic":"Wh","payload":"50770","payloadType":"str","repeat":"5","crontab":"","once":false,"x":110,"y":200,"wires":[["ceb5d6e0.bbff78"]]},{"id":"8f02b0be.180e6","type":"modbus-client","z":"","name":"Modbus Serial USB","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/Modbus-USB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"2","serialParity":"none","serialConnectionDelay":"100","unit_id":"","commandDelay":"50","clientTimeout":"1000","reconnectTimeout":"2000"}]
But i’ve several same counters to read so the best would be to inject the unitId and have a function that read all the registers i need for the differents units.
Also, would it be possible to pass the msg.topic to the buffered output?
best
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
a Wiki article would be cool about ttyAMA0 if you got some experiences
OK try v1.1.0 it is released now