@emdzej/bimmerz-rpc-uart 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/LICENSE +131 -0
- package/README.md +58 -0
- package/dist/client.d.ts +43 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +62 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose. However, you may
|
|
17
|
+
only distribute the software according to [Distribution
|
|
18
|
+
License](#distribution-license) and make changes or new works
|
|
19
|
+
based on the software according to [Changes and New Works
|
|
20
|
+
License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license
|
|
25
|
+
to distribute copies of the software. Your license
|
|
26
|
+
to distribute covers distributing the software with
|
|
27
|
+
changes and new works permitted by [Changes and New Works
|
|
28
|
+
License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to
|
|
43
|
+
make changes and new works based on the software for any
|
|
44
|
+
permitted purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Noncommercial Purposes
|
|
53
|
+
|
|
54
|
+
Any noncommercial purpose is a permitted purpose.
|
|
55
|
+
|
|
56
|
+
## Personal Uses
|
|
57
|
+
|
|
58
|
+
Personal use for research, experiment, and testing for
|
|
59
|
+
the benefit of public knowledge, personal study, private
|
|
60
|
+
entertainment, hobby projects, amateur pursuits, or religious
|
|
61
|
+
observance, without any anticipated commercial application,
|
|
62
|
+
is use for a permitted purpose.
|
|
63
|
+
|
|
64
|
+
## Noncommercial Organizations
|
|
65
|
+
|
|
66
|
+
Use by any charitable organization, educational institution,
|
|
67
|
+
public research organization, public safety or health
|
|
68
|
+
organization, environmental protection organization,
|
|
69
|
+
or government institution is use for a permitted purpose
|
|
70
|
+
regardless of the source of funding or obligations resulting
|
|
71
|
+
from the funding.
|
|
72
|
+
|
|
73
|
+
## Fair Use
|
|
74
|
+
|
|
75
|
+
You may have "fair use" rights for the software under the
|
|
76
|
+
law. These terms do not limit them.
|
|
77
|
+
|
|
78
|
+
## No Other Rights
|
|
79
|
+
|
|
80
|
+
These terms do not allow you to sublicense or transfer any of
|
|
81
|
+
your licenses to anyone else, or prevent the licensor from
|
|
82
|
+
granting licenses to anyone else. These terms do not imply
|
|
83
|
+
any other licenses.
|
|
84
|
+
|
|
85
|
+
## Patent Defense
|
|
86
|
+
|
|
87
|
+
If you make any written claim that the software infringes or
|
|
88
|
+
contributes to infringement of any patent, your patent license
|
|
89
|
+
for the software granted under these terms ends immediately. If
|
|
90
|
+
your company makes such a claim, your patent license ends
|
|
91
|
+
immediately for work on behalf of your company.
|
|
92
|
+
|
|
93
|
+
## Violations
|
|
94
|
+
|
|
95
|
+
The first time you are notified in writing that you have
|
|
96
|
+
violated any of these terms, or done anything with the software
|
|
97
|
+
not covered by your licenses, your licenses can nonetheless
|
|
98
|
+
continue if you come into full compliance with these terms,
|
|
99
|
+
and take practical steps to correct past violations, within
|
|
100
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
101
|
+
end immediately.
|
|
102
|
+
|
|
103
|
+
## No Liability
|
|
104
|
+
|
|
105
|
+
***As far as the law allows, the software comes as is, without
|
|
106
|
+
any warranty or condition, and the licensor will not be liable
|
|
107
|
+
to you for any damages arising out of these terms or the use
|
|
108
|
+
or nature of the software, under any kind of legal claim.***
|
|
109
|
+
|
|
110
|
+
## Definitions
|
|
111
|
+
|
|
112
|
+
The **licensor** is the individual or entity offering these
|
|
113
|
+
terms, and the **software** is the software the licensor makes
|
|
114
|
+
available under these terms.
|
|
115
|
+
|
|
116
|
+
**You** refers to the individual or entity agreeing to these
|
|
117
|
+
terms.
|
|
118
|
+
|
|
119
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
120
|
+
or other kind of organization that you work for, plus all
|
|
121
|
+
organizations that have control over, are under the control of,
|
|
122
|
+
or are under common control with that organization. **Control**
|
|
123
|
+
means ownership of substantially all the assets of an entity,
|
|
124
|
+
or the power to direct its management and policies by vote,
|
|
125
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
126
|
+
|
|
127
|
+
**Your licenses** are all the licenses granted to you for the
|
|
128
|
+
software under these terms.
|
|
129
|
+
|
|
130
|
+
**Use** means anything you do with the software requiring one
|
|
131
|
+
of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @emdzej/bimmerz-rpc-uart
|
|
2
|
+
|
|
3
|
+
Typed client for the bimmerz-box dongle's `/rpc/uart/<n>` endpoint
|
|
4
|
+
(`n = 0` is the K-line UART). Built on `@emdzej/bimmerz-rpc-core`.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
pnpm add @emdzej/bimmerz-rpc-uart
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { connectUart } from "@emdzej/bimmerz-rpc-uart";
|
|
16
|
+
|
|
17
|
+
const { uart } = await connectUart("ws://172.16.7.1/rpc/uart/0", {
|
|
18
|
+
autoReconnect: true,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
await uart.open({ baud: 9600, parity: "even", consumeEcho: true });
|
|
22
|
+
|
|
23
|
+
uart.onRx(({ data }) => {
|
|
24
|
+
console.log("RX:", Array.from(data, (b) => b.toString(16).padStart(2, "0")).join(" "));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// DS2 ident telegram: [ECU, LEN, CMD, XOR-by-server]
|
|
28
|
+
const resp = await uart.transact(new Uint8Array([0x12, 0x04, 0x00, 0x16]), {
|
|
29
|
+
readMs: 1_000,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
await uart.close();
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API mirror
|
|
36
|
+
|
|
37
|
+
Method → server call:
|
|
38
|
+
|
|
39
|
+
| Method | Server endpoint |
|
|
40
|
+
|---------------------------------|------------------|
|
|
41
|
+
| `uart.open(opts)` | `uart.open` |
|
|
42
|
+
| `uart.configure(opts)` | `uart.configure` |
|
|
43
|
+
| `uart.write(bytes)` | `uart.write` |
|
|
44
|
+
| `uart.transact(bytes, opts)` | `uart.transact` |
|
|
45
|
+
| `uart.slowInit(opts)` | `uart.slowInit` |
|
|
46
|
+
| `uart.fastInit(opts)` | `uart.fastInit` |
|
|
47
|
+
| `uart.close()` | `uart.close` |
|
|
48
|
+
| `uart.onRx(handler)` | subscribes to `uart.rx` |
|
|
49
|
+
| `uart.onRevoked(handler)` | subscribes to `uart.revoked` |
|
|
50
|
+
|
|
51
|
+
Base64 wrapping of binary payloads is handled internally — both `write`
|
|
52
|
+
and `onRx` deal in `Uint8Array`.
|
|
53
|
+
|
|
54
|
+
## See also
|
|
55
|
+
|
|
56
|
+
- [bimmerz-box API reference](https://github.com/emdzej/bimmerz-box/blob/main/docs/api.md#rpcuartn)
|
|
57
|
+
- `@emdzej/bimmerz-rpc-core` — the JSON-RPC transport this builds on
|
|
58
|
+
- `@emdzej/bimmerz-rpc-can` — sibling client for the CAN endpoint
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed facade over the dongle's `/rpc/uart/<n>` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* Wraps a connected `RpcClient` and exposes each `uart.*` method with
|
|
5
|
+
* its proper TypeScript shape, converting binary payloads to/from
|
|
6
|
+
* `Uint8Array` so callers never have to deal with base64.
|
|
7
|
+
*/
|
|
8
|
+
import { RpcClient, type RpcClientOptions, type Unsubscribe } from "@emdzej/bimmerz-rpc-core";
|
|
9
|
+
import type { UartOpenOptions, UartConfigureOptions, UartOpenResult, UartWriteResult, UartTransactOptions, UartSlowInitOptions, UartFastInitOptions, UartRxEvent, UartRevokedEvent } from "./types.js";
|
|
10
|
+
export declare class UartClient {
|
|
11
|
+
readonly rpc: RpcClient;
|
|
12
|
+
constructor(rpc: RpcClient);
|
|
13
|
+
/** Claim the UART, configure framing, start the RX stream. */
|
|
14
|
+
open(opts?: UartOpenOptions): Promise<UartOpenResult>;
|
|
15
|
+
/** Update settings while open. Caller must already hold the lock. */
|
|
16
|
+
configure(opts: UartConfigureOptions): Promise<UartOpenResult>;
|
|
17
|
+
/** Transmit raw bytes. Echo is auto-consumed if `consumeEcho` is set on open. */
|
|
18
|
+
write(data: Uint8Array): Promise<UartWriteResult>;
|
|
19
|
+
/** Transmit then synchronously read the response within `readMs`. */
|
|
20
|
+
transact(data: Uint8Array, opts: UartTransactOptions): Promise<Uint8Array>;
|
|
21
|
+
/** 5-baud bit-bang init (ISO 9141 / KWP2000 slow init). */
|
|
22
|
+
slowInit(opts?: UartSlowInitOptions): Promise<{
|
|
23
|
+
ok: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
/** KWP2000 fast-init break/idle pulse. */
|
|
26
|
+
fastInit(opts?: UartFastInitOptions): Promise<{
|
|
27
|
+
ok: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
/** Release the lock and stop the RX pump. */
|
|
30
|
+
close(): Promise<{
|
|
31
|
+
ok: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
/** Subscribe to streamed RX bytes. Returns an unsubscribe function. */
|
|
34
|
+
onRx(handler: (ev: UartRxEvent) => void): Unsubscribe;
|
|
35
|
+
/** Subscribe to revocation events (cooperative `open` from another client). */
|
|
36
|
+
onRevoked(handler: (ev: UartRevokedEvent) => void): Unsubscribe;
|
|
37
|
+
}
|
|
38
|
+
/** Convenience: build the WS URL, open it, and wrap in a UartClient. */
|
|
39
|
+
export declare function connectUart(url: string, options?: RpcClientOptions): Promise<{
|
|
40
|
+
uart: UartClient;
|
|
41
|
+
rpc: RpcClient;
|
|
42
|
+
}>;
|
|
43
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAGjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,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|
+
/**
|
|
2
|
+
* Typed facade over the dongle's `/rpc/uart/<n>` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* Wraps a connected `RpcClient` and exposes each `uart.*` method with
|
|
5
|
+
* its proper TypeScript shape, converting binary payloads to/from
|
|
6
|
+
* `Uint8Array` so callers never have to deal with base64.
|
|
7
|
+
*/
|
|
8
|
+
import { RpcClient, encodeBase64, decodeBase64, } from "@emdzej/bimmerz-rpc-core";
|
|
9
|
+
export class UartClient {
|
|
10
|
+
rpc;
|
|
11
|
+
constructor(rpc) {
|
|
12
|
+
this.rpc = rpc;
|
|
13
|
+
}
|
|
14
|
+
/** Claim the UART, configure framing, start the RX stream. */
|
|
15
|
+
async open(opts = {}) {
|
|
16
|
+
return this.rpc.request("uart.open", opts);
|
|
17
|
+
}
|
|
18
|
+
/** Update settings while open. Caller must already hold the lock. */
|
|
19
|
+
async configure(opts) {
|
|
20
|
+
return this.rpc.request("uart.configure", opts);
|
|
21
|
+
}
|
|
22
|
+
/** Transmit raw bytes. Echo is auto-consumed if `consumeEcho` is set on open. */
|
|
23
|
+
async write(data) {
|
|
24
|
+
return this.rpc.request("uart.write", {
|
|
25
|
+
data: encodeBase64(data),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Transmit then synchronously read the response within `readMs`. */
|
|
29
|
+
async transact(data, opts) {
|
|
30
|
+
const r = await this.rpc.request("uart.transact", { data: encodeBase64(data), readMs: opts.readMs, readBytes: opts.readBytes });
|
|
31
|
+
return decodeBase64(r.data);
|
|
32
|
+
}
|
|
33
|
+
/** 5-baud bit-bang init (ISO 9141 / KWP2000 slow init). */
|
|
34
|
+
async slowInit(opts = {}) {
|
|
35
|
+
return this.rpc.request("uart.slowInit", opts);
|
|
36
|
+
}
|
|
37
|
+
/** KWP2000 fast-init break/idle pulse. */
|
|
38
|
+
async fastInit(opts = {}) {
|
|
39
|
+
return this.rpc.request("uart.fastInit", opts);
|
|
40
|
+
}
|
|
41
|
+
/** Release the lock and stop the RX pump. */
|
|
42
|
+
async close() {
|
|
43
|
+
return this.rpc.request("uart.close", {});
|
|
44
|
+
}
|
|
45
|
+
/** Subscribe to streamed RX bytes. Returns an unsubscribe function. */
|
|
46
|
+
onRx(handler) {
|
|
47
|
+
return this.rpc.on("uart.rx", (params) => {
|
|
48
|
+
handler({ data: decodeBase64(params.data) });
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Subscribe to revocation events (cooperative `open` from another client). */
|
|
52
|
+
onRevoked(handler) {
|
|
53
|
+
return this.rpc.on("uart.revoked", handler);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** Convenience: build the WS URL, open it, and wrap in a UartClient. */
|
|
57
|
+
export async function connectUart(url, options) {
|
|
58
|
+
const rpc = new RpcClient(url, options);
|
|
59
|
+
await rpc.connect();
|
|
60
|
+
return { uart: new UartClient(rpc), rpc };
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,SAAS,EAGT,YAAY,EACZ,YAAY,GACb,MAAM,0BAA0B,CAAC;AAclC,MAAM,OAAO,UAAU;IACO;IAA5B,YAA4B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE9C,8DAA8D;IAC9D,KAAK,CAAC,IAAI,CAAC,OAAwB,EAAE;QACnC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAiB,WAAW,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED,qEAAqE;IACrE,KAAK,CAAC,SAAS,CAAC,IAA0B;QACxC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAiB,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,iFAAiF;IACjF,KAAK,CAAC,KAAK,CAAC,IAAgB;QAC1B,OAAO,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AAmB,cAAc,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACF;AAED,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAW,EACX,OAA0B;IAE1B,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACxC,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,IAAI,EAAE,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;AAC5C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@emdzej/bimmerz-rpc-uart` — typed client for the bimmerz-box dongle's
|
|
3
|
+
* `/rpc/uart/<n>` endpoint. Wraps `@emdzej/bimmerz-rpc-core`.
|
|
4
|
+
*
|
|
5
|
+
* See `bimmerz-box/docs/api.md` for the full server-side contract.
|
|
6
|
+
*/
|
|
7
|
+
export { UartClient, connectUart } from "./client.js";
|
|
8
|
+
export type { Parity, DataBits, StopBits, UartOpenOptions, UartConfigureOptions, UartOpenResult, UartWriteResult, UartTransactOptions, UartSlowInitOptions, UartFastInitOptions, UartRxEvent, UartRevokedEvent, } from "./types.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EACV,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@emdzej/bimmerz-rpc-uart` — typed client for the bimmerz-box dongle's
|
|
3
|
+
* `/rpc/uart/<n>` endpoint. Wraps `@emdzej/bimmerz-rpc-core`.
|
|
4
|
+
*
|
|
5
|
+
* See `bimmerz-box/docs/api.md` for the full server-side contract.
|
|
6
|
+
*/
|
|
7
|
+
export { UartClient, connectUart } from "./client.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UART RPC method param + result shapes. Mirrors the server contract
|
|
3
|
+
* documented in `bimmerz-box/docs/api.md` (`/rpc/uart/<n>` section).
|
|
4
|
+
*/
|
|
5
|
+
export type Parity = "none" | "even" | "odd";
|
|
6
|
+
export type DataBits = 7 | 8;
|
|
7
|
+
export type StopBits = 1 | 2;
|
|
8
|
+
export interface UartOpenOptions {
|
|
9
|
+
/** True → reject open if held; false (default) → revoke prior holder. */
|
|
10
|
+
exclusive?: boolean;
|
|
11
|
+
/** Bit-rate (bps). Default 9600 for K-line. */
|
|
12
|
+
baud?: number;
|
|
13
|
+
parity?: Parity;
|
|
14
|
+
dataBits?: DataBits;
|
|
15
|
+
stopBits?: StopBits;
|
|
16
|
+
/**
|
|
17
|
+
* For half-duplex K-line: `uart.write` reads the matching TX echo
|
|
18
|
+
* back from the bus and discards it before returning, so callers
|
|
19
|
+
* never see their own bytes. When false, the echo arrives via
|
|
20
|
+
* `uart.rx`. Default true.
|
|
21
|
+
*/
|
|
22
|
+
consumeEcho?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export type UartConfigureOptions = UartOpenOptions;
|
|
25
|
+
export interface UartOpenResult {
|
|
26
|
+
ok: boolean;
|
|
27
|
+
baud: number;
|
|
28
|
+
parity: Parity;
|
|
29
|
+
exclusive: boolean;
|
|
30
|
+
consumeEcho: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface UartWriteResult {
|
|
33
|
+
ok: boolean;
|
|
34
|
+
wrote: number;
|
|
35
|
+
}
|
|
36
|
+
export interface UartTransactOptions {
|
|
37
|
+
/** Total budget (ms) for the response read. */
|
|
38
|
+
readMs: number;
|
|
39
|
+
/** Maximum bytes to read. Default 256. */
|
|
40
|
+
readBytes?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface UartSlowInitOptions {
|
|
43
|
+
/** Byte to bit-bang at 5 baud. Default 0x33 (BMW K-line wake address). */
|
|
44
|
+
value?: number;
|
|
45
|
+
/** Bit time. Default 200 ms (ISO 9141). */
|
|
46
|
+
bitTimeMs?: number;
|
|
47
|
+
/** Optional baud rate to switch to immediately after the pulse. */
|
|
48
|
+
baudAfter?: number;
|
|
49
|
+
/** Optional parity to switch to after the pulse. */
|
|
50
|
+
parityAfter?: Parity;
|
|
51
|
+
}
|
|
52
|
+
export interface UartFastInitOptions {
|
|
53
|
+
/** Break duration. Default 25 ms (KWP2000). */
|
|
54
|
+
breakMs?: number;
|
|
55
|
+
/** Idle high duration after break. Default 25 ms. */
|
|
56
|
+
idleMs?: number;
|
|
57
|
+
}
|
|
58
|
+
/** Streamed RX bytes. */
|
|
59
|
+
export interface UartRxEvent {
|
|
60
|
+
data: Uint8Array;
|
|
61
|
+
}
|
|
62
|
+
/** Sent when a cooperative `open` kicks us off the bus. */
|
|
63
|
+
export interface UartRevokedEvent {
|
|
64
|
+
by: string;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG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,CAAC;CACjB;AAED,yBAAyB;AACzB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;CACZ"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@emdzej/bimmerz-rpc-uart",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Typed client for the bimmerz-box dongle's /rpc/uart/<n> endpoint. Built on @emdzej/bimmerz-rpc-core.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@emdzej/bimmerz-rpc-core": "0.1.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^22.13.1",
|
|
23
|
+
"typescript": "^5.7.3"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/emdzej/bimmerz.git",
|
|
31
|
+
"directory": "packages/rpc-uart"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"dev": "tsc --watch",
|
|
36
|
+
"lint": "eslint .",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"clean": "rm -rf dist .turbo *.tsbuildinfo"
|
|
39
|
+
}
|
|
40
|
+
}
|