@v5x/serial 0.5.4 → 0.5.5
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 +72 -6
- package/dist/Vex.d.ts +4 -4
- package/dist/VexCRC.d.ts +0 -1
- package/dist/VexConnection.d.ts +81 -23
- package/dist/VexDevice.d.ts +41 -155
- package/{dts/VexDevice.d.ts → dist/VexDeviceState.d.ts} +63 -55
- package/dist/VexError.d.ts +47 -0
- package/dist/VexFirmware.d.ts +45 -0
- package/dist/VexIniConfig.d.ts +1 -1
- package/dist/VexPacket.d.ts +3 -512
- package/dist/VexPacketBase.d.ts +21 -0
- package/dist/VexPacketEncoder.d.ts +55 -0
- package/{dts/VexPacket.d.ts → dist/VexPacketModels.d.ts} +3 -107
- package/dist/VexPacketView.d.ts +3 -3
- package/dist/VexTransfers.d.ts +20 -0
- package/dist/index.cjs +4541 -0
- package/dist/index.cjs.map +25 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +4460 -0
- package/dist/index.js.map +25 -0
- package/package.json +39 -71
- package/dist/v5-serial-protocol.cjs.js +0 -4516
- package/dist/v5-serial-protocol.cjs.js.map +0 -1
- package/dist/v5-serial-protocol.es.js +0 -4401
- package/dist/v5-serial-protocol.es.js.map +0 -1
- package/dts/Vex.d.ts +0 -235
- package/dts/Vex.js +0 -189
- package/dts/Vex.js.map +0 -1
- package/dts/VexCRC.d.ts +0 -19
- package/dts/VexCRC.js +0 -89
- package/dts/VexCRC.js.map +0 -1
- package/dts/VexConnection.d.ts +0 -45
- package/dts/VexConnection.js +0 -500
- package/dts/VexConnection.js.map +0 -1
- package/dts/VexDevice.js +0 -944
- package/dts/VexDevice.js.map +0 -1
- package/dts/VexEvent.d.ts +0 -16
- package/dts/VexEvent.js +0 -47
- package/dts/VexEvent.js.map +0 -1
- package/dts/VexFirmwareVersion.d.ts +0 -55
- package/dts/VexFirmwareVersion.js +0 -104
- package/dts/VexFirmwareVersion.js.map +0 -1
- package/dts/VexIniConfig.d.ts +0 -27
- package/dts/VexIniConfig.js +0 -122
- package/dts/VexIniConfig.js.map +0 -1
- package/dts/VexPacket.js +0 -1036
- package/dts/VexPacket.js.map +0 -1
- package/dts/VexPacketView.d.ts +0 -18
- package/dts/VexPacketView.js +0 -84
- package/dts/VexPacketView.js.map +0 -1
- package/dts/index.d.ts +0 -9
- package/dts/index.js +0 -10
- package/dts/index.js.map +0 -1
- package/index.d.ts +0 -1098
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed error hierarchy for the serial protocol package.
|
|
3
|
+
*
|
|
4
|
+
* Every public async API that can fail returns a {@link Result} (or
|
|
5
|
+
* {@link ResultAsync}) whose error channel is a {@link VexSerialError}.
|
|
6
|
+
* Each error carries a stable {@link VexSerialError.kind} discriminator
|
|
7
|
+
* so callers can branch on the failure category without parsing messages.
|
|
8
|
+
*/
|
|
9
|
+
export type VexSerialErrorKind = "not-connected" | "invalid-argument" | "protocol" | "transfer" | "download" | "firmware" | "io";
|
|
10
|
+
/** Base class for every failure surfaced by the serial package. */
|
|
11
|
+
export declare class VexSerialError extends Error {
|
|
12
|
+
readonly kind: VexSerialErrorKind;
|
|
13
|
+
constructor(kind: VexSerialErrorKind, message: string);
|
|
14
|
+
}
|
|
15
|
+
/** No connection is currently open to a device. */
|
|
16
|
+
export declare class VexNotConnectedError extends VexSerialError {
|
|
17
|
+
constructor(message?: string);
|
|
18
|
+
}
|
|
19
|
+
/** A caller supplied an invalid argument value. */
|
|
20
|
+
export declare class VexInvalidArgumentError extends VexSerialError {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
/** The device refused, timed out, or replied unexpectedly to a command. */
|
|
24
|
+
export declare class VexProtocolError extends VexSerialError {
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
27
|
+
/** A file-transfer handshake, read, write, or exit failed. */
|
|
28
|
+
export declare class VexTransferError extends VexSerialError {
|
|
29
|
+
constructor(message: string);
|
|
30
|
+
}
|
|
31
|
+
/** A remote resource download (catalog/VEXos) failed. */
|
|
32
|
+
export declare class VexDownloadError extends VexSerialError {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
/** A firmware archive was malformed, oversized, or incomplete. */
|
|
36
|
+
export declare class VexFirmwareError extends VexSerialError {
|
|
37
|
+
constructor(message: string);
|
|
38
|
+
}
|
|
39
|
+
/** An underlying transport (serial port, stream) error. */
|
|
40
|
+
export declare class VexIoError extends VexSerialError {
|
|
41
|
+
constructor(message: string);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Coerce an arbitrary thrown value into a {@link VexSerialError} so it
|
|
45
|
+
* can be returned through the {@link Result} error channel.
|
|
46
|
+
*/
|
|
47
|
+
export declare function toVexSerialError(error: unknown, fallback?: VexSerialErrorKind): VexSerialError;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { V5SerialDeviceState } from "./VexDeviceState.js";
|
|
2
|
+
import { VexSerialError } from "./VexError.js";
|
|
3
|
+
import { ResultAsync } from "neverthrow";
|
|
4
|
+
export interface DownloadFileFromInternetOptions {
|
|
5
|
+
/** Maximum total bytes to read from the response body. */
|
|
6
|
+
maxBytes?: number;
|
|
7
|
+
/** Request timeout in milliseconds. */
|
|
8
|
+
timeout?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Download a remote resource while enforcing a maximum body size. The
|
|
12
|
+
* declared `Content-Length` header is validated up front, and the body
|
|
13
|
+
* is streamed so an oversized payload is rejected before it is fully
|
|
14
|
+
* read into memory. Failures are returned as a {@link VexDownloadError}
|
|
15
|
+
* (or {@link VexInvalidArgumentError} for bad options) instead of
|
|
16
|
+
* thrown.
|
|
17
|
+
*/
|
|
18
|
+
export declare function downloadFileFromInternet(link: string, options?: DownloadFileFromInternetOptions): ResultAsync<ArrayBuffer, VexSerialError>;
|
|
19
|
+
/**
|
|
20
|
+
* Poll an async predicate until it returns true or the timeout elapses.
|
|
21
|
+
* Argument errors are returned as {@link VexInvalidArgumentError}; a
|
|
22
|
+
* throwing predicate surfaces its error through the {@link Result}
|
|
23
|
+
* error channel.
|
|
24
|
+
*/
|
|
25
|
+
export declare function sleepUntilAsync(f: () => Promise<boolean>, timeout: number, interval?: number): ResultAsync<boolean, VexSerialError>;
|
|
26
|
+
/**
|
|
27
|
+
* Poll a synchronous predicate until it returns true or the timeout
|
|
28
|
+
* elapses. The implementation uses a loop with `sleep` rather than
|
|
29
|
+
* `setInterval` so the timer is cleared as soon as the predicate
|
|
30
|
+
* resolves, and so predicate exceptions are surfaced without leaving a
|
|
31
|
+
* pending interval behind.
|
|
32
|
+
*/
|
|
33
|
+
export declare function sleepUntil(f: () => boolean, timeout: number, interval?: number): ResultAsync<boolean, VexSerialError>;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve after `ms` milliseconds. Returns a {@link VexInvalidArgumentError}
|
|
36
|
+
* when `ms` is negative.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sleep(ms: number): ResultAsync<void, VexSerialError>;
|
|
39
|
+
/**
|
|
40
|
+
* Upload a VEXos firmware archive to a connected brain. Network and
|
|
41
|
+
* archive validation failures are returned as {@link VexSerialError}
|
|
42
|
+
* values rather than thrown; a device that refuses a step or a missing
|
|
43
|
+
* connection surfaces as {@link VexProtocolError} / {@link VexNotConnectedError}.
|
|
44
|
+
*/
|
|
45
|
+
export declare function uploadFirmware(state: V5SerialDeviceState, publicUrl?: string, usingVersion?: string, progressCallback?: (state: string, current: number, total: number) => void): ResultAsync<boolean, VexSerialError>;
|
package/dist/VexIniConfig.d.ts
CHANGED
package/dist/VexPacket.d.ts
CHANGED
|
@@ -1,512 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { VexFirmwareVersion } from "./VexFirmwareVersion";
|
|
5
|
-
export declare class PacketEncoder {
|
|
6
|
-
static HEADERS_LENGTH: number;
|
|
7
|
-
static HEADER_TO_DEVICE: number[];
|
|
8
|
-
static HEADER_TO_HOST: number[];
|
|
9
|
-
static J2000_EPOCH: number;
|
|
10
|
-
vexVersion: number;
|
|
11
|
-
crcgen: CrcGenerator;
|
|
12
|
-
allPacketsTable: Record<string, typeof HostBoundPacket>;
|
|
13
|
-
static getInstance(): AllPackets.PacketEncoder;
|
|
14
|
-
private constructor();
|
|
15
|
-
/**
|
|
16
|
-
* Create the vex CDC header
|
|
17
|
-
* @param buf the bytes to send
|
|
18
|
-
*/
|
|
19
|
-
createHeader(buf: ArrayBuffer | undefined): Uint8Array;
|
|
20
|
-
/**
|
|
21
|
-
* Create the vex CDC simple message
|
|
22
|
-
* @param cmd the CDC command byte
|
|
23
|
-
*/
|
|
24
|
-
cdcCommand(cmd: number): Uint8Array;
|
|
25
|
-
/**
|
|
26
|
-
* Create the vex CDC simple message
|
|
27
|
-
* @param cmd the CDC command byte
|
|
28
|
-
* @param data the data to send
|
|
29
|
-
*/
|
|
30
|
-
cdcCommandWithData(cmd: number, data: Uint8Array): Uint8Array;
|
|
31
|
-
/**
|
|
32
|
-
* Create the vex CDC extended message
|
|
33
|
-
* @param cmd the CDC command byte
|
|
34
|
-
* @param ext the CDC extended command byte
|
|
35
|
-
* @return a message
|
|
36
|
-
*/
|
|
37
|
-
cdc2Command(cmd: number, ext: number): Uint8Array;
|
|
38
|
-
/**
|
|
39
|
-
* Calculate buffer length for new CDC extended command
|
|
40
|
-
* @param data the CDC extended command payload
|
|
41
|
-
* @returns the required buffer length of the command message
|
|
42
|
-
*/
|
|
43
|
-
cdc2CommandBufferLength(data: Uint8Array): number;
|
|
44
|
-
/**
|
|
45
|
-
* Create the vex CDC extended message with some data
|
|
46
|
-
* @param cmd the CDC command byte
|
|
47
|
-
* @param ext the CDC extended command byte
|
|
48
|
-
* @param data the CDC extended command payload
|
|
49
|
-
* @return a message
|
|
50
|
-
*/
|
|
51
|
-
cdc2CommandWithData(cmd: number, ext: number, data: Uint8Array): Uint8Array;
|
|
52
|
-
validateHeader(data: Uint8Array): boolean;
|
|
53
|
-
validateMessageCdc(data: Uint8Array): boolean;
|
|
54
|
-
getPayloadSize(data: Uint8Array): number;
|
|
55
|
-
}
|
|
56
|
-
export declare abstract class Packet {
|
|
57
|
-
data: Uint8Array;
|
|
58
|
-
static ENCODER: PacketEncoder;
|
|
59
|
-
constructor(rawData: DataArray);
|
|
60
|
-
}
|
|
61
|
-
export declare class DeviceBoundPacket extends Packet {
|
|
62
|
-
constructor(payload?: Uint8Array);
|
|
63
|
-
}
|
|
64
|
-
export declare class Query1H2DPacket extends DeviceBoundPacket {
|
|
65
|
-
static COMMAND_ID: number;
|
|
66
|
-
static COMMAND_EXTENDED_ID: undefined;
|
|
67
|
-
constructor();
|
|
68
|
-
}
|
|
69
|
-
export declare class SystemVersionH2DPacket extends DeviceBoundPacket {
|
|
70
|
-
static COMMAND_ID: number;
|
|
71
|
-
static COMMAND_EXTENDED_ID: undefined;
|
|
72
|
-
constructor();
|
|
73
|
-
}
|
|
74
|
-
export declare class UpdateMatchModeH2DPacket extends DeviceBoundPacket {
|
|
75
|
-
static COMMAND_ID: number;
|
|
76
|
-
static COMMAND_EXTENDED_ID: number;
|
|
77
|
-
constructor(mode: MatchMode, matchClock: number);
|
|
78
|
-
}
|
|
79
|
-
export declare class GetMatchStatusH2DPacket extends DeviceBoundPacket {
|
|
80
|
-
static COMMAND_ID: number;
|
|
81
|
-
static COMMAND_EXTENDED_ID: number;
|
|
82
|
-
constructor();
|
|
83
|
-
}
|
|
84
|
-
export declare class GetRadioModeH2DPacket extends DeviceBoundPacket {
|
|
85
|
-
static COMMAND_ID: number;
|
|
86
|
-
static COMMAND_EXTENDED_ID: number;
|
|
87
|
-
constructor(mode: number);
|
|
88
|
-
}
|
|
89
|
-
export declare class FileControlH2DPacket extends DeviceBoundPacket {
|
|
90
|
-
static COMMAND_ID: number;
|
|
91
|
-
static COMMAND_EXTENDED_ID: number;
|
|
92
|
-
constructor(a: number, b: number);
|
|
93
|
-
}
|
|
94
|
-
export declare class InitFileTransferH2DPacket extends DeviceBoundPacket {
|
|
95
|
-
static COMMAND_ID: number;
|
|
96
|
-
static COMMAND_EXTENDED_ID: number;
|
|
97
|
-
constructor(operation: FileInitAction, target: FileDownloadTarget, vendor: FileVendor, options: FileInitOption, binary: Uint8Array, addr: number, name: string, type?: string, version?: VexFirmwareVersion);
|
|
98
|
-
}
|
|
99
|
-
export declare class ExitFileTransferH2DPacket extends DeviceBoundPacket {
|
|
100
|
-
static COMMAND_ID: number;
|
|
101
|
-
static COMMAND_EXTENDED_ID: number;
|
|
102
|
-
constructor(action: FileExitAction);
|
|
103
|
-
}
|
|
104
|
-
export declare class WriteFileH2DPacket extends DeviceBoundPacket {
|
|
105
|
-
static COMMAND_ID: number;
|
|
106
|
-
static COMMAND_EXTENDED_ID: number;
|
|
107
|
-
constructor(addr: number, buf: Uint8Array);
|
|
108
|
-
}
|
|
109
|
-
export declare class ReadFileH2DPacket extends DeviceBoundPacket {
|
|
110
|
-
static COMMAND_ID: number;
|
|
111
|
-
static COMMAND_EXTENDED_ID: number;
|
|
112
|
-
constructor(addr: number, size: number);
|
|
113
|
-
}
|
|
114
|
-
export declare class LinkFileH2DPacket extends DeviceBoundPacket {
|
|
115
|
-
static COMMAND_ID: number;
|
|
116
|
-
static COMMAND_EXTENDED_ID: number;
|
|
117
|
-
constructor(vendor: FileVendor, fileName: string, options: number);
|
|
118
|
-
}
|
|
119
|
-
export declare class GetDirectoryFileCountH2DPacket extends DeviceBoundPacket {
|
|
120
|
-
static COMMAND_ID: number;
|
|
121
|
-
static COMMAND_EXTENDED_ID: number;
|
|
122
|
-
constructor(vendor: FileVendor);
|
|
123
|
-
}
|
|
124
|
-
export declare class GetDirectoryEntryH2DPacket extends DeviceBoundPacket {
|
|
125
|
-
static COMMAND_ID: number;
|
|
126
|
-
static COMMAND_EXTENDED_ID: number;
|
|
127
|
-
constructor(index: number);
|
|
128
|
-
}
|
|
129
|
-
export declare class LoadFileActionH2DPacket extends DeviceBoundPacket {
|
|
130
|
-
static COMMAND_ID: number;
|
|
131
|
-
static COMMAND_EXTENDED_ID: number;
|
|
132
|
-
constructor(vendor: FileVendor, actionId: FileLoadAction, fileNameOrSlotNumber: SlotNumber | string);
|
|
133
|
-
}
|
|
134
|
-
export declare class GetFileMetadataH2DPacket extends DeviceBoundPacket {
|
|
135
|
-
static COMMAND_ID: number;
|
|
136
|
-
static COMMAND_EXTENDED_ID: number;
|
|
137
|
-
constructor(vendor: FileVendor, fileName: string, options: number);
|
|
138
|
-
}
|
|
139
|
-
export declare class SetFileMetadataH2DPacket extends DeviceBoundPacket {
|
|
140
|
-
static COMMAND_ID: number;
|
|
141
|
-
static COMMAND_EXTENDED_ID: number;
|
|
142
|
-
constructor(vendor: FileVendor, fileName: string, fileInfo: IFileMetadata, options: number);
|
|
143
|
-
}
|
|
144
|
-
export declare class EraseFileH2DPacket extends DeviceBoundPacket {
|
|
145
|
-
static COMMAND_ID: number;
|
|
146
|
-
static COMMAND_EXTENDED_ID: number;
|
|
147
|
-
constructor(vendor: FileVendor, fileName: string);
|
|
148
|
-
}
|
|
149
|
-
export declare class GetProgramSlotInfoH2DPacket extends DeviceBoundPacket {
|
|
150
|
-
static COMMAND_ID: number;
|
|
151
|
-
static COMMAND_EXTENDED_ID: number;
|
|
152
|
-
constructor(vendor: FileVendor, fileName: string);
|
|
153
|
-
}
|
|
154
|
-
export declare class FileClearUpH2DPacket extends DeviceBoundPacket {
|
|
155
|
-
static COMMAND_ID: number;
|
|
156
|
-
static COMMAND_EXTENDED_ID: number;
|
|
157
|
-
constructor(vendor: FileVendor);
|
|
158
|
-
}
|
|
159
|
-
export declare class FileFormatH2DPacket extends DeviceBoundPacket {
|
|
160
|
-
static COMMAND_ID: number;
|
|
161
|
-
static COMMAND_EXTENDED_ID: number;
|
|
162
|
-
constructor();
|
|
163
|
-
}
|
|
164
|
-
export declare class GetSystemFlagsH2DPacket extends DeviceBoundPacket {
|
|
165
|
-
static COMMAND_ID: number;
|
|
166
|
-
static COMMAND_EXTENDED_ID: number;
|
|
167
|
-
}
|
|
168
|
-
export declare class GetDeviceStatusH2DPacket extends DeviceBoundPacket {
|
|
169
|
-
static COMMAND_ID: number;
|
|
170
|
-
static COMMAND_EXTENDED_ID: number;
|
|
171
|
-
constructor();
|
|
172
|
-
}
|
|
173
|
-
export declare class GetSystemStatusH2DPacket extends DeviceBoundPacket {
|
|
174
|
-
static COMMAND_ID: number;
|
|
175
|
-
static COMMAND_EXTENDED_ID: number;
|
|
176
|
-
constructor();
|
|
177
|
-
}
|
|
178
|
-
export declare class GetFdtStatusH2DPacket extends DeviceBoundPacket {
|
|
179
|
-
static COMMAND_ID: number;
|
|
180
|
-
static COMMAND_EXTENDED_ID: number;
|
|
181
|
-
constructor();
|
|
182
|
-
}
|
|
183
|
-
export declare class GetLogCountH2DPacket extends DeviceBoundPacket {
|
|
184
|
-
static COMMAND_ID: number;
|
|
185
|
-
static COMMAND_EXTENDED_ID: number;
|
|
186
|
-
constructor();
|
|
187
|
-
}
|
|
188
|
-
export declare class ReadLogPageH2DPacket extends DeviceBoundPacket {
|
|
189
|
-
static COMMAND_ID: number;
|
|
190
|
-
static COMMAND_EXTENDED_ID: number;
|
|
191
|
-
constructor(offset: number, count: number);
|
|
192
|
-
}
|
|
193
|
-
export declare class GetRadioStatusH2DPacket extends DeviceBoundPacket {
|
|
194
|
-
static COMMAND_ID: number;
|
|
195
|
-
static COMMAND_EXTENDED_ID: number;
|
|
196
|
-
constructor();
|
|
197
|
-
}
|
|
198
|
-
export declare class GetUserDataH2DPacket extends DeviceBoundPacket {
|
|
199
|
-
static COMMAND_ID: number;
|
|
200
|
-
static COMMAND_EXTENDED_ID: number;
|
|
201
|
-
constructor(e?: Uint8Array);
|
|
202
|
-
}
|
|
203
|
-
export declare class ScreenCaptureH2DPacket extends DeviceBoundPacket {
|
|
204
|
-
static COMMAND_ID: number;
|
|
205
|
-
static COMMAND_EXTENDED_ID: number;
|
|
206
|
-
constructor(e: number);
|
|
207
|
-
}
|
|
208
|
-
export declare class SendDashTouchH2DPacket extends DeviceBoundPacket {
|
|
209
|
-
static COMMAND_ID: number;
|
|
210
|
-
static COMMAND_EXTENDED_ID: number;
|
|
211
|
-
constructor(x: number, y: number, press: boolean);
|
|
212
|
-
}
|
|
213
|
-
export declare class SelectDashH2DPacket extends DeviceBoundPacket {
|
|
214
|
-
static COMMAND_ID: number;
|
|
215
|
-
static COMMAND_EXTENDED_ID: number;
|
|
216
|
-
/** @param port untested */
|
|
217
|
-
constructor(screen: number | SelectDashScreen, port: number);
|
|
218
|
-
}
|
|
219
|
-
export declare class EnableDashH2DPacket extends DeviceBoundPacket {
|
|
220
|
-
static COMMAND_ID: number;
|
|
221
|
-
static COMMAND_EXTENDED_ID: number;
|
|
222
|
-
constructor(unknown1?: number);
|
|
223
|
-
}
|
|
224
|
-
export declare class DisableDashH2DPacket extends DeviceBoundPacket {
|
|
225
|
-
static COMMAND_ID: number;
|
|
226
|
-
static COMMAND_EXTENDED_ID: number;
|
|
227
|
-
constructor();
|
|
228
|
-
}
|
|
229
|
-
export declare class ReadKeyValueH2DPacket extends DeviceBoundPacket {
|
|
230
|
-
static COMMAND_ID: number;
|
|
231
|
-
static COMMAND_EXTENDED_ID: number;
|
|
232
|
-
constructor(key: string);
|
|
233
|
-
}
|
|
234
|
-
export declare class WriteKeyValueH2DPacket extends DeviceBoundPacket {
|
|
235
|
-
static COMMAND_ID: number;
|
|
236
|
-
static COMMAND_EXTENDED_ID: number;
|
|
237
|
-
constructor(key: string, value: string);
|
|
238
|
-
}
|
|
239
|
-
export declare class GetSlot1to4InfoH2DPacket extends DeviceBoundPacket {
|
|
240
|
-
static COMMAND_ID: number;
|
|
241
|
-
static COMMAND_EXTENDED_ID: number;
|
|
242
|
-
constructor();
|
|
243
|
-
}
|
|
244
|
-
export declare class GetSlot5to8InfoH2DPacket extends DeviceBoundPacket {
|
|
245
|
-
static COMMAND_ID: number;
|
|
246
|
-
static COMMAND_EXTENDED_ID: number;
|
|
247
|
-
constructor();
|
|
248
|
-
}
|
|
249
|
-
export declare class FactoryStatusH2DPacket extends DeviceBoundPacket {
|
|
250
|
-
static COMMAND_ID: number;
|
|
251
|
-
static COMMAND_EXTENDED_ID: number;
|
|
252
|
-
}
|
|
253
|
-
export declare class FactoryEnableH2DPacket extends DeviceBoundPacket {
|
|
254
|
-
static COMMAND_ID: number;
|
|
255
|
-
static COMMAND_EXTENDED_ID: number;
|
|
256
|
-
constructor();
|
|
257
|
-
}
|
|
258
|
-
export declare class HostBoundPacket extends Packet {
|
|
259
|
-
ack: AckType;
|
|
260
|
-
payloadSize: number;
|
|
261
|
-
ackIndex: number;
|
|
262
|
-
constructor(data: DataArray);
|
|
263
|
-
static isValidPacket(data: Uint8Array, n: number): boolean;
|
|
264
|
-
}
|
|
265
|
-
export declare class Query1ReplyD2HPacket extends HostBoundPacket {
|
|
266
|
-
static COMMAND_ID: number;
|
|
267
|
-
static COMMAND_EXTENDED_ID: undefined;
|
|
268
|
-
joystickFlag1: number;
|
|
269
|
-
joystickFlag2: number;
|
|
270
|
-
brainFlag1: number;
|
|
271
|
-
brainFlag2: number;
|
|
272
|
-
bootloadFlag1: number;
|
|
273
|
-
bootloadFlag2: number;
|
|
274
|
-
constructor(data: DataArray);
|
|
275
|
-
}
|
|
276
|
-
export declare class SystemVersionReplyD2HPacket extends HostBoundPacket {
|
|
277
|
-
static COMMAND_ID: number;
|
|
278
|
-
static COMMAND_EXTENDED_ID: undefined;
|
|
279
|
-
version: VexFirmwareVersion;
|
|
280
|
-
hardware: number;
|
|
281
|
-
constructor(data: DataArray);
|
|
282
|
-
}
|
|
283
|
-
export declare class MatchModeReplyD2HPacket extends HostBoundPacket {
|
|
284
|
-
static COMMAND_ID: number;
|
|
285
|
-
static COMMAND_EXTENDED_ID: number;
|
|
286
|
-
modebit: number;
|
|
287
|
-
constructor(data: DataArray);
|
|
288
|
-
}
|
|
289
|
-
export declare class MatchStatusReplyD2HPacket extends HostBoundPacket {
|
|
290
|
-
static COMMAND_ID: number;
|
|
291
|
-
static COMMAND_EXTENDED_ID: number;
|
|
292
|
-
rssi: number;
|
|
293
|
-
systemStatusBits: number;
|
|
294
|
-
radioStatusBits: number;
|
|
295
|
-
fieldStatusBits: number;
|
|
296
|
-
matchClock: number;
|
|
297
|
-
brainBatteryPercent: number;
|
|
298
|
-
controllerBatteryPercent: number;
|
|
299
|
-
partnerControllerBatteryPercent: number;
|
|
300
|
-
pad: number;
|
|
301
|
-
buttons: number;
|
|
302
|
-
activeProgram: number;
|
|
303
|
-
radioType: number;
|
|
304
|
-
radioChannel: number;
|
|
305
|
-
radioSlot: number;
|
|
306
|
-
robotName: string;
|
|
307
|
-
controllerFlags: number;
|
|
308
|
-
rxSignalQuality: number;
|
|
309
|
-
constructor(data: DataArray);
|
|
310
|
-
}
|
|
311
|
-
export declare class FileControlReplyD2HPacket extends HostBoundPacket {
|
|
312
|
-
static COMMAND_ID: number;
|
|
313
|
-
static COMMAND_EXTENDED_ID: number;
|
|
314
|
-
}
|
|
315
|
-
export declare class InitFileTransferReplyD2HPacket extends HostBoundPacket {
|
|
316
|
-
static COMMAND_ID: number;
|
|
317
|
-
static COMMAND_EXTENDED_ID: number;
|
|
318
|
-
windowSize: number;
|
|
319
|
-
fileSize: number;
|
|
320
|
-
crc32: number;
|
|
321
|
-
constructor(data: DataArray);
|
|
322
|
-
}
|
|
323
|
-
export declare class ExitFileTransferReplyD2HPacket extends HostBoundPacket {
|
|
324
|
-
static COMMAND_ID: number;
|
|
325
|
-
static COMMAND_EXTENDED_ID: number;
|
|
326
|
-
}
|
|
327
|
-
export declare class WriteFileReplyD2HPacket extends HostBoundPacket {
|
|
328
|
-
static COMMAND_ID: number;
|
|
329
|
-
static COMMAND_EXTENDED_ID: number;
|
|
330
|
-
}
|
|
331
|
-
export declare class ReadFileReplyD2HPacket extends HostBoundPacket {
|
|
332
|
-
static COMMAND_ID: number;
|
|
333
|
-
static COMMAND_EXTENDED_ID: number;
|
|
334
|
-
addr: number;
|
|
335
|
-
length: number;
|
|
336
|
-
buf: ArrayBuffer;
|
|
337
|
-
constructor(data: DataArray);
|
|
338
|
-
static isValidPacket(data: Uint8Array, n: number): boolean;
|
|
339
|
-
}
|
|
340
|
-
export declare class LinkFileReplyD2HPacket extends HostBoundPacket {
|
|
341
|
-
static COMMAND_ID: number;
|
|
342
|
-
static COMMAND_EXTENDED_ID: number;
|
|
343
|
-
}
|
|
344
|
-
export declare class GetDirectoryFileCountReplyD2HPacket extends HostBoundPacket {
|
|
345
|
-
static COMMAND_ID: number;
|
|
346
|
-
static COMMAND_EXTENDED_ID: number;
|
|
347
|
-
count: number;
|
|
348
|
-
constructor(data: DataArray);
|
|
349
|
-
}
|
|
350
|
-
export declare class GetDirectoryEntryReplyD2HPacket extends HostBoundPacket {
|
|
351
|
-
static COMMAND_ID: number;
|
|
352
|
-
static COMMAND_EXTENDED_ID: number;
|
|
353
|
-
file?: IFileEntry;
|
|
354
|
-
constructor(data: DataArray);
|
|
355
|
-
}
|
|
356
|
-
export declare class LoadFileActionReplyD2HPacket extends HostBoundPacket {
|
|
357
|
-
static COMMAND_ID: number;
|
|
358
|
-
static COMMAND_EXTENDED_ID: number;
|
|
359
|
-
}
|
|
360
|
-
export declare class GetFileMetadataReplyD2HPacket extends HostBoundPacket {
|
|
361
|
-
static COMMAND_ID: number;
|
|
362
|
-
static COMMAND_EXTENDED_ID: number;
|
|
363
|
-
file?: IFileMetadata;
|
|
364
|
-
constructor(data: DataArray);
|
|
365
|
-
}
|
|
366
|
-
export declare class SetFileMetadataReplyD2HPacket extends HostBoundPacket {
|
|
367
|
-
static COMMAND_ID: number;
|
|
368
|
-
static COMMAND_EXTENDED_ID: number;
|
|
369
|
-
}
|
|
370
|
-
export declare class EraseFileReplyD2HPacket extends HostBoundPacket {
|
|
371
|
-
static COMMAND_ID: number;
|
|
372
|
-
static COMMAND_EXTENDED_ID: number;
|
|
373
|
-
}
|
|
374
|
-
export declare class GetProgramSlotInfoReplyD2HPacket extends HostBoundPacket {
|
|
375
|
-
static COMMAND_ID: number;
|
|
376
|
-
static COMMAND_EXTENDED_ID: number;
|
|
377
|
-
requestedSlot: number;
|
|
378
|
-
slot: number;
|
|
379
|
-
constructor(data: DataArray);
|
|
380
|
-
}
|
|
381
|
-
export declare class FileClearUpReplyD2HPacket extends HostBoundPacket {
|
|
382
|
-
static COMMAND_ID: number;
|
|
383
|
-
static COMMAND_EXTENDED_ID: number;
|
|
384
|
-
}
|
|
385
|
-
export declare class FileFormatReplyD2HPacket extends HostBoundPacket {
|
|
386
|
-
static COMMAND_ID: number;
|
|
387
|
-
static COMMAND_EXTENDED_ID: number;
|
|
388
|
-
}
|
|
389
|
-
export declare class GetSystemFlagsReplyD2HPacket extends HostBoundPacket {
|
|
390
|
-
static COMMAND_ID: number;
|
|
391
|
-
static COMMAND_EXTENDED_ID: number;
|
|
392
|
-
flags: number;
|
|
393
|
-
radioSearching: boolean;
|
|
394
|
-
radioQuality?: number;
|
|
395
|
-
controllerBatteryPercent?: number;
|
|
396
|
-
partnerControllerBatteryPercent?: number;
|
|
397
|
-
battery?: number;
|
|
398
|
-
currentProgram: number;
|
|
399
|
-
constructor(data: DataArray);
|
|
400
|
-
}
|
|
401
|
-
export declare class GetDeviceStatusReplyD2HPacket extends HostBoundPacket {
|
|
402
|
-
static COMMAND_ID: number;
|
|
403
|
-
static COMMAND_EXTENDED_ID: number;
|
|
404
|
-
count: number;
|
|
405
|
-
devices: ISmartDeviceInfo[];
|
|
406
|
-
constructor(data: DataArray);
|
|
407
|
-
}
|
|
408
|
-
export declare class GetSystemStatusReplyD2HPacket extends HostBoundPacket {
|
|
409
|
-
static COMMAND_ID: number;
|
|
410
|
-
static COMMAND_EXTENDED_ID: number;
|
|
411
|
-
systemVersion: VexFirmwareVersion;
|
|
412
|
-
cpu0Version: VexFirmwareVersion;
|
|
413
|
-
cpu1Version: VexFirmwareVersion;
|
|
414
|
-
nxpVersion: VexFirmwareVersion;
|
|
415
|
-
touchVersion: VexFirmwareVersion;
|
|
416
|
-
uniqueId: number;
|
|
417
|
-
sysflags: number[];
|
|
418
|
-
eventBrain: boolean;
|
|
419
|
-
romBootloaderActive: boolean;
|
|
420
|
-
ramBootloaderActive: boolean;
|
|
421
|
-
goldenVersion: VexFirmwareVersion;
|
|
422
|
-
constructor(data: DataArray);
|
|
423
|
-
}
|
|
424
|
-
export declare class GetFdtStatusReplyD2HPacket extends HostBoundPacket {
|
|
425
|
-
static COMMAND_ID: number;
|
|
426
|
-
static COMMAND_EXTENDED_ID: number;
|
|
427
|
-
count: number;
|
|
428
|
-
status: unknown[];
|
|
429
|
-
constructor(data: DataArray);
|
|
430
|
-
}
|
|
431
|
-
export declare class GetLogCountReplyD2HPacket extends HostBoundPacket {
|
|
432
|
-
static COMMAND_ID: number;
|
|
433
|
-
static COMMAND_EXTENDED_ID: number;
|
|
434
|
-
count: number;
|
|
435
|
-
constructor(data: DataArray);
|
|
436
|
-
}
|
|
437
|
-
export declare class ReadLogPageReplyD2HPacket extends HostBoundPacket {
|
|
438
|
-
static COMMAND_ID: number;
|
|
439
|
-
static COMMAND_EXTENDED_ID: number;
|
|
440
|
-
offset: number;
|
|
441
|
-
count: number;
|
|
442
|
-
entries: unknown[];
|
|
443
|
-
constructor(data: DataArray);
|
|
444
|
-
}
|
|
445
|
-
export declare class GetRadioStatusReplyD2HPacket extends HostBoundPacket {
|
|
446
|
-
static COMMAND_ID: number;
|
|
447
|
-
static COMMAND_EXTENDED_ID: number;
|
|
448
|
-
device: number;
|
|
449
|
-
quality: number;
|
|
450
|
-
strength: number;
|
|
451
|
-
channel: number;
|
|
452
|
-
timeslot: number;
|
|
453
|
-
constructor(data: DataArray);
|
|
454
|
-
}
|
|
455
|
-
export declare class GetUserDataReplyD2HPacket extends HostBoundPacket {
|
|
456
|
-
static COMMAND_ID: number;
|
|
457
|
-
static COMMAND_EXTENDED_ID: number;
|
|
458
|
-
}
|
|
459
|
-
export declare class ScreenCaptureReplyD2HPacket extends HostBoundPacket {
|
|
460
|
-
static COMMAND_ID: number;
|
|
461
|
-
static COMMAND_EXTENDED_ID: number;
|
|
462
|
-
}
|
|
463
|
-
export declare class SendDashTouchReplyD2HPacket extends HostBoundPacket {
|
|
464
|
-
static COMMAND_ID: number;
|
|
465
|
-
static COMMAND_EXTENDED_ID: number;
|
|
466
|
-
}
|
|
467
|
-
export declare class SelectDashReplyD2HPacket extends HostBoundPacket {
|
|
468
|
-
static COMMAND_ID: number;
|
|
469
|
-
static COMMAND_EXTENDED_ID: number;
|
|
470
|
-
}
|
|
471
|
-
export declare class EnableDashReplyD2HPacket extends HostBoundPacket {
|
|
472
|
-
static COMMAND_ID: number;
|
|
473
|
-
static COMMAND_EXTENDED_ID: number;
|
|
474
|
-
}
|
|
475
|
-
export declare class DisableDashReplyD2HPacket extends HostBoundPacket {
|
|
476
|
-
static COMMAND_ID: number;
|
|
477
|
-
static COMMAND_EXTENDED_ID: number;
|
|
478
|
-
}
|
|
479
|
-
export declare class ReadKeyValueReplyD2HPacket extends HostBoundPacket {
|
|
480
|
-
static COMMAND_ID: number;
|
|
481
|
-
static COMMAND_EXTENDED_ID: number;
|
|
482
|
-
value: string;
|
|
483
|
-
constructor(data: DataArray);
|
|
484
|
-
}
|
|
485
|
-
export declare class WriteKeyValueReplyD2HPacket extends HostBoundPacket {
|
|
486
|
-
static COMMAND_ID: number;
|
|
487
|
-
static COMMAND_EXTENDED_ID: number;
|
|
488
|
-
}
|
|
489
|
-
export declare class GetSlot1to4InfoReplyD2HPacket extends HostBoundPacket {
|
|
490
|
-
static COMMAND_ID: number;
|
|
491
|
-
static COMMAND_EXTENDED_ID: number;
|
|
492
|
-
slotFlags: number;
|
|
493
|
-
slots: unknown[];
|
|
494
|
-
constructor(data: DataArray, start?: number);
|
|
495
|
-
}
|
|
496
|
-
export declare class GetSlot5to8InfoReplyD2HPacket extends GetSlot1to4InfoReplyD2HPacket {
|
|
497
|
-
static COMMAND_ID: number;
|
|
498
|
-
static COMMAND_EXTENDED_ID: number;
|
|
499
|
-
slotStartIndex: number;
|
|
500
|
-
constructor(data: DataArray);
|
|
501
|
-
}
|
|
502
|
-
export declare class FactoryStatusReplyD2HPacket extends HostBoundPacket {
|
|
503
|
-
static COMMAND_ID: number;
|
|
504
|
-
static COMMAND_EXTENDED_ID: number;
|
|
505
|
-
status: number;
|
|
506
|
-
percent: number;
|
|
507
|
-
constructor(data: DataArray);
|
|
508
|
-
}
|
|
509
|
-
export declare class FactoryEnableReplyD2HPacket extends HostBoundPacket {
|
|
510
|
-
static COMMAND_ID: number;
|
|
511
|
-
static COMMAND_EXTENDED_ID: number;
|
|
512
|
-
}
|
|
1
|
+
export * from "./VexPacketBase.js";
|
|
2
|
+
export * from "./VexPacketEncoder.js";
|
|
3
|
+
export * from "./VexPacketModels.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AckType, type DataArray } from "./Vex.js";
|
|
2
|
+
import type { PacketEncoder } from "./VexPacketEncoder.js";
|
|
3
|
+
export declare abstract class Packet {
|
|
4
|
+
data: Uint8Array;
|
|
5
|
+
static ENCODER: PacketEncoder;
|
|
6
|
+
constructor(rawData: DataArray);
|
|
7
|
+
}
|
|
8
|
+
export declare class DeviceBoundPacket extends Packet {
|
|
9
|
+
get commandId(): number;
|
|
10
|
+
get commandExtendedId(): number | undefined;
|
|
11
|
+
static COMMAND_ID: number;
|
|
12
|
+
static COMMAND_EXTENDED_ID: number | undefined;
|
|
13
|
+
constructor(payload?: Uint8Array);
|
|
14
|
+
}
|
|
15
|
+
export declare class HostBoundPacket extends Packet {
|
|
16
|
+
ack: AckType;
|
|
17
|
+
payloadSize: number;
|
|
18
|
+
ackIndex: number;
|
|
19
|
+
constructor(data: DataArray);
|
|
20
|
+
static isValidPacket(data: Uint8Array, n: number): boolean;
|
|
21
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { CrcGenerator } from "./VexCRC.js";
|
|
2
|
+
import { HostBoundPacket } from "./VexPacketBase.js";
|
|
3
|
+
export declare function encodeFixedText(value: string, field: string, maxBytes: number): Uint8Array;
|
|
4
|
+
export declare class PacketEncoder {
|
|
5
|
+
static HEADERS_LENGTH: number;
|
|
6
|
+
static HEADER_TO_DEVICE: number[];
|
|
7
|
+
static HEADER_TO_HOST: number[];
|
|
8
|
+
static J2000_EPOCH: number;
|
|
9
|
+
vexVersion: number;
|
|
10
|
+
crcgen: CrcGenerator;
|
|
11
|
+
allPacketsTable: Record<string, typeof HostBoundPacket>;
|
|
12
|
+
static getInstance(): PacketEncoder;
|
|
13
|
+
private constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Create the vex CDC header
|
|
16
|
+
* @param buf the bytes to send
|
|
17
|
+
*/
|
|
18
|
+
createHeader(buf: ArrayBuffer | undefined): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Create the vex CDC simple message
|
|
21
|
+
* @param cmd the CDC command byte
|
|
22
|
+
*/
|
|
23
|
+
cdcCommand(cmd: number): Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Create the vex CDC simple message
|
|
26
|
+
* @param cmd the CDC command byte
|
|
27
|
+
* @param data the data to send
|
|
28
|
+
*/
|
|
29
|
+
cdcCommandWithData(cmd: number, data: Uint8Array): Uint8Array;
|
|
30
|
+
/**
|
|
31
|
+
* Create the vex CDC extended message
|
|
32
|
+
* @param cmd the CDC command byte
|
|
33
|
+
* @param ext the CDC extended command byte
|
|
34
|
+
* @return a message
|
|
35
|
+
*/
|
|
36
|
+
cdc2Command(cmd: number, ext: number): Uint8Array;
|
|
37
|
+
/**
|
|
38
|
+
* Calculate buffer length for new CDC extended command
|
|
39
|
+
* @param data the CDC extended command payload
|
|
40
|
+
* @returns the required buffer length of the command message
|
|
41
|
+
*/
|
|
42
|
+
cdc2CommandBufferLength(data: Uint8Array): number;
|
|
43
|
+
/**
|
|
44
|
+
* Create the vex CDC extended message with some data
|
|
45
|
+
* @param cmd the CDC command byte
|
|
46
|
+
* @param ext the CDC extended command byte
|
|
47
|
+
* @param data the CDC extended command payload
|
|
48
|
+
* @return a message
|
|
49
|
+
*/
|
|
50
|
+
cdc2CommandWithData(cmd: number, ext: number, data: Uint8Array): Uint8Array;
|
|
51
|
+
validateHeader(data: Uint8Array): boolean;
|
|
52
|
+
validateMessageCdc(data: Uint8Array): boolean;
|
|
53
|
+
getPayloadSize(data: Uint8Array): number;
|
|
54
|
+
getHostHeaderLength(data: Uint8Array): number;
|
|
55
|
+
}
|