node-zserial 1.0.0 → 1.0.1
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/package.json +1 -1
- package/zserial.js +17 -11
package/package.json
CHANGED
package/zserial.js
CHANGED
|
@@ -13,22 +13,22 @@ module.exports = function (RED) {
|
|
|
13
13
|
RED.nodes.createNode(this, n);
|
|
14
14
|
var node = this;
|
|
15
15
|
|
|
16
|
-
function onMsg(msg, send, done){
|
|
16
|
+
function onMsg(msg, send, done) {
|
|
17
17
|
if (msg.serialConfig) {
|
|
18
|
-
serialPool.close(msg.serialConfig.serialport,(err) => {
|
|
18
|
+
serialPool.close(msg.serialConfig.serialport, (err) => {
|
|
19
19
|
if (err) {
|
|
20
|
-
msg.status="Close Error"
|
|
21
|
-
}else{
|
|
22
|
-
msg.status="Closed Ok"
|
|
20
|
+
msg.status = "Close Error"
|
|
21
|
+
} else {
|
|
22
|
+
msg.status = "Closed Ok"
|
|
23
23
|
}
|
|
24
24
|
node.send(msg);
|
|
25
25
|
done();
|
|
26
|
-
},node);
|
|
27
|
-
}else{
|
|
26
|
+
}, node);
|
|
27
|
+
} else {
|
|
28
28
|
serialPool.closeAll(() => {
|
|
29
29
|
node.send(msg);
|
|
30
30
|
done();
|
|
31
|
-
},node);
|
|
31
|
+
}, node);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
this.on("input", function (msg, send, done) {
|
|
@@ -152,13 +152,19 @@ module.exports = function (RED) {
|
|
|
152
152
|
node.send(msgout);
|
|
153
153
|
});
|
|
154
154
|
curPort.on('ready', function () {
|
|
155
|
-
node.status({ fill: "green", shape: "dot", text: "node-red:common.status.connected" });
|
|
155
|
+
//node.status({ fill: "green", shape: "dot", text: "node-red:common.status.connected" });
|
|
156
|
+
node.status({ fill: "green", shape: "dot", text: "当前连接数:" + connKeys.length });
|
|
157
|
+
|
|
156
158
|
});
|
|
157
159
|
curPort.on('closed', function () {
|
|
158
|
-
node.status({ fill: "red", shape: "ring", text: "node-red:common.status.not-connected" });
|
|
160
|
+
//node.status({ fill: "red", shape: "ring", text: "node-red:common.status.not-connected" });
|
|
161
|
+
node.status({ fill: "green", shape: "dot", text: "当前连接数:" + connKeys.length });
|
|
162
|
+
|
|
159
163
|
});
|
|
160
164
|
curPort.on('stopped', function () {
|
|
161
|
-
node.status({ fill: "grey", shape: "ring", text: "serial.status.stopped" });
|
|
165
|
+
//node.status({ fill: "grey", shape: "ring", text: "serial.status.stopped" });
|
|
166
|
+
node.status({ fill: "green", shape: "dot", text: "当前连接数:" + connKeys.length });
|
|
167
|
+
|
|
162
168
|
});
|
|
163
169
|
});
|
|
164
170
|
}
|