# PLC -\> Buffer -\> TCP Connection w/ Laptop -\>Buffer Parser -\> CSV

**URL:** <https://discourse.nodered.org/t/plc-buffer-tcp-connection-w-laptop-buffer-parser-csv/70585>\
**Category:** General\
**Created:** [14 November 2022 13:55 UTC](https://discourse.nodered.org/t/plc-buffer-tcp-connection-w-laptop-buffer-parser-csv/70585 "2022-11-14T13:55:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DashAway](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@DashAway](https://discourse.nodered.org/u/DashAway)\
**Post date:** [14 November 2022 13:55 UTC](https://discourse.nodered.org/t/plc-buffer-tcp-connection-w-laptop-buffer-parser-csv/70585/1 "2022-11-14T13:55:24Z")

</div>

We are working on creating a csv file from flow sensor data for a project. The flow sensor data will be coming from a s7 PLC (we have the node for that set up). I then plan to turn that data into a buffer and use a TCP connection (also working) to send the buffer to my laptop where I will parse the buffer into either an array or a series of floats/doubles. Those values will then be made into a csv file on my laptop that can be used for other processes we will be completing.

The problem here is that I am not the most comfortable with creating and parsing the buffer. Are there any straightforward resources that any of you used for working with buffers? I'm extremely new to Node-Red.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 November 2022 14:11 UTC](https://discourse.nodered.org/t/plc-buffer-tcp-connection-w-laptop-buffer-parser-csv/70585/2 "2022-11-14T14:11:45Z")

</div>

I would look at the excellent node-red-contrib-buffer-parser node... that probably does exactly what you want. It has lots of examples under the menu - import - examples list.

---

<div class="post-metadata">

**Author:** ![DashAway](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@DashAway](https://discourse.nodered.org/u/DashAway)\
**Post date:** [14 November 2022 14:23 UTC](https://discourse.nodered.org/t/plc-buffer-tcp-connection-w-laptop-buffer-parser-csv/70585/3 "2022-11-14T14:23:26Z")

</div>

I found the example, and I see a few that mimic PLC data. I believe this will be very helpful, so thank you.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 November 2022 14:25 UTC](https://discourse.nodered.org/t/plc-buffer-tcp-connection-w-laptop-buffer-parser-csv/70585/4 "2022-11-14T14:25:24Z")

</div>

As long as you have the manual for your device that descibes how the data is packed then we should be able to help you unpack it into something useful.

---

<div class="post-metadata">

**Author:** ![DashAway](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@DashAway](https://discourse.nodered.org/u/DashAway)\
**Post date:** [14 November 2022 16:08 UTC](https://discourse.nodered.org/t/plc-buffer-tcp-connection-w-laptop-buffer-parser-csv/70585/5 "2022-11-14T16:08:22Z")

</div>

So it has come to my attention that instead on a TCP connection, I could use a MQTT node. This should remove my need for buffers. I don't have the PLC node set-up yet (I'm currently playing with this from my computer away from our IoT module). However, the PLC data will be sent to a function where I will take on a topic to the msg. Then, I should be able to send the msg to a MQTT node to be sent to my computer (where I am running mosquitto). Is my understanding of how this works correct? My code is below:

```auto
[
    {
        "id": "3cd910722e16ce1f",
        "type": "mqtt out",
        "z": "797817a747fe6a25",
        "name": "",
        "topic": "PLCData",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "407a01e4.6b637",
        "x": 580,
        "y": 460,
        "wires": []
    },
    {
        "id": "afae811ab5ae6cdd",
        "type": "s7 in",
        "z": "797817a747fe6a25",
        "endpoint": "",
        "mode": "single",
        "variable": "",
        "diff": true,
        "name": "",
        "x": 230,
        "y": 420,
        "wires": [
            [
                "3528fb91eb956713"
            ]
        ]
    },
    {
        "id": "3528fb91eb956713",
        "type": "function",
        "z": "797817a747fe6a25",
        "name": "Add Topic",
        "func": "msg.payload;\nmsg.topic = \"PLCData\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 420,
        "wires": [
            [
                "3cd910722e16ce1f"
            ]
        ]
    },
    {
        "id": "407a01e4.6b637",
        "type": "mqtt-broker",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]

```

---

<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:** [13 January 2023 16:08 UTC](https://discourse.nodered.org/t/plc-buffer-tcp-connection-w-laptop-buffer-parser-csv/70585/6 "2023-01-13T16:08:44Z")

</div>

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