njs-modbus 1.3.3 → 1.3.4
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/dist/index.cjs +17 -19
- package/dist/index.mjs +17 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -591,31 +591,29 @@ class RtuApplicationLayer extends AbstractApplicationLayer {
|
|
|
591
591
|
}
|
|
592
592
|
const handleData = (data, response) => {
|
|
593
593
|
this._bufferRx = Buffer.concat([this._bufferRx, data]);
|
|
594
|
-
|
|
594
|
+
clearTimeout(this._timerThreePointFive);
|
|
595
|
+
const handleData = () => {
|
|
595
596
|
this.framing(this._bufferRx, (error, frame) => {
|
|
596
|
-
if (
|
|
597
|
-
|
|
597
|
+
if (this._waitingResponse) {
|
|
598
|
+
if (error && error.message === 'Insufficient data length') {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
this._waitingResponse.callback(error, frame);
|
|
602
|
+
this._bufferRx = Buffer.alloc(0);
|
|
598
603
|
}
|
|
599
|
-
|
|
600
|
-
this._bufferRx = Buffer.alloc(0);
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
clearTimeout(this._timerThreePointFive);
|
|
605
|
-
const handleData = () => {
|
|
606
|
-
this.framing(this._bufferRx, (error, frame) => {
|
|
604
|
+
else {
|
|
607
605
|
if (!error) {
|
|
608
606
|
this.emit('framing', frame, response);
|
|
609
607
|
}
|
|
610
608
|
this._bufferRx = Buffer.alloc(0);
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
};
|
|
612
|
+
if (threePointFiveT) {
|
|
613
|
+
this._timerThreePointFive = setTimeout(handleData, threePointFiveT);
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
handleData();
|
|
619
617
|
}
|
|
620
618
|
};
|
|
621
619
|
physicalLayer.on('data', handleData);
|
package/dist/index.mjs
CHANGED
|
@@ -589,31 +589,29 @@ class RtuApplicationLayer extends AbstractApplicationLayer {
|
|
|
589
589
|
}
|
|
590
590
|
const handleData = (data, response) => {
|
|
591
591
|
this._bufferRx = Buffer.concat([this._bufferRx, data]);
|
|
592
|
-
|
|
592
|
+
clearTimeout(this._timerThreePointFive);
|
|
593
|
+
const handleData = () => {
|
|
593
594
|
this.framing(this._bufferRx, (error, frame) => {
|
|
594
|
-
if (
|
|
595
|
-
|
|
595
|
+
if (this._waitingResponse) {
|
|
596
|
+
if (error && error.message === 'Insufficient data length') {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
this._waitingResponse.callback(error, frame);
|
|
600
|
+
this._bufferRx = Buffer.alloc(0);
|
|
596
601
|
}
|
|
597
|
-
|
|
598
|
-
this._bufferRx = Buffer.alloc(0);
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
else {
|
|
602
|
-
clearTimeout(this._timerThreePointFive);
|
|
603
|
-
const handleData = () => {
|
|
604
|
-
this.framing(this._bufferRx, (error, frame) => {
|
|
602
|
+
else {
|
|
605
603
|
if (!error) {
|
|
606
604
|
this.emit('framing', frame, response);
|
|
607
605
|
}
|
|
608
606
|
this._bufferRx = Buffer.alloc(0);
|
|
609
|
-
}
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
if (threePointFiveT) {
|
|
611
|
+
this._timerThreePointFive = setTimeout(handleData, threePointFiveT);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
handleData();
|
|
617
615
|
}
|
|
618
616
|
};
|
|
619
617
|
physicalLayer.on('data', handleData);
|