node-zserial 1.0.11 → 1.0.13

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/zserial.js +9 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-zserial",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Node-RED nodes to talk to serial ports",
5
5
  "dependencies": {
6
6
  "serialport": "^12.0.0"
package/zserial.js CHANGED
@@ -269,6 +269,7 @@ module.exports = function (RED) {
269
269
  curPort.on('timeout', function (msgout, sender) {
270
270
  if (sender !== node) { return; }
271
271
  msgout.status = "ERR_TIMEOUT";
272
+ msgout.port = curPort.serial.path;
272
273
  node.status({ fill: "red", shape: "ring", text: "timeout:::" + curPort.serial.path });
273
274
  node.send(msgout);
274
275
  if (done) done();
@@ -310,6 +311,7 @@ module.exports = function (RED) {
310
311
  node._msg = null
311
312
 
312
313
  function initMsg(msg) {
314
+ node._msg = msg;
313
315
  node.totallenth = msg.serialConfigs.length;
314
316
  node.totalMsg = {};
315
317
  node.successMsg = {};
@@ -332,7 +334,7 @@ module.exports = function (RED) {
332
334
  sendAll(done);
333
335
  }
334
336
  function onMsg(msg, send, done) {
335
- node._msg = msg;
337
+
336
338
  initMsg(msg);
337
339
  if (!msg.serialConfigs) {
338
340
  node.error("需要配置批量配置:msg.serialConfigs");
@@ -377,6 +379,7 @@ module.exports = function (RED) {
377
379
  if (isNaN(baud)) {
378
380
  // node.error(RED._("serial.errors.badbaudrate"), msg);
379
381
  zsend(null, {
382
+ ...serialConfig,
380
383
  text: RED._("serial.errors.badbaudrate")
381
384
  }, null, curPort.serial.path, done)
382
385
  } else {
@@ -384,7 +387,7 @@ module.exports = function (RED) {
384
387
  if (err) {
385
388
  // node.error(err);
386
389
  zsend(null, {
387
- msg: msg,
390
+ ...serialConfig,
388
391
  status: "ERR_UPDATE",
389
392
  error: err,
390
393
  text: "更新波特率失败"
@@ -395,6 +398,7 @@ module.exports = function (RED) {
395
398
  }
396
399
  if (!serialConfig.hasOwnProperty("payload")) {
397
400
  zsend(null, {
401
+ ...serialConfig,
398
402
  text: "No payload"
399
403
  }, null, curPort.serial.path, done)
400
404
  return;
@@ -424,6 +428,7 @@ module.exports = function (RED) {
424
428
  } else {
425
429
  curPort._retryNum = 0
426
430
  zsend(null, {
431
+ ...serialConfig,
427
432
  status: "ERR_IN_QUEUE",
428
433
  text: '串口未打开,加入消息队列失败',
429
434
  port: curPort.serial.path
@@ -455,11 +460,9 @@ module.exports = function (RED) {
455
460
  curPort.on('timeout', function (msgout, sender) {
456
461
  if (sender !== node) { return; }
457
462
  msgout.status = "ERR_TIMEOUT";
463
+ msgout.port = curPort.serial.path;
458
464
  node.status({ fill: "red", shape: "ring", text: "timeout:::" + curPort.serial.path });
459
- zsend(null, {
460
- status: "ERR_TIMEOUT",
461
- port: curPort.serial.path
462
- }, null, curPort.serial.path, done);
465
+ zsend(null,msgout, null, curPort.serial.path, done);
463
466
  });
464
467
 
465
468
  curPort.on('initerror', function (port, retryNum, olderr) {