@aircast-4g/mavlink 1.1.0 → 1.1.2
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/dist/cli.js +0 -0
- package/dist/{decoders/ardupilotmega.ts → dialects/ardupilotmega/decoder.js} +5 -14
- package/dist/{decoders/common.ts → dialects/common/decoder.js} +5 -14
- package/dist/{decoders/minimal.ts → dialects/minimal/decoder.js} +5 -14
- package/dist/generator/generator.d.ts.map +1 -1
- package/dist/generator/generator.js +15 -22
- package/dist/generator/generator.js.map +1 -1
- package/dist/parser/message-decoder.d.ts +19 -4
- package/dist/parser/message-decoder.d.ts.map +1 -1
- package/dist/parser/message-decoder.js +102 -243
- package/dist/parser/message-decoder.js.map +1 -1
- package/package.json +19 -27
- package/dist/batch-processor.d.ts +0 -17
- package/dist/batch-processor.d.ts.map +0 -1
- package/dist/batch-processor.js +0 -141
- package/dist/batch-processor.js.map +0 -1
- package/dist/cli-generate-decoders.d.ts +0 -4
- package/dist/cli-generate-decoders.d.ts.map +0 -1
- package/dist/cli-generate-decoders.js +0 -201
- package/dist/cli-generate-decoders.js.map +0 -1
- package/dist/generator.d.ts +0 -15
- package/dist/generator.d.ts.map +0 -1
- package/dist/generator.js +0 -92
- package/dist/generator.js.map +0 -1
- package/dist/parser/decoders/ardupilotmega-decoder.d.ts +0 -14
- package/dist/parser/decoders/ardupilotmega-decoder.d.ts.map +0 -1
- package/dist/parser/decoders/ardupilotmega-decoder.js +0 -11929
- package/dist/parser/decoders/ardupilotmega-decoder.js.map +0 -1
- package/dist/parser/decoders/common-decoder.d.ts +0 -14
- package/dist/parser/decoders/common-decoder.d.ts.map +0 -1
- package/dist/parser/decoders/common-decoder.js +0 -9097
- package/dist/parser/decoders/common-decoder.js.map +0 -1
- package/dist/parser/decoders/minimal-decoder.d.ts +0 -14
- package/dist/parser/decoders/minimal-decoder.d.ts.map +0 -1
- package/dist/parser/decoders/minimal-decoder.js +0 -66
- package/dist/parser/decoders/minimal-decoder.js.map +0 -1
- package/dist/parser/generated-decoders.d.ts +0 -15
- package/dist/parser/generated-decoders.d.ts.map +0 -1
- package/dist/parser/generated-decoders.js +0 -11938
- package/dist/parser/generated-decoders.js.map +0 -1
- package/dist/parser/test-decoder.d.ts +0 -2
- package/dist/parser/test-decoder.d.ts.map +0 -1
- package/dist/parser/test-decoder.js +0 -54
- package/dist/parser/test-decoder.js.map +0 -1
- package/dist/template-engine.d.ts +0 -13
- package/dist/template-engine.d.ts.map +0 -1
- package/dist/template-engine.js +0 -220
- package/dist/template-engine.js.map +0 -1
- package/dist/type-converter.d.ts +0 -15
- package/dist/type-converter.d.ts.map +0 -1
- package/dist/type-converter.js +0 -179
- package/dist/type-converter.js.map +0 -1
- package/dist/xml-parser.d.ts +0 -13
- package/dist/xml-parser.d.ts.map +0 -1
- package/dist/xml-parser.js +0 -170
- package/dist/xml-parser.js.map +0 -1
- /package/dist/{types/ardupilotmega/enums.ts → dialects/ardupilotmega/enums.d.ts} +0 -0
- /package/dist/{types/ardupilotmega/index.ts → dialects/ardupilotmega/index.d.ts} +0 -0
- /package/dist/{types/ardupilotmega/messages.ts → dialects/ardupilotmega/messages.d.ts} +0 -0
- /package/dist/{types/ardupilotmega/types.ts → dialects/ardupilotmega/types.d.ts} +0 -0
- /package/dist/{types/common/enums.ts → dialects/common/enums.d.ts} +0 -0
- /package/dist/{types/common/index.ts → dialects/common/index.d.ts} +0 -0
- /package/dist/{types/common/messages.ts → dialects/common/messages.d.ts} +0 -0
- /package/dist/{types/common/types.ts → dialects/common/types.d.ts} +0 -0
- /package/dist/{types/minimal/enums.ts → dialects/minimal/enums.d.ts} +0 -0
- /package/dist/{types/minimal/index.ts → dialects/minimal/index.d.ts} +0 -0
- /package/dist/{types/minimal/messages.ts → dialects/minimal/messages.d.ts} +0 -0
- /package/dist/{types/minimal/types.ts → dialects/minimal/types.d.ts} +0 -0
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
// Auto-generated decoder definitions for ardupilotmega dialect
|
|
2
2
|
// Generated from MAVLink XML definitions
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
id: number;
|
|
6
|
-
name: string;
|
|
7
|
-
fields: FieldDefinition[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface FieldDefinition {
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
arrayLength?: number;
|
|
14
|
-
extension?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const MESSAGE_DEFINITIONS: MessageDefinition[] = [
|
|
4
|
+
const ARDUPILOTMEGA_MESSAGE_DEFINITIONS = [
|
|
18
5
|
{
|
|
19
6
|
id: 0,
|
|
20
7
|
name: 'HEARTBEAT',
|
|
@@ -11937,3 +11924,7 @@ export const MESSAGE_DEFINITIONS: MessageDefinition[] = [
|
|
|
11937
11924
|
]
|
|
11938
11925
|
},
|
|
11939
11926
|
];
|
|
11927
|
+
|
|
11928
|
+
module.exports = {
|
|
11929
|
+
ARDUPILOTMEGA_MESSAGE_DEFINITIONS
|
|
11930
|
+
};
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
// Auto-generated decoder definitions for common dialect
|
|
2
2
|
// Generated from MAVLink XML definitions
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
id: number;
|
|
6
|
-
name: string;
|
|
7
|
-
fields: FieldDefinition[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface FieldDefinition {
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
arrayLength?: number;
|
|
14
|
-
extension?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const MESSAGE_DEFINITIONS: MessageDefinition[] = [
|
|
4
|
+
const COMMON_MESSAGE_DEFINITIONS = [
|
|
18
5
|
{
|
|
19
6
|
id: 0,
|
|
20
7
|
name: 'HEARTBEAT',
|
|
@@ -9105,3 +9092,7 @@ export const MESSAGE_DEFINITIONS: MessageDefinition[] = [
|
|
|
9105
9092
|
]
|
|
9106
9093
|
},
|
|
9107
9094
|
];
|
|
9095
|
+
|
|
9096
|
+
module.exports = {
|
|
9097
|
+
COMMON_MESSAGE_DEFINITIONS
|
|
9098
|
+
};
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
// Auto-generated decoder definitions for minimal dialect
|
|
2
2
|
// Generated from MAVLink XML definitions
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
id: number;
|
|
6
|
-
name: string;
|
|
7
|
-
fields: FieldDefinition[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface FieldDefinition {
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
arrayLength?: number;
|
|
14
|
-
extension?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const MESSAGE_DEFINITIONS: MessageDefinition[] = [
|
|
4
|
+
const MINIMAL_MESSAGE_DEFINITIONS = [
|
|
18
5
|
{
|
|
19
6
|
id: 0,
|
|
20
7
|
name: 'HEARTBEAT',
|
|
@@ -74,3 +61,7 @@ export const MESSAGE_DEFINITIONS: MessageDefinition[] = [
|
|
|
74
61
|
]
|
|
75
62
|
},
|
|
76
63
|
];
|
|
64
|
+
|
|
65
|
+
module.exports = {
|
|
66
|
+
MINIMAL_MESSAGE_DEFINITIONS
|
|
67
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/generator/generator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAA4C,MAAM,UAAU,CAAC;AAEvF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;;IAQjC,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3F,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;YAKzF,QAAQ;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/generator/generator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAA4C,MAAM,UAAU,CAAC;AAEvF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;;IAQjC,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAK3F,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;YAKzF,QAAQ;IAoCtB,OAAO,CAAC,0BAA0B;IAkDlC,KAAK,IAAI,IAAI;CAGd;AAGD,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC,CAsCzC"}
|
|
@@ -33,40 +33,30 @@ class MAVLinkGenerator {
|
|
|
33
33
|
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'index.ts'), content);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
// Generate separate files
|
|
36
|
+
// Generate separate files as .d.ts files
|
|
37
37
|
const typesContent = this.templateEngine.generateTypes(tsDialect);
|
|
38
|
-
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'types.ts'), typesContent);
|
|
38
|
+
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'types.d.ts'), typesContent);
|
|
39
39
|
if (options.includeEnums) {
|
|
40
40
|
const enumsContent = this.templateEngine.generateEnums(tsDialect);
|
|
41
|
-
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'enums.ts'), enumsContent);
|
|
41
|
+
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'enums.d.ts'), enumsContent);
|
|
42
42
|
}
|
|
43
43
|
const messagesContent = this.templateEngine.generateMessages(tsDialect);
|
|
44
|
-
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'messages.ts'), messagesContent);
|
|
44
|
+
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'messages.d.ts'), messagesContent);
|
|
45
45
|
const indexContent = this.templateEngine.generateIndex(tsDialect, options.includeEnums);
|
|
46
|
-
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'index.ts'), indexContent);
|
|
46
|
+
await fs_1.promises.writeFile((0, path_1.join)(outputPath, 'index.d.ts'), indexContent);
|
|
47
47
|
}
|
|
48
|
-
//
|
|
48
|
+
// Generate decoder definitions in the same dialect directory
|
|
49
49
|
const decoderContent = this.generateDecoderDefinitions(definition, options.dialectName);
|
|
50
|
-
const
|
|
51
|
-
await fs_1.promises.
|
|
52
|
-
await fs_1.promises.writeFile(distDecoderPath, decoderContent);
|
|
50
|
+
const decoderPath = (0, path_1.join)(outputPath, 'decoder.js');
|
|
51
|
+
await fs_1.promises.writeFile(decoderPath, decoderContent);
|
|
53
52
|
console.log(`Generated TypeScript types for ${options.dialectName} in ${outputPath}`);
|
|
54
53
|
}
|
|
55
54
|
generateDecoderDefinitions(definition, dialectName) {
|
|
56
55
|
let code = `// Auto-generated decoder definitions for ${dialectName} dialect\n`;
|
|
57
56
|
code += `// Generated from MAVLink XML definitions\n\n`;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
code += `
|
|
61
|
-
code += ` fields: FieldDefinition[];\n`;
|
|
62
|
-
code += `}\n\n`;
|
|
63
|
-
code += `export interface FieldDefinition {\n`;
|
|
64
|
-
code += ` name: string;\n`;
|
|
65
|
-
code += ` type: string;\n`;
|
|
66
|
-
code += ` arrayLength?: number;\n`;
|
|
67
|
-
code += ` extension?: boolean;\n`;
|
|
68
|
-
code += `}\n\n`;
|
|
69
|
-
code += `export const MESSAGE_DEFINITIONS: MessageDefinition[] = [\n`;
|
|
57
|
+
const dialectNameUpper = dialectName.toUpperCase();
|
|
58
|
+
const exportName = `${dialectNameUpper}_MESSAGE_DEFINITIONS`;
|
|
59
|
+
code += `const ${exportName} = [\n`;
|
|
70
60
|
for (const message of definition.messages || []) {
|
|
71
61
|
code += ` {\n`;
|
|
72
62
|
code += ` id: ${message.id},\n`;
|
|
@@ -95,7 +85,10 @@ class MAVLinkGenerator {
|
|
|
95
85
|
code += ` ]\n`;
|
|
96
86
|
code += ` },\n`;
|
|
97
87
|
}
|
|
98
|
-
code += `];\n`;
|
|
88
|
+
code += `];\n\n`;
|
|
89
|
+
code += `module.exports = {\n`;
|
|
90
|
+
code += ` ${exportName}\n`;
|
|
91
|
+
code += `};\n`;
|
|
99
92
|
return code;
|
|
100
93
|
}
|
|
101
94
|
reset() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/generator/generator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/generator/generator.ts"],"names":[],"mappings":";;;AAyHA,oDAyCC;AAlKD,2BAAoC;AACpC,+BAA4B;AAC5B,mCAAqC;AACrC,6CAAyC;AACzC,qDAAiD;AACjD,uDAAmD;AAGnD,MAAa,gBAAgB;IAK3B;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,sBAAS,EAAE,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,IAAI,8BAAa,EAAE,CAAC;QACzC,IAAI,CAAC,cAAc,GAAG,IAAI,gCAAc,EAAE,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,GAAW,EAAE,UAAkB,EAAE,OAA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ACN,KAAK,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC5D,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACzB,KAAK,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,GAAG,cAAc,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAClE,KAAK,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACpF,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -12,20 +12,35 @@ interface FieldDefinition {
|
|
|
12
12
|
}
|
|
13
13
|
export declare class MAVLinkMessageDecoder {
|
|
14
14
|
private messageDefinitions;
|
|
15
|
-
|
|
15
|
+
private definitionsLoaded;
|
|
16
|
+
constructor();
|
|
16
17
|
decode(frame: MAVLinkFrame & {
|
|
17
18
|
crc_ok?: boolean;
|
|
18
19
|
protocol_version?: 1 | 2;
|
|
19
20
|
}): ParsedMAVLinkMessage;
|
|
20
21
|
private decodePayload;
|
|
22
|
+
private getDefaultValue;
|
|
21
23
|
private decodeField;
|
|
22
24
|
private decodeSingleValue;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Load all available generated message definitions from built-in dialects
|
|
27
|
+
* This enables decoding of 319+ messages instead of just basic ones
|
|
28
|
+
*/
|
|
29
|
+
loadGeneratedDefinitions(): Promise<void>;
|
|
30
|
+
private initializeFromGeneratedDefinitions;
|
|
25
31
|
addCustomMessageDefinition(id: number, name: string, fields: FieldDefinition[]): void;
|
|
26
32
|
getMessageDefinition(id: number): MessageDefinition | undefined;
|
|
27
33
|
getSupportedMessageIds(): number[];
|
|
28
|
-
|
|
34
|
+
isDefinitionsLoaded(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Wait for definitions to be loaded before proceeding
|
|
37
|
+
* Returns immediately if already loaded
|
|
38
|
+
*/
|
|
39
|
+
waitForDefinitions(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Factory method to create decoder with all generated definitions loaded
|
|
42
|
+
* @returns Promise that resolves to decoder with 319+ message definitions
|
|
43
|
+
*/
|
|
29
44
|
static createWithGeneratedDefinitions(): Promise<MAVLinkMessageDecoder>;
|
|
30
45
|
}
|
|
31
46
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-decoder.d.ts","sourceRoot":"","sources":["../../src/parser/message-decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7D,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,kBAAkB,CAA6C;
|
|
1
|
+
{"version":3,"file":"message-decoder.d.ts","sourceRoot":"","sources":["../../src/parser/message-decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7D,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,kBAAkB,CAA6C;IACvE,OAAO,CAAC,iBAAiB,CAAkB;;IAU3C,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;KAAE,GAAG,oBAAoB;IAyClG,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,eAAe;IA8BvB,OAAO,CAAC,WAAW;IAqBnB,OAAO,CAAC,iBAAiB;IA2DzB;;;OAGG;IACU,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;YAIxC,kCAAkC;IAgCzC,0BAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI;IAIrF,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI/D,sBAAsB,IAAI,MAAM,EAAE;IAIlC,mBAAmB,IAAI,OAAO;IAIrC;;;OAGG;IACU,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBhD;;;OAGG;WACiB,8BAA8B,IAAI,OAAO,CAAC,qBAAqB,CAAC;CAKrF"}
|
|
@@ -35,14 +35,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.MAVLinkMessageDecoder = void 0;
|
|
37
37
|
class MAVLinkMessageDecoder {
|
|
38
|
-
constructor(
|
|
38
|
+
constructor() {
|
|
39
39
|
this.messageDefinitions = new Map();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
40
|
+
this.definitionsLoaded = false;
|
|
41
|
+
// Start loading generated definitions immediately
|
|
42
|
+
this.loadGeneratedDefinitions().catch(error => {
|
|
43
|
+
console.warn('Failed to load generated message definitions:', error);
|
|
44
|
+
console.warn('Messages will show as UNKNOWN until definitions are loaded');
|
|
45
|
+
});
|
|
46
46
|
}
|
|
47
47
|
decode(frame) {
|
|
48
48
|
const messageDef = this.messageDefinitions.get(frame.message_id);
|
|
@@ -61,7 +61,8 @@ class MAVLinkMessageDecoder {
|
|
|
61
61
|
},
|
|
62
62
|
protocol_version: protocolVersion,
|
|
63
63
|
checksum: frame.checksum,
|
|
64
|
-
crc_ok: frame.crc_ok !== false
|
|
64
|
+
crc_ok: frame.crc_ok !== false,
|
|
65
|
+
signature: frame.signature
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
const payload = this.decodePayload(frame.payload, messageDef.fields);
|
|
@@ -84,14 +85,45 @@ class MAVLinkMessageDecoder {
|
|
|
84
85
|
const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
85
86
|
let offset = 0;
|
|
86
87
|
for (const field of fields) {
|
|
87
|
-
if (offset >= payload.length)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
if (offset >= payload.length) {
|
|
89
|
+
// Set default value for missing fields
|
|
90
|
+
result[field.name] = this.getDefaultValue(field);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const { value, bytesRead } = this.decodeField(view, offset, field);
|
|
94
|
+
result[field.name] = value;
|
|
95
|
+
offset += bytesRead;
|
|
96
|
+
}
|
|
92
97
|
}
|
|
93
98
|
return result;
|
|
94
99
|
}
|
|
100
|
+
getDefaultValue(field) {
|
|
101
|
+
const isArray = field.arrayLength !== undefined && field.arrayLength > 1;
|
|
102
|
+
if (isArray) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
switch (field.type) {
|
|
106
|
+
case 'uint8_t':
|
|
107
|
+
case 'int8_t':
|
|
108
|
+
case 'uint16_t':
|
|
109
|
+
case 'int16_t':
|
|
110
|
+
case 'uint32_t':
|
|
111
|
+
case 'int32_t':
|
|
112
|
+
case 'float':
|
|
113
|
+
case 'double':
|
|
114
|
+
return 0;
|
|
115
|
+
case 'uint64_t':
|
|
116
|
+
case 'int64_t':
|
|
117
|
+
return 0n;
|
|
118
|
+
case 'char':
|
|
119
|
+
return '\0';
|
|
120
|
+
default:
|
|
121
|
+
if (field.type.startsWith('char[') || field.type.includes('[]')) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
95
127
|
decodeField(view, offset, field) {
|
|
96
128
|
const isArray = field.arrayLength !== undefined;
|
|
97
129
|
const arrayLength = field.arrayLength || 1;
|
|
@@ -134,9 +166,10 @@ class MAVLinkMessageDecoder {
|
|
|
134
166
|
return { value: view.getFloat32(offset, true), bytesRead: 4 };
|
|
135
167
|
case 'double':
|
|
136
168
|
return { value: view.getFloat64(offset, true), bytesRead: 8 };
|
|
137
|
-
case 'char':
|
|
169
|
+
case 'char': {
|
|
138
170
|
const charCode = view.getUint8(offset);
|
|
139
171
|
return { value: charCode === 0 ? '\0' : String.fromCharCode(charCode), bytesRead: 1 };
|
|
172
|
+
}
|
|
140
173
|
default:
|
|
141
174
|
if (type.startsWith('char[') && type.endsWith(']')) {
|
|
142
175
|
const length = parseInt(type.slice(5, -1));
|
|
@@ -170,228 +203,12 @@ class MAVLinkMessageDecoder {
|
|
|
170
203
|
return { value: 0, bytesRead: 1 };
|
|
171
204
|
}
|
|
172
205
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
{ name: 'custom_mode', type: 'uint32_t' },
|
|
180
|
-
{ name: 'system_status', type: 'uint8_t' },
|
|
181
|
-
{ name: 'mavlink_version', type: 'uint8_t' }
|
|
182
|
-
]);
|
|
183
|
-
this.addMessageDefinition(1, 'SYS_STATUS', [
|
|
184
|
-
{ name: 'onboard_control_sensors_present', type: 'uint32_t' },
|
|
185
|
-
{ name: 'onboard_control_sensors_enabled', type: 'uint32_t' },
|
|
186
|
-
{ name: 'onboard_control_sensors_health', type: 'uint32_t' },
|
|
187
|
-
{ name: 'load', type: 'uint16_t' },
|
|
188
|
-
{ name: 'voltage_battery', type: 'uint16_t' },
|
|
189
|
-
{ name: 'current_battery', type: 'int16_t' },
|
|
190
|
-
{ name: 'battery_remaining', type: 'int8_t' },
|
|
191
|
-
{ name: 'drop_rate_comm', type: 'uint16_t' },
|
|
192
|
-
{ name: 'errors_comm', type: 'uint16_t' },
|
|
193
|
-
{ name: 'errors_count1', type: 'uint16_t' },
|
|
194
|
-
{ name: 'errors_count2', type: 'uint16_t' },
|
|
195
|
-
{ name: 'errors_count3', type: 'uint16_t' },
|
|
196
|
-
{ name: 'errors_count4', type: 'uint16_t' }
|
|
197
|
-
]);
|
|
198
|
-
this.addMessageDefinition(2, 'SYSTEM_TIME', [
|
|
199
|
-
{ name: 'time_unix_usec', type: 'uint64_t' },
|
|
200
|
-
{ name: 'time_boot_ms', type: 'uint32_t' }
|
|
201
|
-
]);
|
|
202
|
-
this.addMessageDefinition(4, 'PING', [
|
|
203
|
-
{ name: 'time_usec', type: 'uint64_t' },
|
|
204
|
-
{ name: 'seq', type: 'uint32_t' },
|
|
205
|
-
{ name: 'target_system', type: 'uint8_t' },
|
|
206
|
-
{ name: 'target_component', type: 'uint8_t' }
|
|
207
|
-
]);
|
|
208
|
-
this.addMessageDefinition(11, 'SET_MODE', [
|
|
209
|
-
{ name: 'target_system', type: 'uint8_t' },
|
|
210
|
-
{ name: 'base_mode', type: 'uint8_t' },
|
|
211
|
-
{ name: 'custom_mode', type: 'uint32_t' }
|
|
212
|
-
]);
|
|
213
|
-
this.addMessageDefinition(20, 'PARAM_REQUEST_READ', [
|
|
214
|
-
{ name: 'target_system', type: 'uint8_t' },
|
|
215
|
-
{ name: 'target_component', type: 'uint8_t' },
|
|
216
|
-
{ name: 'param_id', type: 'char[16]' },
|
|
217
|
-
{ name: 'param_index', type: 'int16_t' }
|
|
218
|
-
]);
|
|
219
|
-
this.addMessageDefinition(21, 'PARAM_REQUEST_LIST', [
|
|
220
|
-
{ name: 'target_system', type: 'uint8_t' },
|
|
221
|
-
{ name: 'target_component', type: 'uint8_t' }
|
|
222
|
-
]);
|
|
223
|
-
this.addMessageDefinition(22, 'PARAM_VALUE', [
|
|
224
|
-
{ name: 'param_id', type: 'char[16]' },
|
|
225
|
-
{ name: 'param_value', type: 'float' },
|
|
226
|
-
{ name: 'param_type', type: 'uint8_t' },
|
|
227
|
-
{ name: 'param_count', type: 'uint16_t' },
|
|
228
|
-
{ name: 'param_index', type: 'uint16_t' }
|
|
229
|
-
]);
|
|
230
|
-
this.addMessageDefinition(23, 'PARAM_SET', [
|
|
231
|
-
{ name: 'target_system', type: 'uint8_t' },
|
|
232
|
-
{ name: 'target_component', type: 'uint8_t' },
|
|
233
|
-
{ name: 'param_id', type: 'char[16]' },
|
|
234
|
-
{ name: 'param_value', type: 'float' },
|
|
235
|
-
{ name: 'param_type', type: 'uint8_t' }
|
|
236
|
-
]);
|
|
237
|
-
this.addMessageDefinition(24, 'GPS_RAW_INT', [
|
|
238
|
-
{ name: 'time_usec', type: 'uint64_t' },
|
|
239
|
-
{ name: 'fix_type', type: 'uint8_t' },
|
|
240
|
-
{ name: 'lat', type: 'int32_t' },
|
|
241
|
-
{ name: 'lon', type: 'int32_t' },
|
|
242
|
-
{ name: 'alt', type: 'int32_t' },
|
|
243
|
-
{ name: 'eph', type: 'uint16_t' },
|
|
244
|
-
{ name: 'epv', type: 'uint16_t' },
|
|
245
|
-
{ name: 'vel', type: 'uint16_t' },
|
|
246
|
-
{ name: 'cog', type: 'uint16_t' },
|
|
247
|
-
{ name: 'satellites_visible', type: 'uint8_t' }
|
|
248
|
-
]);
|
|
249
|
-
this.addMessageDefinition(25, 'GPS_STATUS', [
|
|
250
|
-
{ name: 'satellites_visible', type: 'uint8_t' },
|
|
251
|
-
{ name: 'satellite_prn', type: 'uint8_t', arrayLength: 20 },
|
|
252
|
-
{ name: 'satellite_used', type: 'uint8_t', arrayLength: 20 },
|
|
253
|
-
{ name: 'satellite_elevation', type: 'uint8_t', arrayLength: 20 },
|
|
254
|
-
{ name: 'satellite_azimuth', type: 'uint8_t', arrayLength: 20 },
|
|
255
|
-
{ name: 'satellite_snr', type: 'uint8_t', arrayLength: 20 }
|
|
256
|
-
]);
|
|
257
|
-
this.addMessageDefinition(26, 'SCALED_IMU', [
|
|
258
|
-
{ name: 'time_boot_ms', type: 'uint32_t' },
|
|
259
|
-
{ name: 'xacc', type: 'int16_t' },
|
|
260
|
-
{ name: 'yacc', type: 'int16_t' },
|
|
261
|
-
{ name: 'zacc', type: 'int16_t' },
|
|
262
|
-
{ name: 'xgyro', type: 'int16_t' },
|
|
263
|
-
{ name: 'ygyro', type: 'int16_t' },
|
|
264
|
-
{ name: 'zgyro', type: 'int16_t' },
|
|
265
|
-
{ name: 'xmag', type: 'int16_t' },
|
|
266
|
-
{ name: 'ymag', type: 'int16_t' },
|
|
267
|
-
{ name: 'zmag', type: 'int16_t' }
|
|
268
|
-
]);
|
|
269
|
-
this.addMessageDefinition(27, 'RAW_IMU', [
|
|
270
|
-
{ name: 'time_usec', type: 'uint64_t' },
|
|
271
|
-
{ name: 'xacc', type: 'int16_t' },
|
|
272
|
-
{ name: 'yacc', type: 'int16_t' },
|
|
273
|
-
{ name: 'zacc', type: 'int16_t' },
|
|
274
|
-
{ name: 'xgyro', type: 'int16_t' },
|
|
275
|
-
{ name: 'ygyro', type: 'int16_t' },
|
|
276
|
-
{ name: 'zgyro', type: 'int16_t' },
|
|
277
|
-
{ name: 'xmag', type: 'int16_t' },
|
|
278
|
-
{ name: 'ymag', type: 'int16_t' },
|
|
279
|
-
{ name: 'zmag', type: 'int16_t' }
|
|
280
|
-
]);
|
|
281
|
-
this.addMessageDefinition(28, 'RAW_PRESSURE', [
|
|
282
|
-
{ name: 'time_usec', type: 'uint64_t' },
|
|
283
|
-
{ name: 'press_abs', type: 'int16_t' },
|
|
284
|
-
{ name: 'press_diff1', type: 'int16_t' },
|
|
285
|
-
{ name: 'press_diff2', type: 'int16_t' },
|
|
286
|
-
{ name: 'temperature', type: 'int16_t' }
|
|
287
|
-
]);
|
|
288
|
-
this.addMessageDefinition(29, 'SCALED_PRESSURE', [
|
|
289
|
-
{ name: 'time_boot_ms', type: 'uint32_t' },
|
|
290
|
-
{ name: 'press_abs', type: 'float' },
|
|
291
|
-
{ name: 'press_diff', type: 'float' },
|
|
292
|
-
{ name: 'temperature', type: 'int16_t' }
|
|
293
|
-
]);
|
|
294
|
-
this.addMessageDefinition(30, 'ATTITUDE', [
|
|
295
|
-
{ name: 'time_boot_ms', type: 'uint32_t' },
|
|
296
|
-
{ name: 'roll', type: 'float' },
|
|
297
|
-
{ name: 'pitch', type: 'float' },
|
|
298
|
-
{ name: 'yaw', type: 'float' },
|
|
299
|
-
{ name: 'rollspeed', type: 'float' },
|
|
300
|
-
{ name: 'pitchspeed', type: 'float' },
|
|
301
|
-
{ name: 'yawspeed', type: 'float' }
|
|
302
|
-
]);
|
|
303
|
-
this.addMessageDefinition(31, 'ATTITUDE_QUATERNION', [
|
|
304
|
-
{ name: 'time_boot_ms', type: 'uint32_t' },
|
|
305
|
-
{ name: 'q1', type: 'float' },
|
|
306
|
-
{ name: 'q2', type: 'float' },
|
|
307
|
-
{ name: 'q3', type: 'float' },
|
|
308
|
-
{ name: 'q4', type: 'float' },
|
|
309
|
-
{ name: 'rollspeed', type: 'float' },
|
|
310
|
-
{ name: 'pitchspeed', type: 'float' },
|
|
311
|
-
{ name: 'yawspeed', type: 'float' }
|
|
312
|
-
]);
|
|
313
|
-
this.addMessageDefinition(32, 'LOCAL_POSITION_NED', [
|
|
314
|
-
{ name: 'time_boot_ms', type: 'uint32_t' },
|
|
315
|
-
{ name: 'x', type: 'float' },
|
|
316
|
-
{ name: 'y', type: 'float' },
|
|
317
|
-
{ name: 'z', type: 'float' },
|
|
318
|
-
{ name: 'vx', type: 'float' },
|
|
319
|
-
{ name: 'vy', type: 'float' },
|
|
320
|
-
{ name: 'vz', type: 'float' }
|
|
321
|
-
]);
|
|
322
|
-
this.addMessageDefinition(33, 'GLOBAL_POSITION_INT', [
|
|
323
|
-
{ name: 'time_boot_ms', type: 'uint32_t' },
|
|
324
|
-
{ name: 'lat', type: 'int32_t' },
|
|
325
|
-
{ name: 'lon', type: 'int32_t' },
|
|
326
|
-
{ name: 'alt', type: 'int32_t' },
|
|
327
|
-
{ name: 'relative_alt', type: 'int32_t' },
|
|
328
|
-
{ name: 'vx', type: 'int16_t' },
|
|
329
|
-
{ name: 'vy', type: 'int16_t' },
|
|
330
|
-
{ name: 'vz', type: 'int16_t' },
|
|
331
|
-
{ name: 'hdg', type: 'uint16_t' }
|
|
332
|
-
]);
|
|
333
|
-
this.addMessageDefinition(62, 'NAV_CONTROLLER_OUTPUT', [
|
|
334
|
-
{ name: 'nav_roll', type: 'float' },
|
|
335
|
-
{ name: 'nav_pitch', type: 'float' },
|
|
336
|
-
{ name: 'nav_bearing', type: 'int16_t' },
|
|
337
|
-
{ name: 'target_bearing', type: 'int16_t' },
|
|
338
|
-
{ name: 'wp_dist', type: 'uint16_t' },
|
|
339
|
-
{ name: 'alt_error', type: 'float' },
|
|
340
|
-
{ name: 'aspd_error', type: 'float' },
|
|
341
|
-
{ name: 'xtrack_error', type: 'float' }
|
|
342
|
-
]);
|
|
343
|
-
this.addMessageDefinition(74, 'VFR_HUD', [
|
|
344
|
-
{ name: 'airspeed', type: 'float' },
|
|
345
|
-
{ name: 'groundspeed', type: 'float' },
|
|
346
|
-
{ name: 'heading', type: 'int16_t' },
|
|
347
|
-
{ name: 'throttle', type: 'uint16_t' },
|
|
348
|
-
{ name: 'alt', type: 'float' },
|
|
349
|
-
{ name: 'climb', type: 'float' }
|
|
350
|
-
]);
|
|
351
|
-
this.addMessageDefinition(76, 'COMMAND_INT', [
|
|
352
|
-
{ name: 'target_system', type: 'uint8_t' },
|
|
353
|
-
{ name: 'target_component', type: 'uint8_t' },
|
|
354
|
-
{ name: 'frame', type: 'uint8_t' },
|
|
355
|
-
{ name: 'command', type: 'uint16_t' },
|
|
356
|
-
{ name: 'current', type: 'uint8_t' },
|
|
357
|
-
{ name: 'autocontinue', type: 'uint8_t' },
|
|
358
|
-
{ name: 'param1', type: 'float' },
|
|
359
|
-
{ name: 'param2', type: 'float' },
|
|
360
|
-
{ name: 'param3', type: 'float' },
|
|
361
|
-
{ name: 'param4', type: 'float' },
|
|
362
|
-
{ name: 'x', type: 'int32_t' },
|
|
363
|
-
{ name: 'y', type: 'int32_t' },
|
|
364
|
-
{ name: 'z', type: 'float' }
|
|
365
|
-
]);
|
|
366
|
-
this.addMessageDefinition(77, 'COMMAND_LONG', [
|
|
367
|
-
{ name: 'target_system', type: 'uint8_t' },
|
|
368
|
-
{ name: 'target_component', type: 'uint8_t' },
|
|
369
|
-
{ name: 'command', type: 'uint16_t' },
|
|
370
|
-
{ name: 'confirmation', type: 'uint8_t' },
|
|
371
|
-
{ name: 'param1', type: 'float' },
|
|
372
|
-
{ name: 'param2', type: 'float' },
|
|
373
|
-
{ name: 'param3', type: 'float' },
|
|
374
|
-
{ name: 'param4', type: 'float' },
|
|
375
|
-
{ name: 'param5', type: 'float' },
|
|
376
|
-
{ name: 'param6', type: 'float' },
|
|
377
|
-
{ name: 'param7', type: 'float' }
|
|
378
|
-
]);
|
|
379
|
-
this.addMessageDefinition(253, 'STATUSTEXT', [
|
|
380
|
-
{ name: 'severity', type: 'uint8_t' },
|
|
381
|
-
{ name: 'text', type: 'char[50]' }
|
|
382
|
-
]);
|
|
383
|
-
}
|
|
384
|
-
addMessageDefinition(id, name, fields) {
|
|
385
|
-
this.messageDefinitions.set(id, { id, name, fields });
|
|
386
|
-
}
|
|
387
|
-
addCustomMessageDefinition(id, name, fields) {
|
|
388
|
-
this.addMessageDefinition(id, name, fields);
|
|
389
|
-
}
|
|
390
|
-
getMessageDefinition(id) {
|
|
391
|
-
return this.messageDefinitions.get(id);
|
|
392
|
-
}
|
|
393
|
-
getSupportedMessageIds() {
|
|
394
|
-
return Array.from(this.messageDefinitions.keys()).sort((a, b) => a - b);
|
|
206
|
+
/**
|
|
207
|
+
* Load all available generated message definitions from built-in dialects
|
|
208
|
+
* This enables decoding of 319+ messages instead of just basic ones
|
|
209
|
+
*/
|
|
210
|
+
async loadGeneratedDefinitions() {
|
|
211
|
+
await this.initializeFromGeneratedDefinitions();
|
|
395
212
|
}
|
|
396
213
|
async initializeFromGeneratedDefinitions() {
|
|
397
214
|
try {
|
|
@@ -400,10 +217,14 @@ class MAVLinkMessageDecoder {
|
|
|
400
217
|
const allDefinitions = new Map();
|
|
401
218
|
for (const dialectName of dialects) {
|
|
402
219
|
try {
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
220
|
+
const decoderModule = await Promise.resolve(`${`../../dist/dialects/${dialectName}/decoder`}`).then(s => __importStar(require(s)));
|
|
221
|
+
const exportName = `${dialectName.toUpperCase()}_MESSAGE_DEFINITIONS`;
|
|
222
|
+
const MESSAGE_DEFINITIONS = decoderModule[exportName];
|
|
223
|
+
if (MESSAGE_DEFINITIONS) {
|
|
224
|
+
for (const def of MESSAGE_DEFINITIONS) {
|
|
225
|
+
if (!allDefinitions.has(def.id)) {
|
|
226
|
+
allDefinitions.set(def.id, def);
|
|
227
|
+
}
|
|
407
228
|
}
|
|
408
229
|
}
|
|
409
230
|
}
|
|
@@ -412,16 +233,54 @@ class MAVLinkMessageDecoder {
|
|
|
412
233
|
}
|
|
413
234
|
}
|
|
414
235
|
this.messageDefinitions = allDefinitions;
|
|
236
|
+
this.definitionsLoaded = true;
|
|
415
237
|
console.log(`Loaded ${this.messageDefinitions.size} message definitions from generated decoders`);
|
|
416
238
|
}
|
|
417
239
|
catch (error) {
|
|
418
|
-
console.
|
|
419
|
-
this.
|
|
240
|
+
console.error('Failed to load generated definitions:', error);
|
|
241
|
+
this.definitionsLoaded = false;
|
|
420
242
|
}
|
|
421
243
|
}
|
|
244
|
+
addCustomMessageDefinition(id, name, fields) {
|
|
245
|
+
this.messageDefinitions.set(id, { id, name, fields });
|
|
246
|
+
}
|
|
247
|
+
getMessageDefinition(id) {
|
|
248
|
+
return this.messageDefinitions.get(id);
|
|
249
|
+
}
|
|
250
|
+
getSupportedMessageIds() {
|
|
251
|
+
return Array.from(this.messageDefinitions.keys()).sort((a, b) => a - b);
|
|
252
|
+
}
|
|
253
|
+
isDefinitionsLoaded() {
|
|
254
|
+
return this.definitionsLoaded;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Wait for definitions to be loaded before proceeding
|
|
258
|
+
* Returns immediately if already loaded
|
|
259
|
+
*/
|
|
260
|
+
async waitForDefinitions() {
|
|
261
|
+
if (this.definitionsLoaded) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
// Wait a bit for async loading to complete
|
|
265
|
+
return new Promise((resolve) => {
|
|
266
|
+
const checkLoaded = () => {
|
|
267
|
+
if (this.definitionsLoaded) {
|
|
268
|
+
resolve();
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
setTimeout(checkLoaded, 10);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
checkLoaded();
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Factory method to create decoder with all generated definitions loaded
|
|
279
|
+
* @returns Promise that resolves to decoder with 319+ message definitions
|
|
280
|
+
*/
|
|
422
281
|
static async createWithGeneratedDefinitions() {
|
|
423
282
|
const decoder = new MAVLinkMessageDecoder();
|
|
424
|
-
await decoder.
|
|
283
|
+
await decoder.loadGeneratedDefinitions();
|
|
425
284
|
return decoder;
|
|
426
285
|
}
|
|
427
286
|
}
|