@aircast-4g/mavlink 1.0.1 → 1.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/dist/cli-generate-decoders.d.ts +4 -0
- package/dist/cli-generate-decoders.d.ts.map +1 -0
- package/dist/cli-generate-decoders.js +201 -0
- package/dist/cli-generate-decoders.js.map +1 -0
- package/dist/decoders/ardupilotmega.ts +11939 -0
- package/dist/decoders/common.ts +9107 -0
- package/dist/decoders/minimal.ts +76 -0
- package/dist/generator/generator.d.ts +1 -0
- package/dist/generator/generator.d.ts.map +1 -1
- package/dist/generator/generator.js +51 -0
- package/dist/generator/generator.js.map +1 -1
- package/dist/generator/template-engine.d.ts +1 -0
- package/dist/generator/template-engine.d.ts.map +1 -1
- package/dist/generator/template-engine.js +50 -0
- package/dist/generator/template-engine.js.map +1 -1
- package/dist/parser/decoders/ardupilotmega-decoder.d.ts +14 -0
- package/dist/parser/decoders/ardupilotmega-decoder.d.ts.map +1 -0
- package/dist/parser/decoders/ardupilotmega-decoder.js +11929 -0
- package/dist/parser/decoders/ardupilotmega-decoder.js.map +1 -0
- package/dist/parser/decoders/common-decoder.d.ts +14 -0
- package/dist/parser/decoders/common-decoder.d.ts.map +1 -0
- package/dist/parser/decoders/common-decoder.js +9097 -0
- package/dist/parser/decoders/common-decoder.js.map +1 -0
- package/dist/parser/decoders/minimal-decoder.d.ts +14 -0
- package/dist/parser/decoders/minimal-decoder.d.ts.map +1 -0
- package/dist/parser/decoders/minimal-decoder.js +66 -0
- package/dist/parser/decoders/minimal-decoder.js.map +1 -0
- package/dist/parser/generated-decoders.d.ts +15 -0
- package/dist/parser/generated-decoders.d.ts.map +1 -0
- package/dist/parser/generated-decoders.js +11938 -0
- package/dist/parser/generated-decoders.js.map +1 -0
- package/dist/parser/mavlink-parser.d.ts.map +1 -1
- package/dist/parser/mavlink-parser.js +17 -6
- package/dist/parser/mavlink-parser.js.map +1 -1
- package/dist/parser/message-decoder.d.ts +26 -5
- package/dist/parser/message-decoder.d.ts.map +1 -1
- package/dist/parser/message-decoder.js +406 -224
- package/dist/parser/message-decoder.js.map +1 -1
- package/dist/parser/test-decoder.d.ts +2 -0
- package/dist/parser/test-decoder.d.ts.map +1 -0
- package/dist/parser/test-decoder.js +54 -0
- package/dist/parser/test-decoder.js.map +1 -0
- package/dist/parser/types.d.ts +1 -0
- package/dist/parser/types.d.ts.map +1 -1
- package/dist/parser/types.js.map +1 -1
- package/package.json +24 -25
- package/types/ardupilotmega/enums.d.ts +0 -2427
- package/types/ardupilotmega/enums.d.ts.map +0 -1
- package/types/ardupilotmega/enums.js +0 -4636
- package/types/ardupilotmega/enums.js.map +0 -1
- package/types/ardupilotmega/index.d.ts +0 -4
- package/types/ardupilotmega/index.d.ts.map +0 -1
- package/types/ardupilotmega/index.js +0 -22
- package/types/ardupilotmega/index.js.map +0 -1
- package/types/ardupilotmega/messages.d.ts +0 -3719
- package/types/ardupilotmega/messages.d.ts.map +0 -1
- package/types/ardupilotmega/messages.js +0 -1281
- package/types/ardupilotmega/messages.js.map +0 -1
- package/types/ardupilotmega/types.d.ts +0 -221
- package/types/ardupilotmega/types.d.ts.map +0 -1
- package/types/ardupilotmega/types.js +0 -5
- package/types/ardupilotmega/types.js.map +0 -1
- package/types/common/enums.d.ts +0 -1843
- package/types/common/enums.d.ts.map +0 -1
- package/types/common/enums.js +0 -3636
- package/types/common/enums.js.map +0 -1
- package/types/common/index.d.ts +0 -4
- package/types/common/index.d.ts.map +0 -1
- package/types/common/index.js +0 -21
- package/types/common/index.js.map +0 -1
- package/types/common/messages.d.ts +0 -2805
- package/types/common/messages.d.ts.map +0 -1
- package/types/common/messages.js +0 -920
- package/types/common/messages.js.map +0 -1
- package/types/common/types.d.ts +0 -157
- package/types/common/types.d.ts.map +0 -1
- package/types/common/types.js +0 -4
- package/types/common/types.js.map +0 -1
- package/types/minimal/enums.d.ts +0 -244
- package/types/minimal/enums.d.ts.map +0 -1
- package/types/minimal/enums.js +0 -496
- package/types/minimal/enums.js.map +0 -1
- package/types/minimal/index.d.ts +0 -4
- package/types/minimal/index.d.ts.map +0 -1
- package/types/minimal/index.js +0 -21
- package/types/minimal/index.js.map +0 -1
- package/types/minimal/messages.d.ts +0 -25
- package/types/minimal/messages.d.ts.map +0 -1
- package/types/minimal/messages.js +0 -12
- package/types/minimal/messages.js.map +0 -1
- package/types/minimal/types.d.ts +0 -14
- package/types/minimal/types.d.ts.map +0 -1
- package/types/minimal/types.js +0 -4
- package/types/minimal/types.js.map +0 -1
- package/types/paparazzi/enums.ts +0 -3632
- package/types/paparazzi/index.ts +0 -6
- package/types/paparazzi/messages.ts +0 -6185
- package/types/paparazzi/types.ts +0 -2159
- package/types/python_array_test/enums.ts +0 -3632
- package/types/python_array_test/index.ts +0 -6
- package/types/python_array_test/messages.ts +0 -6258
- package/types/python_array_test/types.ts +0 -2159
- package/types/standard/enums.d.ts +0 -248
- package/types/standard/enums.d.ts.map +0 -1
- package/types/standard/enums.js +0 -505
- package/types/standard/enums.js.map +0 -1
- package/types/standard/enums.ts +0 -502
- package/types/standard/index.d.ts +0 -4
- package/types/standard/index.d.ts.map +0 -1
- package/types/standard/index.js +0 -22
- package/types/standard/index.js.map +0 -1
- package/types/standard/index.ts +0 -6
- package/types/standard/messages.d.ts +0 -25
- package/types/standard/messages.d.ts.map +0 -1
- package/types/standard/messages.js +0 -13
- package/types/standard/messages.js.map +0 -1
- package/types/standard/messages.ts +0 -63
- package/types/standard/types.d.ts +0 -15
- package/types/standard/types.d.ts.map +0 -1
- package/types/standard/types.js +0 -5
- package/types/standard/types.js.map +0 -1
- package/types/standard/types.ts +0 -278
- package/types/test/enums.ts +0 -2
- package/types/test/index.ts +0 -6
- package/types/test/messages.ts +0 -69
- package/types/test/types.ts +0 -11
- /package/{types → dist/types}/ardupilotmega/enums.ts +0 -0
- /package/{types → dist/types}/ardupilotmega/index.ts +0 -0
- /package/{types → dist/types}/ardupilotmega/messages.ts +0 -0
- /package/{types → dist/types}/ardupilotmega/types.ts +0 -0
- /package/{types → dist/types}/common/enums.ts +0 -0
- /package/{types → dist/types}/common/index.ts +0 -0
- /package/{types → dist/types}/common/messages.ts +0 -0
- /package/{types → dist/types}/common/types.ts +0 -0
- /package/{types → dist/types}/minimal/enums.ts +0 -0
- /package/{types → dist/types}/minimal/index.ts +0 -0
- /package/{types → dist/types}/minimal/messages.ts +0 -0
- /package/{types → dist/types}/minimal/types.ts +0 -0
|
@@ -1,246 +1,428 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.MAVLinkMessageDecoder = void 0;
|
|
4
|
-
// Message decoder for MAVLink messages
|
|
5
|
-
const types_1 = require("./types");
|
|
6
37
|
class MAVLinkMessageDecoder {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.
|
|
9
|
-
|
|
38
|
+
constructor(useGeneratedDefinitions = false) {
|
|
39
|
+
this.messageDefinitions = new Map();
|
|
40
|
+
if (useGeneratedDefinitions) {
|
|
41
|
+
this.initializeFromGeneratedDefinitions();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.initializeMessageDefinitions();
|
|
45
|
+
}
|
|
10
46
|
}
|
|
11
47
|
decode(frame) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const messageName = this.getMessageName(frame.message_id);
|
|
48
|
+
const messageDef = this.messageDefinitions.get(frame.message_id);
|
|
49
|
+
// Determine protocol version from magic byte if not provided
|
|
50
|
+
const protocolVersion = frame.protocol_version || (frame.magic === 0xFD ? 2 : 1);
|
|
51
|
+
if (!messageDef) {
|
|
17
52
|
return {
|
|
18
|
-
timestamp,
|
|
53
|
+
timestamp: Date.now(),
|
|
19
54
|
system_id: frame.system_id,
|
|
20
55
|
component_id: frame.component_id,
|
|
21
56
|
message_id: frame.message_id,
|
|
22
|
-
message_name:
|
|
57
|
+
message_name: `UNKNOWN_${frame.message_id}`,
|
|
23
58
|
sequence: frame.sequence,
|
|
24
|
-
payload
|
|
25
|
-
|
|
59
|
+
payload: {
|
|
60
|
+
raw_payload: Array.from(frame.payload)
|
|
61
|
+
},
|
|
62
|
+
protocol_version: protocolVersion,
|
|
26
63
|
checksum: frame.checksum,
|
|
27
|
-
|
|
64
|
+
crc_ok: frame.crc_ok !== false
|
|
28
65
|
};
|
|
29
66
|
}
|
|
67
|
+
const payload = this.decodePayload(frame.payload, messageDef.fields);
|
|
68
|
+
return {
|
|
69
|
+
timestamp: Date.now(),
|
|
70
|
+
system_id: frame.system_id,
|
|
71
|
+
component_id: frame.component_id,
|
|
72
|
+
message_id: frame.message_id,
|
|
73
|
+
message_name: messageDef.name,
|
|
74
|
+
sequence: frame.sequence,
|
|
75
|
+
payload,
|
|
76
|
+
protocol_version: protocolVersion,
|
|
77
|
+
checksum: frame.checksum,
|
|
78
|
+
crc_ok: frame.crc_ok !== false,
|
|
79
|
+
signature: frame.signature
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
decodePayload(payload, fields) {
|
|
83
|
+
const result = {};
|
|
84
|
+
const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
|
|
85
|
+
let offset = 0;
|
|
86
|
+
for (const field of fields) {
|
|
87
|
+
if (offset >= payload.length)
|
|
88
|
+
break;
|
|
89
|
+
const { value, bytesRead } = this.decodeField(view, offset, field);
|
|
90
|
+
result[field.name] = value;
|
|
91
|
+
offset += bytesRead;
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
decodeField(view, offset, field) {
|
|
96
|
+
const isArray = field.arrayLength !== undefined;
|
|
97
|
+
const arrayLength = field.arrayLength || 1;
|
|
98
|
+
if (isArray && arrayLength > 1) {
|
|
99
|
+
const values = [];
|
|
100
|
+
let totalBytes = 0;
|
|
101
|
+
for (let i = 0; i < arrayLength; i++) {
|
|
102
|
+
if (offset + totalBytes >= view.byteLength)
|
|
103
|
+
break;
|
|
104
|
+
const { value, bytesRead } = this.decodeSingleValue(view, offset + totalBytes, field.type);
|
|
105
|
+
values.push(value);
|
|
106
|
+
totalBytes += bytesRead;
|
|
107
|
+
}
|
|
108
|
+
return { value: values, bytesRead: totalBytes };
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return this.decodeSingleValue(view, offset, field.type);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
decodeSingleValue(view, offset, type) {
|
|
115
|
+
try {
|
|
116
|
+
switch (type) {
|
|
117
|
+
case 'uint8_t':
|
|
118
|
+
return { value: view.getUint8(offset), bytesRead: 1 };
|
|
119
|
+
case 'int8_t':
|
|
120
|
+
return { value: view.getInt8(offset), bytesRead: 1 };
|
|
121
|
+
case 'uint16_t':
|
|
122
|
+
return { value: view.getUint16(offset, true), bytesRead: 2 };
|
|
123
|
+
case 'int16_t':
|
|
124
|
+
return { value: view.getInt16(offset, true), bytesRead: 2 };
|
|
125
|
+
case 'uint32_t':
|
|
126
|
+
return { value: view.getUint32(offset, true), bytesRead: 4 };
|
|
127
|
+
case 'int32_t':
|
|
128
|
+
return { value: view.getInt32(offset, true), bytesRead: 4 };
|
|
129
|
+
case 'uint64_t':
|
|
130
|
+
return { value: view.getBigUint64(offset, true), bytesRead: 8 };
|
|
131
|
+
case 'int64_t':
|
|
132
|
+
return { value: view.getBigInt64(offset, true), bytesRead: 8 };
|
|
133
|
+
case 'float':
|
|
134
|
+
return { value: view.getFloat32(offset, true), bytesRead: 4 };
|
|
135
|
+
case 'double':
|
|
136
|
+
return { value: view.getFloat64(offset, true), bytesRead: 8 };
|
|
137
|
+
case 'char':
|
|
138
|
+
const charCode = view.getUint8(offset);
|
|
139
|
+
return { value: charCode === 0 ? '\0' : String.fromCharCode(charCode), bytesRead: 1 };
|
|
140
|
+
default:
|
|
141
|
+
if (type.startsWith('char[') && type.endsWith(']')) {
|
|
142
|
+
const length = parseInt(type.slice(5, -1));
|
|
143
|
+
const chars = [];
|
|
144
|
+
for (let i = 0; i < length && offset + i < view.byteLength; i++) {
|
|
145
|
+
const charCode = view.getUint8(offset + i);
|
|
146
|
+
if (charCode === 0)
|
|
147
|
+
break;
|
|
148
|
+
chars.push(String.fromCharCode(charCode));
|
|
149
|
+
}
|
|
150
|
+
return { value: chars.join(''), bytesRead: length };
|
|
151
|
+
}
|
|
152
|
+
else if (type.includes('[') && type.includes(']')) {
|
|
153
|
+
const baseType = type.substring(0, type.indexOf('['));
|
|
154
|
+
const arrayLength = parseInt(type.substring(type.indexOf('[') + 1, type.indexOf(']')));
|
|
155
|
+
const values = [];
|
|
156
|
+
let totalBytes = 0;
|
|
157
|
+
for (let i = 0; i < arrayLength; i++) {
|
|
158
|
+
if (offset + totalBytes >= view.byteLength)
|
|
159
|
+
break;
|
|
160
|
+
const { value, bytesRead } = this.decodeSingleValue(view, offset + totalBytes, baseType);
|
|
161
|
+
values.push(value);
|
|
162
|
+
totalBytes += bytesRead;
|
|
163
|
+
}
|
|
164
|
+
return { value: values, bytesRead: totalBytes };
|
|
165
|
+
}
|
|
166
|
+
return { value: view.getUint8(offset), bytesRead: 1 };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
30
169
|
catch (error) {
|
|
31
|
-
|
|
170
|
+
return { value: 0, bytesRead: 1 };
|
|
32
171
|
}
|
|
33
172
|
}
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
173
|
+
initializeMessageDefinitions() {
|
|
174
|
+
// Common MAVLink messages - these definitions come from the official MAVLink specification
|
|
175
|
+
this.addMessageDefinition(0, 'HEARTBEAT', [
|
|
176
|
+
{ name: 'type', type: 'uint8_t' },
|
|
177
|
+
{ name: 'autopilot', type: 'uint8_t' },
|
|
178
|
+
{ name: 'base_mode', type: 'uint8_t' },
|
|
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);
|
|
395
|
+
}
|
|
396
|
+
async initializeFromGeneratedDefinitions() {
|
|
397
|
+
try {
|
|
398
|
+
// Load decoder definitions from dist folder
|
|
399
|
+
const dialects = ['common', 'ardupilotmega', 'minimal'];
|
|
400
|
+
const allDefinitions = new Map();
|
|
401
|
+
for (const dialectName of dialects) {
|
|
402
|
+
try {
|
|
403
|
+
const { MESSAGE_DEFINITIONS } = await Promise.resolve(`${`../../dist/decoders/${dialectName}`}`).then(s => __importStar(require(s)));
|
|
404
|
+
for (const def of MESSAGE_DEFINITIONS) {
|
|
405
|
+
if (!allDefinitions.has(def.id)) {
|
|
406
|
+
allDefinitions.set(def.id, def);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
console.warn(`Failed to load ${dialectName} decoder definitions:`, error);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
this.messageDefinitions = allDefinitions;
|
|
415
|
+
console.log(`Loaded ${this.messageDefinitions.size} message definitions from generated decoders`);
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
console.warn('Failed to load generated decoder definitions, falling back to hardcoded definitions:', error);
|
|
419
|
+
this.initializeMessageDefinitions();
|
|
85
420
|
}
|
|
86
|
-
return decoded;
|
|
87
421
|
}
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
2: 'SYSTEM_TIME',
|
|
93
|
-
4: 'PING',
|
|
94
|
-
5: 'CHANGE_OPERATOR_CONTROL',
|
|
95
|
-
6: 'CHANGE_OPERATOR_CONTROL_ACK',
|
|
96
|
-
7: 'AUTH_KEY',
|
|
97
|
-
11: 'SET_MODE',
|
|
98
|
-
20: 'PARAM_REQUEST_READ',
|
|
99
|
-
21: 'PARAM_REQUEST_LIST',
|
|
100
|
-
22: 'PARAM_VALUE',
|
|
101
|
-
23: 'PARAM_SET',
|
|
102
|
-
24: 'GPS_RAW_INT',
|
|
103
|
-
25: 'GPS_STATUS',
|
|
104
|
-
26: 'SCALED_IMU',
|
|
105
|
-
27: 'RAW_IMU',
|
|
106
|
-
28: 'RAW_PRESSURE',
|
|
107
|
-
29: 'SCALED_PRESSURE',
|
|
108
|
-
30: 'ATTITUDE',
|
|
109
|
-
31: 'ATTITUDE_QUATERNION',
|
|
110
|
-
32: 'LOCAL_POSITION_NED',
|
|
111
|
-
33: 'GLOBAL_POSITION_INT',
|
|
112
|
-
34: 'RC_CHANNELS_SCALED',
|
|
113
|
-
35: 'RC_CHANNELS_RAW',
|
|
114
|
-
36: 'SERVO_OUTPUT_RAW',
|
|
115
|
-
37: 'MISSION_REQUEST_PARTIAL_LIST',
|
|
116
|
-
38: 'MISSION_WRITE_PARTIAL_LIST',
|
|
117
|
-
39: 'MISSION_ITEM',
|
|
118
|
-
40: 'MISSION_REQUEST',
|
|
119
|
-
41: 'MISSION_SET_CURRENT',
|
|
120
|
-
42: 'MISSION_CURRENT',
|
|
121
|
-
43: 'MISSION_REQUEST_LIST',
|
|
122
|
-
44: 'MISSION_COUNT',
|
|
123
|
-
45: 'MISSION_CLEAR_ALL',
|
|
124
|
-
46: 'MISSION_ITEM_REACHED',
|
|
125
|
-
47: 'MISSION_ACK',
|
|
126
|
-
48: 'SET_GPS_GLOBAL_ORIGIN',
|
|
127
|
-
49: 'GPS_GLOBAL_ORIGIN',
|
|
128
|
-
50: 'PARAM_MAP_RC',
|
|
129
|
-
51: 'MISSION_REQUEST_INT',
|
|
130
|
-
54: 'SAFETY_SET_ALLOWED_AREA',
|
|
131
|
-
55: 'SAFETY_ALLOWED_AREA',
|
|
132
|
-
61: 'ATTITUDE_QUATERNION_COV',
|
|
133
|
-
62: 'NAV_CONTROLLER_OUTPUT',
|
|
134
|
-
63: 'GLOBAL_POSITION_INT_COV',
|
|
135
|
-
64: 'LOCAL_POSITION_NED_COV',
|
|
136
|
-
65: 'RC_CHANNELS',
|
|
137
|
-
66: 'REQUEST_DATA_STREAM',
|
|
138
|
-
67: 'DATA_STREAM',
|
|
139
|
-
69: 'MANUAL_CONTROL',
|
|
140
|
-
70: 'RC_CHANNELS_OVERRIDE',
|
|
141
|
-
73: 'MISSION_ITEM_INT',
|
|
142
|
-
74: 'VFR_HUD',
|
|
143
|
-
75: 'COMMAND_INT',
|
|
144
|
-
76: 'COMMAND_LONG',
|
|
145
|
-
77: 'COMMAND_ACK',
|
|
146
|
-
81: 'MANUAL_SETPOINT',
|
|
147
|
-
82: 'SET_ATTITUDE_TARGET',
|
|
148
|
-
83: 'ATTITUDE_TARGET',
|
|
149
|
-
84: 'SET_POSITION_TARGET_LOCAL_NED',
|
|
150
|
-
85: 'POSITION_TARGET_LOCAL_NED',
|
|
151
|
-
86: 'SET_POSITION_TARGET_GLOBAL_INT',
|
|
152
|
-
87: 'POSITION_TARGET_GLOBAL_INT',
|
|
153
|
-
89: 'LOCAL_POSITION_NED_SYSTEM_GLOBAL_OFFSET',
|
|
154
|
-
90: 'HIL_STATE',
|
|
155
|
-
91: 'HIL_CONTROLS',
|
|
156
|
-
92: 'HIL_RC_INPUTS_RAW',
|
|
157
|
-
100: 'OPTICAL_FLOW',
|
|
158
|
-
101: 'GLOBAL_VISION_POSITION_ESTIMATE',
|
|
159
|
-
102: 'VISION_POSITION_ESTIMATE',
|
|
160
|
-
103: 'VISION_SPEED_ESTIMATE',
|
|
161
|
-
104: 'VICON_POSITION_ESTIMATE',
|
|
162
|
-
105: 'HIGHRES_IMU',
|
|
163
|
-
106: 'OPTICAL_FLOW_RAD',
|
|
164
|
-
107: 'HIL_SENSOR',
|
|
165
|
-
108: 'SIM_STATE',
|
|
166
|
-
109: 'RADIO_STATUS',
|
|
167
|
-
110: 'FILE_TRANSFER_PROTOCOL',
|
|
168
|
-
111: 'TIMESYNC',
|
|
169
|
-
112: 'CAMERA_TRIGGER',
|
|
170
|
-
113: 'HIL_GPS',
|
|
171
|
-
114: 'HIL_OPTICAL_FLOW',
|
|
172
|
-
115: 'HIL_STATE_QUATERNION',
|
|
173
|
-
116: 'SCALED_IMU2',
|
|
174
|
-
117: 'LOG_REQUEST_LIST',
|
|
175
|
-
118: 'LOG_ENTRY',
|
|
176
|
-
119: 'LOG_REQUEST_DATA',
|
|
177
|
-
120: 'LOG_DATA',
|
|
178
|
-
121: 'LOG_ERASE',
|
|
179
|
-
122: 'LOG_REQUEST_END',
|
|
180
|
-
123: 'GPS_INJECT_DATA',
|
|
181
|
-
124: 'GPS2_RAW',
|
|
182
|
-
125: 'POWER_STATUS',
|
|
183
|
-
126: 'SERIAL_CONTROL',
|
|
184
|
-
127: 'GPS_RTK',
|
|
185
|
-
128: 'GPS2_RTK',
|
|
186
|
-
129: 'SCALED_IMU3',
|
|
187
|
-
130: 'DATA_TRANSMISSION_HANDSHAKE',
|
|
188
|
-
131: 'ENCAPSULATED_DATA',
|
|
189
|
-
132: 'DISTANCE_SENSOR',
|
|
190
|
-
133: 'TERRAIN_REQUEST',
|
|
191
|
-
134: 'TERRAIN_DATA',
|
|
192
|
-
135: 'TERRAIN_CHECK',
|
|
193
|
-
136: 'TERRAIN_REPORT',
|
|
194
|
-
137: 'SCALED_PRESSURE2',
|
|
195
|
-
138: 'ATT_POS_MOCAP',
|
|
196
|
-
139: 'SET_ACTUATOR_CONTROL_TARGET',
|
|
197
|
-
140: 'ACTUATOR_CONTROL_TARGET',
|
|
198
|
-
141: 'ALTITUDE',
|
|
199
|
-
142: 'RESOURCE_REQUEST',
|
|
200
|
-
143: 'SCALED_PRESSURE3',
|
|
201
|
-
144: 'FOLLOW_TARGET',
|
|
202
|
-
146: 'CONTROL_SYSTEM_STATE',
|
|
203
|
-
147: 'BATTERY_STATUS',
|
|
204
|
-
148: 'AUTOPILOT_VERSION',
|
|
205
|
-
149: 'LANDING_TARGET',
|
|
206
|
-
230: 'ESTIMATOR_STATUS',
|
|
207
|
-
231: 'WIND_COV',
|
|
208
|
-
232: 'GPS_INPUT',
|
|
209
|
-
233: 'GPS_RTCM_DATA',
|
|
210
|
-
234: 'HIGH_LATENCY',
|
|
211
|
-
235: 'HIGH_LATENCY2',
|
|
212
|
-
241: 'VIBRATION',
|
|
213
|
-
242: 'HOME_POSITION',
|
|
214
|
-
243: 'SET_HOME_POSITION',
|
|
215
|
-
244: 'MESSAGE_INTERVAL',
|
|
216
|
-
245: 'EXTENDED_SYS_STATE',
|
|
217
|
-
246: 'ADSB_VEHICLE',
|
|
218
|
-
247: 'COLLISION',
|
|
219
|
-
248: 'V2_EXTENSION',
|
|
220
|
-
249: 'MEMORY_VECT',
|
|
221
|
-
250: 'DEBUG_VECT',
|
|
222
|
-
251: 'NAMED_VALUE_FLOAT',
|
|
223
|
-
252: 'NAMED_VALUE_INT',
|
|
224
|
-
253: 'STATUSTEXT',
|
|
225
|
-
254: 'DEBUG',
|
|
226
|
-
256: 'SETUP_SIGNING',
|
|
227
|
-
257: 'BUTTON_CHANGE',
|
|
228
|
-
258: 'PLAY_TUNE',
|
|
229
|
-
259: 'CAMERA_INFORMATION',
|
|
230
|
-
260: 'CAMERA_SETTINGS',
|
|
231
|
-
261: 'STORAGE_INFORMATION',
|
|
232
|
-
262: 'CAMERA_CAPTURE_STATUS',
|
|
233
|
-
263: 'CAMERA_IMAGE_CAPTURED',
|
|
234
|
-
264: 'FLIGHT_INFORMATION',
|
|
235
|
-
265: 'MOUNT_ORIENTATION',
|
|
236
|
-
266: 'LOGGING_DATA',
|
|
237
|
-
267: 'LOGGING_DATA_ACKED',
|
|
238
|
-
268: 'LOGGING_ACK',
|
|
239
|
-
269: 'VIDEO_STREAM_INFORMATION',
|
|
240
|
-
270: 'VIDEO_STREAM_STATUS',
|
|
241
|
-
299: 'WIFI_CONFIG_AP'
|
|
242
|
-
};
|
|
243
|
-
return messageNames[messageId] || `UNKNOWN_${messageId}`;
|
|
422
|
+
static async createWithGeneratedDefinitions() {
|
|
423
|
+
const decoder = new MAVLinkMessageDecoder();
|
|
424
|
+
await decoder.initializeFromGeneratedDefinitions();
|
|
425
|
+
return decoder;
|
|
244
426
|
}
|
|
245
427
|
}
|
|
246
428
|
exports.MAVLinkMessageDecoder = MAVLinkMessageDecoder;
|