# Conversation with STONE Panel via Serial Port

**URL:** https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156
**Category:** General
**Created:** [24 May 2021 12:37 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156 "2021-05-24T12:37:04Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![DerD74](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@DerD74](https://discourse.nodered.org/u/DerD74)
#### Post date: [24 May 2021 12:37 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/1 "2021-05-24T12:37:05Z")

</div>

Dear all,

I try to comuicate with STONE Panel via Serial Port. This is working with hex commands as you can read in the screenshot below.

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cde8c46a8b6563e07e3328eb79407276390dc028.png)

I tried out folloiwing with serial nodes. But it does not work and I dont know why.  
Someone have expirence with this kind of Panel or similar?

```auto
[{"id":"2d25e76c.f15d2","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"680ef872.5eb5a8","type":"s7comm read","z":"2d25e76c.f15d2","connection":"d4a46384.90c6b8","payload":"{\"S7_Type\":\"DB\",\"S7_DBnum\":\"5\",\"S7_Datatype\":\"W\",\"S7_Offset\":\"2\",\"S7_BitOffset\":\"0\",\"S7_Quantity\":\"1\",\"S7_Name\":\"test16\"}","s7Name":"test16","topic":"S7_312","name":"DB5.DBW2","signalSetted":false,"none":"false","repeat":"10","once":false,"x":488.5,"y":418,"wires":[["476f533a.b50634","3a290f42.312de","5a0b9feb.b2d59"]]},{"id":"f47c82d8.28c22","type":"inject","z":"2d25e76c.f15d2","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":290.5,"y":421,"wires":[["680ef872.5eb5a8","a695edb7.a202f"]]},{"id":"476f533a.b50634","type":"debug","z":"2d25e76c.f15d2","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":703.5,"y":422,"wires":[]},{"id":"3a290f42.312de","type":"function","z":"2d25e76c.f15d2","name":"Msg to int","func":"msg.payload=msg.payload.value[0];\nreturn msg;","outputs":1,"noerr":0,"x":610.5,"y":565,"wires":[["ad76d300.136f68","8f7cbbfe.6b0ba8"]]},{"id":"ad76d300.136f68","type":"ui_gauge","z":"2d25e76c.f15d2","name":"","group":"11555359.e3265d","order":3,"width":0,"height":0,"gtype":"gage","title":"Analogwert","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":817.5,"y":573,"wires":[]},{"id":"8f7cbbfe.6b0ba8","type":"debug","z":"2d25e76c.f15d2","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":761.5,"y":636,"wires":[]},{"id":"36a7e77d.d50e28","type":"serial out","z":"2d25e76c.f15d2","name":"Analog Panel1","serial":"e6c39153.e8eab8","x":948.5,"y":694,"wires":[]},{"id":"5a0b9feb.b2d59","type":"function","z":"2d25e76c.f15d2","name":"Msg to hex Command","func":"var msg1 = { payload:\"0xA5 0x5A 0x05 0x82 0x00 0x06 0x00 0x08\" };\nreturn msg1;","outputs":1,"noerr":0,"x":660,"y":695,"wires":[["36a7e77d.d50e28","a050eb95.d7edd"]]},{"id":"a050eb95.d7edd","type":"debug","z":"2d25e76c.f15d2","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":929.5,"y":753,"wires":[]},{"id":"898152e6.a6b92","type":"debug","z":"2d25e76c.f15d2","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","x":853.5,"y":896,"wires":[]},{"id":"2d377948.e3da86","type":"serial request","z":"2d25e76c.f15d2","name":"","serial":"e6c39153.e8eab8","x":611.5,"y":894,"wires":[["898152e6.a6b92"]]},{"id":"a695edb7.a202f","type":"function","z":"2d25e76c.f15d2","name":"Msg to hex Command","func":"var msg1 = { payload:\"0xA5 0x5A 0x04 0x83 0x00 0x06 0x02\" };\nreturn msg1;","outputs":1,"noerr":0,"x":373,"y":900,"wires":[["2d377948.e3da86"]]},{"id":"d4a46384.90c6b8","type":"s7comm","z":"","ip":"192.168.0.20","port":"102","rack":"0","slot":"2","payload":[{"S7_Type":"DB","S7_DBnum":"5","S7_Datatype":"W","S7_Offset":"2","S7_BitOffset":"0","S7_Quantity":"1","S7_Name":"test16"}]},{"id":"11555359.e3265d","type":"ui_group","z":"","name":"S7_312","tab":"b23ac66c.9f67a8","disp":true,"width":"6","collapse":false},{"id":"e6c39153.e8eab8","type":"serial-port","z":"","serialport":"/dev/ttyUSB0","serialbaud":"115200","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"","bin":"false","out":"char","addchar":"","responsetimeout":"10000"},{"id":"b23ac66c.9f67a8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

Best Regards  
Denis

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [24 May 2021 12:58 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/2 "2021-05-24T12:58:20Z")

</div>

change your function "Msg to hex Command" to this...

```auto
var msg1 = { 
    payload: Buffer.from("A55A058200060008", "hex")
}
return msg1;

```

---

<div class="post-metadata">

### Author: ![DerD74](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@DerD74](https://discourse.nodered.org/u/DerD74)
#### Post date: [24 May 2021 13:28 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/3 "2021-05-24T13:28:45Z")

</div>

Thx for verry fast reply. It works perfectly with your command.  
Please could give one more tip, how can I build this hex buffer with my value, what I receive from Siemens PLC?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [24 May 2021 13:33 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/4 "2021-05-24T13:33:47Z")

</div>

> [@DerD74](#):
>
> Please could give one more tip, how can I build this hex buffer with my value, what I receive from Siemens PLC?

what value is that? show me the payload from your PLC & indicate what value you want to send.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [24 May 2021 13:48 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/5 "2021-05-24T13:48:30Z")

</div>

This should get you moving...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6f1b4045f5aa7fefd4f12fd21f7d2a0c94fb8f5e.png)

Set `msg.address` to the screen register number  
Set `msg.payload` to the value you want to write  
Push that through the function & then connect the buffer to your serial node.

```auto
[{"id":"3222ff1a.748ad","type":"function","z":"2d25e76c.f15d2","name":"write to screen register","func":"\nvar address = msg.address;\nvar value = msg.payload;\n\nvar buf = Buffer.from(\"A55A058200000000\", \"hex\")\nbuf.writeUInt16BE(address, 4);\nbuf.writeUInt16BE(value, 6);\n\nvar msg1 = { payload: buf };\nreturn msg1;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":360,"wires":[["ecfb40a9.271a6"]]},{"id":"4f8c847e.831b2c","type":"inject","z":"2d25e76c.f15d2","name":"write 55 to address 6","props":[{"p":"payload"},{"p":"address","v":"6","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"55","payloadType":"num","x":310,"y":360,"wires":[["3222ff1a.748ad"]]},{"id":"d73ebe80.ef91e","type":"inject","z":"2d25e76c.f15d2","name":"write 123 to address 7","props":[{"p":"payload"},{"p":"address","v":"7","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"123","payloadType":"num","x":320,"y":400,"wires":[["3222ff1a.748ad"]]},{"id":"ecfb40a9.271a6","type":"debug","z":"2d25e76c.f15d2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":810,"y":360,"wires":[]}]

```

---

<div class="post-metadata">

### Author: ![DerD74](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@DerD74](https://discourse.nodered.org/u/DerD74)
#### Post date: [24 May 2021 17:57 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/6 "2021-05-24T17:57:07Z")

</div>

it works well, thx  
The next step is to read a variable from Panel, but I'am afraid I think again in the wrong direction.

```auto
[
    {
        "id": "a95c881f.a9d73",
        "type": "function",
        "z": "d7bd4bc.94bf8b8",
        "name": "Msg to hex Command",
        "func": "var msg1 = { payload:Buffer.from(\"A55A0483000602\", \"hex\") };\nreturn msg1;",
        "outputs": 1,
        "noerr": 0,
        "x": 297.5,
        "y": 394,
        "wires": [
            [
                "aabdd783.50cc18"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [24 May 2021 19:44 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/7 "2021-05-24T19:44:21Z")

</div>

Do you send that to a serial request?

Do you get a response (output) from the serial request? (Use a debug node)

---

<div class="post-metadata">

### Author: ![DerD74](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@DerD74](https://discourse.nodered.org/u/DerD74)
#### Post date: [25 May 2021 07:52 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/8 "2021-05-25T07:52:28Z")

</div>

Yes I send this hex code to serial request node, but the response output is undifined.  
like this `�`

After I tried followi

```auto
[
    {
        "id": "546c8c94.722bf4",
        "type": "serial in",
        "z": "d7bd4bc.94bf8b8",
        "name": "",
        "serial": "e6c39153.e8eab8",
        "x": 572.5,
        "y": 502,
        "wires": [
            [
                "7970e4c3.110324"
            ]
        ]
    },
    {
        "id": "e6c39153.e8eab8",
        "type": "serial-port",
        "z": "",
        "serialport": "/dev/ttyUSB0",
        "serialbaud": "115200",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "newline": "",
        "bin": "false",
        "out": "char",
        "addchar": "",
        "responsetimeout": "10000"
    }
]

```

with this output from Debugnode:

 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c3bcec85b8d9933ae4f8ef7943bffc9f176f28bc.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [25 May 2021 09:04 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/9 "2021-05-25T09:04:16Z")

</div>

Firstly, you are going to have to set the return your of the serial node to buffer in order to correctly interpret the response. Well get to how you do that once we have a good reply.

Does the manual describe what the terminating character is for serial data? Often it is CR or LF or EOT - have a read of the manual.

Lastly do you still have a "serial in" node on your editor as well as the serial request nodes? It might be stealing the response intended for the serial request node.

---

<div class="post-metadata">

### Author: ![DerD74](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@DerD74](https://discourse.nodered.org/u/DerD74)
#### Post date: [25 May 2021 16:42 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/10 "2021-05-25T16:42:21Z")

</div>

Hi,  
I was following your instruction an put the Return of Serial Node to hex Buffer. Now I get a response in Debug Node but not what I expect. In manual si nothing written about terminating character, there is only talk of Data length.

```auto
[
    {
        "id": "d7bd4bc.94bf8b8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "5ec0c9f3.a2c4a8",
        "type": "inject",
        "z": "d7bd4bc.94bf8b8",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 104.5,
        "y": 401,
        "wires": [
            [
                "e92864ae.255e4"
            ]
        ]
    },
    {
        "id": "66da4e1d.73435",
        "type": "serial out",
        "z": "d7bd4bc.94bf8b8",
        "name": "",
        "serial": "e6c39153.e8eab8",
        "x": 565.5,
        "y": 402,
        "wires": []
    },
    {
        "id": "e92864ae.255e4",
        "type": "function",
        "z": "d7bd4bc.94bf8b8",
        "name": "Msg to hex Command",
        "func": "var msg1 = { payload:Buffer.from(\"A55A0483000602\", \"hex\") };\nreturn msg1;",
        "outputs": 1,
        "noerr": 0,
        "x": 301,
        "y": 401,
        "wires": [
            [
                "66da4e1d.73435"
            ]
        ]
    },
    {
        "id": "546c8c94.722bf4",
        "type": "serial in",
        "z": "d7bd4bc.94bf8b8",
        "name": "",
        "serial": "e6c39153.e8eab8",
        "x": 572.5,
        "y": 502,
        "wires": [
            [
                "b09d5645.940ed8",
                "9eb7c46a.cf512"
            ]
        ]
    },
    {
        "id": "7970e4c3.110324",
        "type": "debug",
        "z": "d7bd4bc.94bf8b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 1184.5,
        "y": 511,
        "wires": []
    },
    {
        "id": "b09d5645.940ed8",
        "type": "function",
        "z": "d7bd4bc.94bf8b8",
        "name": "Msg from Panel separated",
        "func": "var buf = Buffer.alloc(20,0x01, \"hex\");\n\nbuf.write(msg.payload);\nvar msg2 = {payload: buf};\n\nreturn msg2;",
        "outputs": 1,
        "noerr": 0,
        "x": 878,
        "y": 506,
        "wires": [
            [
                "7970e4c3.110324"
            ]
        ]
    },
    {
        "id": "9eb7c46a.cf512",
        "type": "debug",
        "z": "d7bd4bc.94bf8b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 837.5,
        "y": 595,
        "wires": []
    },
    {
        "id": "e6c39153.e8eab8",
        "type": "serial-port",
        "z": "d7bd4bc.94bf8b8",
        "serialport": "/dev/ttyUSB0",
        "serialbaud": "115200",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "0xA5",
        "newline": "0x00",
        "bin": "false",
        "out": "char",
        "addchar": "",
        "responsetimeout": "10000"
    }
]

```

I expect A55A08000602... but get following  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/e/ce49e36ab441188d813b20865ba8a357c9a1e43b.png)

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [25 May 2021 17:02 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/11 "2021-05-25T17:02:20Z")

</div>

so 239 191 189 90 8 is 0xEF 0xBF 0xBD 0x5A

It might be an error response. Look in the manual for these values.

Also, why are you using serial in and serial out instead of the single serial request node?

---

<div class="post-metadata">

### Author: ![DerD74](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@DerD74](https://discourse.nodered.org/u/DerD74)
#### Post date: [28 May 2021 15:28 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/12 "2021-05-28T15:28:13Z")

</div>

Hello Steve,

I have noe test the connection to Panel with the Tool "sscom32E.exe" from Distributer and with the same command "A55A0483000602" I get the right Return.  
Now I'am verry confused about this, because if I send a Value with the same created Hex Buffer it is diyplayed on screen and can be changed from node red as well.  
Do you have any Idia what I can do. I'am clueless right now. 🤪

Thx  
Denis

---

<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: [27 July 2021 15:28 UTC](https://discourse.nodered.org/t/conversation-with-stone-panel-via-serial-port/46156/13 "2021-07-27T15:28:43Z")

</div>

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