var m = [];
for (var i=0;i<10;i++)
{m[i] = { payload: msg.payload[i] };}return m;
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
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+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/d820f87a-45a3-44ee-9853-b82c27a8c1e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Function nodes must return message objects, not plain values.For example:var m = [];for (var i=0;i<10;i++){m[i] = { payload: msg.payload[i] };}return m;RegardsNick
On 27 September 2017 at 09:13, <chris....@gmail.com> wrote:
I use modbus read node to read register(ID=1,FC=3, Address=0, Quantity=10) and try to get each value through function node. However, it debug shows "Function tried to send a message of type number". However to solve it.flow as follows.[{"id":"fcbc3779.b529b8","type":"modbus-read","z":"6f3fbd9e.4f4b9c","name":"","showStatusActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"10","rate":"1","rateUnit":"s","server":"d631304d.f42a4","x":377,"y":414.1600036621094,"wires":[["c9fb2a0f.12a118","601cbf63.33b9cc"],[]]},{"id":"6f3d0382.d932ac","type":"debug","z":"6f3fbd9e.4f4b9c","name":"","active":true,"console":"false","complete":"payload","x":830,"y":400,"wires":[]},{"id":"c9fb2a0f.12a118","type":"function","z":"6f3fbd9e.4f4b9c","name":"Get Array value","func":"var m = [];\n\nfor (var i=0;i<10;i++)\n{\n m[i] = msg.payload[i];\n}\nreturn m;","outputs":"10","noerr":0,"x":623.7899780273437,"y":413.3399963378906,"wires":[["6f3d0382.d932ac"],["bedd1abf.66a488"],[],[],[],[],[],[],[],[]]},{"id":"bedd1abf.66a488","type":"debug","z":"6f3fbd9e.4f4b9c","name":"","active":true,"console":"false","complete":"payload","x":830,"y":440,"wires":[]},{"id":"601cbf63.33b9cc","type":"debug","z":"6f3fbd9e.4f4b9c","name":"","active":true,"console":"false","complete":"payload","x":550,"y":540,"wires":[]},{"id":"d631304d.f42a4","type":"modbus-client","z":"","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectTimeout":"2000"}]
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
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.
The function is expected to return a message object (or multiple message objects),
but can choose to return nothing in order to halt a flow.
N.B. Returning any javascript primitive (string, number, boolean) will cause an error in your flow!
Instead, that value would typically be set as the payload of the returned msg object.
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
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+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/e397a8b0-6425-4263-83ed-431eb6f93a6c%40googlegroups.com.