Problems sending TCP (Telnet) String

1,778 views
Skip to first unread message

Richard

unread,
Nov 15, 2015, 5:01:34 PM11/15/15
to Node-RED
Hi,

I have just started using Node Red so still getting to grips with the basics. I am trying to inject a string to control my Wifi Kettle. I have tested successfully using telnet manually and all works ok. 

When I build the inject to a tcp out node it doesn't work. The TCP out node is showing connected to the kettle, and the string seems to send from the inject node (monitoring via debug). However, the string doesn't seem to reach the kettle. I must be doing something fundamentally wrong here.

When I test manually, I open a telnet connection to the ip address at port 2000. I then simply type and send the following "set sys output 0x4". This all works fine.

In the inject I have set the payload as a string with the following "set sys output 0x4\n". Which then is sent to a tcp out.

Can anyone please help?

Many thanks
Richard 

Nicholas O'Leary

unread,
Nov 15, 2015, 5:04:49 PM11/15/15
to Node-RED Mailing LIst
The inject node does handle escape sequences like \n - it treats them as literal strings.

For now, use a Function node after your Inject node to append the newline: 
    msg.payload = msg.payload + '\n';
    return msg;

Nick


--
http://nodered.org
---
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.
For more options, visit https://groups.google.com/d/optout.

Richard

unread,
Nov 15, 2015, 5:12:53 PM11/15/15
to Node-RED
Perfect. It works. Thanks very much.

Richard

Joe Hackman

unread,
Jan 21, 2018, 11:11:01 AM1/21/18
to Node-RED
Hi,

I am wanting to do something similar using a change node. I tried using a series of commands with \n after each and sending that to a TCP node. It all gets sent as one line, I assume this is due to how the change node interprets the \n as part of the literal string like you've noted previously. Basically when the change node receives a message payload of 1 I am wanting to send a multi line message via TCP. With a message payload of 0, I am sending a series of messages with only the last one being different.

Thanks for any suggestions you have.

Joe Hackman

unread,
Jan 21, 2018, 12:09:47 PM1/21/18
to Node-RED
I figured out a fix, the change node had added an extra \ on each of my commands. I stripped them out and the message is delivered correctly now.

Julian Knight

unread,
Jan 21, 2018, 2:57:05 PM1/21/18
to Node-RED
Wow, that sounds REALLY secure! Not

I hope your kettle is isolated from the Internet.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages