node-zserial 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,86 +1,81 @@
1
- node-red-node-serialport
1
+ node-zserialport
2
2
  ========================
3
3
 
4
- <a href="http://nodered.org" target="noderedinfo">Node-RED</a> nodes to talk to
5
- hardware serial ports.
4
+ <a href="http://nodered.org" target="noderedinfo">Node-RED</a> 节点,用于与硬件串口通信。
5
+ ![node-red-zserialport](images/demo.png)
6
6
 
7
- ## Install
7
+ ## 安装
8
8
 
9
- To install the stable version use the `Menu - Manage palette - Install` option and search for node-red-node-serialport, or run the following command in your Node-RED user directory, typically `~/.node-red`
9
+ 要安装稳定版本,可以使用 `菜单 - 管理调色板 - 安装` 选项并搜索 node-zserialport,或者在你的 Node-RED 用户目录(通常为 `~/.node-red`)下运行以下命令:
10
10
 
11
- npm i node-red-node-serialport
11
+ npm i node-zserialport
12
12
 
13
- During install there may be multiple messages about optional compilation.
14
- These may look like failures... as they report as failure to compile errors -
15
- but often are warnings and the node will continue to install and, assuming nothing else
16
- failed, you should be able to use it. Occasionally some platforms *will* require
17
- you to install the full set of tools in order to compile the underlying package.
13
+ 安装过程中可能会出现多条关于可选编译的消息。
14
+ 这些消息看起来像是失败……因为它们报告为编译错误失败——但通常只是警告,节点会继续安装,如果没有其他错误,你应该可以正常使用。有些平台*确实*需要你安装完整的工具集来编译底层包。
18
15
 
19
- ## Usage
16
+ ## 用法
20
17
 
21
- Provides four nodes - one to receive messages, and one to send, a request node which can send then wait for a response, and a control node that allows dynamic control of the ports in use.
18
+ 提供四个节点——一个用于接收消息,一个用于发送,一个请求节点可以发送并等待响应,还有一个关闭所使用的端口。
22
19
 
23
- ### Input
20
+ ### 输入
24
21
 
25
- Reads data from a local serial port.
22
+ 从本地串口读取数据。
26
23
 
27
- Clicking on the search icon will attempt to autodetect serial ports attached to
28
- the device, however you many need to manually specify it. COM1, /dev/ttyUSB0, etc
24
+ 点击搜索图标会尝试自动检测连接到设备的串口,但你可能需要手动指定,比如 COM1、/dev/ttyUSB0 等。
29
25
 
30
- It can either
26
+ 它可以:
31
27
 
32
- - wait for a "split" character (default \n). Also accepts hex notation (0x0a).
33
- - wait for a timeout in milliseconds from the first character received
34
- - wait to fill a fixed sized buffer
28
+ - 等待一个“分隔”字符(默认 \n),也接受十六进制表示(0x0a)。
29
+ - 等待从接收到第一个字符起的超时时间(毫秒)
30
+ - 等待填满一个固定大小的缓冲区
35
31
 
36
- It then outputs `msg.payload` as either a UTF8 ascii string or a binary Buffer object.
32
+ 然后会将 `msg.payload` 输出为 UTF8 ascii 字符串或二进制 Buffer 对象。
37
33
 
38
- If no split character is specified, or a timeout or buffer size of 0, then a stream
39
- of single characters is sent - again either as ascii chars or size 1 binary buffers.
34
+ 如果没有指定分隔字符,或超时时间或缓冲区大小为 0,则会以流的形式发送单个字符——同样可以是 ascii 字符或长度为 1 的二进制 buffer
40
35
 
41
- ### Output
36
+ ### 输出
42
37
 
43
- Provides a connection to an outbound serial port.
38
+ 提供一个到外部串口的连接。
44
39
 
45
- Only the `msg.payload` is sent.
40
+ 只会发送 `msg.payload`。
46
41
 
47
- Optionally the character used to split the input can be appended to every message sent out to the serial port.
42
+ 可选地,可以将用于分割输入的字符附加到每条发送到串口的消息后面。
48
43
 
49
- ### Request
44
+ ### 请求
50
45
 
51
- Provides a connection to a request/response serial port.
46
+ 提供一个请求/响应串口的连接。
52
47
 
53
- This node behaves as a tightly coupled combination of serial in and serial out nodes, with which it shares the configuration.
48
+ 该节点行为类似于串口输入和输出节点的紧密结合,并共享配置。
54
49
 
55
- Send the request message in `msg.payload` as you would do with a serial out node. The message will be forwarded to the serial port following a strict FIFO (First In, First Out) queue, waiting for a single response before transmitting the next request. Once a response is received (with the same logic of a serial in node), or after a timeout occurs, a message is produced on the output, with msg.payload containing the received response (or missing in case if timeout), msg.status containing relevant info, and all other fields preserved.
50
+ 像使用串口输出节点一样,将请求消息放在 `msg.payload` 中发送。消息会按照严格的 FIFO(先进先出)队列转发到串口,等待单个响应后才会发送下一个请求。一旦收到响应(逻辑同串口输入节点),或超时发生,就会在输出端产生一条消息,msg.payload 包含收到的响应(或超时时为空),msg.status 包含相关信息,其他字段保持不变。
56
51
 
57
- For consistency with the serial in node, msg.port is also set to the name of the port selected.
52
+ 为了与串口输入节点保持一致,msg.port 也会被设置为所选端口的名称。
58
53
 
59
- ### Control
54
+ ### 控制
60
55
 
61
- When the node-red starts, the flow(program) picks up the pre-programmed serial port, open it, and starts the communication. But there are some cases the port needs to switch to a different port, stop, and start again. For example, in order to upload a new binary for Arduino, the serial port needs to be stopped relased from the nodered, and start it again after uploading. Or when the FTDI device re-connects after disconnecting for any reason, it may be possible that the port number changes, and the end user of the flow can't change the port.
56
+ node-red 启动时,流程(程序)会选取预设的串口,打开并开始通信。但有些情况下需要切换到不同的端口、停止并重新启动。例如,为 Arduino 上传新固件时,需要先停止串口、释放串口,然后上传后再重新启动。或者当 FTDI 设备因某种原因断开后重新连接,端口号可能会变化,流程的最终用户无法更改端口。
62
57
 
63
- This node provides the ability to:
58
+ 该节点提供以下能力:
64
59
 
65
- 1. change the serial port and its configuration on the run time programatically.
66
- 2. stop the communication and release the serial port.
67
- 3. reopen the port and restart the communications.
60
+ 1. 在运行时以编程方式更改串口及其配置。
61
+ 2. 停止通信并释放串口。
62
+ 3. 重新打开端口并重启通信。
68
63
 
69
- In order to control the communication, send a **msg.payload** to the control node.
64
+ 要控制通信,向控制节点发送 **msg.payload**。
70
65
 
71
66
  {
72
- "serialport": "/dev/ttyUSB0",
73
- "serialbaud": 115200,
74
- "databits": 8,
75
- "parity": "none",
76
- "stopbits": 1,
77
- "enabled": true
67
+ "serialport": "/dev/ttyUSB0",
68
+ "serialbaud": 115200,
69
+ "databits": 8,
70
+ "parity": "none",
71
+ "stopbits": 1,
72
+ "enabled": true
78
73
  }
79
74
 
80
- changes the serial port and the configuration on the fly.
75
+ 可以动态更改串口及其配置。
81
76
 
82
- The following optional parameters will change the configuration only if they are present.
83
- Any combination of them can be passed to change/control the serial communication
77
+ 以下可选参数仅在存在时更改配置。
78
+ 可以任意组合传递它们来更改/控制串口通信:
84
79
 
85
80
  - serialport
86
81
  - serialbaud
@@ -93,10 +88,11 @@ Any combination of them can be passed to change/control the serial communication
93
88
  - dsr
94
89
  - enabled
95
90
 
96
- If the `enabled` property is not present, it will default to `true`.
91
+ 如果未提供 `enabled` 属性,则默认为 `true`。
97
92
 
98
- `{"enabled":true}` or `{"enabled":false}` will start or stop the communication.
93
+ `{"enabled":true}` `{"enabled":false}` 将启动或停止通信。
99
94
 
100
- If `enabled` is passed along with other parameters, the configuration will be changed and the port will be either started or remain stopped, ready to be started later depending on its value.
95
+ 如果 `enabled` 与其他参数一起传递,则会更改配置,并根据其值启动或保持停止,准备稍后启动。
96
+
97
+ 任何输入消息都会导致节点输出当前端口配置。
101
98
 
102
- Any input message will cause the node to output the current port configuration.
@@ -0,0 +1,289 @@
1
+ [
2
+ {
3
+ "id": "ac7bf7ec36d6a989",
4
+ "type": "function",
5
+ "z": "6c5cb5c635f82b56",
6
+ "name": "发送内容",
7
+ "func": "msg.serialConfig=msg.serialPorts;\nmsg.payload=msg.serialConfig.serialport+\"\\n\";\nreturn msg;",
8
+ "outputs": 1,
9
+ "timeout": 0,
10
+ "noerr": 0,
11
+ "initialize": "",
12
+ "finalize": "",
13
+ "libs": [],
14
+ "x": 680,
15
+ "y": 160,
16
+ "wires": [
17
+ [
18
+ "1bbc5a3a00e0c543",
19
+ "cc85519d5a973bd6"
20
+ ]
21
+ ]
22
+ },
23
+ {
24
+ "id": "1b8e7a8fee300657",
25
+ "type": "inject",
26
+ "z": "6c5cb5c635f82b56",
27
+ "name": "",
28
+ "props": [],
29
+ "repeat": "",
30
+ "crontab": "",
31
+ "once": false,
32
+ "onceDelay": 0.1,
33
+ "topic": "",
34
+ "x": 310,
35
+ "y": 100,
36
+ "wires": [
37
+ [
38
+ "fcaaa0d1d662e5c5"
39
+ ]
40
+ ]
41
+ },
42
+ {
43
+ "id": "c5b2a60e99954c23",
44
+ "type": "debug",
45
+ "z": "6c5cb5c635f82b56",
46
+ "name": "=========调试 6",
47
+ "active": true,
48
+ "tosidebar": true,
49
+ "console": false,
50
+ "tostatus": false,
51
+ "complete": "true",
52
+ "targetType": "full",
53
+ "statusVal": "",
54
+ "statusType": "auto",
55
+ "x": 1050,
56
+ "y": 200,
57
+ "wires": []
58
+ },
59
+ {
60
+ "id": "2e52a7d5dcba1731",
61
+ "type": "split",
62
+ "z": "6c5cb5c635f82b56",
63
+ "name": "",
64
+ "splt": "\\n",
65
+ "spltType": "str",
66
+ "arraySplt": 1,
67
+ "arraySpltType": "len",
68
+ "stream": false,
69
+ "addname": "",
70
+ "property": "serialPorts",
71
+ "x": 670,
72
+ "y": 100,
73
+ "wires": [
74
+ [
75
+ "ac7bf7ec36d6a989"
76
+ ]
77
+ ]
78
+ },
79
+ {
80
+ "id": "fcaaa0d1d662e5c5",
81
+ "type": "function",
82
+ "z": "6c5cb5c635f82b56",
83
+ "name": "窗口配置数组",
84
+ "func": "let serialPorts = [\n {\n serialport: '/dev/ttys018',\n baud: 9600,\n databits: 8,\n parity: 'NONE',\n stopbits: 1\n },\n {\n serialport:'/dev/ttys021',\n baud:9600,\n databits:8,\n parity:'NONE',\n stopbits:1\n }\n];\nmsg.serialPorts=serialPorts;\nreturn msg;",
85
+ "outputs": 1,
86
+ "timeout": 0,
87
+ "noerr": 0,
88
+ "initialize": "",
89
+ "finalize": "",
90
+ "libs": [],
91
+ "x": 500,
92
+ "y": 100,
93
+ "wires": [
94
+ [
95
+ "2e52a7d5dcba1731"
96
+ ]
97
+ ]
98
+ },
99
+ {
100
+ "id": "fd3f7169e7cc20e8",
101
+ "type": "inject",
102
+ "z": "6c5cb5c635f82b56",
103
+ "name": "",
104
+ "props": [],
105
+ "repeat": "",
106
+ "crontab": "",
107
+ "once": false,
108
+ "onceDelay": 0.1,
109
+ "topic": "",
110
+ "x": 310,
111
+ "y": 160,
112
+ "wires": [
113
+ [
114
+ "9b1c32cc48ea5751"
115
+ ]
116
+ ]
117
+ },
118
+ {
119
+ "id": "9b1c32cc48ea5751",
120
+ "type": "function",
121
+ "z": "6c5cb5c635f82b56",
122
+ "name": "单独配置",
123
+ "func": "\nmsg.serialPorts = {\n serialport: '/dev/ttys021',\n baud: 9600,\n databits: 8,\n parity: 'NONE',\n stopbits: 1\n};\nmsg.queueSend = false;\nreturn msg;",
124
+ "outputs": 1,
125
+ "timeout": 0,
126
+ "noerr": 0,
127
+ "initialize": "",
128
+ "finalize": "",
129
+ "libs": [],
130
+ "x": 480,
131
+ "y": 160,
132
+ "wires": [
133
+ [
134
+ "ac7bf7ec36d6a989"
135
+ ]
136
+ ]
137
+ },
138
+ {
139
+ "id": "b55e31e41cb990b1",
140
+ "type": "zserial in",
141
+ "z": "6c5cb5c635f82b56",
142
+ "name": "统一接收通道",
143
+ "x": 500,
144
+ "y": 240,
145
+ "wires": [
146
+ [
147
+ "a4725e6909264fb5"
148
+ ]
149
+ ]
150
+ },
151
+ {
152
+ "id": "a4725e6909264fb5",
153
+ "type": "debug",
154
+ "z": "6c5cb5c635f82b56",
155
+ "name": "调试 1",
156
+ "active": true,
157
+ "tosidebar": true,
158
+ "console": false,
159
+ "tostatus": false,
160
+ "complete": "true",
161
+ "targetType": "full",
162
+ "statusVal": "",
163
+ "statusType": "auto",
164
+ "x": 670,
165
+ "y": 240,
166
+ "wires": []
167
+ },
168
+ {
169
+ "id": "a6efadadceca633c",
170
+ "type": "inject",
171
+ "z": "6c5cb5c635f82b56",
172
+ "name": "",
173
+ "props": [],
174
+ "repeat": "",
175
+ "crontab": "",
176
+ "once": false,
177
+ "onceDelay": "1",
178
+ "topic": "",
179
+ "x": 310,
180
+ "y": 240,
181
+ "wires": [
182
+ [
183
+ "b55e31e41cb990b1"
184
+ ]
185
+ ]
186
+ },
187
+ {
188
+ "id": "1bbc5a3a00e0c543",
189
+ "type": "zserial out",
190
+ "z": "6c5cb5c635f82b56",
191
+ "name": "统一发送通道",
192
+ "x": 860,
193
+ "y": 140,
194
+ "wires": []
195
+ },
196
+ {
197
+ "id": "cc85519d5a973bd6",
198
+ "type": "zserial request",
199
+ "z": "6c5cb5c635f82b56",
200
+ "name": "发收通道",
201
+ "x": 840,
202
+ "y": 200,
203
+ "wires": [
204
+ [
205
+ "c5b2a60e99954c23"
206
+ ]
207
+ ]
208
+ },
209
+ {
210
+ "id": "0e4c242820dcc156",
211
+ "type": "zserial closeAll",
212
+ "z": "6c5cb5c635f82b56",
213
+ "name": "全部关闭",
214
+ "x": 480,
215
+ "y": 340,
216
+ "wires": [
217
+ []
218
+ ]
219
+ },
220
+ {
221
+ "id": "052eea87f99970b0",
222
+ "type": "inject",
223
+ "z": "6c5cb5c635f82b56",
224
+ "name": "",
225
+ "props": [],
226
+ "repeat": "",
227
+ "crontab": "",
228
+ "once": false,
229
+ "onceDelay": "1",
230
+ "topic": "",
231
+ "x": 310,
232
+ "y": 340,
233
+ "wires": [
234
+ [
235
+ "0e4c242820dcc156"
236
+ ]
237
+ ]
238
+ },
239
+ {
240
+ "id": "ef3b251330bafa25",
241
+ "type": "zserial closeAll",
242
+ "z": "6c5cb5c635f82b56",
243
+ "name": "单独关闭",
244
+ "x": 640,
245
+ "y": 400,
246
+ "wires": [
247
+ []
248
+ ]
249
+ },
250
+ {
251
+ "id": "98f8acd5d825b6dd",
252
+ "type": "inject",
253
+ "z": "6c5cb5c635f82b56",
254
+ "name": "",
255
+ "props": [],
256
+ "repeat": "",
257
+ "crontab": "",
258
+ "once": false,
259
+ "onceDelay": "1",
260
+ "topic": "",
261
+ "x": 310,
262
+ "y": 400,
263
+ "wires": [
264
+ [
265
+ "48f42e1d3e51dd37"
266
+ ]
267
+ ]
268
+ },
269
+ {
270
+ "id": "48f42e1d3e51dd37",
271
+ "type": "function",
272
+ "z": "6c5cb5c635f82b56",
273
+ "name": "单独配置",
274
+ "func": "\nmsg.serialConfig = {\n serialport: '/dev/ttys021',\n baud: 9600,\n databits: 8,\n parity: 'NONE',\n stopbits: 1\n};\nreturn msg;",
275
+ "outputs": 1,
276
+ "timeout": 0,
277
+ "noerr": 0,
278
+ "initialize": "",
279
+ "finalize": "",
280
+ "libs": [],
281
+ "x": 480,
282
+ "y": 400,
283
+ "wires": [
284
+ [
285
+ "ef3b251330bafa25"
286
+ ]
287
+ ]
288
+ }
289
+ ]
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-zserial",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Node-RED nodes to talk to serial ports",
5
5
  "dependencies": {
6
6
  "serialport": "^12.0.0"