@depz/sensor-sdk 0.1.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.
- package/README.md +69 -0
- package/dist/dataset.d.ts +93 -0
- package/dist/dataset.d.ts.map +1 -0
- package/dist/dataset.js +253 -0
- package/dist/dataset.js.map +1 -0
- package/dist/device/device.d.ts +185 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +421 -0
- package/dist/device/device.js.map +1 -0
- package/dist/device/link.d.ts +62 -0
- package/dist/device/link.d.ts.map +1 -0
- package/dist/device/link.js +130 -0
- package/dist/device/link.js.map +1 -0
- package/dist/discovery.d.ts +109 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +281 -0
- package/dist/discovery.js.map +1 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +69 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol/bno086.d.ts +36 -0
- package/dist/protocol/bno086.d.ts.map +1 -0
- package/dist/protocol/bno086.js +38 -0
- package/dist/protocol/bno086.js.map +1 -0
- package/dist/protocol/common.d.ts +103 -0
- package/dist/protocol/common.d.ts.map +1 -0
- package/dist/protocol/common.js +121 -0
- package/dist/protocol/common.js.map +1 -0
- package/dist/protocol/crc.d.ts +17 -0
- package/dist/protocol/crc.d.ts.map +1 -0
- package/dist/protocol/crc.js +55 -0
- package/dist/protocol/crc.js.map +1 -0
- package/dist/protocol/framing.d.ts +65 -0
- package/dist/protocol/framing.d.ts.map +1 -0
- package/dist/protocol/framing.js +152 -0
- package/dist/protocol/framing.js.map +1 -0
- package/dist/protocol/fwdepz.d.ts +21 -0
- package/dist/protocol/fwdepz.d.ts.map +1 -0
- package/dist/protocol/fwdepz.js +46 -0
- package/dist/protocol/fwdepz.js.map +1 -0
- package/dist/protocol/identity.d.ts +14 -0
- package/dist/protocol/identity.d.ts.map +1 -0
- package/dist/protocol/identity.js +28 -0
- package/dist/protocol/identity.js.map +1 -0
- package/dist/protocol/sr04.d.ts +38 -0
- package/dist/protocol/sr04.d.ts.map +1 -0
- package/dist/protocol/sr04.js +58 -0
- package/dist/protocol/sr04.js.map +1 -0
- package/dist/protocol/usb-ids.d.ts +60 -0
- package/dist/protocol/usb-ids.d.ts.map +1 -0
- package/dist/protocol/usb-ids.js +79 -0
- package/dist/protocol/usb-ids.js.map +1 -0
- package/dist/protocol/vl53l8.d.ts +59 -0
- package/dist/protocol/vl53l8.d.ts.map +1 -0
- package/dist/protocol/vl53l8.js +116 -0
- package/dist/protocol/vl53l8.js.map +1 -0
- package/dist/sensors/bno086/bno086.d.ts +197 -0
- package/dist/sensors/bno086/bno086.d.ts.map +1 -0
- package/dist/sensors/bno086/bno086.js +543 -0
- package/dist/sensors/bno086/bno086.js.map +1 -0
- package/dist/sensors/bno086/reports.d.ts +289 -0
- package/dist/sensors/bno086/reports.d.ts.map +1 -0
- package/dist/sensors/bno086/reports.js +397 -0
- package/dist/sensors/bno086/reports.js.map +1 -0
- package/dist/sensors/bno086/sh2.d.ts +307 -0
- package/dist/sensors/bno086/sh2.d.ts.map +1 -0
- package/dist/sensors/bno086/sh2.js +480 -0
- package/dist/sensors/bno086/sh2.js.map +1 -0
- package/dist/sensors/bno086/shtp.d.ts +98 -0
- package/dist/sensors/bno086/shtp.d.ts.map +1 -0
- package/dist/sensors/bno086/shtp.js +205 -0
- package/dist/sensors/bno086/shtp.js.map +1 -0
- package/dist/sensors/sr04.d.ts +65 -0
- package/dist/sensors/sr04.d.ts.map +1 -0
- package/dist/sensors/sr04.js +121 -0
- package/dist/sensors/sr04.js.map +1 -0
- package/dist/sensors/vl53l8/assets/ch.d.ts +16 -0
- package/dist/sensors/vl53l8/assets/ch.d.ts.map +1 -0
- package/dist/sensors/vl53l8/assets/ch.js +22 -0
- package/dist/sensors/vl53l8/assets/ch.js.map +1 -0
- package/dist/sensors/vl53l8/assets/cx.d.ts +16 -0
- package/dist/sensors/vl53l8/assets/cx.d.ts.map +1 -0
- package/dist/sensors/vl53l8/assets/cx.js +22 -0
- package/dist/sensors/vl53l8/assets/cx.js.map +1 -0
- package/dist/sensors/vl53l8/assets/decode.d.ts +7 -0
- package/dist/sensors/vl53l8/assets/decode.d.ts.map +1 -0
- package/dist/sensors/vl53l8/assets/decode.js +35 -0
- package/dist/sensors/vl53l8/assets/decode.js.map +1 -0
- package/dist/sensors/vl53l8/assets/index.d.ts +19 -0
- package/dist/sensors/vl53l8/assets/index.d.ts.map +1 -0
- package/dist/sensors/vl53l8/assets/index.js +11 -0
- package/dist/sensors/vl53l8/assets/index.js.map +1 -0
- package/dist/sensors/vl53l8/cnh.d.ts +113 -0
- package/dist/sensors/vl53l8/cnh.d.ts.map +1 -0
- package/dist/sensors/vl53l8/cnh.js +299 -0
- package/dist/sensors/vl53l8/cnh.js.map +1 -0
- package/dist/sensors/vl53l8/uld.d.ts +346 -0
- package/dist/sensors/vl53l8/uld.d.ts.map +1 -0
- package/dist/sensors/vl53l8/uld.js +1388 -0
- package/dist/sensors/vl53l8/uld.js.map +1 -0
- package/dist/sensors/vl53l8/vl53l8.d.ts +182 -0
- package/dist/sensors/vl53l8/vl53l8.d.ts.map +1 -0
- package/dist/sensors/vl53l8/vl53l8.js +411 -0
- package/dist/sensors/vl53l8/vl53l8.js.map +1 -0
- package/dist/transport/loopback.d.ts +18 -0
- package/dist/transport/loopback.d.ts.map +1 -0
- package/dist/transport/loopback.js +53 -0
- package/dist/transport/loopback.js.map +1 -0
- package/dist/transport/node.d.ts +51 -0
- package/dist/transport/node.d.ts.map +1 -0
- package/dist/transport/node.js +123 -0
- package/dist/transport/node.js.map +1 -0
- package/dist/transport/replay.d.ts +68 -0
- package/dist/transport/replay.d.ts.map +1 -0
- package/dist/transport/replay.js +196 -0
- package/dist/transport/replay.js.map +1 -0
- package/dist/transport/types.d.ts +23 -0
- package/dist/transport/types.d.ts.map +1 -0
- package/dist/transport/types.js +7 -0
- package/dist/transport/types.js.map +1 -0
- package/dist/transport/webserial.d.ts +69 -0
- package/dist/transport/webserial.d.ts.map +1 -0
- package/dist/transport/webserial.js +196 -0
- package/dist/transport/webserial.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device discovery & selection (contract 02 §4).
|
|
3
|
+
*
|
|
4
|
+
* The engine here is transport-agnostic: it takes an enumerated list of
|
|
5
|
+
* candidate ports plus a factory that turns a port into a (not-yet-open)
|
|
6
|
+
* `SerialTransport`. The Node entry (`@depz/sensor-sdk/node`) wires it to
|
|
7
|
+
* `serialport`; the browser entry (`@depz/sensor-sdk/web`) wires it to
|
|
8
|
+
* granted WebSerial ports. Both expose `openDevice` / `listDepzDevices`.
|
|
9
|
+
*
|
|
10
|
+
* Selection is by USB identity (`usb-ids.ts`) — never "first port in system
|
|
11
|
+
* order", which could grab an unrelated `/dev/ttyS0`. Mirrors the Python
|
|
12
|
+
* reference `depz_sensor_sdk.discovery`.
|
|
13
|
+
*/
|
|
14
|
+
import { DepzDevice } from "./device/device.js";
|
|
15
|
+
import { type SensorType } from "./protocol/identity.js";
|
|
16
|
+
import type { SerialTransport } from "./transport/types.js";
|
|
17
|
+
/** One enumerated candidate port (Node: serialport.list; Web: granted port). */
|
|
18
|
+
export interface DepzPortInfo {
|
|
19
|
+
/** Stable identifier: an OS path (Node) or a synthetic id (WebSerial). */
|
|
20
|
+
path: string;
|
|
21
|
+
/**
|
|
22
|
+
* USB iSerial as reported by the OS — the sort/selection key. WebSerial
|
|
23
|
+
* cannot read this, so it is undefined there (selection falls back to
|
|
24
|
+
* granted-port order).
|
|
25
|
+
*/
|
|
26
|
+
serialNumber?: string;
|
|
27
|
+
usbVid?: number;
|
|
28
|
+
usbPid?: number;
|
|
29
|
+
}
|
|
30
|
+
/** Result of probing a port (parity with Python `DeviceInfo`). */
|
|
31
|
+
export interface DeviceInfo {
|
|
32
|
+
path: string;
|
|
33
|
+
mode: "app" | "bootloader" | "unknown";
|
|
34
|
+
sensorType: SensorType | null;
|
|
35
|
+
softwareName: string;
|
|
36
|
+
fwVersion: string;
|
|
37
|
+
deviceName: string;
|
|
38
|
+
/** Device-reported serial (GET_SERIAL); "" when the device does not answer. */
|
|
39
|
+
serialNumber: string;
|
|
40
|
+
usbVid: number | null;
|
|
41
|
+
usbPid: number | null;
|
|
42
|
+
}
|
|
43
|
+
/** Turns an enumerated port into a fresh, not-yet-open transport. */
|
|
44
|
+
export type TransportFactory = (port: DepzPortInfo) => SerialTransport;
|
|
45
|
+
export interface OpenDeviceOptions {
|
|
46
|
+
/** Select the candidate whose USB iSerial equals this exact string. */
|
|
47
|
+
serial?: string;
|
|
48
|
+
/** Per-request timeout for the probe and the opened device (ms). */
|
|
49
|
+
timeoutMs?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface ListOptions {
|
|
52
|
+
/** Probe only ports with a known DEPZ (vid,pid) (default). */
|
|
53
|
+
matchUsb?: boolean;
|
|
54
|
+
timeoutMs?: number;
|
|
55
|
+
}
|
|
56
|
+
/** `undefined` = auto; number = Nth candidate; string = port path; DeviceInfo = its port. */
|
|
57
|
+
export type OpenTarget = number | string | DeviceInfo | null | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Sort ports by USB iSerial ascending; empty/missing serials sort last, ties
|
|
60
|
+
* broken by path. Pure and deterministic — a given bench always maps the same
|
|
61
|
+
* serial to index 0. Exposed so the ordering rule can be golden-tested.
|
|
62
|
+
*/
|
|
63
|
+
export declare function orderPortsBySerial(ports: DepzPortInfo[]): DepzPortInfo[];
|
|
64
|
+
export declare function isDeviceInfo(t: unknown): t is DeviceInfo;
|
|
65
|
+
/**
|
|
66
|
+
* Order *probed* devices by their DEVICE-reported serial (GET_SERIAL, i.e.
|
|
67
|
+
* `DeviceInfo.serialNumber`); empty serials sort last, ties broken by path.
|
|
68
|
+
* This is the selection key for transports that cannot read the USB iSerial
|
|
69
|
+
* (WebSerial), where the serial is only knowable by probing.
|
|
70
|
+
*/
|
|
71
|
+
export declare function orderDevicesBySerial(infos: DeviceInfo[]): DeviceInfo[];
|
|
72
|
+
/**
|
|
73
|
+
* Open `port`, ask its identity (+ device name/serial), then close. Returns
|
|
74
|
+
* null when nothing DEPZ-shaped answers. Probing *opens* the port, so callers
|
|
75
|
+
* should restrict the port list to plausible candidates.
|
|
76
|
+
*/
|
|
77
|
+
export declare function probePort(port: DepzPortInfo, factory: TransportFactory, timeoutMs?: number): Promise<DeviceInfo | null>;
|
|
78
|
+
/**
|
|
79
|
+
* Probe candidate ports and return every DEPZ device found, in selection
|
|
80
|
+
* order (sorted by USB iSerial). With `matchUsb` (default) only ports with a
|
|
81
|
+
* known DEPZ (vid,pid) are probed.
|
|
82
|
+
*/
|
|
83
|
+
export declare function listDepzDevicesFrom(ports: DepzPortInfo[], factory: TransportFactory, opts?: ListOptions): Promise<DeviceInfo[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Open the right sensor class for `target` (contract 02 §4).
|
|
86
|
+
*
|
|
87
|
+
* - `undefined`/`null`: the candidate with the alphabetically-smallest USB
|
|
88
|
+
* iSerial (or the one whose serial == `opts.serial`). No candidate → throws
|
|
89
|
+
* `NoDepzDeviceError` (never falls back to "first port in system").
|
|
90
|
+
* - `number N`: the Nth candidate, sorted by USB iSerial (0-based). Out of
|
|
91
|
+
* range → `NoDepzDeviceError`.
|
|
92
|
+
* - `string`: open exactly that port path; warns if its (vid,pid) is not a
|
|
93
|
+
* known DEPZ id (may be an unprogrammed unit).
|
|
94
|
+
* - `DeviceInfo`: opens its `.path`.
|
|
95
|
+
*/
|
|
96
|
+
export declare function openDeviceFrom(ports: DepzPortInfo[], factory: TransportFactory, target?: OpenTarget, opts?: OpenDeviceOptions): Promise<DepzDevice>;
|
|
97
|
+
/**
|
|
98
|
+
* Select and open a device by its DEVICE-reported serial (GET_SERIAL), for
|
|
99
|
+
* transports that cannot enumerate USB iSerials (WebSerial). Probes every
|
|
100
|
+
* given port (open → GET_SERIAL → close), orders the answers by device
|
|
101
|
+
* serial, then selects — `opts.serial` picks an exact match, a numeric
|
|
102
|
+
* `target` picks the Nth, otherwise the smallest serial — and reopens it.
|
|
103
|
+
*
|
|
104
|
+
* The probing cost (opening each granted port once) is the price of not
|
|
105
|
+
* having USB iSerials up front; the *result* matches Node's serial-based
|
|
106
|
+
* selection because for programmed units USB iSerial == device serial.
|
|
107
|
+
*/
|
|
108
|
+
export declare function openDeviceByDeviceSerial(ports: DepzPortInfo[], factory: TransportFactory, target?: number | null, opts?: OpenDeviceOptions): Promise<DepzDevice>;
|
|
109
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAK5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,GAAG,YAAY,GAAG,SAAS,CAAC;IACvC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,YA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AgB,EACzB,MAAM,CAAC,EAAE,UAAU,EACnB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,UAAU,CAAC,CA4DrB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,YAAY,EAAE,EACrB,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,UAAU,CAAC,CAwBrB"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device discovery & selection (contract 02 §4).
|
|
3
|
+
*
|
|
4
|
+
* The engine here is transport-agnostic: it takes an enumerated list of
|
|
5
|
+
* candidate ports plus a factory that turns a port into a (not-yet-open)
|
|
6
|
+
* `SerialTransport`. The Node entry (`@depz/sensor-sdk/node`) wires it to
|
|
7
|
+
* `serialport`; the browser entry (`@depz/sensor-sdk/web`) wires it to
|
|
8
|
+
* granted WebSerial ports. Both expose `openDevice` / `listDepzDevices`.
|
|
9
|
+
*
|
|
10
|
+
* Selection is by USB identity (`usb-ids.ts`) — never "first port in system
|
|
11
|
+
* order", which could grab an unrelated `/dev/ttyS0`. Mirrors the Python
|
|
12
|
+
* reference `depz_sensor_sdk.discovery`.
|
|
13
|
+
*/
|
|
14
|
+
import { DepzDevice } from "./device/device.js";
|
|
15
|
+
import { DepzError, NoDepzDeviceError } from "./errors.js";
|
|
16
|
+
import { parseSoftwareName } from "./protocol/identity.js";
|
|
17
|
+
import { isKnownDepzUsb, usbModelHint } from "./protocol/usb-ids.js";
|
|
18
|
+
import { Bno086 } from "./sensors/bno086/bno086.js";
|
|
19
|
+
import { Sr04 } from "./sensors/sr04.js";
|
|
20
|
+
import { Vl53l8Ch, Vl53l8Cx } from "./sensors/vl53l8/vl53l8.js";
|
|
21
|
+
const DEFAULT_PROBE_TIMEOUT_MS = 200;
|
|
22
|
+
// ── selection helpers ─────────────────────────────────────────────────────────
|
|
23
|
+
function isKnownPort(p) {
|
|
24
|
+
return isKnownDepzUsb(p.usbVid, p.usbPid);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Sort ports by USB iSerial ascending; empty/missing serials sort last, ties
|
|
28
|
+
* broken by path. Pure and deterministic — a given bench always maps the same
|
|
29
|
+
* serial to index 0. Exposed so the ordering rule can be golden-tested.
|
|
30
|
+
*/
|
|
31
|
+
export function orderPortsBySerial(ports) {
|
|
32
|
+
return ports.slice().sort((a, b) => {
|
|
33
|
+
const sa = a.serialNumber ?? "";
|
|
34
|
+
const sb = b.serialNumber ?? "";
|
|
35
|
+
const ea = sa === "" ? 1 : 0;
|
|
36
|
+
const eb = sb === "" ? 1 : 0;
|
|
37
|
+
if (ea !== eb)
|
|
38
|
+
return ea - eb;
|
|
39
|
+
if (sa !== sb)
|
|
40
|
+
return sa < sb ? -1 : 1;
|
|
41
|
+
return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Candidate ports (known DEPZ vid/pid) sorted by USB iSerial (index 0 = the
|
|
46
|
+
* one auto-select opens).
|
|
47
|
+
*/
|
|
48
|
+
function sortedCandidates(ports) {
|
|
49
|
+
return orderPortsBySerial(ports.filter(isKnownPort));
|
|
50
|
+
}
|
|
51
|
+
export function isDeviceInfo(t) {
|
|
52
|
+
return typeof t === "object" && t !== null && "path" in t && "sensorType" in t;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Order *probed* devices by their DEVICE-reported serial (GET_SERIAL, i.e.
|
|
56
|
+
* `DeviceInfo.serialNumber`); empty serials sort last, ties broken by path.
|
|
57
|
+
* This is the selection key for transports that cannot read the USB iSerial
|
|
58
|
+
* (WebSerial), where the serial is only knowable by probing.
|
|
59
|
+
*/
|
|
60
|
+
export function orderDevicesBySerial(infos) {
|
|
61
|
+
return infos.slice().sort((a, b) => {
|
|
62
|
+
const ea = a.serialNumber === "" ? 1 : 0;
|
|
63
|
+
const eb = b.serialNumber === "" ? 1 : 0;
|
|
64
|
+
if (ea !== eb)
|
|
65
|
+
return ea - eb;
|
|
66
|
+
if (a.serialNumber !== b.serialNumber)
|
|
67
|
+
return a.serialNumber < b.serialNumber ? -1 : 1;
|
|
68
|
+
return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// ── probing ───────────────────────────────────────────────────────────────────
|
|
72
|
+
/**
|
|
73
|
+
* Open `port`, ask its identity (+ device name/serial), then close. Returns
|
|
74
|
+
* null when nothing DEPZ-shaped answers. Probing *opens* the port, so callers
|
|
75
|
+
* should restrict the port list to plausible candidates.
|
|
76
|
+
*/
|
|
77
|
+
export async function probePort(port, factory, timeoutMs = DEFAULT_PROBE_TIMEOUT_MS) {
|
|
78
|
+
const transport = factory(port);
|
|
79
|
+
let dev;
|
|
80
|
+
try {
|
|
81
|
+
dev = new DepzDevice(transport, { timeoutMs });
|
|
82
|
+
await dev.open();
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
try {
|
|
86
|
+
await transport.close();
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
/* already gone */
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const ident = parseSoftwareName(await dev.getSoftwareName());
|
|
95
|
+
let deviceName = "";
|
|
96
|
+
try {
|
|
97
|
+
deviceName = await dev.getDeviceName();
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
/* optional */
|
|
101
|
+
}
|
|
102
|
+
let serialNumber = "";
|
|
103
|
+
try {
|
|
104
|
+
serialNumber = await dev.getSerialNumber();
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
/* optional */
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
path: port.path,
|
|
111
|
+
mode: ident.mode,
|
|
112
|
+
sensorType: ident.sensorType,
|
|
113
|
+
softwareName: ident.softwareName,
|
|
114
|
+
fwVersion: ident.version,
|
|
115
|
+
deviceName,
|
|
116
|
+
serialNumber,
|
|
117
|
+
usbVid: port.usbVid ?? null,
|
|
118
|
+
usbPid: port.usbPid ?? null,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
await dev.close();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// ── list ──────────────────────────────────────────────────────────────────────
|
|
129
|
+
/**
|
|
130
|
+
* Probe candidate ports and return every DEPZ device found, in selection
|
|
131
|
+
* order (sorted by USB iSerial). With `matchUsb` (default) only ports with a
|
|
132
|
+
* known DEPZ (vid,pid) are probed.
|
|
133
|
+
*/
|
|
134
|
+
export async function listDepzDevicesFrom(ports, factory, opts = {}) {
|
|
135
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
|
|
136
|
+
const matchUsb = opts.matchUsb ?? true;
|
|
137
|
+
const scan = matchUsb ? sortedCandidates(ports) : ports.slice();
|
|
138
|
+
const found = [];
|
|
139
|
+
for (const port of scan) {
|
|
140
|
+
const info = await probePort(port, factory, timeoutMs);
|
|
141
|
+
if (info !== null)
|
|
142
|
+
found.push(info);
|
|
143
|
+
}
|
|
144
|
+
return found;
|
|
145
|
+
}
|
|
146
|
+
// ── open ──────────────────────────────────────────────────────────────────────
|
|
147
|
+
function constructSensor(transport, sensorType, timeoutMs, port) {
|
|
148
|
+
switch (sensorType) {
|
|
149
|
+
case "sr04":
|
|
150
|
+
return new Sr04(transport, { timeoutMs });
|
|
151
|
+
case "vl53l8":
|
|
152
|
+
// The USB model hint distinguishes CH silicon (PID 0xED40 → 'vl53l8ch')
|
|
153
|
+
// from CX; the dev-default id (0x56DC) and the silicon id are
|
|
154
|
+
// indistinguishable, so those fall through to the CX base class.
|
|
155
|
+
return usbModelHint(port?.usbVid, port?.usbPid) === "vl53l8ch"
|
|
156
|
+
? new Vl53l8Ch(transport, { timeoutMs })
|
|
157
|
+
: new Vl53l8Cx(transport, { timeoutMs });
|
|
158
|
+
case "bno086":
|
|
159
|
+
return new Bno086(transport, { timeoutMs });
|
|
160
|
+
default:
|
|
161
|
+
return new DepzDevice(transport, { timeoutMs });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function openProbed(port, info, factory, timeoutMs) {
|
|
165
|
+
if (info.mode === "bootloader") {
|
|
166
|
+
throw new DepzError("device is in bootloader mode; use the bootloader client (contract 06)");
|
|
167
|
+
}
|
|
168
|
+
const transport = factory(port);
|
|
169
|
+
const dev = constructSensor(transport, info.sensorType, timeoutMs, port);
|
|
170
|
+
await dev.open();
|
|
171
|
+
return dev;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Open the right sensor class for `target` (contract 02 §4).
|
|
175
|
+
*
|
|
176
|
+
* - `undefined`/`null`: the candidate with the alphabetically-smallest USB
|
|
177
|
+
* iSerial (or the one whose serial == `opts.serial`). No candidate → throws
|
|
178
|
+
* `NoDepzDeviceError` (never falls back to "first port in system").
|
|
179
|
+
* - `number N`: the Nth candidate, sorted by USB iSerial (0-based). Out of
|
|
180
|
+
* range → `NoDepzDeviceError`.
|
|
181
|
+
* - `string`: open exactly that port path; warns if its (vid,pid) is not a
|
|
182
|
+
* known DEPZ id (may be an unprogrammed unit).
|
|
183
|
+
* - `DeviceInfo`: opens its `.path`.
|
|
184
|
+
*/
|
|
185
|
+
export async function openDeviceFrom(ports, factory, target, opts = {}) {
|
|
186
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
|
|
187
|
+
// Explicit port path (string or DeviceInfo) — open exactly that port.
|
|
188
|
+
if (typeof target === "string" || isDeviceInfo(target)) {
|
|
189
|
+
const path = typeof target === "string" ? target : target.path;
|
|
190
|
+
const enumerated = ports.find((p) => p.path === path);
|
|
191
|
+
const port = enumerated ?? { path };
|
|
192
|
+
const info = await probePort(port, factory, timeoutMs);
|
|
193
|
+
if (info === null) {
|
|
194
|
+
throw new NoDepzDeviceError(`no DEPZ device answered on ${path}`);
|
|
195
|
+
}
|
|
196
|
+
if (!isKnownDepzUsb(port.usbVid, port.usbPid)) {
|
|
197
|
+
console.warn(`depz: ${path} has an unrecognized USB id ` +
|
|
198
|
+
`(vid=${fmtId(port.usbVid)}, pid=${fmtId(port.usbPid)}); opening anyway`);
|
|
199
|
+
}
|
|
200
|
+
if (opts.serial !== undefined && enumerated?.serialNumber !== undefined && enumerated.serialNumber !== opts.serial) {
|
|
201
|
+
console.warn(`depz: requested serial ${opts.serial} but ${path} enumerates as ` +
|
|
202
|
+
`${enumerated.serialNumber}`);
|
|
203
|
+
}
|
|
204
|
+
return openProbed(port, info, factory, timeoutMs);
|
|
205
|
+
}
|
|
206
|
+
const candidates = sortedCandidates(ports);
|
|
207
|
+
// Nth candidate by USB iSerial.
|
|
208
|
+
if (typeof target === "number") {
|
|
209
|
+
if (!Number.isInteger(target) || target < 0 || target >= candidates.length) {
|
|
210
|
+
throw new NoDepzDeviceError(`no DEPZ device at index ${target} (${candidates.length} candidate(s) found)`);
|
|
211
|
+
}
|
|
212
|
+
const port = candidates[target];
|
|
213
|
+
if (opts.serial !== undefined && port.serialNumber !== opts.serial) {
|
|
214
|
+
console.warn(`depz: index ${target} selects serial ${port.serialNumber ?? "(none)"}, ` +
|
|
215
|
+
`not the requested ${opts.serial}`);
|
|
216
|
+
}
|
|
217
|
+
return openIndexed(port, factory, timeoutMs);
|
|
218
|
+
}
|
|
219
|
+
// Auto: by serial, else smallest serial (index 0).
|
|
220
|
+
let port;
|
|
221
|
+
if (opts.serial !== undefined) {
|
|
222
|
+
port = candidates.find((p) => p.serialNumber === opts.serial);
|
|
223
|
+
if (port === undefined) {
|
|
224
|
+
throw new NoDepzDeviceError(`no DEPZ device with serial ${opts.serial}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
port = candidates[0];
|
|
229
|
+
if (port === undefined) {
|
|
230
|
+
throw new NoDepzDeviceError("no DEPZ device found (no port with a known DEPZ USB id)");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return openIndexed(port, factory, timeoutMs);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Select and open a device by its DEVICE-reported serial (GET_SERIAL), for
|
|
237
|
+
* transports that cannot enumerate USB iSerials (WebSerial). Probes every
|
|
238
|
+
* given port (open → GET_SERIAL → close), orders the answers by device
|
|
239
|
+
* serial, then selects — `opts.serial` picks an exact match, a numeric
|
|
240
|
+
* `target` picks the Nth, otherwise the smallest serial — and reopens it.
|
|
241
|
+
*
|
|
242
|
+
* The probing cost (opening each granted port once) is the price of not
|
|
243
|
+
* having USB iSerials up front; the *result* matches Node's serial-based
|
|
244
|
+
* selection because for programmed units USB iSerial == device serial.
|
|
245
|
+
*/
|
|
246
|
+
export async function openDeviceByDeviceSerial(ports, factory, target, opts = {}) {
|
|
247
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
|
|
248
|
+
// matchUsb:false — a granted port is user-curated and may not expose a
|
|
249
|
+
// recognizable vid/pid; the protocol probe is the real filter.
|
|
250
|
+
const infos = orderDevicesBySerial(await listDepzDevicesFrom(ports, factory, { matchUsb: false, timeoutMs }));
|
|
251
|
+
let chosen;
|
|
252
|
+
if (opts.serial !== undefined) {
|
|
253
|
+
chosen = infos.find((d) => d.serialNumber === opts.serial);
|
|
254
|
+
if (chosen === undefined)
|
|
255
|
+
throw new NoDepzDeviceError(`no DEPZ device with serial ${opts.serial}`);
|
|
256
|
+
}
|
|
257
|
+
else if (typeof target === "number") {
|
|
258
|
+
if (!Number.isInteger(target) || target < 0 || target >= infos.length) {
|
|
259
|
+
throw new NoDepzDeviceError(`no DEPZ device at index ${target} (${infos.length} candidate(s) found)`);
|
|
260
|
+
}
|
|
261
|
+
chosen = infos[target];
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
chosen = infos[0];
|
|
265
|
+
if (chosen === undefined)
|
|
266
|
+
throw new NoDepzDeviceError("no DEPZ device found");
|
|
267
|
+
}
|
|
268
|
+
const port = ports.find((p) => p.path === chosen.path) ?? { path: chosen.path };
|
|
269
|
+
return openProbed(port, chosen, factory, timeoutMs);
|
|
270
|
+
}
|
|
271
|
+
async function openIndexed(port, factory, timeoutMs) {
|
|
272
|
+
const info = await probePort(port, factory, timeoutMs);
|
|
273
|
+
if (info === null) {
|
|
274
|
+
throw new NoDepzDeviceError(`no DEPZ device answered on ${port.path}`);
|
|
275
|
+
}
|
|
276
|
+
return openProbed(port, info, factory, timeoutMs);
|
|
277
|
+
}
|
|
278
|
+
function fmtId(v) {
|
|
279
|
+
return v == null ? "?" : `0x${v.toString(16).toUpperCase().padStart(4, "0")}`;
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAmB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAkDhE,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC,iFAAiF;AAEjF,SAAS,WAAW,CAAC,CAAe;IAClC,OAAO,cAAc,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC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O,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AAChF,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exception hierarchy of the DEPZ sensor SDK.
|
|
3
|
+
* Status code names follow contracts/02_COMMON_COMMANDS.md §3.
|
|
4
|
+
*/
|
|
5
|
+
/** Base class for all SDK errors. */
|
|
6
|
+
export declare class DepzError extends Error {
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
/** A request got no matching reply within the timeout. */
|
|
10
|
+
export declare class DepzTimeoutError extends DepzError {
|
|
11
|
+
readonly cmd: number;
|
|
12
|
+
readonly timeoutMs: number;
|
|
13
|
+
constructor(cmd: number, timeoutMs: number);
|
|
14
|
+
}
|
|
15
|
+
/** Device answered a request with a non-OK RPT_STATUS. */
|
|
16
|
+
export declare class StatusError extends DepzError {
|
|
17
|
+
readonly cmd: number;
|
|
18
|
+
readonly status: number;
|
|
19
|
+
readonly statusName: string;
|
|
20
|
+
constructor(cmd: number, status: number);
|
|
21
|
+
}
|
|
22
|
+
/** Device answered ERR_BUSY; the operation may be retried later. */
|
|
23
|
+
export declare class BusyError extends StatusError {
|
|
24
|
+
constructor(cmd: number);
|
|
25
|
+
}
|
|
26
|
+
/** The serial link dropped (unplug, reboot) while in use. */
|
|
27
|
+
export declare class DeviceLostError extends DepzError {
|
|
28
|
+
}
|
|
29
|
+
/** Operation attempted on a closed link/device. */
|
|
30
|
+
export declare class LinkClosedError extends DepzError {
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Discovery found no DEPZ device matching the request (no candidate port by
|
|
34
|
+
* USB id, an out-of-range index, or a serial that nothing answered to).
|
|
35
|
+
* Mirrors the Python reference `NoDepzDeviceError`.
|
|
36
|
+
*/
|
|
37
|
+
export declare class NoDepzDeviceError extends DepzError {
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qCAAqC;AACrC,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,CAAC,EAAE,MAAM;CAI7B;AAMD,0DAA0D;AAC1D,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAK3C;AAeD,0DAA0D;AAC1D,qBAAa,WAAY,SAAQ,SAAS;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAOxC;AAED,oEAAoE;AACpE,qBAAa,SAAU,SAAQ,WAAW;gBAC5B,GAAG,EAAE,MAAM;CAGxB;AAED,6DAA6D;AAC7D,qBAAa,eAAgB,SAAQ,SAAS;CAAG;AAEjD,mDAAmD;AACnD,qBAAa,eAAgB,SAAQ,SAAS;CAAG;AAEjD;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;CAAG"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exception hierarchy of the DEPZ sensor SDK.
|
|
3
|
+
* Status code names follow contracts/02_COMMON_COMMANDS.md §3.
|
|
4
|
+
*/
|
|
5
|
+
/** Base class for all SDK errors. */
|
|
6
|
+
export class DepzError extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = new.target.name;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function hex2(n) {
|
|
13
|
+
return n.toString(16).toUpperCase().padStart(2, "0");
|
|
14
|
+
}
|
|
15
|
+
/** A request got no matching reply within the timeout. */
|
|
16
|
+
export class DepzTimeoutError extends DepzError {
|
|
17
|
+
cmd;
|
|
18
|
+
timeoutMs;
|
|
19
|
+
constructor(cmd, timeoutMs) {
|
|
20
|
+
super(`no reply to cmd 0x${hex2(cmd)} within ${timeoutMs}ms`);
|
|
21
|
+
this.cmd = cmd;
|
|
22
|
+
this.timeoutMs = timeoutMs;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const STATUS_NAMES = {
|
|
26
|
+
0x00: "OK",
|
|
27
|
+
0x01: "ERROR",
|
|
28
|
+
0x02: "ERR_INVALID_CMD",
|
|
29
|
+
0x03: "ERR_PAYLOAD_FORMAT",
|
|
30
|
+
0x04: "ERR_INVALID_PARAM",
|
|
31
|
+
0x05: "ERR_PAYLOAD_CRC",
|
|
32
|
+
0x06: "ERR_BUSY",
|
|
33
|
+
0x07: "ERR_CMD_NOT_SUPPORTED",
|
|
34
|
+
0x08: "ERR_NOT_INITIALIZED",
|
|
35
|
+
0x09: "ERR_HARDWARE_FAULT",
|
|
36
|
+
};
|
|
37
|
+
/** Device answered a request with a non-OK RPT_STATUS. */
|
|
38
|
+
export class StatusError extends DepzError {
|
|
39
|
+
cmd;
|
|
40
|
+
status;
|
|
41
|
+
statusName;
|
|
42
|
+
constructor(cmd, status) {
|
|
43
|
+
const statusName = STATUS_NAMES[status] ?? `0x${hex2(status)}`;
|
|
44
|
+
super(`cmd 0x${hex2(cmd)} failed: ${statusName} (0x${hex2(status)})`);
|
|
45
|
+
this.cmd = cmd;
|
|
46
|
+
this.status = status;
|
|
47
|
+
this.statusName = statusName;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Device answered ERR_BUSY; the operation may be retried later. */
|
|
51
|
+
export class BusyError extends StatusError {
|
|
52
|
+
constructor(cmd) {
|
|
53
|
+
super(cmd, 0x06);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** The serial link dropped (unplug, reboot) while in use. */
|
|
57
|
+
export class DeviceLostError extends DepzError {
|
|
58
|
+
}
|
|
59
|
+
/** Operation attempted on a closed link/device. */
|
|
60
|
+
export class LinkClosedError extends DepzError {
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Discovery found no DEPZ device matching the request (no candidate port by
|
|
64
|
+
* USB id, an out-of-range index, or a serial that nothing answered to).
|
|
65
|
+
* Mirrors the Python reference `NoDepzDeviceError`.
|
|
66
|
+
*/
|
|
67
|
+
export class NoDepzDeviceError extends DepzError {
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,qCAAqC;AACrC,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAED,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,0DAA0D;AAC1D,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IACpC,GAAG,CAAS;IACZ,SAAS,CAAS;IAE3B,YAAY,GAAW,EAAE,SAAiB;QACxC,KAAK,CAAC,qBAAqB,IAAI,CAAC,GAAG,CAAC,WAAW,SAAS,IAAI,CAAC,CAAC;QAC9D,IAAI,CAAC,GAAG,GAAG,GA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|
|
2
|
+
* @depz/sensor-sdk — browser-safe root export.
|
|
3
|
+
* Node-only pieces live in `@depz/sensor-sdk/node`.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./protocol/crc.js";
|
|
6
|
+
export * from "./protocol/framing.js";
|
|
7
|
+
export * from "./protocol/common.js";
|
|
8
|
+
export * from "./protocol/identity.js";
|
|
9
|
+
export * from "./protocol/sr04.js";
|
|
10
|
+
export * from "./protocol/vl53l8.js";
|
|
11
|
+
export * from "./protocol/bno086.js";
|
|
12
|
+
export * from "./protocol/fwdepz.js";
|
|
13
|
+
export * from "./protocol/usb-ids.js";
|
|
14
|
+
export * from "./errors.js";
|
|
15
|
+
export { isDeviceInfo, listDepzDevicesFrom, openDeviceByDeviceSerial, openDeviceFrom, orderDevicesBySerial, orderPortsBySerial, probePort, } from "./discovery.js";
|
|
16
|
+
export type { DeviceInfo, DepzPortInfo, ListOptions, OpenDeviceOptions, OpenTarget, TransportFactory, } from "./discovery.js";
|
|
17
|
+
export { DepzLink } from "./device/link.js";
|
|
18
|
+
export type { LinkStats } from "./device/link.js";
|
|
19
|
+
export { DEFAULT_TIMEOUT_MS, DepzDevice, NO_MATCH, StreamQueue, hostNowUs, syncTimeAll, } from "./device/device.js";
|
|
20
|
+
export type { DeviceEvent, DeviceOptions, Matcher, RequestOptions, TimeSync, } from "./device/device.js";
|
|
21
|
+
export { Sr04 } from "./sensors/sr04.js";
|
|
22
|
+
export type { Sr04Measurement } from "./sensors/sr04.js";
|
|
23
|
+
export { MIN_RANGING_FREQUENCY_HZ, Vl53l8, Vl53l8Ch, Vl53l8Cx, zoneGrid, } from "./sensors/vl53l8/vl53l8.js";
|
|
24
|
+
export type { Vl53l8Frame, Vl53l8InitOptions, Vl53l8Options, } from "./sensors/vl53l8/vl53l8.js";
|
|
25
|
+
export { CALIBRATE_XTALK, FW_CHECKSUM, GET_XTALK_CMD, MotionConfig, NB_THRESHOLDS, POWER_MODE_DEEP_SLEEP, POWER_MODE_SLEEP, POWER_MODE_WAKEUP, RANGING_MODE_AUTONOMOUS, RANGING_MODE_CONTINUOUS, RESOLUTION_4X4, RESOLUTION_8X8, TARGET_ORDER_CLOSEST, TARGET_ORDER_STRONGEST, THRESH_IN_WINDOW, THRESH_OP_AND, THRESH_OP_NONE, THRESH_OP_OR, THRESH_OUT_OF_WINDOW, VL53L8CX, Vl53l8cxError, defaultMotionConfig, motionConfigSetResolution, packDetectionThresholds, swapBuffer, xtalkMarginToRaw, } from "./sensors/vl53l8/uld.js";
|
|
26
|
+
export type { DetectionThreshold, MotionResult, Vl53l8Platform, Vl53l8Results, } from "./sensors/vl53l8/uld.js";
|
|
27
|
+
export { CNH_BIN_WIDTH_MM, CNH_MAX_DATA_BYTES, CnhConfig, CnhConfigError, MI_CFG_DEV_IDX, decode as decodeCnh, maxBins as cnhMaxBins, } from "./sensors/vl53l8/cnh.js";
|
|
28
|
+
export type { CnhAggregate, CnhDecoded } from "./sensors/vl53l8/cnh.js";
|
|
29
|
+
export { loadAssets } from "./sensors/vl53l8/assets/index.js";
|
|
30
|
+
export type { Vl53l8Assets, Vl53l8Variant } from "./sensors/vl53l8/assets/index.js";
|
|
31
|
+
export * from "./sensors/bno086/shtp.js";
|
|
32
|
+
export * from "./sensors/bno086/reports.js";
|
|
33
|
+
export * from "./sensors/bno086/sh2.js";
|
|
34
|
+
export * from "./sensors/bno086/bno086.js";
|
|
35
|
+
export { RECORDING_SCHEMA, RecordingTransport, ReplayTransport } from "./transport/replay.js";
|
|
36
|
+
export { DATASET_SCHEMA, DatasetPlayer, DatasetReader, DatasetRecorder, DatasetWriter, } from "./dataset.js";
|
|
37
|
+
export type { DatasetDeviceMeta, DatasetHeader, DatasetRecord, PlayerState, } from "./dataset.js";
|
|
38
|
+
export type { SerialTransport, SerialTransportInfo } from "./transport/types.js";
|
|
39
|
+
export { LoopbackTransport } from "./transport/loopback.js";
|
|
40
|
+
export { WebSerialTransport, isWebSerialSupported, getGrantedPorts, watchConnect, } from "./transport/webserial.js";
|
|
41
|
+
export type { WebSerialPortLike } from "./transport/webserial.js";
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,WAAW,EACX,aAAa,EACb,OAAO,EACP,cAAc,EACd,QAAQ,GACT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EACL,wBAAwB,EACxB,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,WAAW,EACX,iBAAi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AAsB,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @depz/sensor-sdk — browser-safe root export.
|
|
3
|
+
* Node-only pieces live in `@depz/sensor-sdk/node`.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./protocol/crc.js";
|
|
6
|
+
export * from "./protocol/framing.js";
|
|
7
|
+
export * from "./protocol/common.js";
|
|
8
|
+
export * from "./protocol/identity.js";
|
|
9
|
+
export * from "./protocol/sr04.js";
|
|
10
|
+
export * from "./protocol/vl53l8.js";
|
|
11
|
+
export * from "./protocol/bno086.js";
|
|
12
|
+
export * from "./protocol/fwdepz.js";
|
|
13
|
+
export * from "./protocol/usb-ids.js";
|
|
14
|
+
export * from "./errors.js";
|
|
15
|
+
export { isDeviceInfo, listDepzDevicesFrom, openDeviceByDeviceSerial, openDeviceFrom, orderDevicesBySerial, orderPortsBySerial, probePort, } from "./discovery.js";
|
|
16
|
+
export { DepzLink } from "./device/link.js";
|
|
17
|
+
export { DEFAULT_TIMEOUT_MS, DepzDevice, NO_MATCH, StreamQueue, hostNowUs, syncTimeAll, } from "./device/device.js";
|
|
18
|
+
export { Sr04 } from "./sensors/sr04.js";
|
|
19
|
+
export { MIN_RANGING_FREQUENCY_HZ, Vl53l8, Vl53l8Ch, Vl53l8Cx, zoneGrid, } from "./sensors/vl53l8/vl53l8.js";
|
|
20
|
+
export { CALIBRATE_XTALK, FW_CHECKSUM, GET_XTALK_CMD, MotionConfig, NB_THRESHOLDS, POWER_MODE_DEEP_SLEEP, POWER_MODE_SLEEP, POWER_MODE_WAKEUP, RANGING_MODE_AUTONOMOUS, RANGING_MODE_CONTINUOUS, RESOLUTION_4X4, RESOLUTION_8X8, TARGET_ORDER_CLOSEST, TARGET_ORDER_STRONGEST, THRESH_IN_WINDOW, THRESH_OP_AND, THRESH_OP_NONE, THRESH_OP_OR, THRESH_OUT_OF_WINDOW, VL53L8CX, Vl53l8cxError, defaultMotionConfig, motionConfigSetResolution, packDetectionThresholds, swapBuffer, xtalkMarginToRaw, } from "./sensors/vl53l8/uld.js";
|
|
21
|
+
export { CNH_BIN_WIDTH_MM, CNH_MAX_DATA_BYTES, CnhConfig, CnhConfigError, MI_CFG_DEV_IDX, decode as decodeCnh, maxBins as cnhMaxBins, } from "./sensors/vl53l8/cnh.js";
|
|
22
|
+
export { loadAssets } from "./sensors/vl53l8/assets/index.js";
|
|
23
|
+
export * from "./sensors/bno086/shtp.js";
|
|
24
|
+
export * from "./sensors/bno086/reports.js";
|
|
25
|
+
export * from "./sensors/bno086/sh2.js";
|
|
26
|
+
export * from "./sensors/bno086/bno086.js";
|
|
27
|
+
export { RECORDING_SCHEMA, RecordingTransport, ReplayTransport } from "./transport/replay.js";
|
|
28
|
+
export { DATASET_SCHEMA, DatasetPlayer, DatasetReader, DatasetRecorder, DatasetWriter, } from "./dataset.js";
|
|
29
|
+
export { LoopbackTransport } from "./transport/loopback.js";
|
|
30
|
+
export { WebSerialTransport, isWebSerialSupported, getGrantedPorts, watchConnect, } from "./transport/webserial.js";
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,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