njs-modbus 1.2.0 → 1.3.0
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
CHANGED
|
@@ -546,7 +546,13 @@ function lrc(data) {
|
|
|
546
546
|
}
|
|
547
547
|
|
|
548
548
|
class RtuApplicationLayer extends AbstractApplicationLayer {
|
|
549
|
-
constructor(physicalLayer,
|
|
549
|
+
constructor(physicalLayer,
|
|
550
|
+
/**
|
|
551
|
+
* The time interval between two frames, support two formats:
|
|
552
|
+
* - bit: `48bit` as default
|
|
553
|
+
* - millisecond: `20ms`
|
|
554
|
+
*/
|
|
555
|
+
intervalBetweenFrames) {
|
|
550
556
|
super();
|
|
551
557
|
Object.defineProperty(this, "_timerThreePointFive", {
|
|
552
558
|
enumerable: true,
|
|
@@ -568,9 +574,14 @@ class RtuApplicationLayer extends AbstractApplicationLayer {
|
|
|
568
574
|
});
|
|
569
575
|
let threePointFiveT = 0;
|
|
570
576
|
if (physicalLayer.TYPE === 'SERIAL') {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
577
|
+
if (intervalBetweenFrames && intervalBetweenFrames.endsWith('ms')) {
|
|
578
|
+
threePointFiveT = Number(intervalBetweenFrames.slice(0, -2));
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
threePointFiveT = Math.ceil(physicalLayer.baudRate > 19200
|
|
582
|
+
? 1.8
|
|
583
|
+
: getThreePointFiveT(physicalLayer.baudRate, intervalBetweenFrames ? Number(intervalBetweenFrames.slice(0, -3)) : 48));
|
|
584
|
+
}
|
|
574
585
|
}
|
|
575
586
|
const handleData = (data, response) => {
|
|
576
587
|
this._bufferRx = Buffer.concat([this._bufferRx, data]);
|
package/dist/index.d.ts
CHANGED
|
@@ -164,7 +164,13 @@ declare class RtuApplicationLayer extends AbstractApplicationLayer {
|
|
|
164
164
|
private _timerThreePointFive?;
|
|
165
165
|
private _bufferRx;
|
|
166
166
|
private _removeAllListeners;
|
|
167
|
-
constructor(physicalLayer: SerialPhysicalLayer | TcpServerPhysicalLayer | TcpClientPhysicalLayer | UdpPhysicalLayer,
|
|
167
|
+
constructor(physicalLayer: SerialPhysicalLayer | TcpServerPhysicalLayer | TcpClientPhysicalLayer | UdpPhysicalLayer,
|
|
168
|
+
/**
|
|
169
|
+
* The time interval between two frames, support two formats:
|
|
170
|
+
* - bit: `48bit` as default
|
|
171
|
+
* - millisecond: `20ms`
|
|
172
|
+
*/
|
|
173
|
+
intervalBetweenFrames?: `${number}bit` | `${number}ms`);
|
|
168
174
|
private framing;
|
|
169
175
|
encode(data: ApplicationDataUnit): Buffer;
|
|
170
176
|
destroy(): void;
|
package/dist/index.mjs
CHANGED
|
@@ -544,7 +544,13 @@ function lrc(data) {
|
|
|
544
544
|
}
|
|
545
545
|
|
|
546
546
|
class RtuApplicationLayer extends AbstractApplicationLayer {
|
|
547
|
-
constructor(physicalLayer,
|
|
547
|
+
constructor(physicalLayer,
|
|
548
|
+
/**
|
|
549
|
+
* The time interval between two frames, support two formats:
|
|
550
|
+
* - bit: `48bit` as default
|
|
551
|
+
* - millisecond: `20ms`
|
|
552
|
+
*/
|
|
553
|
+
intervalBetweenFrames) {
|
|
548
554
|
super();
|
|
549
555
|
Object.defineProperty(this, "_timerThreePointFive", {
|
|
550
556
|
enumerable: true,
|
|
@@ -566,9 +572,14 @@ class RtuApplicationLayer extends AbstractApplicationLayer {
|
|
|
566
572
|
});
|
|
567
573
|
let threePointFiveT = 0;
|
|
568
574
|
if (physicalLayer.TYPE === 'SERIAL') {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
575
|
+
if (intervalBetweenFrames && intervalBetweenFrames.endsWith('ms')) {
|
|
576
|
+
threePointFiveT = Number(intervalBetweenFrames.slice(0, -2));
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
threePointFiveT = Math.ceil(physicalLayer.baudRate > 19200
|
|
580
|
+
? 1.8
|
|
581
|
+
: getThreePointFiveT(physicalLayer.baudRate, intervalBetweenFrames ? Number(intervalBetweenFrames.slice(0, -3)) : 48));
|
|
582
|
+
}
|
|
572
583
|
}
|
|
573
584
|
const handleData = (data, response) => {
|
|
574
585
|
this._bufferRx = Buffer.concat([this._bufferRx, data]);
|
|
@@ -6,7 +6,13 @@ export declare class RtuApplicationLayer extends AbstractApplicationLayer {
|
|
|
6
6
|
private _timerThreePointFive?;
|
|
7
7
|
private _bufferRx;
|
|
8
8
|
private _removeAllListeners;
|
|
9
|
-
constructor(physicalLayer: SerialPhysicalLayer | TcpServerPhysicalLayer | TcpClientPhysicalLayer | UdpPhysicalLayer,
|
|
9
|
+
constructor(physicalLayer: SerialPhysicalLayer | TcpServerPhysicalLayer | TcpClientPhysicalLayer | UdpPhysicalLayer,
|
|
10
|
+
/**
|
|
11
|
+
* The time interval between two frames, support two formats:
|
|
12
|
+
* - bit: `48bit` as default
|
|
13
|
+
* - millisecond: `20ms`
|
|
14
|
+
*/
|
|
15
|
+
intervalBetweenFrames?: `${number}bit` | `${number}ms`);
|
|
10
16
|
private framing;
|
|
11
17
|
encode(data: ApplicationDataUnit): Buffer;
|
|
12
18
|
destroy(): void;
|