@ya-modbus/transport 0.13.0 → 0.14.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/CHANGELOG.md +12 -0
- package/README.md +16 -0
- package/dist/cjs/src/answer-length.d.ts +7 -0
- package/dist/cjs/src/answer-length.d.ts.map +1 -0
- package/dist/cjs/src/answer-length.js +15 -0
- package/dist/cjs/src/answer-length.js.map +1 -0
- package/dist/cjs/src/create-modbus-transport.d.ts.map +1 -1
- package/dist/cjs/src/create-modbus-transport.js +5 -4
- package/dist/cjs/src/create-modbus-transport.js.map +1 -1
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/cjs/src/index.d.ts.map +1 -1
- package/dist/cjs/src/index.js +3 -1
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/last-request.d.ts +29 -0
- package/dist/cjs/src/last-request.d.ts.map +1 -0
- package/dist/cjs/src/last-request.js +44 -0
- package/dist/cjs/src/last-request.js.map +1 -0
- package/dist/cjs/src/manager.d.ts +2 -0
- package/dist/cjs/src/manager.d.ts.map +1 -1
- package/dist/cjs/src/manager.js +5 -1
- package/dist/cjs/src/manager.js.map +1 -1
- package/dist/cjs/src/retry.d.ts +7 -0
- package/dist/cjs/src/retry.d.ts.map +1 -1
- package/dist/cjs/src/retry.js +1 -0
- package/dist/cjs/src/retry.js.map +1 -1
- package/dist/cjs/src/rtu-transport.d.ts +7 -0
- package/dist/cjs/src/rtu-transport.d.ts.map +1 -1
- package/dist/cjs/src/rtu-transport.js.map +1 -1
- package/dist/cjs/src/slave-transport.d.ts +18 -1
- package/dist/cjs/src/slave-transport.d.ts.map +1 -1
- package/dist/cjs/src/slave-transport.js +60 -53
- package/dist/cjs/src/slave-transport.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/answer-length.d.ts +7 -0
- package/dist/esm/src/answer-length.d.ts.map +1 -0
- package/dist/esm/src/answer-length.js +12 -0
- package/dist/esm/src/answer-length.js.map +1 -0
- package/dist/esm/src/create-modbus-transport.d.ts.map +1 -1
- package/dist/esm/src/create-modbus-transport.js +5 -4
- package/dist/esm/src/create-modbus-transport.js.map +1 -1
- package/dist/esm/src/index.d.ts +1 -0
- package/dist/esm/src/index.d.ts.map +1 -1
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/last-request.d.ts +29 -0
- package/dist/esm/src/last-request.d.ts.map +1 -0
- package/dist/esm/src/last-request.js +40 -0
- package/dist/esm/src/last-request.js.map +1 -0
- package/dist/esm/src/manager.d.ts +2 -0
- package/dist/esm/src/manager.d.ts.map +1 -1
- package/dist/esm/src/manager.js +5 -1
- package/dist/esm/src/manager.js.map +1 -1
- package/dist/esm/src/retry.d.ts +7 -0
- package/dist/esm/src/retry.d.ts.map +1 -1
- package/dist/esm/src/retry.js +1 -1
- package/dist/esm/src/retry.js.map +1 -1
- package/dist/esm/src/rtu-transport.d.ts +7 -0
- package/dist/esm/src/rtu-transport.d.ts.map +1 -1
- package/dist/esm/src/rtu-transport.js.map +1 -1
- package/dist/esm/src/slave-transport.d.ts +18 -1
- package/dist/esm/src/slave-transport.d.ts.map +1 -1
- package/dist/esm/src/slave-transport.js +60 -53
- package/dist/esm/src/slave-transport.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.14.1](https://github.com/groupsky/ya-modbus/compare/@ya-modbus/transport@0.14.0...@ya-modbus/transport@0.14.1) (2026-10-20)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **transport:** retry a read whose answer has the wrong length ([#674](https://github.com/groupsky/ya-modbus/issues/674)) ([01f71bf](https://github.com/groupsky/ya-modbus/commit/01f71bf9e594d25ce228ed442ecd2c23c4f0eaca)), closes [#673](https://github.com/groupsky/ya-modbus/issues/673)
|
|
11
|
+
|
|
12
|
+
# [0.14.0](https://github.com/groupsky/ya-modbus/compare/@ya-modbus/transport@0.13.0...@ya-modbus/transport@0.14.0) (2026-10-15)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **mqtt-bridge:** pause between devices on one serial port and poll them in turn ([#657](https://github.com/groupsky/ya-modbus/issues/657)) ([52725e6](https://github.com/groupsky/ya-modbus/commit/52725e61a9860bf118162c3b1faba0ef9a9c8db6)), closes [#655](https://github.com/groupsky/ya-modbus/issues/655)
|
|
17
|
+
|
|
6
18
|
# [0.13.0](https://github.com/groupsky/ya-modbus/compare/@ya-modbus/transport@0.12.2...@ya-modbus/transport@0.13.0) (2026-10-15)
|
|
7
19
|
|
|
8
20
|
### Features
|
package/README.md
CHANGED
|
@@ -91,6 +91,22 @@ The life of a pooled connection:
|
|
|
91
91
|
- `closeAll()` closes all connections and stops opening lost ports again. It waits for
|
|
92
92
|
connections that are opening or closing. Use it at shutdown.
|
|
93
93
|
|
|
94
|
+
### Pause between devices on a serial port
|
|
95
|
+
|
|
96
|
+
Some meters do not answer a request that comes too soon after another meter's reply. Set
|
|
97
|
+
`interDeviceDelay` (milliseconds) in the RTU config of such a device. Before a request to this
|
|
98
|
+
device, when the previous request on the port went to another slave, the transport waits until
|
|
99
|
+
`interDeviceDelay` ms have passed since that request ended (also when it failed). A request to the
|
|
100
|
+
same slave as the previous one, or the first request on the port, does not wait. Default: 0, no
|
|
101
|
+
pause.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const meter = await manager.getTransport({ ...bus, slaveId: 3, interDeviceDelay: 150 })
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`SlaveTransport` takes the delay and a `LastRequest` that all transports on the connection share
|
|
108
|
+
as its last two arguments.
|
|
109
|
+
|
|
94
110
|
## Error handling
|
|
95
111
|
|
|
96
112
|
Some `modbus-serial` failures (response timeouts, closed port) are plain objects instead of `Error`
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reject an answer with the wrong number of data bytes, so that withRetry
|
|
3
|
+
* sends the request again like after a timeout. The request context is added
|
|
4
|
+
* by withRequestContext.
|
|
5
|
+
*/
|
|
6
|
+
export declare function checkLength(buffer: Buffer, expectedBytes: number): Buffer;
|
|
7
|
+
//# sourceMappingURL=answer-length.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer-length.d.ts","sourceRoot":"","sources":["../../../src/answer-length.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAOzE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkLength = checkLength;
|
|
4
|
+
/**
|
|
5
|
+
* Reject an answer with the wrong number of data bytes, so that withRetry
|
|
6
|
+
* sends the request again like after a timeout. The request context is added
|
|
7
|
+
* by withRequestContext.
|
|
8
|
+
*/
|
|
9
|
+
function checkLength(buffer, expectedBytes) {
|
|
10
|
+
if (buffer.length !== expectedBytes) {
|
|
11
|
+
throw new Error(`Wrong answer length: expected ${expectedBytes} data bytes, got ${buffer.length}`);
|
|
12
|
+
}
|
|
13
|
+
return buffer;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=answer-length.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer-length.js","sourceRoot":"","sources":["../../../src/answer-length.ts"],"names":[],"mappings":";;AAKA,kCAOC;AAZD;;;;GAIG;AACH,SAAgB,WAAW,CAAC,MAAc,EAAE,aAAqB;IAC/D,IAAI,MAAM,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CACb,iCAAiC,aAAa,oBAAoB,MAAM,CAAC,MAAM,EAAE,CAClF,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-modbus-transport.d.ts","sourceRoot":"","sources":["../../../src/create-modbus-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,SAAS,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"create-modbus-transport.d.ts","sourceRoot":"","sources":["../../../src/create-modbus-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,SAAS,MAAM,eAAe,CAAA;AAG1C,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAExD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,GAAG,gBAAgB,EACpC,UAAU,GAAE,MAAU,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,SAAS,CA4GX"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createModbusTransport = createModbusTransport;
|
|
4
|
+
const answer_length_js_1 = require("./answer-length.js");
|
|
4
5
|
const connection_js_1 = require("./connection.js");
|
|
5
6
|
const retry_js_1 = require("./retry.js");
|
|
6
7
|
/**
|
|
@@ -21,25 +22,25 @@ function createModbusTransport(client, maxRetries = 3, logger) {
|
|
|
21
22
|
async readHoldingRegisters(address, count) {
|
|
22
23
|
return (0, retry_js_1.withRetry)(() => connection.run(async (modbus) => {
|
|
23
24
|
const result = await modbus.readHoldingRegisters(address, count);
|
|
24
|
-
return result.buffer;
|
|
25
|
+
return (0, answer_length_js_1.checkLength)(result.buffer, count * 2);
|
|
25
26
|
}), maxRetries, logger);
|
|
26
27
|
},
|
|
27
28
|
async readInputRegisters(address, count) {
|
|
28
29
|
return (0, retry_js_1.withRetry)(() => connection.run(async (modbus) => {
|
|
29
30
|
const result = await modbus.readInputRegisters(address, count);
|
|
30
|
-
return result.buffer;
|
|
31
|
+
return (0, answer_length_js_1.checkLength)(result.buffer, count * 2);
|
|
31
32
|
}), maxRetries, logger);
|
|
32
33
|
},
|
|
33
34
|
async readCoils(address, count) {
|
|
34
35
|
return (0, retry_js_1.withRetry)(() => connection.run(async (modbus) => {
|
|
35
36
|
const result = await modbus.readCoils(address, count);
|
|
36
|
-
return result.buffer;
|
|
37
|
+
return (0, answer_length_js_1.checkLength)(result.buffer, Math.ceil(count / 8));
|
|
37
38
|
}), maxRetries, logger);
|
|
38
39
|
},
|
|
39
40
|
async readDiscreteInputs(address, count) {
|
|
40
41
|
return (0, retry_js_1.withRetry)(() => connection.run(async (modbus) => {
|
|
41
42
|
const result = await modbus.readDiscreteInputs(address, count);
|
|
42
|
-
return result.buffer;
|
|
43
|
+
return (0, answer_length_js_1.checkLength)(result.buffer, Math.ceil(count / 8));
|
|
43
44
|
}), maxRetries, logger);
|
|
44
45
|
},
|
|
45
46
|
async writeSingleRegister(address, value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-modbus-transport.js","sourceRoot":"","sources":["../../../src/create-modbus-transport.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"create-modbus-transport.js","sourceRoot":"","sources":["../../../src/create-modbus-transport.ts"],"names":[],"mappings":";;AAmBA,sDAgHC;AAhID,yDAAgD;AAChD,mDAAqE;AACrE,yCAAwD;AAExD;;;;;;;;;;;GAWG;AACH,SAAgB,qBAAqB,CACnC,MAAoC,EACpC,aAAqB,CAAC,EACtB,MAAoB;IAEpB,MAAM,UAAU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AAC,CAAC,EACJ,UAAU,EACV,MAAM,CACP,CAAA;QACH,CAAC;QAED,KAAK,CAAC,kBAAkB,CAAC,OAAe,EAAE,MAAc;YACtD,OAAO,IAAA,oBAAS,EACd,GAAG,EAAE,CACH,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;gBAC9B,kCAAkC;gBAClC,MAAM,KAAK,GAAc,EAAE,CAAA;gBAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;oBACnC,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAA;oBACtB,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAW,CAAA,CAAC,kDAAkD;oBAC3F,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;gBAC5C,CAAC;gBACD,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;YACzC,CAAC,CAAC,EACJ,UAAU,EACV,MAAM,CACP,CAAA;QACH,CAAC;QAED,KAAK,CAAC,KAAK;YACT,OAAO,UAAU,CAAC,KAAK,EAAE,CAAA;QAC3B,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/cjs/src/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { isConnectionLostError, ModbusConnection, type OpenClient } from './conn
|
|
|
14
14
|
export { TransportManager, type TransportManagerOptions, type TransportStats } from './manager.js';
|
|
15
15
|
export { MutexTransport } from './mutex-transport.js';
|
|
16
16
|
export { SlaveTransport } from './slave-transport.js';
|
|
17
|
+
export { LastRequest } from './last-request.js';
|
|
17
18
|
export { getSerialNodeWarning } from './serial-node-warning.js';
|
|
18
19
|
export { listSerialPorts, matchSerialPorts, type SerialPortInfo, type SerialPortMatch, } from './serial-ports.js';
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,kBAAkB,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AACrF,OAAO,EAAE,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC1F,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,kBAAkB,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AACrF,OAAO,EAAE,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC1F,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAClG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAA"}
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* and transport pooling with mutex-based RTU bus serialization
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.matchSerialPorts = exports.listSerialPorts = exports.getSerialNodeWarning = exports.SlaveTransport = exports.MutexTransport = exports.TransportManager = exports.ModbusConnection = exports.isConnectionLostError = exports.normalizeModbusError = exports.RETRY_DELAY_MS = exports.MAX_RETRIES = exports.withRetry = exports.createModbusTransport = exports.createTCPTransport = exports.createRTUTransport = exports.createTransport = void 0;
|
|
9
|
+
exports.matchSerialPorts = exports.listSerialPorts = exports.getSerialNodeWarning = exports.LastRequest = exports.SlaveTransport = exports.MutexTransport = exports.TransportManager = exports.ModbusConnection = exports.isConnectionLostError = exports.normalizeModbusError = exports.RETRY_DELAY_MS = exports.MAX_RETRIES = exports.withRetry = exports.createModbusTransport = exports.createTCPTransport = exports.createRTUTransport = exports.createTransport = void 0;
|
|
10
10
|
var factory_js_1 = require("./factory.js");
|
|
11
11
|
Object.defineProperty(exports, "createTransport", { enumerable: true, get: function () { return factory_js_1.createTransport; } });
|
|
12
12
|
var rtu_transport_js_1 = require("./rtu-transport.js");
|
|
@@ -30,6 +30,8 @@ var mutex_transport_js_1 = require("./mutex-transport.js");
|
|
|
30
30
|
Object.defineProperty(exports, "MutexTransport", { enumerable: true, get: function () { return mutex_transport_js_1.MutexTransport; } });
|
|
31
31
|
var slave_transport_js_1 = require("./slave-transport.js");
|
|
32
32
|
Object.defineProperty(exports, "SlaveTransport", { enumerable: true, get: function () { return slave_transport_js_1.SlaveTransport; } });
|
|
33
|
+
var last_request_js_1 = require("./last-request.js");
|
|
34
|
+
Object.defineProperty(exports, "LastRequest", { enumerable: true, get: function () { return last_request_js_1.LastRequest; } });
|
|
33
35
|
var serial_node_warning_js_1 = require("./serial-node-warning.js");
|
|
34
36
|
Object.defineProperty(exports, "getSerialNodeWarning", { enumerable: true, get: function () { return serial_node_warning_js_1.getSerialNodeWarning; } });
|
|
35
37
|
var serial_ports_js_1 = require("./serial-ports.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2CAAoE;AAA3D,6GAAA,eAAe,OAAA;AACxB,uDAAuE;AAA9D,sHAAA,kBAAkB,OAAA;AAC3B,uDAAuE;AAA9D,sHAAA,kBAAkB,OAAA;AAC3B,2EAAoE;AAA3D,mIAAA,qBAAqB,OAAA;AAC9B,uCAAqF;AAA5E,q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pause between requests to different slaves on one connection
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The last request on a connection: the slave it went to and when it ended.
|
|
6
|
+
*
|
|
7
|
+
* The SlaveTransports on one connection share one LastRequest, so a transport knows when the
|
|
8
|
+
* previous request went to another slave. Some meters do not answer a request that comes too
|
|
9
|
+
* soon after another meter's reply.
|
|
10
|
+
*/
|
|
11
|
+
export declare class LastRequest {
|
|
12
|
+
private slaveId;
|
|
13
|
+
private endedAt;
|
|
14
|
+
/**
|
|
15
|
+
* Wait until `delay` ms have passed since the end of the last request, when it went to
|
|
16
|
+
* another slave. No wait before the first request, or before a request to the same slave.
|
|
17
|
+
*
|
|
18
|
+
* @param slaveId - Slave of the next request
|
|
19
|
+
* @param delay - Pause in milliseconds after a request to another slave
|
|
20
|
+
*/
|
|
21
|
+
waitBefore(slaveId: number, delay: number): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Note the end of a request, also of a failed one
|
|
24
|
+
*
|
|
25
|
+
* @param slaveId - Slave of the request
|
|
26
|
+
*/
|
|
27
|
+
ended(slaveId: number): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=last-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"last-request.d.ts","sourceRoot":"","sources":["../../../src/last-request.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,OAAO,CAAI;IAEnB;;;;;;OAMG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/D;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAI7B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pause between requests to different slaves on one connection
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LastRequest = void 0;
|
|
7
|
+
const retry_js_1 = require("./retry.js");
|
|
8
|
+
/**
|
|
9
|
+
* The last request on a connection: the slave it went to and when it ended.
|
|
10
|
+
*
|
|
11
|
+
* The SlaveTransports on one connection share one LastRequest, so a transport knows when the
|
|
12
|
+
* previous request went to another slave. Some meters do not answer a request that comes too
|
|
13
|
+
* soon after another meter's reply.
|
|
14
|
+
*/
|
|
15
|
+
class LastRequest {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.endedAt = 0;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Wait until `delay` ms have passed since the end of the last request, when it went to
|
|
21
|
+
* another slave. No wait before the first request, or before a request to the same slave.
|
|
22
|
+
*
|
|
23
|
+
* @param slaveId - Slave of the next request
|
|
24
|
+
* @param delay - Pause in milliseconds after a request to another slave
|
|
25
|
+
*/
|
|
26
|
+
async waitBefore(slaveId, delay) {
|
|
27
|
+
if (this.slaveId === undefined || this.slaveId === slaveId)
|
|
28
|
+
return;
|
|
29
|
+
const wait = this.endedAt + delay - performance.now();
|
|
30
|
+
if (wait > 0)
|
|
31
|
+
await (0, retry_js_1.sleep)(wait);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Note the end of a request, also of a failed one
|
|
35
|
+
*
|
|
36
|
+
* @param slaveId - Slave of the request
|
|
37
|
+
*/
|
|
38
|
+
ended(slaveId) {
|
|
39
|
+
this.slaveId = slaveId;
|
|
40
|
+
this.endedAt = performance.now();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.LastRequest = LastRequest;
|
|
44
|
+
//# sourceMappingURL=last-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"last-request.js","sourceRoot":"","sources":["../../../src/last-request.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yCAAkC;AAElC;;;;;;GAMG;AACH,MAAa,WAAW;IAAxB;QAEU,YAAO,GAAG,CAAC,CAAA;IAyBrB,CAAC;IAvBC;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,CAAC,OAAe,EAAE,KAAa;QAC7C,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO;YAAE,OAAM;QAElE,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,GAAG,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QACrD,IAAI,IAAI,GAAG,CAAC;YAAE,MAAM,IAAA,gBAAK,EAAC,IAAI,CAAC,CAAA;IACjC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAClC,CAAC;CACF;AA3BD,kCA2BC"}
|
|
@@ -33,6 +33,8 @@ export interface TransportStats {
|
|
|
33
33
|
* - Returns Transport objects (SlaveTransport wrapped with request details in errors) that set the slave ID before each operation
|
|
34
34
|
* - Multiple devices on the same connection share a single client and mutex
|
|
35
35
|
* - All operations are serialized using async-mutex to prevent race conditions
|
|
36
|
+
* - On a serial port, a request waits `interDeviceDelay` ms (RTU config of its device) after
|
|
37
|
+
* a request to another slave
|
|
36
38
|
* - A lost connection (USB adapter unplugged, TCP connection closed) drops the client.
|
|
37
39
|
* The first request after a backoff opens a new client for all devices on the
|
|
38
40
|
* connection (see ModbusConnection)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAMxD,OAAO,KAAK,EAAwB,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/manager.ts"],"names":[],"m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;;OAMG;YACW,eAAe;IAU7B;;;;;OAKG;IACH,OAAO,CAAC,WAAW;CAGpB"}
|
package/dist/cjs/src/manager.js
CHANGED
|
@@ -6,6 +6,7 @@ const async_mutex_1 = require("async-mutex");
|
|
|
6
6
|
const modbus_serial_1 = tslib_1.__importDefault(require("modbus-serial"));
|
|
7
7
|
const client_config_js_1 = require("./client-config.js");
|
|
8
8
|
const connection_js_1 = require("./connection.js");
|
|
9
|
+
const last_request_js_1 = require("./last-request.js");
|
|
9
10
|
const normalize_error_js_1 = require("./normalize-error.js");
|
|
10
11
|
const request_context_js_1 = require("./request-context.js");
|
|
11
12
|
const slave_transport_js_1 = require("./slave-transport.js");
|
|
@@ -19,6 +20,8 @@ const slave_transport_js_1 = require("./slave-transport.js");
|
|
|
19
20
|
* - Returns Transport objects (SlaveTransport wrapped with request details in errors) that set the slave ID before each operation
|
|
20
21
|
* - Multiple devices on the same connection share a single client and mutex
|
|
21
22
|
* - All operations are serialized using async-mutex to prevent race conditions
|
|
23
|
+
* - On a serial port, a request waits `interDeviceDelay` ms (RTU config of its device) after
|
|
24
|
+
* a request to another slave
|
|
22
25
|
* - A lost connection (USB adapter unplugged, TCP connection closed) drops the client.
|
|
23
26
|
* The first request after a backoff opens a new client for all devices on the
|
|
24
27
|
* connection (see ModbusConnection)
|
|
@@ -73,7 +76,7 @@ class TransportManager {
|
|
|
73
76
|
entry = await opening;
|
|
74
77
|
}
|
|
75
78
|
// Return a new SlaveTransport for this specific slave
|
|
76
|
-
const transport = new slave_transport_js_1.SlaveTransport(config.slaveId, entry.connection, entry.mutex, config.maxRetries ?? 3, config.logger);
|
|
79
|
+
const transport = new slave_transport_js_1.SlaveTransport(config.slaveId, entry.connection, entry.mutex, config.maxRetries ?? 3, config.logger, this.isRTUConfig(config) ? config.interDeviceDelay : undefined, entry.lastRequest);
|
|
77
80
|
const target = this.getTarget(config);
|
|
78
81
|
const where = this.isRTUConfig(config) ? `${target} ${(0, request_context_js_1.formatSerialSettings)(config)}` : target;
|
|
79
82
|
const described = (0, request_context_js_1.withRequestContext)(transport, `${where}, slave ${config.slaveId}`);
|
|
@@ -132,6 +135,7 @@ class TransportManager {
|
|
|
132
135
|
const entry = {
|
|
133
136
|
connection,
|
|
134
137
|
mutex: new async_mutex_1.Mutex(),
|
|
138
|
+
lastRequest: new last_request_js_1.LastRequest(),
|
|
135
139
|
config,
|
|
136
140
|
isRTU,
|
|
137
141
|
transports: new Set(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/manager.ts"],"names":[],"mappings":";;;;AACA,6CAAmC;AACnC,0EAAqC;AAErC,yDAAmE;AACnE,mDAAkD;AAElD,6DAA6E;AAC7E,6DAA+E;AAC/E,6DAAqD;
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../src/manager.ts"],"names":[],"mappings":";;;;AACA,6CAAmC;AACnC,0EAAqC;AAErC,yDAAmE;AACnE,mDAAkD;AAElD,uDAA+C;AAC/C,6DAA6E;AAC7E,6DAA+E;AAC/E,6DAAqD;AAsCrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAa,gBAAgB;IAO3B,YAA6B,UAAmC,EAAE;QAArC,YAAO,GAAP,OAAO,CAA8B;QANjD,gBAAW,GAAG,IAAI,GAAG,EAA2B,CAAA;QACjE,wFAAwF;QACvE,YAAO,GAAG,IAAI,GAAG,EAAoC,CAAA;QACtE,mEAAmE;QAClD,YAAO,GAAG,IAAI,GAAG,EAAiB,CAAA;IAEkB,CAAC;IAEtE;;;;;;;;;OASG;IACH,KAAK,CAAC,YAAY,CAAC,MAAuB;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAA;QAEjD,sCAAsC;QACtC,IAAI,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK,EAAE,C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,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,GAAG,EAAE,CAAA;IACxF,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,eAAe,CAAC,MAAiB;QAC7C,MAAM,MAAM,GAAG,IAAI,uBAAS,EAAE,CAAA;QAE9B,MAAM,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,EAAE;YAC3C,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAA;QAEF,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,IAAI,qCAAkB,CAAC,CAAA;QAEvD,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,eAAe,CAAC,MAAiB;QAC7C,MAAM,MAAM,GAAG,IAAI,uBAAS,EAAE,CAAA;QAE9B,MAAM,IAAA,6BAAU,EAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;QAEzE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,IAAI,qCAAkB,CAAC,CAAA;QAEvD,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;OAKG;IACK,WAAW,CAAC,MAAuB;QACzC,OAAO,MAAM,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,CAAA;IACnF,CAAC;CACF;AArPD,4CAqPC"}
|
package/dist/cjs/src/retry.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ import { type ModbusError } from './normalize-error.js';
|
|
|
6
6
|
export declare const MAX_RETRIES = 3;
|
|
7
7
|
/** Delay between retry attempts in milliseconds */
|
|
8
8
|
export declare const RETRY_DELAY_MS = 100;
|
|
9
|
+
/**
|
|
10
|
+
* Sleep for a specified duration
|
|
11
|
+
*
|
|
12
|
+
* @param ms - Duration in milliseconds
|
|
13
|
+
* @returns Promise that resolves after the specified duration
|
|
14
|
+
*/
|
|
15
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
9
16
|
/**
|
|
10
17
|
* Logger function to track retry attempts
|
|
11
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAE7E,6DAA6D;AAC7D,eAAO,MAAM,WAAW,IAAI,CAAA;AAE5B,mDAAmD;AACnD,eAAO,MAAM,cAAc,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAE7E,6DAA6D;AAC7D,eAAO,MAAM,WAAW,IAAI,CAAA;AAE5B,mDAAmD;AACnD,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;AAEvE;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,GAAE,MAAoB,EAChC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
|
package/dist/cjs/src/retry.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RETRY_DELAY_MS = exports.MAX_RETRIES = void 0;
|
|
7
|
+
exports.sleep = sleep;
|
|
7
8
|
exports.withRetry = withRetry;
|
|
8
9
|
const normalize_error_js_1 = require("./normalize-error.js");
|
|
9
10
|
/** Maximum number of retry attempts for failed operations */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/retry.ts"],"names":[],"mappings":";AAAA;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/retry.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAgBH,sBAEC;AAoBD,8BAyBC;AA7DD,6DAA6E;AAE7E,6DAA6D;AAChD,QAAA,WAAW,GAAG,CAAC,CAAA;AAE5B,mDAAmD;AACtC,QAAA,cAAc,GAAG,GAAG,CAAA;AAEjC;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAC1D,CAAC;AAUD;;;;;;;;;GASG;AACI,KAAK,UAAU,SAAS,CAC7B,EAAoB,EACpB,aAAqB,mBAAW,EAChC,MAAoB;IAEpB,IAAI,SAAS,GAAgB,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAErE,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACvD,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAA;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,IAAA,yCAAoB,EAAC,KAAK,CAAC,CAAA;YAEvC,kCAAkC;YAClC,IAAI,OAAO,GAAG,UAAU,EAAE,CAAC;gBACzB,8CAA8C;gBAC9C,IAAI,MAAM,EAAE,CAAC;oBACX,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;gBAC5B,CAAC;gBACD,MAAM,KAAK,CAAC,sBAAc,CAAC,CAAA;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,CAAA;AACjB,CAAC"}
|
|
@@ -22,6 +22,13 @@ export interface RTUConfig {
|
|
|
22
22
|
maxRetries?: number | undefined;
|
|
23
23
|
/** Optional callback to log retry attempts for debugging */
|
|
24
24
|
logger?: RetryLogger | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Pause in milliseconds before a request to this slave when the previous request on the port
|
|
27
|
+
* went to another slave, counted from the end of that request (default: 0, no pause). Some
|
|
28
|
+
* meters do not answer a request that comes too soon after another meter's reply. Only for
|
|
29
|
+
* devices that share a port through TransportManager.
|
|
30
|
+
*/
|
|
31
|
+
interDeviceDelay?: number | undefined;
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* Create an RTU transport
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rtu-transport.d.ts","sourceRoot":"","sources":["../../../src/rtu-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAO9F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB;IAChB,QAAQ,EAAE,QAAQ,CAAA;IAClB,gBAAgB;IAChB,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa;IACb,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB;IAChB,QAAQ,EAAE,QAAQ,CAAA;IAClB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"rtu-transport.d.ts","sourceRoot":"","sources":["../../../src/rtu-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAO9F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB;IAChB,QAAQ,EAAE,QAAQ,CAAA;IAClB,gBAAgB;IAChB,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa;IACb,MAAM,EAAE,MAAM,CAAA;IACd,gBAAgB;IAChB,QAAQ,EAAE,QAAQ,CAAA;IAClB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;IAChC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACtC;AAED;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAqB9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rtu-transport.js","sourceRoot":"","sources":["../../../src/rtu-transport.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"rtu-transport.js","sourceRoot":"","sources":["../../../src/rtu-transport.ts"],"names":[],"mappings":";;AAkDA,gDAqBC;;AAtED,0EAAqC;AAErC,yDAAoD;AACpD,mDAAkD;AAClD,6EAAoE;AACpE,6DAA+E;AAkC/E;;;;;;;;;GASG;AACI,KAAK,UAAU,kBAAkB,CAAC,MAAiB;IACxD,MAAM,IAAI,GAAG,KAAK,IAAwB,EAAE;QAC1C,MAAM,MAAM,GAAG,IAAI,uBAAS,EAAE,CAAA;QAE9B,yBAAyB;QACzB,MAAM,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,EAAE;YAC3C,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAA;QAEF,IAAA,kCAAe,EAAC,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;QACvD,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,IAAI,gCAAgB,CAAC,MAAM,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACxE,OAAO,IAAA,uCAAkB,EACvB,IAAA,kDAAqB,EAAC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EACnE,GAAG,MAAM,CAAC,IAAI,IAAI,IAAA,yCAAoB,EAAC,MAAM,CAAC,WAAW,MAAM,CAAC,OAAO,EAAE,CAC1E,CAAA;AACH,CAAC"}
|
|
@@ -2,6 +2,7 @@ import type { Transport } from '@ya-modbus/driver-types';
|
|
|
2
2
|
import type { Mutex } from 'async-mutex';
|
|
3
3
|
import type ModbusRTU from 'modbus-serial';
|
|
4
4
|
import { type ModbusConnection } from './connection.js';
|
|
5
|
+
import { LastRequest } from './last-request.js';
|
|
5
6
|
import { type RetryLogger } from './retry.js';
|
|
6
7
|
/**
|
|
7
8
|
* SlaveTransport wraps a shared ModbusRTU client with slave-specific addressing.
|
|
@@ -13,6 +14,10 @@ import { type RetryLogger } from './retry.js';
|
|
|
13
14
|
* Requests on a lost connection reject with a ConnectionLostError. When the shared
|
|
14
15
|
* ModbusConnection can reopen its client, all devices on the connection use the new client.
|
|
15
16
|
*
|
|
17
|
+
* With an `interDeviceDelay` and a LastRequest shared by the transports on the connection, a
|
|
18
|
+
* request waits after a request to another slave. Some meters do not answer a request that
|
|
19
|
+
* comes too soon after another meter's reply.
|
|
20
|
+
*
|
|
16
21
|
* @example
|
|
17
22
|
* ```typescript
|
|
18
23
|
* const client = new ModbusRTU()
|
|
@@ -34,6 +39,8 @@ export declare class SlaveTransport implements Transport {
|
|
|
34
39
|
private readonly mutex;
|
|
35
40
|
private readonly maxRetries;
|
|
36
41
|
private readonly logger?;
|
|
42
|
+
private readonly interDeviceDelay;
|
|
43
|
+
private readonly lastRequest;
|
|
37
44
|
private readonly connection;
|
|
38
45
|
/**
|
|
39
46
|
* @param slaveId - Modbus slave/unit ID for this device
|
|
@@ -41,8 +48,13 @@ export declare class SlaveTransport implements Transport {
|
|
|
41
48
|
* @param mutex - Shared mutex for serializing operations on the bus
|
|
42
49
|
* @param maxRetries - Maximum retry attempts for failed operations (default: 3)
|
|
43
50
|
* @param logger - Optional callback to log retry attempts
|
|
51
|
+
* @param interDeviceDelay - Pause in milliseconds before a request to this slave when the
|
|
52
|
+
* previous request on the connection went to another slave, counted from the end of that
|
|
53
|
+
* request (default: 0, no pause)
|
|
54
|
+
* @param lastRequest - Last request on the connection, the same for all transports that share
|
|
55
|
+
* the mutex. interDeviceDelay needs it.
|
|
44
56
|
*/
|
|
45
|
-
constructor(slaveId: number, client: ModbusConnection | ModbusRTU, mutex: Mutex, maxRetries?: number, logger?: RetryLogger | undefined);
|
|
57
|
+
constructor(slaveId: number, client: ModbusConnection | ModbusRTU, mutex: Mutex, maxRetries?: number, logger?: RetryLogger | undefined, interDeviceDelay?: number, lastRequest?: LastRequest);
|
|
46
58
|
readHoldingRegisters(address: number, count: number): Promise<Buffer>;
|
|
47
59
|
readInputRegisters(address: number, count: number): Promise<Buffer>;
|
|
48
60
|
readCoils(address: number, count: number): Promise<Buffer>;
|
|
@@ -63,5 +75,10 @@ export declare class SlaveTransport implements Transport {
|
|
|
63
75
|
* TransportManager.closeAll() at shutdown.
|
|
64
76
|
*/
|
|
65
77
|
close(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Run a request to this slave while no other request uses the bus: wait for the pause after
|
|
80
|
+
* a request to another slave, then send it with retries
|
|
81
|
+
*/
|
|
82
|
+
private request;
|
|
66
83
|
}
|
|
67
84
|
//# sourceMappingURL=slave-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slave-transport.d.ts","sourceRoot":"","sources":["../../../src/slave-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,SAAS,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"slave-transport.d.ts","sourceRoot":"","sources":["../../../src/slave-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,SAAS,MAAM,eAAe,CAAA;AAG1C,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,cAAe,YAAW,SAAS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