modbus-rs 0.13.0 → 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 (4) hide show
  1. package/README.md +47 -26
  2. package/index.d.ts +85 -47
  3. package/index.js +55 -52
  4. package/package.json +6 -6
package/README.md CHANGED
@@ -21,19 +21,23 @@ npm install modbus-rs
21
21
 
22
22
  ## Quick Start
23
23
 
24
+ ### Examples
25
+ [https://github.com/Raghava-Ch/modbus-rs/tree/main/mbus-ffi/nodejs/examples](https://github.com/Raghava-Ch/modbus-rs/tree/main/mbus-ffi/nodejs/examples)
26
+
24
27
  ### TCP Client
25
28
 
26
29
  ```javascript
27
- const { AsyncTcpModbusClient } = require('modbus-rs');
30
+ const { AsyncTcpTransport } = require('modbus-rs');
28
31
 
29
32
  async function main() {
30
- const client = await AsyncTcpModbusClient.connect({
33
+ const transport = await AsyncTcpTransport.connect({
31
34
  host: '127.0.0.1',
32
35
  port: 502,
33
- unitId: 1,
34
36
  timeoutMs: 5000,
35
37
  });
36
38
 
39
+ const client = transport.createClient({ unitId: 1 });
40
+
37
41
  try {
38
42
  // Read holding registers (FC03)
39
43
  const registers = await client.readHoldingRegisters({
@@ -48,7 +52,7 @@ async function main() {
48
52
  value: 12345,
49
53
  });
50
54
  } finally {
51
- await client.close();
55
+ await transport.close();
52
56
  }
53
57
  }
54
58
 
@@ -58,18 +62,19 @@ main().catch(console.error);
58
62
  ### Serial RTU Client
59
63
 
60
64
  ```javascript
61
- const { AsyncSerialModbusClient } = require('modbus-rs');
65
+ const { AsyncRtuTransport } = require('modbus-rs');
62
66
 
63
67
  async function main() {
64
- const client = await AsyncSerialModbusClient.connectRtu({
68
+ const transport = await AsyncRtuTransport.open({
65
69
  portPath: '/dev/ttyUSB0',
66
- unitId: 1,
67
70
  baudRate: 19200,
68
71
  dataBits: 8,
69
72
  stopBits: 1,
70
73
  parity: 'even',
71
74
  });
72
75
 
76
+ const client = transport.createClient({ unitId: 1 });
77
+
73
78
  try {
74
79
  const registers = await client.readHoldingRegisters({
75
80
  address: 0,
@@ -77,7 +82,7 @@ async function main() {
77
82
  });
78
83
  console.log('Registers:', registers);
79
84
  } finally {
80
- await client.close();
85
+ await transport.close();
81
86
  }
82
87
  }
83
88
 
@@ -91,16 +96,15 @@ const { AsyncTcpModbusServer } = require('modbus-rs');
91
96
 
92
97
  const holdingRegisters = new Array(1000).fill(0);
93
98
 
94
- async function main() {
95
- const server = await AsyncTcpModbusServer.bind(
96
- { host: '0.0.0.0', port: 502 },
99
+ function main() {
100
+ const server = AsyncTcpModbusServer.bind(
101
+ { host: '0.0.0.0', port: 502, unitId: 1 },
97
102
  {
98
103
  onReadHoldingRegisters: (req) => {
99
- return holdingRegisters.slice(req.address, req.address + req.count);
104
+ return holdingRegisters.slice(req.address, req.address + req.quantity);
100
105
  },
101
106
  onWriteSingleRegister: (req) => {
102
107
  holdingRegisters[req.address] = req.value;
103
- return true;
104
108
  },
105
109
  }
106
110
  );
@@ -113,7 +117,11 @@ async function main() {
113
117
  });
114
118
  }
115
119
 
116
- main().catch(console.error);
120
+ try {
121
+ main();
122
+ } catch (err) {
123
+ console.error(err);
124
+ }
117
125
  ```
118
126
 
119
127
  ### TCP Gateway
@@ -149,10 +157,30 @@ main().catch(console.error);
149
157
 
150
158
  ## API Reference
151
159
 
152
- ### AsyncTcpModbusClient
160
+ ### AsyncTcpTransport
161
+
162
+ - `static connect(opts: TcpTransportOptions): Promise<AsyncTcpTransport>` - Connect to a Modbus TCP server
163
+ - `close(): Promise<void>` - Close the connection
164
+ - `reconnect(): Promise<void>` - Re-establish the connection
165
+ - `createClient(opts?: CreateClientOptions): AsyncTcpModbusClient` - Create a logical client instance bound to a specific unit ID (defaults to `1`)
166
+ - `setRequestTimeout(ms: number): void` - Set a global request timeout (in milliseconds)
167
+ - `clearRequestTimeout(): void` - Clear the global request timeout
168
+ - `pendingRequests: boolean` - (Getter) Returns whether there are requests currently in flight
169
+
170
+ ### AsyncRtuTransport / AsyncAsciiTransport
171
+
172
+ - `static open(opts: RtuTransportOptions | AsciiTransportOptions): Promise<AsyncRtuTransport | AsyncAsciiTransport>` - Open the serial port
173
+ - `close(): Promise<void>` - Close the connection
174
+ - `reconnect(): Promise<void>` - Re-establish the connection
175
+ - `createClient(opts: CreateClientOptions): AsyncSerialModbusClient` - Create a logical client instance bound to a specific unit ID (required)
176
+ - `setRequestTimeout(ms: number): void` - Set a global request timeout (in milliseconds)
177
+ - `clearRequestTimeout(): void` - Clear the global request timeout
178
+ - `pendingRequests: boolean` - (Getter) Returns whether there are requests currently in flight
179
+
180
+ ### AsyncTcpModbusClient / AsyncSerialModbusClient
181
+
182
+ These logical clients contain all the Modbus function code methods:
153
183
 
154
- - `connect(opts: TcpClientOptions)` - Connect to a Modbus TCP server
155
- - `close()` - Close the connection
156
184
  - `readCoils(opts)` - FC01: Read Coils
157
185
  - `readDiscreteInputs(opts)` - FC02: Read Discrete Inputs
158
186
  - `readHoldingRegisters(opts)` - FC03: Read Holding Registers
@@ -169,13 +197,6 @@ main().catch(console.error);
169
197
  - `diagnostics(opts)` - FC08: Diagnostics
170
198
  - `readDeviceIdentification(opts)` - FC43/14: Read Device Identification
171
199
 
172
- ### AsyncSerialModbusClient
173
-
174
- Same methods as `AsyncTcpModbusClient`, with different connection options:
175
-
176
- - `connectRtu(opts: SerialClientOptions)` - Connect using Modbus RTU
177
- - `connectAscii(opts: SerialClientOptions)` - Connect using Modbus ASCII
178
-
179
200
  ### AsyncTcpModbusServer
180
201
 
181
202
  - `bind(opts, handlers)` - Create and start a TCP server
@@ -192,7 +213,7 @@ All errors are thrown as JavaScript Error objects with descriptive messages:
192
213
 
193
214
  ```javascript
194
215
  try {
195
- await client.readHoldingRegisters({ address: 0, count: 10 });
216
+ await client.readHoldingRegisters({ address: 0, quantity: 10 });
196
217
  } catch (err) {
197
218
  if (err.message.includes('MODBUS_EXCEPTION')) {
198
219
  console.error('Modbus exception:', err.message);
@@ -211,7 +232,7 @@ Pre-built binaries are published for:
211
232
  - Linux x64 (glibc), Linux arm64 (glibc)
212
233
  - macOS x64, macOS arm64
213
234
  - Windows x64 (MSVC)
214
- - WebAssembly `modbus-rs-wasm`
235
+ - WebAssembly [modbus-rs-wasm](https://www.npmjs.com/package/modbus-rs-wasm)
215
236
 
216
237
  Other targets can be built locally via `cargo build -p mbus-ffi --features nodejs,full`
217
238
  followed by `npm run build`.
package/index.d.ts CHANGED
@@ -1,21 +1,43 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
- /** Async Modbus Serial client supporting RTU and ASCII transports. */
4
- export declare class AsyncSerialModbusClient {
5
- /** Creates and connects a new Serial RTU client. */
6
- static connectRtu(opts: SerialClientOptions): Promise<AsyncSerialModbusClient>
7
- /** Creates and connects a new Serial ASCII client. */
8
- static connectAscii(opts: SerialClientOptions): Promise<AsyncSerialModbusClient>
3
+ /** Physical serial port in ASCII mode. Factory for device clients. */
4
+ export declare class AsyncAsciiTransport {
5
+ /** Opens the serial port in ASCII mode. */
6
+ static open(opts: AsciiTransportOptions): Promise<AsyncAsciiTransport>
7
+ /** Creates a device client bound to the specified unit ID. */
8
+ createClient(opts: CreateClientOptions): AsyncSerialModbusClient
9
+ /** Sets the per-request timeout in milliseconds. */
10
+ setRequestTimeout(timeoutMs: number): void
11
+ /** Clears the per-request timeout. */
12
+ clearRequestTimeout(): void
13
+ /** Returns whether there are pending requests. */
14
+ get pendingRequests(): boolean
15
+ /** Closes the transport. */
16
+ close(): Promise<void>
17
+ /** Reconnects the transport after a disconnect. */
18
+ reconnect(): Promise<void>
19
+ }
20
+
21
+ /** Physical serial port in RTU mode. Factory for device clients. */
22
+ export declare class AsyncRtuTransport {
23
+ /** Opens the serial port in RTU mode. */
24
+ static open(opts: RtuTransportOptions): Promise<AsyncRtuTransport>
25
+ /** Creates a device client bound to the specified unit ID. */
26
+ createClient(opts: CreateClientOptions): AsyncSerialModbusClient
9
27
  /** Sets the per-request timeout in milliseconds. */
10
28
  setRequestTimeout(timeoutMs: number): void
11
29
  /** Clears the per-request timeout. */
12
30
  clearRequestTimeout(): void
13
31
  /** Returns whether there are pending requests. */
14
32
  get pendingRequests(): boolean
15
- /** Closes the client connection. */
33
+ /** Closes the transport. */
16
34
  close(): Promise<void>
17
- /** Reconnects the client after a disconnect. */
35
+ /** Reconnects the transport after a disconnect. */
18
36
  reconnect(): Promise<void>
37
+ }
38
+
39
+ /** Lightweight device client sharing the serial transport. */
40
+ export declare class AsyncSerialModbusClient {
19
41
  /** Reads holding registers (FC03). */
20
42
  readHoldingRegisters(opts: ReadRegistersOptions): Promise<number[]>
21
43
  /** Reads input registers (FC04). */
@@ -76,30 +98,8 @@ export declare class AsyncTcpGateway {
76
98
  shutdown(): Promise<void>
77
99
  }
78
100
 
79
- /**
80
- * Async Modbus TCP client.
81
- *
82
- * All methods are async and return Promises. The client must be connected
83
- * before issuing Modbus requests.
84
- */
101
+ /** Lightweight device client sharing the TCP transport. */
85
102
  export declare class AsyncTcpModbusClient {
86
- /**
87
- * Creates and connects a new TCP client.
88
- *
89
- * @param opts - Connection options including host, port, unitId, and optional timeout.
90
- * @returns A connected client instance.
91
- */
92
- static connect(opts: TcpClientOptions): Promise<AsyncTcpModbusClient>
93
- /** Sets the per-request timeout in milliseconds. */
94
- setRequestTimeout(timeoutMs: number): void
95
- /** Clears the per-request timeout. */
96
- clearRequestTimeout(): void
97
- /** Returns whether there are pending requests. */
98
- get pendingRequests(): boolean
99
- /** Closes the client connection. */
100
- close(): Promise<void>
101
- /** Reconnects the client after a disconnect. */
102
- reconnect(): Promise<void>
103
103
  /** Reads holding registers (FC03). */
104
104
  readHoldingRegisters(opts: ReadRegistersOptions): Promise<number[]>
105
105
  /** Reads input registers (FC04). */
@@ -150,6 +150,48 @@ export declare class AsyncTcpModbusServer {
150
150
  shutdown(): Promise<void>
151
151
  }
152
152
 
153
+ /** Physical TCP socket connection to a Modbus device or gateway. */
154
+ export declare class AsyncTcpTransport {
155
+ /** Connects to a Modbus TCP device or gateway. */
156
+ static connect(opts: TcpTransportOptions): Promise<AsyncTcpTransport>
157
+ /** Creates a device client bound to the specified unit ID. */
158
+ createClient(opts?: CreateClientOptions | undefined | null): AsyncTcpModbusClient
159
+ /** Sets the per-request timeout in milliseconds. */
160
+ setRequestTimeout(timeoutMs: number): void
161
+ /** Clears the per-request timeout. */
162
+ clearRequestTimeout(): void
163
+ /** Returns whether there are pending requests. */
164
+ get pendingRequests(): boolean
165
+ /** Closes the connection. */
166
+ close(): Promise<void>
167
+ /** Reconnects the transport after a disconnect. */
168
+ reconnect(): Promise<void>
169
+ }
170
+
171
+ /** Connection options for the serial ASCII transport. */
172
+ export interface AsciiTransportOptions {
173
+ /** Serial port path (e.g., "/dev/ttyUSB0", "COM3"). */
174
+ portPath: string
175
+ /** Baud rate (e.g., 9600, 19200, 38400, 57600, 115200). */
176
+ baudRate: number
177
+ /** Data bits (5, 6, 7, or 8). */
178
+ dataBits?: number
179
+ /** Parity ("none", "even", "odd"). */
180
+ parity?: string
181
+ /** Stop bits (1 or 2). */
182
+ stopBits?: number
183
+ /** Response timeout in milliseconds. */
184
+ responseTimeoutMs?: number
185
+ /** Per-request timeout in milliseconds. */
186
+ requestTimeoutMs?: number
187
+ }
188
+
189
+ /** Options for creating a device client. */
190
+ export interface CreateClientOptions {
191
+ /** Modbus unit ID (1-247). */
192
+ unitId?: number
193
+ }
194
+
153
195
  /** Device identification object. */
154
196
  export interface DeviceIdentificationObject {
155
197
  /** Object ID. */
@@ -349,8 +391,8 @@ export interface RouteEntry {
349
391
  channel: number
350
392
  }
351
393
 
352
- /** Connection options for the serial client. */
353
- export interface SerialClientOptions {
394
+ /** Connection options for the serial RTU transport. */
395
+ export interface RtuTransportOptions {
354
396
  /** Serial port path (e.g., "/dev/ttyUSB0", "COM3"). */
355
397
  portPath: string
356
398
  /** Baud rate (e.g., 9600, 19200, 38400, 57600, 115200). */
@@ -361,8 +403,6 @@ export interface SerialClientOptions {
361
403
  parity?: string
362
404
  /** Stop bits (1 or 2). */
363
405
  stopBits?: number
364
- /** Modbus unit ID (1-247). */
365
- unitId: number
366
406
  /** Response timeout in milliseconds. */
367
407
  responseTimeoutMs?: number
368
408
  /** Per-request timeout in milliseconds. */
@@ -399,18 +439,6 @@ export interface ServerExceptionResponse {
399
439
  exception?: number
400
440
  }
401
441
 
402
- /** Connection options for the TCP client. */
403
- export interface TcpClientOptions {
404
- /** Target host address (IP or hostname). */
405
- host: string
406
- /** Target TCP port (typically 502). */
407
- port: number
408
- /** Modbus unit ID (1-247). */
409
- unitId: number
410
- /** Per-request timeout in milliseconds (optional). */
411
- timeoutMs?: number
412
- }
413
-
414
442
  /** Server bind options. */
415
443
  export interface TcpServerOptions {
416
444
  /** Bind host address (e.g., "0.0.0.0"). */
@@ -421,6 +449,16 @@ export interface TcpServerOptions {
421
449
  unitId: number
422
450
  }
423
451
 
452
+ /** Connection options for the TCP transport. */
453
+ export interface TcpTransportOptions {
454
+ /** Target host address (IP or hostname). */
455
+ host: string
456
+ /** Target TCP port (typically 502). */
457
+ port: number
458
+ /** Per-request timeout in milliseconds (optional). */
459
+ timeoutMs?: number
460
+ }
461
+
424
462
  /** Options for writing file records. */
425
463
  export interface WriteFileRecordOptions {
426
464
  /** Array of sub-requests. */
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('modbus-rs-android-arm64')
79
79
  const bindingPackageVersion = require('modbus-rs-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('modbus-rs-android-arm-eabi')
95
95
  const bindingPackageVersion = require('modbus-rs-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('modbus-rs-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('modbus-rs-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('modbus-rs-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('modbus-rs-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('modbus-rs-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('modbus-rs-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('modbus-rs-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('modbus-rs-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('modbus-rs-darwin-universal')
184
184
  const bindingPackageVersion = require('modbus-rs-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('modbus-rs-darwin-x64')
200
200
  const bindingPackageVersion = require('modbus-rs-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('modbus-rs-darwin-arm64')
216
216
  const bindingPackageVersion = require('modbus-rs-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('modbus-rs-freebsd-x64')
236
236
  const bindingPackageVersion = require('modbus-rs-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('modbus-rs-freebsd-arm64')
252
252
  const bindingPackageVersion = require('modbus-rs-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('modbus-rs-linux-x64-musl')
273
273
  const bindingPackageVersion = require('modbus-rs-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('modbus-rs-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('modbus-rs-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('modbus-rs-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('modbus-rs-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('modbus-rs-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('modbus-rs-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('modbus-rs-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('modbus-rs-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('modbus-rs-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('modbus-rs-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('modbus-rs-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('modbus-rs-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('modbus-rs-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('modbus-rs-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('modbus-rs-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('modbus-rs-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('modbus-rs-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('modbus-rs-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('modbus-rs-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('modbus-rs-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('modbus-rs-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('modbus-rs-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('modbus-rs-openharmony-arm64')
478
478
  const bindingPackageVersion = require('modbus-rs-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('modbus-rs-openharmony-x64')
494
494
  const bindingPackageVersion = require('modbus-rs-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('modbus-rs-openharmony-arm')
510
510
  const bindingPackageVersion = require('modbus-rs-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.13.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.13.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.14.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.14.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -576,8 +576,11 @@ if (!nativeBinding) {
576
576
  }
577
577
 
578
578
  module.exports = nativeBinding
579
+ module.exports.AsyncAsciiTransport = nativeBinding.AsyncAsciiTransport
580
+ module.exports.AsyncRtuTransport = nativeBinding.AsyncRtuTransport
579
581
  module.exports.AsyncSerialModbusClient = nativeBinding.AsyncSerialModbusClient
580
582
  module.exports.AsyncSerialModbusServer = nativeBinding.AsyncSerialModbusServer
581
583
  module.exports.AsyncTcpGateway = nativeBinding.AsyncTcpGateway
582
584
  module.exports.AsyncTcpModbusClient = nativeBinding.AsyncTcpModbusClient
583
585
  module.exports.AsyncTcpModbusServer = nativeBinding.AsyncTcpModbusServer
586
+ module.exports.AsyncTcpTransport = nativeBinding.AsyncTcpTransport
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modbus-rs",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "High-performance Modbus TCP/RTU/ASCII client, server and gateway for Node.js, powered by Rust",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -64,10 +64,10 @@
64
64
  ],
65
65
  "dependencies": {},
66
66
  "optionalDependencies": {
67
- "modbus-rs-win32-x64-msvc": "0.9.0",
68
- "modbus-rs-linux-x64-gnu": "0.9.0",
69
- "modbus-rs-darwin-x64": "0.9.0",
70
- "modbus-rs-darwin-arm64": "0.9.0",
71
- "modbus-rs-linux-arm64-gnu": "0.9.0"
67
+ "modbus-rs-win32-x64-msvc": "0.14.0",
68
+ "modbus-rs-linux-x64-gnu": "0.14.0",
69
+ "modbus-rs-darwin-x64": "0.14.0",
70
+ "modbus-rs-darwin-arm64": "0.14.0",
71
+ "modbus-rs-linux-arm64-gnu": "0.14.0"
72
72
  }
73
73
  }