@technoculture/safeserial 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,50 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SafeSerial for Node.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reliable serial messaging with CRC32, fragmentation, and ACK/Retry. Built for Electron and embedded workflows where silent corruption is unacceptable.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @technoculture/safeserial
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
If a prebuilt binary is not available for your platform, it will build from source on install.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Quickstart
|
|
14
14
|
|
|
15
|
-
```
|
|
16
|
-
import { DataBridge } from
|
|
15
|
+
```ts
|
|
16
|
+
import { DataBridge } from "@technoculture/safeserial";
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
const bridge = await DataBridge.open('/dev/ttyUSB0', { baudRate: 115200 });
|
|
18
|
+
const bridge = await DataBridge.open("/dev/ttyUSB0", { baudRate: 115200 });
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
console.log('Received:', data.toString());
|
|
20
|
+
bridge.on("data", (data) => {
|
|
21
|
+
console.log("Received:", data.toString());
|
|
24
22
|
});
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
await bridge.send('Hello, World!');
|
|
28
|
-
|
|
29
|
-
// Close when done
|
|
24
|
+
await bridge.send("Hello, SafeSerial");
|
|
30
25
|
await bridge.close();
|
|
31
26
|
```
|
|
32
27
|
|
|
33
|
-
##
|
|
28
|
+
## Why SafeSerial
|
|
34
29
|
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
30
|
+
- Guaranteed delivery with ACK/Retry
|
|
31
|
+
- CRC32 corruption detection
|
|
32
|
+
- Automatic fragmentation and reassembly
|
|
33
|
+
- Resilient reconnect support
|
|
34
|
+
- Electron-friendly native bindings
|
|
39
35
|
|
|
40
|
-
## API
|
|
36
|
+
## API (Essentials)
|
|
41
37
|
|
|
42
38
|
### `DataBridge.open(port, options?)`
|
|
43
39
|
|
|
44
40
|
Opens a serial port with reliable communication enabled.
|
|
45
41
|
|
|
46
|
-
- `port
|
|
47
|
-
- `options.baudRate
|
|
42
|
+
- `port`: device path (e.g. `/dev/ttyUSB0`, `COM3`)
|
|
43
|
+
- `options.baudRate`: default `115200`
|
|
48
44
|
|
|
49
45
|
Returns: `Promise<DataBridge>`
|
|
50
46
|
|
|
@@ -52,11 +48,11 @@ Returns: `Promise<DataBridge>`
|
|
|
52
48
|
|
|
53
49
|
Sends data with guaranteed delivery.
|
|
54
50
|
|
|
55
|
-
- `data
|
|
51
|
+
- `data`: `Buffer` or `string`
|
|
56
52
|
|
|
57
|
-
Returns: `Promise<void>`
|
|
53
|
+
Returns: `Promise<void>`
|
|
58
54
|
|
|
59
|
-
### `bridge.on(
|
|
55
|
+
### `bridge.on("data", callback)`
|
|
60
56
|
|
|
61
57
|
Subscribe to received data.
|
|
62
58
|
|
|
@@ -64,7 +60,7 @@ Subscribe to received data.
|
|
|
64
60
|
|
|
65
61
|
Closes the serial port.
|
|
66
62
|
|
|
67
|
-
##
|
|
63
|
+
## Build From Source
|
|
68
64
|
|
|
69
65
|
```bash
|
|
70
66
|
cd bindings/node
|