node-zserial 1.0.15 → 1.0.16
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 +29 -5
package/package.json
CHANGED
package/zserial.js
CHANGED
|
@@ -640,14 +640,38 @@ module.exports = function (RED) {
|
|
|
640
640
|
this.tout = null;
|
|
641
641
|
var msgout = obj.dequeue() || {};
|
|
642
642
|
msgout.port = id;
|
|
643
|
-
// if we have some leftover stuff, just send it
|
|
644
|
-
if (i !== 0) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
643
|
+
// // if we have some leftover stuff, just send it
|
|
644
|
+
// if (i !== 0) {
|
|
645
|
+
// var m = buf.slice(0, i);
|
|
646
|
+
// m = Buffer.from(m);
|
|
647
|
+
// i = 0;
|
|
648
|
+
// if (binoutput !== "bin") { m = m.toString(); }
|
|
649
|
+
// msgout.payload = m;
|
|
650
|
+
// }
|
|
651
|
+
// Prefer flushing data depending on split mode
|
|
652
|
+
var m = null;
|
|
653
|
+
if (spliton === "frame") {
|
|
654
|
+
// In frame mode, partial bytes are accumulated in assembleBuf
|
|
655
|
+
if (typeof assembleBuf !== "undefined" && assembleBuf && assembleBuf.length) {
|
|
656
|
+
m = Buffer.from(assembleBuf);
|
|
657
|
+
// clear partials so they don't leak into next request
|
|
658
|
+
assembleBuf = Buffer.alloc(0);
|
|
659
|
+
}
|
|
660
|
+
} else {
|
|
661
|
+
// legacy modes use buf/i
|
|
662
|
+
if (i !== 0) {
|
|
663
|
+
m = buf.slice(0, i);
|
|
664
|
+
i = 0;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (m) {
|
|
648
668
|
if (binoutput !== "bin") { m = m.toString(); }
|
|
649
669
|
msgout.payload = m;
|
|
670
|
+
}else {
|
|
671
|
+
// ensure payload exists for upstream logic
|
|
672
|
+
msgout.payload = (binoutput !== "bin") ? "" : Buffer.alloc(0);
|
|
650
673
|
}
|
|
674
|
+
msgout.status = "ERR_TIMEOUT";
|
|
651
675
|
/* Notify the sender that a timeout occurred */
|
|
652
676
|
obj._emitter.emit('timeout', msgout, qobj.sender);
|
|
653
677
|
}, timeout);
|