node-red-contrib-modbus-rtu 1.1.26 → 1.1.28
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/modbus_rtu.html +14 -13
- package/modbus_rtu.js +2 -2
- package/package.json +1 -1
package/modbus_rtu.html
CHANGED
|
@@ -3,23 +3,19 @@
|
|
|
3
3
|
category: 'function',
|
|
4
4
|
color: '#fff000',
|
|
5
5
|
defaults: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
addr: {
|
|
13
|
-
value: ""
|
|
14
|
-
},
|
|
15
|
-
count: {
|
|
16
|
-
value: ""
|
|
17
|
-
},
|
|
6
|
+
ten : { value: ""},
|
|
7
|
+
slave_id: { value: ""},
|
|
8
|
+
fn : { value: "0" },
|
|
9
|
+
addr : { value: "" },
|
|
10
|
+
count : { value: "" },
|
|
18
11
|
},
|
|
19
12
|
inputs: 1,
|
|
20
13
|
outputs: 1,
|
|
21
14
|
icon: 'bridge.png',
|
|
22
15
|
label: function() {
|
|
16
|
+
if(this.ten != ""){
|
|
17
|
+
return this.ten;
|
|
18
|
+
}
|
|
23
19
|
if (this.fn == "-1") {
|
|
24
20
|
return "ModbusRTU fn=DYNAMIC";
|
|
25
21
|
} else if (this.fn == "-2") {
|
|
@@ -71,6 +67,11 @@
|
|
|
71
67
|
<div class="form-row">
|
|
72
68
|
<h3>modbus_rtu Build payload msg</h3><hr>
|
|
73
69
|
<div/>
|
|
70
|
+
<div class="form-row">
|
|
71
|
+
<label for="node-input-ten"><i class="fa fa-tag"></i> Name</label>
|
|
72
|
+
<input type="text" id="node-input-ten" value="" placeholder="Custom name">
|
|
73
|
+
</div>
|
|
74
|
+
<hr>
|
|
74
75
|
<div class="form-row">
|
|
75
76
|
<label for="node-input-fn"><i class="fa fa-tag"></i> Function</label>
|
|
76
77
|
<select id="node-input-fn" style="width:70%">
|
|
@@ -118,7 +119,7 @@ msg.payload = add_crc16(data);</pre>
|
|
|
118
119
|
//input: phụ thuộc vào payload của node trước ở dạng Buffer
|
|
119
120
|
//output: msg if CRC==0 else msg.crc=crc
|
|
120
121
|
const data = msg.payload;
|
|
121
|
-
|
|
122
|
+
const _payload = add_crc16(data, out_crc);
|
|
122
123
|
msg.crc = out_crc
|
|
123
124
|
if(out_crc==0)return msg;</pre>
|
|
124
125
|
<pre class="modbus-dynamic">//DYNAMIC:
|
package/modbus_rtu.js
CHANGED
|
@@ -47,10 +47,10 @@ module.exports = function (RED) {
|
|
|
47
47
|
return;
|
|
48
48
|
} else if (fn == -2) { //CHECK CRC
|
|
49
49
|
data = msg.payload;
|
|
50
|
-
|
|
50
|
+
var _payload = add_crc(data, out_crc);
|
|
51
51
|
msg.crc = out_crc.crc;
|
|
52
52
|
if(out_crc.crc == 0){
|
|
53
|
-
node.status({ fill: "green", shape: "dot", text: "CRC == 0 : OK"
|
|
53
|
+
node.status({ fill: "green", shape: "dot", text: "CRC == 0 : OK"});
|
|
54
54
|
node.send(msg);
|
|
55
55
|
}else{
|
|
56
56
|
node.status({ fill: "red", shape: "ring", text: "CRC error: 0x" + out_crc.crc.toString(16) });
|