# I want to get the serialport data using edge workflow,do you have any sample workflow for getting serial port data?

**URL:** <https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865>\
**Category:** Help\
**Tags:** edge\
**Created:** [June 9, 2019, 5:10pm UTC](https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865 "2019-06-09T17:10:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivasankari\_s](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@sivasankari\_s](https://forums.losant.com/u/sivasankari_s)\
**Post date:** [June 9, 2019, 5:10pm UTC](https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865/1 "2019-06-09T17:10:35Z")

</div>

Hi,

The below one is my serialport information.

1.I have installed losant edge agent in my laptop.

 ![Screenshot%20from%202019-06-09%2021-54-27](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/a/a04781f499d5ee2d7b05b9a765f0eda53d299c56.png)  
2.My gateway information

 ![gateway](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/7/7227a57a3da40b61a63230ffc8a8f62d211fde93.png)  
3.My losant edge agent log.

```json
{
  "topic": "losant/5cfb4dfbafabc800087c61d1/toAgent/flows",
  "payload": {
    "time": 1560075667344,
    "mode": "complete",
    "flows": {
      "5cfbef7c50371c00095ba876": {
        "name": "energymtr work flow",
        "globals": {},
        "triggers": [
          {
            "type": "serial",
            "meta": {
              "x": 40,
              "y": 60,
              "id": "cwbYEnvljv",
              "category": "trigger",
              "name": "serial",
              "label": "Serial",
              "uiId": "cwbYEnvljv",
              "description": "",
              "parseBy": "byteLength"
            },
            "config": {
              "path": "/dev/ttyUSB0",
              "baudRate": 9600,
              "encoding": "hex",
              "writeOnOpen": "hi em",
              "byteLength": "8"
            },
            "key": "5cfbef7c50371c00095ba876-lohrEzH3aYJ4QlsWrieVE",
            "outputIds": [["hJdOs_FpLR"]]
          }
        ],
        "nodes": [
          {
            "type": "DebugNode",
            "config": {"message": "", "property": ""},
            "id": "hJdOs_FpLR",
            "outputIds": []
          }
        ],
        "version": "2019-06-08T18-01-58",
        "versionId": "5cfbf81b66b3b30008490a67",
        "minimumAgentVersion": "1.8.0"
      }
    },
    "application": {"name": "smartphone", "id": "5ca5f7f18b62290008d0e84d", "globals": {}},
    "device": {"name": "comportgateway", "id": "5cfb4dfbafabc800087c61d1", "tags": {}}
  }
}

```

4.after my edge workflow deployment,I got the following error.

2019-06-09T10:23:51.326Z [#[33mwarn#[39m] Serial path will retry to open in 30 seconds.  
2019-06-09T10:24:21.340Z [#[33mwarn#[39m] Serial path /dev/ttyUSB0 is attempting to reopen…  
2019-06-09T10:24:21.340Z [#[33mwarn#[39m] Error in serial manager while listening at /dev/ttyUSB0: Error:Error: No such file or directory,

5.I want to get the serialport data using edge workflow,do you have any sample workflow for  
getting serial port data?

---

<div class="post-metadata">

**Author:** ![Tim\_Hoffman](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@Tim\_Hoffman](https://forums.losant.com/u/Tim_Hoffman)\
**Post date:** [June 9, 2019, 11:48pm UTC](https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865/2 "2019-06-09T23:48:58Z")

</div>

Hi

Have you mapped the serial port with the device option so the container has access to the serial port ?  
this is used as an argument with the `docker run` command

```auto
--device=/dev/ttyUSB0

```

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [June 10, 2019, 3:29pm UTC](https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865/3 "2019-06-10T15:29:22Z")

</div>

Hi @sivasankari_s,

A similar question can be found [here](https://forums.losant.com/t/python-libraries-minimalmodbus-on-edge-device-in-run-executable-node/1599/2) with the same error, I recommend checking it out. I will look further into this as well to see if anything obvious is amiss.

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [June 10, 2019, 4:30pm UTC](https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865/4 "2019-06-10T16:30:26Z")

</div>

Getting serial devices across the Docker boundary can be a challenge. If you’re using a Debian-based Linux distribution, here are the steps we’ve taken to successfully and reliably gain access to serial devices from inside Docker.

## 1. Set udev rule

By default, serial devices are mounted so that only root users can access the device. We need to add a udev rule to make them readable by non-root users. For security reasons, Losant’s Edge Agent does not run under a root user.

Create a file named `/etc/udev/rules.d/99-serial.rules`. Add the following line to that file:

```auto
KERNEL=="ttyUSB[0-9]*",MODE="0666"

```

`MODE="0666"` will give all users read/write (but not execute) permissions to your ttyUSB devices. This is the most permissive option, and you may want to restrict this further depending on your security requirements. You can read up on [udev](https://en.wikipedia.org/wiki/Udev) to learn more about controlling what happens when a device is plugged into a Linux gateway.

## 2. Mount in /dev folder from host to container

Serial devices are often ephemeral (can be plugged and unplugged at any time). Because of this, we can’t mount in the direct device or even the `/dev/serial` folder, because those can disappear when things are unplugged. Even if you plug them back in and the device shows up again, it’s technically a different file than what was mounted in, so Docker won’t see it. For this reason, we mount the entire `/dev` folder from the host to the container. You can do this by adding the following [volume](https://docs.docker.com/storage/volumes/) command to your Docker run command:

```nohighlight
-v /dev:/dev

```

If your device is permanently attached, then using the `--device` option or a more specific volume mount is likely a better option from a security perspective. Since we are the authors of the Edge Agent, we obviously trust the code running in there and aren’t worried about exposing additional devices.

## 3. Run container in privileged mode

If you did not use the `--device` option and mounted in the entire `/dev` folder, you will be required to run the container is privileged mode. You can do this by adding the following to your Docker run command:

```nohighlight
--privileged

```

## 4. Access device from the `/dev/serial/by-id` folder

If your device can be plugged and unplugged, Linux does not guarantee it will always be mounted at the same ttyUSBxxx location (especially if you have multiple devices). Fortunately, Linux will make a symlink automatically to the device in the `/dev/serial/by-id` folder. The file in this folder will always be named the same.

---

<div class="post-metadata">

**Author:** ![sivasankari\_s](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@sivasankari\_s](https://forums.losant.com/u/sivasankari_s)\
**Post date:** [June 12, 2019, 12:34pm UTC](https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865/5 "2019-06-12T12:34:21Z")

</div>

Thank you very much Brandon\_Cannaday.  
Your reply was super helpful .once i set up the permission for my serial port,my serial  
write node working fine.

Now I want to read my serial port data using edge work flow.do we have any  
specific node for read serial port data?

Thanks  
Sivasankari S

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [June 12, 2019, 3:47pm UTC](https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865/6 "2019-06-12T15:47:58Z")

</div>

@sivasankari_s,

We don’t have a “Serial Read” Node. Instead, that’s the purpose of the [Serial Trigger](https://docs.losant.com/workflows/triggers/serial/). With it, you are listening on that Serial port and triggering a workflow whenever your device(s) write Serial.

---

<div class="post-metadata">

**Author:** ![sivasankari\_s](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@sivasankari\_s](https://forums.losant.com/u/sivasankari_s)\
**Post date:** [June 13, 2019, 6:46am UTC](https://forums.losant.com/t/i-want-to-get-the-serialport-data-using-edge-workflow-do-you-have-any-sample-workflow-for-getting-serial-port-data/1865/7 "2019-06-13T06:46:42Z")

</div>

Thank you anaptfox.  
I am trying serial trigger at the same time if you have any samples  
for serial write and serial trigger kindly share me.

Thanks  
Sivasankari S
