@ya-modbus/transport 0.12.2 → 0.14.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +30 -1
  3. package/dist/cjs/src/index.d.ts +1 -0
  4. package/dist/cjs/src/index.d.ts.map +1 -1
  5. package/dist/cjs/src/index.js +3 -1
  6. package/dist/cjs/src/index.js.map +1 -1
  7. package/dist/cjs/src/last-request.d.ts +29 -0
  8. package/dist/cjs/src/last-request.d.ts.map +1 -0
  9. package/dist/cjs/src/last-request.js +44 -0
  10. package/dist/cjs/src/last-request.js.map +1 -0
  11. package/dist/cjs/src/manager.d.ts +6 -3
  12. package/dist/cjs/src/manager.d.ts.map +1 -1
  13. package/dist/cjs/src/manager.js +15 -6
  14. package/dist/cjs/src/manager.js.map +1 -1
  15. package/dist/cjs/src/request-context.d.ts +27 -0
  16. package/dist/cjs/src/request-context.d.ts.map +1 -0
  17. package/dist/cjs/src/request-context.js +81 -0
  18. package/dist/cjs/src/request-context.js.map +1 -0
  19. package/dist/cjs/src/retry.d.ts +7 -0
  20. package/dist/cjs/src/retry.d.ts.map +1 -1
  21. package/dist/cjs/src/retry.js +1 -0
  22. package/dist/cjs/src/retry.js.map +1 -1
  23. package/dist/cjs/src/rtu-transport.d.ts +7 -0
  24. package/dist/cjs/src/rtu-transport.d.ts.map +1 -1
  25. package/dist/cjs/src/rtu-transport.js +2 -1
  26. package/dist/cjs/src/rtu-transport.js.map +1 -1
  27. package/dist/cjs/src/slave-transport.d.ts +18 -1
  28. package/dist/cjs/src/slave-transport.d.ts.map +1 -1
  29. package/dist/cjs/src/slave-transport.js +59 -53
  30. package/dist/cjs/src/slave-transport.js.map +1 -1
  31. package/dist/cjs/src/tcp-transport.d.ts.map +1 -1
  32. package/dist/cjs/src/tcp-transport.js +2 -1
  33. package/dist/cjs/src/tcp-transport.js.map +1 -1
  34. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  35. package/dist/esm/src/index.d.ts +1 -0
  36. package/dist/esm/src/index.d.ts.map +1 -1
  37. package/dist/esm/src/index.js +1 -0
  38. package/dist/esm/src/index.js.map +1 -1
  39. package/dist/esm/src/last-request.d.ts +29 -0
  40. package/dist/esm/src/last-request.d.ts.map +1 -0
  41. package/dist/esm/src/last-request.js +40 -0
  42. package/dist/esm/src/last-request.js.map +1 -0
  43. package/dist/esm/src/manager.d.ts +6 -3
  44. package/dist/esm/src/manager.d.ts.map +1 -1
  45. package/dist/esm/src/manager.js +15 -6
  46. package/dist/esm/src/manager.js.map +1 -1
  47. package/dist/esm/src/request-context.d.ts +27 -0
  48. package/dist/esm/src/request-context.d.ts.map +1 -0
  49. package/dist/esm/src/request-context.js +77 -0
  50. package/dist/esm/src/request-context.js.map +1 -0
  51. package/dist/esm/src/retry.d.ts +7 -0
  52. package/dist/esm/src/retry.d.ts.map +1 -1
  53. package/dist/esm/src/retry.js +1 -1
  54. package/dist/esm/src/retry.js.map +1 -1
  55. package/dist/esm/src/rtu-transport.d.ts +7 -0
  56. package/dist/esm/src/rtu-transport.d.ts.map +1 -1
  57. package/dist/esm/src/rtu-transport.js +2 -1
  58. package/dist/esm/src/rtu-transport.js.map +1 -1
  59. package/dist/esm/src/slave-transport.d.ts +18 -1
  60. package/dist/esm/src/slave-transport.d.ts.map +1 -1
  61. package/dist/esm/src/slave-transport.js +59 -53
  62. package/dist/esm/src/slave-transport.js.map +1 -1
  63. package/dist/esm/src/tcp-transport.d.ts.map +1 -1
  64. package/dist/esm/src/tcp-transport.js +2 -1
  65. package/dist/esm/src/tcp-transport.js.map +1 -1
  66. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  67. 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.0](https://github.com/groupsky/ya-modbus/compare/@ya-modbus/transport@0.13.0...@ya-modbus/transport@0.14.0) (2026-10-15)
7
+
8
+ ### Features
9
+
10
+ - **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)
11
+
12
+ # [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)
13
+
14
+ ### Features
15
+
16
+ - **transport:** name port, slave, function and registers in request errors ([#648](https://github.com/groupsky/ya-modbus/issues/648)) ([48f185c](https://github.com/groupsky/ya-modbus/commit/48f185c0ab2a149f8611055882a101713f0be707)), closes [#605](https://github.com/groupsky/ya-modbus/issues/605)
17
+
6
18
  ## [0.12.2](https://github.com/groupsky/ya-modbus/compare/@ya-modbus/transport@0.12.1...@ya-modbus/transport@0.12.2) (2026-10-15)
7
19
 
8
20
  ### Bug Fixes
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`
@@ -118,6 +134,18 @@ try {
118
134
 
119
135
  `normalizeModbusError(error)` applies the same conversion to any caught value.
120
136
 
137
+ ### Errors of failed requests
138
+
139
+ Only `TransportManager.getTransport()`, `createRTUTransport()` and `createTCPTransport()` add the
140
+ details (not `SlaveTransport` or `createModbusTransport()` used directly) of the request to the message of a failed request, after all retries. The message ends with
141
+ the port or host, serial settings, slave ID, function code, start address and count, for example
142
+ `Timed out (/dev/ttyUSB0 9600 8E1, slave 1, FC03 read holding registers, address 16 (0x0010), count 2)`
143
+ or `Timed out (192.168.1.10:502, slave 1, FC04 read input registers, address 0 (0x0000), count 10)`.
144
+ The serial settings are baud rate, data bits, parity and stop bits. `name`, `code`, `errno`,
145
+ `modbusCode` and `cause` are those of the original error. The retry logger gets the errors without
146
+ details. A timeout can also mean wrong serial settings or a register that the device does not
147
+ have, because many devices do not answer then.
148
+
121
149
  ### Lost connections
122
150
 
123
151
  When a USB serial adapter is unplugged or a TCP connection closes, `modbus-serial` emits a
@@ -128,7 +156,8 @@ so the process does not crash. The connection is then lost:
128
156
  - Later requests reject at once, without using the port.
129
157
  - The error has the name `ConnectionLostError` and a message like
130
158
  `Connection to /dev/ttyUSB0 lost: port closed`, or
131
- `Connection to /dev/ttyUSB0 lost: EIO: i/o error, write` when a write failed. The underlying
159
+ `Connection to /dev/ttyUSB0 lost: EIO: i/o error, write` when a write failed (followed by the
160
+ details of the request, as above). The underlying
132
161
  error is in `cause`. `code` and `errno` are set only when the underlying error is a Node.js
133
162
  system error, for example `ECONNREFUSED` when a TCP connection cannot be opened again.
134
163
 
@@ -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"}
@@ -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,qGAAA,SAAS,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,0GAAA,cAAc,OAAA;AAC/C,2DAA6E;AAApE,0HAAA,oBAAoB,OAAA;AAC7B,iDAA0F;AAAjF,sHAAA,qBAAqB,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAChD,2CAAkG;AAAzF,8GAAA,gBAAgB,OAAA;AACzB,2DAAqD;AAA5C,oHAAA,cAAc,OAAA;AACvB,2DAAqD;AAA5C,oHAAA,cAAc,OAAA;AACvB,mEAA+D;AAAtD,8HAAA,oBAAoB,OAAA;AAC7B,qDAK0B;AAJxB,kHAAA,eAAe,OAAA;AACf,mHAAA,gBAAgB,OAAA"}
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,qGAAA,SAAS,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,0GAAA,cAAc,OAAA;AAC/C,2DAA6E;AAApE,0HAAA,oBAAoB,OAAA;AAC7B,iDAA0F;AAAjF,sHAAA,qBAAqB,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAChD,2CAAkG;AAAzF,8GAAA,gBAAgB,OAAA;AACzB,2DAAqD;AAA5C,oHAAA,cAAc,OAAA;AACvB,2DAAqD;AAA5C,oHAAA,cAAc,OAAA;AACvB,qDAA+C;AAAtC,8GAAA,WAAW,OAAA;AACpB,mEAA+D;AAAtD,8HAAA,oBAAoB,OAAA;AAC7B,qDAK0B;AAJxB,kHAAA,eAAe,OAAA;AACf,mHAAA,gBAAgB,OAAA"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 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"}
@@ -30,9 +30,11 @@ export interface TransportStats {
30
30
  * - Pools modbus-serial clients by physical connection (excluding slave ID)
31
31
  * - RTU clients are pooled by bus configuration (port, baud rate, parity, etc.)
32
32
  * - TCP clients are pooled by host and port
33
- * - Returns SlaveTransport instances that set the slave ID before each operation
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)
@@ -63,11 +65,12 @@ export declare class TransportManager {
63
65
  constructor(options?: TransportManagerOptions);
64
66
  /**
65
67
  * Get or create a transport for the given configuration.
66
- * Returns a new SlaveTransport instance bound to the slave ID in the config.
68
+ * Returns a new Transport bound to the slave ID in the config.
67
69
  * Multiple devices on the same physical connection share the same client and mutex.
68
70
  *
69
71
  * @param config - RTU or TCP transport configuration
70
- * @returns SlaveTransport instance for the specific slave device
72
+ * @returns Transport for the specific slave device. It wraps a SlaveTransport, and the
73
+ * message of a failed request ends with the port, slave, function and registers.
71
74
  * @throws When the port cannot be opened, unless the `startLost` option is set
72
75
  */
73
76
  getTransport(config: TransportConfig): Promise<Transport>;
@@ -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;AACzE,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAc7E;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,gBAAgB;IAOf,OAAO,CAAC,QAAQ,C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;IACrB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,gBAAgB;IAOf,OAAO,CAAC,QAAQ,CAAC,OAAO;IANpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqC;IAEjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8C;IAEtE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;gBAEtB,OAAO,GAAE,uBAA4B;IAElE;;;;;;;;;OASG;IACG,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC;IA+B/D;;;;;;;;;;;OAWG;IACG,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAc3D;;;;;;OAMG;YACW,cAAc;IA4B5B;;;;;;OAMG;IACH,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,GAAG,SAAS;IAIpE;;;;OAIG;IACH,QAAQ,IAAI,cAAc;IAS1B;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B;;;;;OAKG;YACW,eAAe;IAQ7B;;;;;;;;OAQG;IACH,OAAO,CAAC,wBAAwB;IAShC;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAIjB;;;;;;OAMG;YACW,eAAe;IAe7B;;;;;;OAMG;YACW,eAAe;IAU7B;;;;;OAKG;IACH,OAAO,CAAC,WAAW;CAGpB"}
@@ -6,7 +6,9 @@ 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");
11
+ const request_context_js_1 = require("./request-context.js");
10
12
  const slave_transport_js_1 = require("./slave-transport.js");
11
13
  /**
12
14
  * TransportManager pools modbus-serial clients and provides slave-specific transports.
@@ -15,9 +17,11 @@ const slave_transport_js_1 = require("./slave-transport.js");
15
17
  * - Pools modbus-serial clients by physical connection (excluding slave ID)
16
18
  * - RTU clients are pooled by bus configuration (port, baud rate, parity, etc.)
17
19
  * - TCP clients are pooled by host and port
18
- * - Returns SlaveTransport instances that set the slave ID before each operation
20
+ * - Returns Transport objects (SlaveTransport wrapped with request details in errors) that set the slave ID before each operation
19
21
  * - Multiple devices on the same connection share a single client and mutex
20
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
21
25
  * - A lost connection (USB adapter unplugged, TCP connection closed) drops the client.
22
26
  * The first request after a backoff opens a new client for all devices on the
23
27
  * connection (see ModbusConnection)
@@ -51,11 +55,12 @@ class TransportManager {
51
55
  }
52
56
  /**
53
57
  * Get or create a transport for the given configuration.
54
- * Returns a new SlaveTransport instance bound to the slave ID in the config.
58
+ * Returns a new Transport bound to the slave ID in the config.
55
59
  * Multiple devices on the same physical connection share the same client and mutex.
56
60
  *
57
61
  * @param config - RTU or TCP transport configuration
58
- * @returns SlaveTransport instance for the specific slave device
62
+ * @returns Transport for the specific slave device. It wraps a SlaveTransport, and the
63
+ * message of a failed request ends with the port, slave, function and registers.
59
64
  * @throws When the port cannot be opened, unless the `startLost` option is set
60
65
  */
61
66
  async getTransport(config) {
@@ -71,9 +76,12 @@ class TransportManager {
71
76
  entry = await opening;
72
77
  }
73
78
  // Return a new SlaveTransport for this specific slave
74
- const transport = new slave_transport_js_1.SlaveTransport(config.slaveId, entry.connection, entry.mutex, config.maxRetries ?? 3, config.logger);
75
- entry.transports.add(transport);
76
- return transport;
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);
80
+ const target = this.getTarget(config);
81
+ const where = this.isRTUConfig(config) ? `${target} ${(0, request_context_js_1.formatSerialSettings)(config)}` : target;
82
+ const described = (0, request_context_js_1.withRequestContext)(transport, `${where}, slave ${config.slaveId}`);
83
+ entry.transports.add(described);
84
+ return described;
77
85
  }
78
86
  /**
79
87
  * Release the transport of a device that does not use it any more, for example a device
@@ -127,6 +135,7 @@ class TransportManager {
127
135
  const entry = {
128
136
  connection,
129
137
  mutex: new async_mutex_1.Mutex(),
138
+ lastRequest: new last_request_js_1.LastRequest(),
130
139
  config,
131
140
  isRTU,
132
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,6DAAqD;AAqCrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;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;;;;;;;;OAQG;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,CAAC;YACX,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,MA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AC,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"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Context for failed requests: which port, slave, function and registers
3
+ */
4
+ import type { Transport } from '@ya-modbus/driver-types';
5
+ /**
6
+ * Serial settings in the usual short form, from the settings that are present
7
+ *
8
+ * @example formatSerialSettings({ baudRate: 9600, dataBits: 8, parity: 'even', stopBits: 1 }) // '9600 8E1'
9
+ */
10
+ export declare function formatSerialSettings(settings: {
11
+ baudRate?: number | undefined;
12
+ dataBits?: number | undefined;
13
+ parity?: string | undefined;
14
+ stopBits?: number | undefined;
15
+ }): string;
16
+ /**
17
+ * Wrap a Transport so that a failed request says where it went
18
+ *
19
+ * The error message gets the label and the request appended, for example
20
+ * `Timed out (/dev/ttyUSB0 9600 8E1, slave 1, FC03 read holding registers, address 16 (0x0010), count 2)`.
21
+ * Retries of the wrapped transport are not changed.
22
+ *
23
+ * @param transport - Transport to wrap
24
+ * @param label - Port or host, serial settings and slave, shown in the message
25
+ */
26
+ export declare function withRequestContext(transport: Transport, label: string): Transport;
27
+ //# sourceMappingURL=request-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../../src/request-context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AA2BxD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE;IAC7C,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,GAAG,MAAM,CAIT;AAsBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAoBjF"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * Context for failed requests: which port, slave, function and registers
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatSerialSettings = formatSerialSettings;
7
+ exports.withRequestContext = withRequestContext;
8
+ const normalize_error_js_1 = require("./normalize-error.js");
9
+ /** How each request of a Transport is named in error messages, and how many items it covers */
10
+ const REQUESTS = {
11
+ readCoils: { code: 1, name: 'read coils', count: (n) => n },
12
+ readDiscreteInputs: { code: 2, name: 'read discrete inputs', count: (n) => n },
13
+ readHoldingRegisters: { code: 3, name: 'read holding registers', count: (n) => n },
14
+ readInputRegisters: { code: 4, name: 'read input registers', count: (n) => n },
15
+ writeSingleCoil: { code: 5, name: 'write single coil', count: () => 1 },
16
+ writeSingleRegister: { code: 6, name: 'write single register', count: () => 1 },
17
+ writeMultipleCoils: {
18
+ code: 15,
19
+ name: 'write multiple coils',
20
+ count: (values) => values.length * 8,
21
+ },
22
+ writeMultipleRegisters: {
23
+ code: 16,
24
+ name: 'write multiple registers',
25
+ count: (values) => values.length / 2,
26
+ },
27
+ };
28
+ /**
29
+ * Serial settings in the usual short form, from the settings that are present
30
+ *
31
+ * @example formatSerialSettings({ baudRate: 9600, dataBits: 8, parity: 'even', stopBits: 1 }) // '9600 8E1'
32
+ */
33
+ function formatSerialSettings(settings) {
34
+ const { baudRate, dataBits, parity, stopBits } = settings;
35
+ const frame = `${dataBits ?? ''}${parity?.charAt(0).toUpperCase() ?? ''}${stopBits ?? ''}`;
36
+ return [baudRate, frame].filter((part) => part !== undefined && part !== '').join(' ');
37
+ }
38
+ /**
39
+ * Copy of an error with a new message
40
+ *
41
+ * Name, code, errno, modbusCode and cause stay, and the stack starts with the new message.
42
+ * The error is copied because a lost connection rejects all requests with the same
43
+ * object, and the details of one request must not pile up on it.
44
+ */
45
+ function withMessage(error, message) {
46
+ const copy = Object.assign(new Error(message, error.cause === undefined ? undefined : { cause: error.cause }), error);
47
+ copy.message = message;
48
+ copy.name = error.name;
49
+ if (error.stack !== undefined && error.message !== '') {
50
+ copy.stack = error.stack.replace(error.message, () => message);
51
+ }
52
+ return copy;
53
+ }
54
+ /**
55
+ * Wrap a Transport so that a failed request says where it went
56
+ *
57
+ * The error message gets the label and the request appended, for example
58
+ * `Timed out (/dev/ttyUSB0 9600 8E1, slave 1, FC03 read holding registers, address 16 (0x0010), count 2)`.
59
+ * Retries of the wrapped transport are not changed.
60
+ *
61
+ * @param transport - Transport to wrap
62
+ * @param label - Port or host, serial settings and slave, shown in the message
63
+ */
64
+ function withRequestContext(transport, label) {
65
+ const wrapped = { close: () => transport.close() };
66
+ for (const [method, request] of Object.entries(REQUESTS)) {
67
+ wrapped[method] = async (address, value) => {
68
+ try {
69
+ return await transport[method](address, value);
70
+ }
71
+ catch (error) {
72
+ const normalized = (0, normalize_error_js_1.normalizeModbusError)(error);
73
+ const hex = `0x${address.toString(16).toUpperCase().padStart(4, '0')}`;
74
+ const code = String(request.code).padStart(2, '0');
75
+ throw withMessage(normalized, `${normalized.message} (${label}, FC${code} ${request.name}, address ${address} (${hex}), count ${request.count(value)})`);
76
+ }
77
+ };
78
+ }
79
+ return wrapped;
80
+ }
81
+ //# sourceMappingURL=request-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../../src/request-context.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAkCH,oDASC;AAgCD,gDAoBC;AA3FD,6DAA6E;AAE7E,+FAA+F;AAC/F,MAAM,QAAQ,GAGV;IACF,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAW,EAAE;IACrE,kBAAkB,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAW,EAAE;IACxF,oBAAoB,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAW,EAAE;IAC5F,kBAAkB,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAW,EAAE;IACxF,eAAe,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,mBAAmB,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AAC,OAAO,KAAK,KAAK,OAAO,IAAI,IAAI,OAAO,CAAC,IAAI,aAAa,OAAO,KAAK,GAAG,YAAY,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAC1H,CAAA;YACH,CAAC;QACH,CAAC,CAAA;IACH,CAAC;IACD,OAAO,OAA+B,CAAA;AACxC,CAAC"}
@@ -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;AAYjC;;;;;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"}
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"}
@@ -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;;;AAsCH,8BAyBC;AA7DD,6DAA6E;AAE7E,6DAA6D;AAChD,QAAA,WAAW,GAAG,CAAC,CAAA;AAE5B,mDAAmD;AACtC,QAAA,cAAc,GAAG,GAAG,CAAA;AAEjC;;;;;GAKG;AACH,SAAS,KAAK,CAAC,EAAU;IACvB,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,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AAC;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;AAM9F,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;IA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CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAqB9E"}
@@ -6,6 +6,7 @@ const modbus_serial_1 = tslib_1.__importDefault(require("modbus-serial"));
6
6
  const client_config_js_1 = require("./client-config.js");
7
7
  const connection_js_1 = require("./connection.js");
8
8
  const create_modbus_transport_js_1 = require("./create-modbus-transport.js");
9
+ const request_context_js_1 = require("./request-context.js");
9
10
  /**
10
11
  * Create an RTU transport
11
12
  *
@@ -30,6 +31,6 @@ async function createRTUTransport(config) {
30
31
  return client;
31
32
  };
32
33
  const connection = new connection_js_1.ModbusConnection(await open(), config.port, open);
33
- return (0, create_modbus_transport_js_1.createModbusTransport)(connection, config.maxRetries, config.logger);
34
+ return (0, request_context_js_1.withRequestContext)((0, create_modbus_transport_js_1.createModbusTransport)(connection, config.maxRetries, config.logger), `${config.port} ${(0, request_context_js_1.formatSerialSettings)(config)}, slave ${config.slaveId}`);
34
35
  }
35
36
  //# sourceMappingURL=rtu-transport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rtu-transport.js","sourceRoot":"","sources":["../../../src/rtu-transport.ts"],"names":[],"mappings":";;AA0CA,gDAkBC;;AA3DD,0EAAqC;AAErC,yDAAoD;AACpD,mDAAkD;AAClD,6EAAoE;AA2BpE;;;;;;;;;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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M,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;AAE1C,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,cAAe,YAAW,SAAS;IAW5C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAExB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAd1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAE7C;;;;;;OAMG;gBAEgB,OAAO,EAAE,MAAM,EAChC,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACnB,KAAK,EAAE,KAAK,EACZ,UAAU,GAAE,MAAU,E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