forked from tyrrellsystems/node-red-contrib-serial-modbus
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmodbus-serial.html
259 lines (250 loc) · 8.87 KB
/
modbus-serial.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!--
Copyright 2016 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-template-name="modbusSerialConfig">
<div class="form-row">
<label for="node-config-input-port"><i class="fa "></i> Port</label>
<input type="text" id="node-config-input-port" placeholder="/dev/ttyUSB0">
</div>
<div class="form-row">
<table width="100%">
<tr>
<td width="100px"><i class="fa fa-wrench"></i> Settings</td>
<td width="110px">Baud Rate</td>
<td with="70px">Data Bits</td>
<td width="80px">Parity</td>
<td width="70px">Stop Bits</td>
</tr>
<tr>
<td> </td>
<td>
<input type="text" id="node-config-input-baud" style="width:100px">
</td>
<td>
<select type="text" id="node-config-input-data" style="width:70px">
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
</select>
</td>
<td>
<select type="text" id="node-config-input-parity" style="width:80px">
<option value="none">None</option>
<option value="even">Even</option>
<option value="mark">Mark</option>
<option value="odd">Odd</option>
<option value="space">Space</option>
</select>
</td>
<td>
<select type="text" id="node-config-input-stop" style="width:70px">
<option value="2">2</option>
<option value="1">1</option>
</select>
</td>
</tr>
</table>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa "></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="ModbusSerial">
</div>
</script>
<script type="text/x-red" data-help-name="modbusSerialConfig">
<p>Details of the serial port to use to connect to the RS485 bus</p>
</script>
<script type="text/javascript">
RED.nodes.registerType("modbusSerialConfig",{
category:'config',
defaults: {
port: {value: '', required: true},
baud: {value: 38400, required: true},
data: {value: 8, required: true},
parity: {value: 'none', required: true},
stop: {value: 1, required: true},
name: {value: ''}
},
label: function(){
return this.name || this.port + ":" + this.baud;
}
});
</script>
<script type="text/x-red" data-template-name="modbusSerial in">
<div class="form-row">
<label for="node-input-port"><i class="fa "></i> Port</label>
<input type="text" id="node-input-port" placeholder="/dev/ttyUSB0">
</div>
<!-- <div class="form-row">
<table width="100%">
<tr>
<td width="100px"><i class="fa fa-wrench"></i> Settings</td>
<td width="110px">Baud Rate</td>
<td with="70px">Data Bits</td>
<td width="80px">Parity</td>
<td width="70px">Stop Bits</td>
</tr>
<tr>
<td> </td>
<td>
<input type="text" id="node-input-baud" style="width:100px">
</td>
<td>
<select type="text" id="node-input-data" style="width:70px">
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5">5</option>
</select>
</td>
<td>
<select type="text" id="node-input-parity" style="width:80px">
<option value="none">None</option>
<option value="even">Even</option>
<option value="mark">Mark</option>
<option value="odd">Odd</option>
<option value="space">Space</option>
</select>
</td>
<td>
<select type="text" id="node-input-stop" style="width:70px">
<option value="2">2</option>
<option value="1">1</option>
</select>
</td>
</tr>
</table>
</div> -->
<div class="form-row">
<label for="node-input-slaves"><i class="fa "></i> Slaves</label>
<input type="text" id="node-input-slaves">
</div>
<div class="form-row">
<label for="node-input-dtype"><i class="fa "></i> Type</label>
<select type="text" id="node-input-dtype">
<option value="descrete">Descrete</option>
<option value="coil">Coil</option>
<option value="input">Input Register</option>
<option value="holding">Holding Register</option>
</select>
</div>
<div class="form-row">
<label for="node-input-start"><i class="fa "></i> Start</label>
<input type="text" id="node-input-start">
</div>
<div class="form-row">
<label for="node-input-count"><i class="fa "></i> Count</label>
<input type="text" id="node-input-count">
</div>
<div class="form-row">
<label for="node-input-period"><i class="fa "></i> Poll Period</label>
<input type="text" id="node-input-period">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa "></i> Topic Prefix</label>
<input type="text" id="node-input-topic">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa "></i> Name</label>
<input type="text" id="node-input-name">
</div>
</script>
<script type="text/x-red" data-help-name="modbusSerial in">
<p>A Node-RED node to read values from Modus devices over a
serial connection.</p>
<p>The node takes a comma seperated list of slave ids and start
and number of fields to read. The node will poll each slave in
turn at the given interval and send one message per slave.</p>
<p>The output messages have a buffer payload and the the slave
id appended to the configured topic.</p>
<p>For help with parsing the buffer into constituent parts see
the Formating data section of the README.md</p>
</script>
<script type="text/javascript">
RED.nodes.registerType("modbusSerial in",{
category:'modbus',
defaults: {
port: {type: 'modbusSerialConfig', required: true},
// port: {value:"", required: true},
// baud: {value:38400, required: true},
// data: {value:8, required: true},
// parity: {value:'none', required: true},
// stop: {value:1, required: true},
slaves: {required: true},
start: {required:true},
count: {value:1, required: true},
dtype: {value:'coil', required: true},
period: {value:60, required: true},
topic: {value: ''},
name: {value:''}
},
outputs: 1,
inputs: 0,
label: function() {
return this.name || "Modbus-Serial In";
},
color: 'grey',
icon: 'mb.png'
});
</script>
<script type="text/x-red" data-template-name="modbusSerial out">
<div class="form-row">
<label for="node-input-port"><i class="fa "></i> Port</label>
<input type="text" id="node-input-port" placeholder="/dev/ttyUSB0">
</div>
<div class="form-row">
<label for="node-input-slave"><i class="fa "></i> Slave</label>
<input type="text" id="node-input-slave">
</div>
<div class="form-row">
<label for="node-input-dtype"><i class="fa "></i> Type</label>
<select type="text" id="node-input-dtype">
<option value="descrete">Descrete</option>
<option value="coil">Coil</option>
<option value="input">Input Register</option>
<option value="holding">Holding Register</option>
</select>
</div>
<div class="form-row">
<label for="node-input-start"><i class="fa "></i> Start</label>
<input type="text" id="node-input-start">
</div>
</script>
<script type="text/x-red" data-help-name="modbusSerial out">
<p>A node to update the state of a Modbus device.</p>
<p>Slave is the address of the device to update (only one device). If left blank
then the msg.topic will be used if it's a integer. The last part of topic,
seperated by '/' will be used</p>
<p>The <i>msg.payload</i> of the input should be a buffer object formated to
match what ever format the device expects. The Formating Data section of the
README.md has guidence on how to do this.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType("modbusSerial out",{
category:'modbus',
defaults: {
port: {type: 'modbusSerialConfig', required: true},
slave: {},
start: {required:true},
dtype: {value:'coil', required: true},
topic: {value: ''},
name: {value:''}
},
outputs: 0,
inputs: 1,
label: function(){
return this.name || "Modbus-Serial Out";
},
color: 'grey',
icon: 'mb.png'
});
</script>