Skip to content

Commit c39a81c

Browse files
committed
Pipeline: input: serial: style
Signed-off-by: Lynette Miles <[email protected]>
1 parent 8c843cf commit c39a81c

File tree

1 file changed

+71
-53
lines changed

1 file changed

+71
-53
lines changed

pipeline/inputs/serial-interface.md

Lines changed: 71 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
1-
# Serial Interface
1+
# Serial interface
22

3-
The **serial** input plugin, allows to retrieve messages/data from a _Serial_ interface.
3+
The _Serial_ input plugin lets you retrieve messages and data from a serial interface.
44

5-
## Configuration Parameters
5+
## Configuration parameters
66

7-
| Key | Description |
8-
| :--- | :--- |
9-
| File | Absolute path to the device entry, e.g: /dev/ttyS0 |
10-
| Bitrate | The bitrate for the communication, e.g: 9600, 38400, 115200, etc |
11-
| Min\_Bytes | The serial interface will expect at least _Min\_Bytes_ to be available before to process the message \(default: 1\) |
12-
| Separator | Allows to specify a _separator_ string that's used to determinate when a message ends. |
13-
| Format | Specify the format of the incoming data stream. The only option available is 'json'. Note that _Format_ and _Separator_ cannot be used at the same time. |
14-
| Threaded | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). Default: `false`. |
7+
This plugin has the following configuration parameters:
158

16-
## Getting Started
9+
| Key | Description | Default |
10+
| :--- | :--- | ---------|
11+
| `File` | Absolute path to the device entry. For example, `/dev/ttyS0`. | _none_ |
12+
| `Bitrate` | The bit rate for the communication. For example: `9600`, `38400`, `115200`. | _none_ |
13+
| `Min_Bytes` | The serial interface expects at least `Min_Bytes` to be available before processing the message. | `1` |
14+
| `Separator` | Specify a separator string that's used to determinate when a message ends. | _none_ |
15+
| `Format` | Specify the format of the incoming data stream. `Format` and `Separator` can't be used at the same time. | `json` (no other options available) |
16+
| `Threaded` | Indicates whether to run this input in its own [thread](../../administration/multithreading.md#inputs). | `false` |
1717

18-
In order to retrieve messages over the _Serial_ interface, you can run the plugin from the command line or through the configuration file:
18+
## Get started
1919

20-
### Command Line
20+
To retrieve messages over the Serial interface, you can run the plugin from the command line or through the configuration file:
2121

22-
The following example loads the input _serial_ plugin where it set a Bitrate of 9600, listen from the _/dev/tnt0_ interface and use the custom tag _data_ to route the message.
22+
### Command line
2323

24-
```text
25-
$ fluent-bit -i serial -t data -p File=/dev/tnt0 -p BitRate=9600 -o stdout -m '*'
24+
The following example loads the input serial plugin where it set a `Bitrate` of `9600`, listens from the `/dev/tnt0` interface and uses the custom tag `data` to route the message.
25+
26+
```shell
27+
fluent-bit -i serial -t data -p File=/dev/tnt0 -p BitRate=9600 -o stdout -m '*'
2628
```
2729

28-
The above interface \(/dev/tnt0\) is an emulation of the serial interface \(more details at bottom\), for demonstrative purposes we will write some message to the other end of the interface, in this case _/dev/tnt1_, e.g:
30+
The interface (`/dev/tnt0`) is an emulation of the serial interface. Further examples will write some message to the other end of the interface. For example, `/dev/tnt1`.
2931

30-
```text
31-
$ echo 'this is some message' > /dev/tnt1
32+
```shell
33+
echo 'this is some message' > /dev/tnt1
3234
```
3335

34-
In Fluent Bit you should see an output like this:
36+
In Fluent Bit you can run the command:
3537

3638
```bash
37-
$ fluent-bit -i serial -t data -p File=/dev/tnt0 -p BitRate=9600 -o stdout -m '*'
39+
fluent-bit -i serial -t data -p File=/dev/tnt0 -p BitRate=9600 -o stdout -m '*'
40+
```
41+
42+
Which should produce output like:
43+
44+
```text
3845
Fluent Bit v1.x.x
3946
* Copyright (C) 2019-2020 The Fluent Bit Authors
4047
* Copyright (C) 2015-2018 Treasure Data
@@ -45,14 +52,23 @@ Fluent Bit v1.x.x
4552
[0] data: [1463780680, {"msg"=>"this is some message"}]
4653
```
4754

48-
Now using the _Separator_ configuration, we could send multiple messages at once \(run this command after starting Fluent Bit\):
55+
Using the `Separator` configuration, you can send multiple messages at once.
4956

50-
```text
51-
$ echo 'aaXbbXccXddXee' > /dev/tnt1
57+
Run this command after starting Fluent Bit:
58+
59+
```shell
60+
echo 'aaXbbXccXddXee' > /dev/tnt1
61+
```
62+
63+
Then, run Fluent Bit:
64+
65+
```shell
66+
fluent-bit -i serial -t data -p File=/dev/tnt0 -p BitRate=9600 -p Separator=X -o stdout -m '*'
5267
```
5368

69+
This should produce results similar to the following:
70+
5471
```text
55-
$ fluent-bit -i serial -t data -p File=/dev/tnt0 -p BitRate=9600 -p Separator=X -o stdout -m '*'
5672
Fluent-Bit v0.8.0
5773
Copyright (C) Treasure Data
5874
@@ -63,9 +79,9 @@ Copyright (C) Treasure Data
6379
[3] data: [1463781902, {"msg"=>"dd"}]
6480
```
6581

66-
### Configuration File
82+
### Configuration file
6783

68-
In your main configuration file append the following _Input_ & _Output_ sections:
84+
In your main configuration file append the following sections:
6985

7086
```python
7187
[INPUT]
@@ -80,43 +96,45 @@ In your main configuration file append the following _Input_ & _Output_ sections
8096
Match *
8197
```
8298

83-
## Emulating Serial Interface on Linux
99+
## Emulating a serial interface on Linux
84100

85-
The following content is some extra information that will allow you to emulate a serial interface on your Linux system, so you can test this _Serial_ input plugin locally in case you don't have such interface in your computer. The following procedure has been tested on Ubuntu 15.04 running a Linux Kernel 4.0.
101+
You can emulate a serial interface on your Linux system and test the serial input plugin locally when you don't have an interface in your computer. The following procedure has been tested on Ubuntu 15.04 running a Linux Kernel 4.0.
86102

87-
## Build and install the tty0tty module
103+
### Build and install the `tty0tty` module
88104

89-
Download the sources
105+
1. Download the sources
90106

91-
```bash
92-
$ git clone https://github.com/freemed/tty0tty
93-
```
107+
```bash
108+
git clone https://github.com/freemed/tty0tty
109+
```
94110

95-
Unpack and compile
111+
1. Unpack and compile
96112

97-
```bash
98-
$ cd tty0tty/module
99-
$ make
100-
```
113+
```bash
114+
cd tty0tty/module
115+
make
116+
```
101117

102-
Copy the new kernel module into the kernel modules directory
118+
1. Copy the new kernel module into the kernel modules directory
103119

104-
```bash
105-
$ sudo cp tty0tty.ko /lib/modules/$(uname -r)/kernel/drivers/misc/
106-
```
120+
```bash
121+
sudo cp tty0tty.ko /lib/modules/$(uname -r)/kernel/drivers/misc/
122+
```
107123

108-
Load the module
124+
1. Load the module
109125

110-
```bash
111-
$ sudo depmod
112-
$ sudo modprobe tty0tty
113-
```
126+
```bash
127+
sudo depmod
128+
sudo modprobe tty0tty
129+
```
114130

115-
You should see new serial ports in /dev/ \(ls /dev/tnt\*\) Give appropriate permissions to the new serial ports:
131+
You should see new serial ports in `dev` (`ls /dev/tnt\*\`).
116132

117-
```bash
118-
$ sudo chmod 666 /dev/tnt*
119-
```
133+
1. Give appropriate permissions to the new serial ports:
134+
135+
```bash
136+
sudo chmod 666 /dev/tnt*
137+
```
120138

121139
When the module is loaded, it will interconnect the following virtual interfaces:
122140

0 commit comments

Comments
 (0)