Basic Node-RED telnet question

Sorry if this is a rather basic question...

My projector is connected to the LAN. I'd like to switch it on over telnet.

I can do this in Windows as follows:

  • When I connect, it prompts for a password which I type in e.g. 1234 [enter]
  • It returns Hello.
  • I then type C00 [enter] to switch the projector on
  • I can type C02 [enter] C02 [enter] to switch it off (once to request power off, second time to confirm)

I have a basic function node like this:

msg.payload = '\n';
node.send(msg);
msg.payload = '1234\n';
node.send(msg);
msg.payload = 'C00\n';
node.send(msg);

plugged in to the TCP request node, set to return Never - keep the request open.

But it doesn't seem to work. I've set the output of the TCP request node to a function:

msg.payload = msg.payload.toString();
return msg;

then to a debug node, and I see:

6/11/2019, 12:09:43 AMnode: b0162d2f.c5451msg.payload : string[12]

"↵PASSWORD: "

6/11/2019, 12:09:43 AMnode: b0162d2f.c5451msg.payload : string[12]

"************"

Any idea what's going on here?

Nice idea, cool. Without access to the device it is a little guesswork from my side. But here I go anyway:

From the answers in the debug output, this looks promising.
One thing to try is, send \r\n instead of just \n

Another thing to try: you hammer out password and command quickly one after the other. Sometimes the receiving devices can't handle it all. Adding a short delay might help.

And then there is the obvious but more complex issue. Send one string, wait for the answer, then send the next string. But I suggest to try the first two ideas first.
Kind regards,
Urs.

1 Like