String sent to serial out

已查看 256 次
跳至第一个未读帖子

Hermann

未读,
2015年5月21日 09:21:542015/5/21
收件人 node...@googlegroups.com
Just out of curiosity: What is the difference between a string in the payload of an inject node and the string in the payload of a function node?

I am trying to send a string like "aaax\n" from an inject node directly to a serial out node to be read by an Arduino. The string is sent, the Arduino reads the serial output correctly (the "x" indicates the end of the message for the Arduino) but the serial buffer of the Rasberry Pi is not emptied because the \n is not recognized.
If I send the string "aaax" from the inject node to a function node first and attach the \n there (msg.payload = msg.payload + "\n") everything works as expected.

Dave C-J

未读,
2015年5月21日 09:39:082015/5/21
收件人 node...@googlegroups.com

That is the difference.... :-)

On the inject node the input field is read, and the \n is automatically escaped to be \\n internally... And that then appears as \n on the arduino...  Doing it inside the function doesn't escape the \ so it then sends the "\n" character.

Hermann

未读,
2015年5月21日 10:31:022015/5/21
收件人 node...@googlegroups.com
Thanks for the information Dave. ;-)

It took me a couple of days to find that out. Maybe there should be a remark in the documentation that escape sequences do not work in inject nodes...

Dave C-J

未读,
2015年5月21日 11:42:032015/5/21
收件人 node...@googlegroups.com

Good point...

回复全部
回复作者
转发
0 个新帖子