Conversation with STONE Panel via Serial Port

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.

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?

[{"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

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

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

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?

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

This should get you moving...

image

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.

[{"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":[]}]

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.

[
    {
        "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"
            ]
        ]
    }
]

Do you send that to a serial request?

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

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

After I tried followi

[
    {
        "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:

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.

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.

[
    {
        "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

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?

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. :crazy_face:

Thx
Denis

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