# TCP input convert

**URL:** <https://discourse.nodered.org/t/tcp-input-convert/24612>\
**Category:** General\
**Created:** [10 April 2020 19:44 UTC](https://discourse.nodered.org/t/tcp-input-convert/24612 "2020-04-10T19:44:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fulltopuk](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Fulltopuk](https://discourse.nodered.org/u/Fulltopuk)\
**Post date:** [10 April 2020 19:44 UTC](https://discourse.nodered.org/t/tcp-input-convert/24612/1 "2020-04-10T19:44:08Z")

</div>

Hi All

I am trying to get my head around Nodered syntax but I am not yet understanding most of how things work. ☹

I have a light system which communicates over RS232 and I 'listen' to it over LAN via a TCP connection.

What I what to do is listen for certain messages and when they appear on the TCP, switch a hue lamp. I am OK for the hue side but what is stumping me is how to set up a flow to do it.

The TCP gives me a msg.payload of [3,97,153,16] which can also be viewed in debug as:-

msg.payload : buffer[4]

buffer[4][raw](http://hoobs.local:1880/#)

0: 0x3

1: 0x61

2: 0x99

3: 0x2e

So the question is what do I use to check the message and act if it is that particular message. I have tried switch, change etc but nothing seems to work. Do I need to use the function command?

Any advice or help is greatly appreciated, I have tried to find examples and have read the user manual but I think I am lacking the basics.

Thanks Fulltopuk

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 April 2020 08:32 UTC](https://discourse.nodered.org/t/tcp-input-convert/24612/2 "2020-04-11T08:32:47Z")

</div>

I couldn't immediately see how to do it in a switch node, but a Function node containing this should do the job, though I have not tested it.

```auto
if (msg.payload[0] == 0x03 && msg.payload[1] == 0x61 && msg.payload[2] == 0x99 && msg.payload[3] == 0x2e ) {
  return msg
}

```

That should pass on the message if the test matches and do nothing if not.

---

<div class="post-metadata">

**Author:** ![Fulltopuk](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@Fulltopuk](https://discourse.nodered.org/u/Fulltopuk)\
**Post date:** [13 April 2020 12:01 UTC](https://discourse.nodered.org/t/tcp-input-convert/24612/3 "2020-04-13T12:01:01Z")

</div>

Hi Colin

Many thanks for your response.

I will give it a try

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 June 2020 12:01 UTC](https://discourse.nodered.org/t/tcp-input-convert/24612/4 "2020-06-12T12:01:03Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
