@iobroker/modbus 7.7.3 → 7.8.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.
Files changed (31) hide show
  1. package/README.md +11 -0
  2. package/build/index.js +3 -0
  3. package/build/index.js.map +1 -1
  4. package/build/lib/Master.d.ts +5 -0
  5. package/build/lib/Master.js +64 -34
  6. package/build/lib/Master.js.map +1 -1
  7. package/build/lib/Slave.js +30 -0
  8. package/build/lib/Slave.js.map +1 -1
  9. package/build/lib/modbus/modbus-client-core.d.ts +15 -1
  10. package/build/lib/modbus/modbus-client-core.js +108 -23
  11. package/build/lib/modbus/modbus-client-core.js.map +1 -1
  12. package/build/lib/modbus/transports/modbus-client-serial.js +1 -4
  13. package/build/lib/modbus/transports/modbus-client-serial.js.map +1 -1
  14. package/build/lib/modbus/transports/modbus-client-tcp-rtu.js +1 -4
  15. package/build/lib/modbus/transports/modbus-client-tcp-rtu.js.map +1 -1
  16. package/build/lib/modbus/transports/modbus-client-tcp-ssl.d.ts +4 -1
  17. package/build/lib/modbus/transports/modbus-client-tcp-ssl.js +11 -9
  18. package/build/lib/modbus/transports/modbus-client-tcp-ssl.js.map +1 -1
  19. package/build/lib/modbus/transports/modbus-client-tcp.d.ts +4 -1
  20. package/build/lib/modbus/transports/modbus-client-tcp.js +11 -9
  21. package/build/lib/modbus/transports/modbus-client-tcp.js.map +1 -1
  22. package/build/lib/modbus/transports/modbus-client-udp.d.ts +4 -1
  23. package/build/lib/modbus/transports/modbus-client-udp.js +9 -8
  24. package/build/lib/modbus/transports/modbus-client-udp.js.map +1 -1
  25. package/build/lib/modbus/transports/modbus-server-tcp.js +4 -0
  26. package/build/lib/modbus/transports/modbus-server-tcp.js.map +1 -1
  27. package/build/lib/usedResources.d.ts +79 -0
  28. package/build/lib/usedResources.js +207 -0
  29. package/build/lib/usedResources.js.map +1 -0
  30. package/build/types.d.ts +10 -0
  31. package/package.json +6 -6
@@ -0,0 +1,79 @@
1
+ /** A serial port occupied by an instance */
2
+ export interface UsedSerialPort {
3
+ /** Path or name of the port as it is opened, e.g. `/dev/ttyUSB0`, a `/dev/serial/by-id/...` link or `COM3` */
4
+ port: string;
5
+ /** Baud rate the port is opened with */
6
+ baudRate?: number;
7
+ }
8
+ /** A TCP port occupied by an instance */
9
+ export interface UsedTcpPort {
10
+ /** TCP port number */
11
+ port: number;
12
+ /** Address the socket is bound to, `0.0.0.0` or `::` for every interface */
13
+ bind?: string;
14
+ /** Address family, only reported for a concrete bind address */
15
+ family?: 4 | 6;
16
+ }
17
+ /** The resource types this library can occupy, with the payload the registry wants for each */
18
+ interface UsedResourceDataMap {
19
+ serialPort: UsedSerialPort;
20
+ tcpPort: UsedTcpPort;
21
+ }
22
+ /** Kind of an exclusive resource */
23
+ export type UsedResourceType = keyof UsedResourceDataMap;
24
+ /** One entry of the registry, as `checkUsedResource` returns it */
25
+ export interface RegisteredResource<T extends UsedResourceType = UsedResourceType> {
26
+ /** Instance that occupies the resource, e.g. `modbus.1` */
27
+ instance: string;
28
+ /** Whether that instance is running and really holds it now */
29
+ isBlocked: boolean;
30
+ /** What it holds */
31
+ data: UsedResourceDataMap[T];
32
+ }
33
+ /**
34
+ * Report a resource as occupied by this instance.
35
+ *
36
+ * Registering is additive, one call per resource - a proxy that serves TCP while it talks to a
37
+ * serial device reports both. The host drops what this instance registered before whenever it
38
+ * starts, so a stale registration of a previous configuration cannot survive a restart.
39
+ *
40
+ * @param adapter the ioBroker adapter
41
+ * @param type the kind of resource
42
+ * @param data what is occupied
43
+ * @returns whether the host accepted the registration
44
+ */
45
+ export declare function registerUsedResource<T extends UsedResourceType>(adapter: ioBroker.Adapter, type: T, data: UsedResourceDataMap[T]): Promise<boolean>;
46
+ /**
47
+ * Take previously reported resources back.
48
+ *
49
+ * `data` is a filter and not the exact payload: every field it names has to match, fields it leaves
50
+ * out are ignored - so omitting it frees every resource of that type. Freeing on shutdown is not
51
+ * needed, the host marks the entries of a stopped instance as no longer held by itself.
52
+ *
53
+ * @param adapter the ioBroker adapter
54
+ * @param type the kind of resource
55
+ * @param data the fields identifying what to free; everything of this type without it
56
+ * @returns whether the host accepted the request
57
+ */
58
+ export declare function freeUsedResource<T extends UsedResourceType>(adapter: ioBroker.Adapter, type: T, data?: Partial<UsedResourceDataMap[T]>): Promise<boolean>;
59
+ /**
60
+ * Say in the log which other instance holds a resource this adapter is about to open.
61
+ *
62
+ * Asked before opening it: afterwards the operating system has already decided the conflict, and all
63
+ * this could do is improve the wording of the error. The answer is a hint and not a permission - the
64
+ * registry knows what adapters declare, so an empty result does not promise the resource is free,
65
+ * and a program outside ioBroker holding it is not in the registry at all.
66
+ *
67
+ * @param adapter the ioBroker adapter
68
+ * @param type the kind of resource
69
+ * @param data what is about to be opened
70
+ * @param what which part of the adapter wants it, for the log line
71
+ */
72
+ export declare function reportResourceConflict<T extends UsedResourceType>(adapter: ioBroker.Adapter, type: T, data: Partial<UsedResourceDataMap[T]>, what: string): Promise<RegisteredResource<T>[]>;
73
+ /**
74
+ * What a listening server occupies, as the registry wants it.
75
+ *
76
+ * @param address what `server.address()` returned
77
+ */
78
+ export declare function listeningPort(address: unknown): UsedTcpPort | undefined;
79
+ export {};
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ /*
3
+ * Reports the exclusive resources an instance occupies to the per-host registry js-controller 8
4
+ * keeps (`system.host.<hostname>.usedResources.<type>`).
5
+ *
6
+ * The registry answers "who already holds this serial port / this TCP port", so a user configuring a
7
+ * second instance sees what is taken instead of running into EADDRINUSE or "Resource temporarily
8
+ * unavailable". js-controller derives an entry for an adapter that declares nothing, but only from
9
+ * `native.port` - which is no help here: a Modbus adapter keeps its settings in `native.params`, and
10
+ * a master in TCP mode does not occupy a local port at all, it dials a foreign one.
11
+ *
12
+ * So what is reported is what was really opened, once it is open:
13
+ * - master over serial, slave over serial → the serial port
14
+ * - slave over TCP, and the proxy endpoint → the port it listens on
15
+ * - master over TCP/UDP/SSL → nothing, the endpoint belongs to the other side
16
+ *
17
+ * The adapter using this library has to declare that it does this itself, with
18
+ * `"declareUsedResources": true` in the `common` part of its io-package.json. Without it the host
19
+ * refuses the registrations, and this module stays silent.
20
+ *
21
+ * Nothing here is required for Modbus to work - every failure is logged and swallowed.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.registerUsedResource = registerUsedResource;
25
+ exports.freeUsedResource = freeUsedResource;
26
+ exports.reportResourceConflict = reportResourceConflict;
27
+ exports.listeningPort = listeningPort;
28
+ /** Feature a js-controller announces once it maintains the registry. Since js-controller 8. */
29
+ const USED_RESOURCES_FEATURE = 'CONTROLLER_USED_RESOURCES';
30
+ /**
31
+ * Addresses that stand for every interface. A socket bound to one of them occupies the port in both
32
+ * address families (a wildcard listener is dual-stack), so the family must not be reported for it.
33
+ */
34
+ const WILDCARD_ADDRESSES = ['0.0.0.0', '::', '*', ''];
35
+ /**
36
+ * Log without ever throwing.
37
+ *
38
+ * A free arrives while the adapter is being torn down, at which point its logger can already be
39
+ * gone. A throwing log statement in one of these calls would end up as a rejection nobody listens
40
+ * to, which terminates the adapter - a lot of damage for a line that only says a port was reported.
41
+ *
42
+ * @param adapter the ioBroker adapter
43
+ * @param level the log level to write with
44
+ * @param message what to write
45
+ */
46
+ function log(adapter, level, message) {
47
+ try {
48
+ adapter.log[level](message);
49
+ }
50
+ catch {
51
+ // There is nothing left that could report this
52
+ }
53
+ }
54
+ /**
55
+ * How a resource is named in the log.
56
+ *
57
+ * @param type the kind of resource
58
+ * @param data what is occupied
59
+ */
60
+ function describe(type, data) {
61
+ if (type === 'serialPort') {
62
+ return `${data.port}${data.baudRate ? ` @ ${data.baudRate}` : ''}`;
63
+ }
64
+ if (!data.bind) {
65
+ return `${data.port}`;
66
+ }
67
+ return data.bind.includes(':') ? `[${data.bind}]:${data.port}` : `${data.bind}:${data.port}`;
68
+ }
69
+ /**
70
+ * Whether this instance may report its used resources to the host.
71
+ *
72
+ * All three reasons against it are perfectly normal - an older controller, an adapter built against
73
+ * an older `@iobroker/adapter-core`, an adapter that does not declare its resources - so none is
74
+ * worth more than a debug line. A host that knows no `registerUsedResource` does not refuse the
75
+ * call, it simply never answers it, so every single one would first sit out the five second timeout
76
+ * of the adapter API. That is why the feature is asked for before anything is sent.
77
+ *
78
+ * @param adapter the ioBroker adapter
79
+ */
80
+ function canReportUsedResources(adapter) {
81
+ const api = adapter;
82
+ if (typeof api.registerUsedResource !== 'function' || typeof api.freeUsedResource !== 'function') {
83
+ // Told apart from the feature below only to name the half that is missing: this one can be
84
+ // fixed by the adapter, by updating its @iobroker/adapter-core
85
+ log(adapter, 'debug', 'Used resources are not reported: @iobroker/adapter-core is older than js-controller 8');
86
+ return false;
87
+ }
88
+ if (typeof api.supportsFeature !== 'function' || !api.supportsFeature(USED_RESOURCES_FEATURE)) {
89
+ log(adapter, 'debug', `Used resources are not reported: js-controller keeps no registry of used resources (feature "${USED_RESOURCES_FEATURE}")`);
90
+ return false;
91
+ }
92
+ if (adapter.common?.declareUsedResources !== true) {
93
+ // The host would refuse the registration in this case, and asking it first only to be told
94
+ // so costs a message round-trip
95
+ log(adapter, 'debug', 'Used resources are not reported: set "declareUsedResources" to true in the "common" part of io-package.json');
96
+ return false;
97
+ }
98
+ return true;
99
+ }
100
+ /**
101
+ * Report a resource as occupied by this instance.
102
+ *
103
+ * Registering is additive, one call per resource - a proxy that serves TCP while it talks to a
104
+ * serial device reports both. The host drops what this instance registered before whenever it
105
+ * starts, so a stale registration of a previous configuration cannot survive a restart.
106
+ *
107
+ * @param adapter the ioBroker adapter
108
+ * @param type the kind of resource
109
+ * @param data what is occupied
110
+ * @returns whether the host accepted the registration
111
+ */
112
+ async function registerUsedResource(adapter, type, data) {
113
+ if (!canReportUsedResources(adapter)) {
114
+ return false;
115
+ }
116
+ try {
117
+ await adapter.registerUsedResource(type, data);
118
+ log(adapter, 'debug', `Registered ${type} ${describe(type, data)} as used by this instance`);
119
+ return true;
120
+ }
121
+ catch (e) {
122
+ log(adapter, 'warn', `Could not register ${type} ${describe(type, data)} as used: ${e.message}`);
123
+ return false;
124
+ }
125
+ }
126
+ /**
127
+ * Take previously reported resources back.
128
+ *
129
+ * `data` is a filter and not the exact payload: every field it names has to match, fields it leaves
130
+ * out are ignored - so omitting it frees every resource of that type. Freeing on shutdown is not
131
+ * needed, the host marks the entries of a stopped instance as no longer held by itself.
132
+ *
133
+ * @param adapter the ioBroker adapter
134
+ * @param type the kind of resource
135
+ * @param data the fields identifying what to free; everything of this type without it
136
+ * @returns whether the host accepted the request
137
+ */
138
+ async function freeUsedResource(adapter, type, data) {
139
+ if (!canReportUsedResources(adapter)) {
140
+ return false;
141
+ }
142
+ try {
143
+ await adapter.freeUsedResource(type, data);
144
+ log(adapter, 'debug', `Freed ${type} ${data ? describe(type, data) : 'registrations'} of this instance`);
145
+ return true;
146
+ }
147
+ catch (e) {
148
+ log(adapter, 'warn', `Could not free ${type} ${data ? describe(type, data) : 'registrations'}: ${e.message}`);
149
+ return false;
150
+ }
151
+ }
152
+ /**
153
+ * Say in the log which other instance holds a resource this adapter is about to open.
154
+ *
155
+ * Asked before opening it: afterwards the operating system has already decided the conflict, and all
156
+ * this could do is improve the wording of the error. The answer is a hint and not a permission - the
157
+ * registry knows what adapters declare, so an empty result does not promise the resource is free,
158
+ * and a program outside ioBroker holding it is not in the registry at all.
159
+ *
160
+ * @param adapter the ioBroker adapter
161
+ * @param type the kind of resource
162
+ * @param data what is about to be opened
163
+ * @param what which part of the adapter wants it, for the log line
164
+ */
165
+ async function reportResourceConflict(adapter, type, data, what) {
166
+ if (!canReportUsedResources(adapter)) {
167
+ return [];
168
+ }
169
+ let holders;
170
+ try {
171
+ holders = (await adapter.checkUsedResource(type, data)) || [];
172
+ }
173
+ catch (e) {
174
+ log(adapter, 'debug', `Could not ask which instance uses ${type} ${describe(type, data)}: ${e.message}`);
175
+ return [];
176
+ }
177
+ if (holders.length) {
178
+ const running = holders.filter(holder => holder.isBlocked);
179
+ log(adapter, 'warn', `${type === 'serialPort' ? 'Serial port' : 'TCP port'} ${describe(type, data)} for ${what} is declared by ${holders
180
+ .map(holder => holder.instance)
181
+ .join(', ')}${running.length ? '' : ' (not running at the moment)'}`);
182
+ }
183
+ return holders;
184
+ }
185
+ /**
186
+ * What a listening server occupies, as the registry wants it.
187
+ *
188
+ * @param address what `server.address()` returned
189
+ */
190
+ function listeningPort(address) {
191
+ if (!address || typeof address !== 'object') {
192
+ // A pipe or a UNIX socket - no port, and no resource type the registry knows for it
193
+ return undefined;
194
+ }
195
+ const { port, address: bind, family } = address;
196
+ if (typeof port !== 'number') {
197
+ return undefined;
198
+ }
199
+ const data = { port, bind };
200
+ if (bind !== undefined && !WILDCARD_ADDRESSES.includes(bind)) {
201
+ // Named only for a concrete address: on a wildcard one the port is occupied in both families,
202
+ // and the host treats a family it is not told about as "every family", which is exactly that.
203
+ data.family = family === 'IPv6' ? 6 : 4;
204
+ }
205
+ return data;
206
+ }
207
+ //# sourceMappingURL=usedResources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usedResources.js","sourceRoot":"","sources":["../../src/lib/usedResources.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AA0KH,oDAiBC;AAcD,4CAiBC;AAeD,wDA8BC;AAOD,sCAoBC;AAhSD,+FAA+F;AAC/F,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AAE3D;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AA+DtD;;;;;;;;;;GAUG;AACH,SAAS,GAAG,CAAC,OAAyB,EAAE,KAAuB,EAAE,OAAe;IAC5E,IAAI,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACL,+CAA+C;IACnD,CAAC;AACL,CAAC;AASD;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,IAAsB,EAAE,IAA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AC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,8BAA8B,EAAE,CAC3E,CAAC;IACN,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,OAAgB;IAC1C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC1C,oFAAoF;QACpF,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAA+D,CAAC;IACxG,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,IAAI,GAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAEzC,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3D,8FAA8F;QAC9F,8FAA8F;QAC9F,IAAI,CAAC,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}
package/build/types.d.ts CHANGED
@@ -196,6 +196,8 @@ export interface Options {
196
196
  disableLogging?: boolean;
197
197
  /** Enable automatic sanitization of invalid register values */
198
198
  enableSanitization?: boolean;
199
+ /** TCP, SSL, UDP: accept a response with any transaction ID, for devices that do not echo it (issue #829) */
200
+ ignoreTransactionId?: boolean;
199
201
 
200
202
  // Only for slave — read-notify feature
201
203
  /** Expire time in seconds for counter-mode read-notify states; 0 = no expire */
@@ -331,6 +333,12 @@ export interface ModbusParameters {
331
333
  sslAllowSelfSigned?: boolean;
332
334
  /** Enable automatic sanitization of invalid register values (NaN, Infinity, extreme floats, out-of-range) */
333
335
  enableSanitization?: boolean;
336
+ /**
337
+ * TCP, SSL, UDP master: accept a response with any transaction ID. Only for devices that do not echo
338
+ * the transaction ID of the request - otherwise a stale or duplicated answer is taken for the next
339
+ * request and the registers of another block are stored (issue #829)
340
+ */
341
+ ignoreTransactionId?: boolean | 'true';
334
342
 
335
343
  // Slave mode — read-notify feature
336
344
  /** Expire time in seconds for counter-mode states; 0 or omitted = no expire */
@@ -453,6 +461,8 @@ export interface ModbusParametersTyped extends ModbusParameters {
453
461
  disableLogging: boolean;
454
462
  /** Enable automatic sanitization of invalid register values */
455
463
  enableSanitization?: boolean;
464
+ /** TCP, SSL, UDP master: accept a response with any transaction ID, for devices that do not echo it */
465
+ ignoreTransactionId?: boolean | 'true';
456
466
 
457
467
  // Slave mode — read-notify feature
458
468
  notifyOnReadExpire?: number | string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iobroker/modbus",
3
- "version": "7.7.3",
3
+ "version": "7.8.1",
4
4
  "description": "Template for Modbus protocol in ioBroker",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -28,7 +28,7 @@
28
28
  "url": "https://github.com/ioBroker/modbus"
29
29
  },
30
30
  "engines": {
31
- "node": ">=20"
31
+ "node": ">=22.19.0"
32
32
  },
33
33
  "dependencies": {
34
34
  "@iobroker/adapter-core": "^3.4.3",
@@ -37,14 +37,14 @@
37
37
  "devDependencies": {
38
38
  "@alcalzone/release-script": "^5.2.1",
39
39
  "@alcalzone/release-script-plugin-license": "^5.2.2",
40
- "@iobroker/build-tools": "^3.0.1",
40
+ "@iobroker/build-tools": "^3.0.3",
41
41
  "@iobroker/eslint-config": "^2.3.4",
42
42
  "@types/mocha": "^10.0.10",
43
- "@types/node": "^22.20.1",
43
+ "@types/node": "^22.20.4",
44
44
  "@types/serialport": "^10.2.0",
45
- "mocha": "^11.8.0",
45
+ "mocha": "^12.0.2",
46
46
  "ts-node": "^10.9.2",
47
- "typescript": "^6.0.3"
47
+ "typescript": "~6.0.3"
48
48
  },
49
49
  "main": "build/index.js",
50
50
  "files": [