node-mavlink 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +8 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/magic-numbers.d.ts +3 -0
- package/dist/lib/magic-numbers.d.ts.map +1 -0
- package/dist/lib/magic-numbers.js +24 -0
- package/dist/lib/mavesp.d.ts +3 -3
- package/dist/lib/mavesp.d.ts.map +1 -1
- package/dist/lib/mavesp.js +8 -8
- package/dist/lib/mavlink.d.ts +1 -1
- package/dist/lib/mavlink.d.ts.map +1 -1
- package/dist/lib/mavlink.js +2 -2
- package/dist/lib/utils.d.ts +5 -5
- package/dist/lib/utils.js +5 -5
- package/examples/pool-param-udp.ts +1 -1
- package/examples/send-receive-signed-udp.ts +1 -1
- package/examples/send-receive-udp.ts +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
@@ -75,7 +75,7 @@ import { MavLinkProtocolV2, send } from 'node-mavlink'
|
|
75
75
|
// By convention the intermediate fields that are then serialized
|
76
76
|
// are named with `_` (underscore) prefix and should not be used
|
77
77
|
// directly. That doesn't mean you can't use them, but if there
|
78
|
-
// is
|
78
|
+
// is an equivalent Command class it is just a lot easier and every
|
79
79
|
// parameter not only has a more descriptive names but also in-line
|
80
80
|
// documentation.
|
81
81
|
const command = new common.RequestProtocolVersionCommand()
|
@@ -128,7 +128,7 @@ async function main() {
|
|
128
128
|
// start the communication
|
129
129
|
await port.start()
|
130
130
|
|
131
|
-
// log
|
131
|
+
// log incoming packets
|
132
132
|
port.on('data', packet => {
|
133
133
|
console.log(packet.debug())
|
134
134
|
})
|
@@ -151,7 +151,7 @@ That's it! Easy as a lion :)
|
|
151
151
|
|
152
152
|
## Signed packages
|
153
153
|
|
154
|
-
MavLink v2 introduces package signing. The way it currently works with Mission planner is you give it a pass phrase, Mission Planner encodes it using sha256 hashing algorithm and uses it as part of the signature calculation. Therefore if someone does not know the secret passphrase they won't be able to create packets that would seem to be
|
154
|
+
MavLink v2 introduces package signing. The way it currently works with Mission planner is you give it a pass phrase, Mission Planner encodes it using sha256 hashing algorithm and uses it as part of the signature calculation. Therefore if someone does not know the secret passphrase they won't be able to create packets that would seem to be coming from a source. It's a kind of security thing.
|
155
155
|
|
156
156
|
### Reading signature
|
157
157
|
|
@@ -163,7 +163,7 @@ import { MavLinkPacketSignature } from 'node-mavlink'
|
|
163
163
|
// calculate secret key (change 'qwerty' to your secret phrase)
|
164
164
|
const key = MavLinkPacketSignature.key('qwerty')
|
165
165
|
|
166
|
-
// log
|
166
|
+
// log incoming messages
|
167
167
|
port.on('data', packet => {
|
168
168
|
console.log(packet.debug())
|
169
169
|
if (packet.signature) {
|
@@ -218,7 +218,7 @@ This function calls the `cb` callback periodically at the `interval` (default: 1
|
|
218
218
|
|
219
219
|
#### `async send(stream: Writable, msg: MavLinkData, protocol: MavLinkProtocol)`
|
220
220
|
|
221
|
-
This function serializes the `msg` message using the provided `protocol` (default: `MavLinkProtocolV1`) and sends it to the `stream`. If the process is successful the method returns with the length of written data denoting that no error
|
221
|
+
This function serializes the `msg` message using the provided `protocol` (default: `MavLinkProtocolV1`) and sends it to the `stream`. If the process is successful the method returns with the length of written data denoting that no error occurred. However, if the process was not successful it will error out with the underlying error object returned on by the stream.
|
222
222
|
|
223
223
|
#### `async sendSigned(stream: Writable, msg: MavLinkData, key: Buffer, linkId: uint8_t, sysid: uint8_t, compid: uint8_t)`
|
224
224
|
|
@@ -235,7 +235,7 @@ This is a very handy utility function that asynchronously pauses for a given tim
|
|
235
235
|
|
236
236
|
## Running sim_vehicle.py
|
237
237
|
|
238
|
-
The easiest way to start playing around with this package is to use `sim_vehicle.py`. You can use the default parameters
|
238
|
+
The easiest way to start playing around with this package is to use `sim_vehicle.py`. You can use the default parameters for the MavEsp8266 if you'll make the simulator compatible with it:
|
239
239
|
|
240
240
|
```
|
241
241
|
$ Tools/autotest/sim_vehicle.py -v ArduCopter -f quad --console --map --out udpin:127.0.0.1:14555
|
@@ -249,7 +249,7 @@ The original generated sources lack one very important aspect of a reusable libr
|
|
249
249
|
|
250
250
|
When generating sources for data classes a number of things happen:
|
251
251
|
|
252
|
-
- `enum` values are trimmed from common prefix; duplicating enum name in its value when its value cannot be spelled without the enum name is pointless and leads to
|
252
|
+
- `enum` values are trimmed from common prefix; duplicating enum name in its value when its value cannot be spelled without the enum name is pointless and leads to unnecessarily verbose code
|
253
253
|
- enum values, whenever available, contain JSDoc describing their purpose
|
254
254
|
- data classes are properly named (PascalCase)
|
255
255
|
- data classes fields are properly named (camelCase)
|
@@ -259,6 +259,6 @@ When generating sources for data classes a number of things happen:
|
|
259
259
|
|
260
260
|
This leads to generated code that contains not only raw types but also documentation where it is mostly useful: right at your fingertips.
|
261
261
|
|
262
|
-
I hope you'll enjoy using this library! If you have any comments, find a bug or just generally want to share your thoughts you can reach me via
|
262
|
+
I hope you'll enjoy using this library! If you have any comments, find a bug or just generally want to share your thoughts you can reach me via email: padcom@gmail.com
|
263
263
|
|
264
264
|
Peace!
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
17
|
__exportStar(require("mavlink-mappings"), exports);
|
18
|
+
__exportStar(require("./lib/magic-numbers"), exports);
|
18
19
|
__exportStar(require("./lib/utils"), exports);
|
19
20
|
__exportStar(require("./lib/logger"), exports);
|
20
21
|
__exportStar(require("./lib/mavlink"), exports);
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"magic-numbers.d.ts","sourceRoot":"","sources":["../../lib/magic-numbers.ts"],"names":[],"mappings":"AAEA,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAO5E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAOtE"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.overrideMessageMagicNumber = exports.registerCustomMessageMagicNumber = void 0;
|
4
|
+
const mavlink_mappings_1 = require("mavlink-mappings");
|
5
|
+
function registerCustomMessageMagicNumber(msgid, magic) {
|
6
|
+
const numbers = mavlink_mappings_1.MSG_ID_MAGIC_NUMBER;
|
7
|
+
if (numbers[msgid] !== undefined) {
|
8
|
+
throw new Error(`Magic number for message "${msgid}" already registered`);
|
9
|
+
}
|
10
|
+
else {
|
11
|
+
numbers[msgid] = magic;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.registerCustomMessageMagicNumber = registerCustomMessageMagicNumber;
|
15
|
+
function overrideMessageMagicNumber(msgid, magic) {
|
16
|
+
const numbers = mavlink_mappings_1.MSG_ID_MAGIC_NUMBER;
|
17
|
+
if (numbers[msgid] === undefined) {
|
18
|
+
throw new Error(`Magic number for message "${msgid}" not registered`);
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
numbers[msgid] = magic;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
exports.overrideMessageMagicNumber = overrideMessageMagicNumber;
|
package/dist/lib/mavesp.d.ts
CHANGED
@@ -18,7 +18,7 @@ export declare class MavEsp8266 extends EventEmitter {
|
|
18
18
|
private seq;
|
19
19
|
constructor();
|
20
20
|
/**
|
21
|
-
* Start communication with the controller via
|
21
|
+
* Start communication with the controller via MAVESP8266
|
22
22
|
*
|
23
23
|
* @param receivePort port to receive messages on (default: 14550)
|
24
24
|
* @param sendPort port to send messages to (default: 14555)
|
@@ -51,7 +51,7 @@ export declare class MavEsp8266 extends EventEmitter {
|
|
51
51
|
* @param buffer buffer to send
|
52
52
|
*/
|
53
53
|
sendBuffer(buffer: Buffer): Promise<number>;
|
54
|
-
private
|
55
|
-
private
|
54
|
+
private processIncomingUDPData;
|
55
|
+
private processIncomingPacket;
|
56
56
|
}
|
57
57
|
//# sourceMappingURL=mavesp.d.ts.map
|
package/dist/lib/mavesp.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mavesp.d.ts","sourceRoot":"","sources":["../../lib/mavesp.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAOrC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEvD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,YAAY;IAC1C,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,MAAM,CAAC,CAAQ;IACvB,OAAO,CAAC,EAAE,CAAa;IACvB,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,GAAG,CAAY;;IAmBvB;;;;;OAKG;IACG,KAAK,CAAC,WAAW,GAAE,MAAc,EAAE,QAAQ,GAAE,MAAc,GAAG,OAAO,CAAC,cAAc,CAAC;IAmB3F;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5B;;;;;;OAMG;IACG,I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OAOG;IACG,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAW,EAAE,KAAK,GAAE,OAAgC,EAAE,MAAM,GAAE,OAAiC,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzK;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASjD,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,qBAAqB;CAI9B"}
|
package/dist/lib/mavesp.js
CHANGED
@@ -19,17 +19,17 @@ class MavEsp8266 extends events_1.EventEmitter {
|
|
19
19
|
constructor() {
|
20
20
|
super();
|
21
21
|
this.input = new stream_1.PassThrough();
|
22
|
-
this.
|
23
|
-
this.
|
22
|
+
this.processIncomingUDPData = this.processIncomingUDPData.bind(this);
|
23
|
+
this.processIncomingPacket = this.processIncomingPacket.bind(this);
|
24
24
|
// Create the reader as usual by piping the source stream through the splitter
|
25
25
|
// and packet parser
|
26
26
|
const reader = this.input
|
27
27
|
.pipe(new mavlink_1.MavLinkPacketSplitter())
|
28
28
|
.pipe(new mavlink_1.MavLinkPacketParser());
|
29
|
-
reader.on('data', this.
|
29
|
+
reader.on('data', this.processIncomingPacket);
|
30
30
|
}
|
31
31
|
/**
|
32
|
-
* Start communication with the controller via
|
32
|
+
* Start communication with the controller via MAVESP8266
|
33
33
|
*
|
34
34
|
* @param receivePort port to receive messages on (default: 14550)
|
35
35
|
* @param sendPort port to send messages to (default: 14555)
|
@@ -38,7 +38,7 @@ class MavEsp8266 extends events_1.EventEmitter {
|
|
38
38
|
this.sendPort = sendPort;
|
39
39
|
// Create a UDP socket
|
40
40
|
this.socket = (0, dgram_1.createSocket)({ type: 'udp4', reuseAddr: true });
|
41
|
-
this.socket.on('message', this.
|
41
|
+
this.socket.on('message', this.processIncomingUDPData);
|
42
42
|
// Start listening on the socket
|
43
43
|
return new Promise((resolve, reject) => {
|
44
44
|
this.socket?.bind(receivePort, () => {
|
@@ -57,7 +57,7 @@ class MavEsp8266 extends events_1.EventEmitter {
|
|
57
57
|
if (!this.socket)
|
58
58
|
throw new Error('Not connected');
|
59
59
|
// Unregister event handlers
|
60
|
-
this.socket.off('message', this.
|
60
|
+
this.socket.off('message', this.processIncomingUDPData);
|
61
61
|
// Close the socket
|
62
62
|
return new Promise(resolve => {
|
63
63
|
this.socket?.close(resolve);
|
@@ -106,14 +106,14 @@ class MavEsp8266 extends events_1.EventEmitter {
|
|
106
106
|
});
|
107
107
|
});
|
108
108
|
}
|
109
|
-
|
109
|
+
processIncomingUDPData(buffer, metadata) {
|
110
110
|
// store the remote ip address
|
111
111
|
if (this.ip === '')
|
112
112
|
this.ip = metadata.address;
|
113
113
|
// pass on the data to the input stream
|
114
114
|
this.input.write(buffer);
|
115
115
|
}
|
116
|
-
|
116
|
+
processIncomingPacket(packet) {
|
117
117
|
// let the user know we received the packet
|
118
118
|
this.emit('data', packet);
|
119
119
|
}
|
package/dist/lib/mavlink.d.ts
CHANGED
@@ -190,7 +190,7 @@ export declare class MavLinkPacket {
|
|
190
190
|
}
|
191
191
|
declare type BufferCallback = (buffer: Buffer) => void;
|
192
192
|
/**
|
193
|
-
* A transform stream that splits the
|
193
|
+
* A transform stream that splits the incoming data stream into chunks containing full MavLink messages
|
194
194
|
*/
|
195
195
|
export declare class MavLinkPacketSplitter extends Transform {
|
196
196
|
protected readonly log: Logger;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mavlink.d.ts","sourceRoot":"","sources":["../../lib/mavlink.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEzE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAU,MAAM,kBAAkB,CAAA;AAE5D,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAGtE,OAAO,EAAE,MAAM,EAAE,MA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EAAE,cAAc,uBAI9E;AAID;;;;;;;GAOG;AACH,wBAAsB,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,GAAE,eAAyC,oBASjH;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,QAAQ,EAChB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,OAAW,EAAE,KAAK,GAAE,OAAgC,EAAE,MAAM,GAAE,OAAiC,EACvG,SAAS,SAAa,oBAYvB"}
|
package/dist/lib/mavlink.js
CHANGED
@@ -402,7 +402,7 @@ var PacketValidationResult;
|
|
402
402
|
PacketValidationResult[PacketValidationResult["UNKNOWN"] = 2] = "UNKNOWN";
|
403
403
|
})(PacketValidationResult || (PacketValidationResult = {}));
|
404
404
|
/**
|
405
|
-
* A transform stream that splits the
|
405
|
+
* A transform stream that splits the incoming data stream into chunks containing full MavLink messages
|
406
406
|
*/
|
407
407
|
class MavLinkPacketSplitter extends stream_1.Transform {
|
408
408
|
log = logger_1.Logger.getLogger(this);
|
@@ -444,7 +444,7 @@ class MavLinkPacketSplitter extends stream_1.Transform {
|
|
444
444
|
// get protocol this buffer is encoded with
|
445
445
|
const Protocol = this.getPacketProtocol(this.buffer);
|
446
446
|
this.log.debug('Packet protocol is', Protocol.NAME);
|
447
|
-
// check if the buffer contains at least the
|
447
|
+
// check if the buffer contains at least the minimum size of data
|
448
448
|
if (this.buffer.length < Protocol.PAYLOAD_OFFSET + MavLinkProtocol.CHECKSUM_LENGTH) {
|
449
449
|
// current buffer shorter than the shortest message - skipping
|
450
450
|
this.log.debug('Current buffer shorter than the shortest message - skipping');
|
package/dist/lib/utils.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
/**
|
3
|
-
* Convert a number to hexadecimal representation with a
|
3
|
+
* Convert a number to hexadecimal representation with a minimum
|
4
4
|
* number of characters and optional prefix (0x by default)
|
5
5
|
*
|
6
6
|
* @param n value to convert
|
@@ -16,9 +16,9 @@ export declare function hex(n: number, len?: number, prefix?: string): string;
|
|
16
16
|
*/
|
17
17
|
export declare function dump(buffer: Buffer, lineWidth?: number): void;
|
18
18
|
/**
|
19
|
-
* Sleep for a given number of
|
19
|
+
* Sleep for a given number of milliseconds
|
20
20
|
*
|
21
|
-
* @param {number} ms of
|
21
|
+
* @param {number} ms of milliseconds to sleep
|
22
22
|
*/
|
23
23
|
export declare function sleep(ms: number): Promise<unknown>;
|
24
24
|
/**
|
@@ -29,8 +29,8 @@ export declare function sleep(ms: number): Promise<unknown>;
|
|
29
29
|
* the execution without success. Great for time-sensitive operations.
|
30
30
|
*
|
31
31
|
* @param cb callback to call every <code>interval</code>ms. Waiting stops if the callback returns a truthy value.
|
32
|
-
* @param timeout number of
|
33
|
-
* @param interval number of
|
32
|
+
* @param timeout number of milliseconds that need to pass before the Timeout exception is thrown
|
33
|
+
* @param interval number of milliseconds before re-running the callback
|
34
34
|
*/
|
35
35
|
export declare function waitFor<T>(cb: () => T, timeout?: number, interval?: number): Promise<T>;
|
36
36
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/lib/utils.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.waitFor = exports.sleep = exports.dump = exports.hex = void 0;
|
4
4
|
/**
|
5
|
-
* Convert a number to hexadecimal representation with a
|
5
|
+
* Convert a number to hexadecimal representation with a minimum
|
6
6
|
* number of characters and optional prefix (0x by default)
|
7
7
|
*
|
8
8
|
* @param n value to convert
|
@@ -36,9 +36,9 @@ function dump(buffer, lineWidth = 16) {
|
|
36
36
|
}
|
37
37
|
exports.dump = dump;
|
38
38
|
/**
|
39
|
-
* Sleep for a given number of
|
39
|
+
* Sleep for a given number of milliseconds
|
40
40
|
*
|
41
|
-
* @param {number} ms of
|
41
|
+
* @param {number} ms of milliseconds to sleep
|
42
42
|
*/
|
43
43
|
function sleep(ms) {
|
44
44
|
return new Promise(resolve => setTimeout(resolve, ms));
|
@@ -52,8 +52,8 @@ exports.sleep = sleep;
|
|
52
52
|
* the execution without success. Great for time-sensitive operations.
|
53
53
|
*
|
54
54
|
* @param cb callback to call every <code>interval</code>ms. Waiting stops if the callback returns a truthy value.
|
55
|
-
* @param timeout number of
|
56
|
-
* @param interval number of
|
55
|
+
* @param timeout number of milliseconds that need to pass before the Timeout exception is thrown
|
56
|
+
* @param interval number of milliseconds before re-running the callback
|
57
57
|
*/
|
58
58
|
async function waitFor(cb, timeout = 10000, interval = 100) {
|
59
59
|
return new Promise((resolve, reject) => {
|
@@ -11,7 +11,7 @@ async function main() {
|
|
11
11
|
// know what is the remote IP address to send the messages to
|
12
12
|
await port.start()
|
13
13
|
|
14
|
-
// log
|
14
|
+
// log incoming messages
|
15
15
|
port.on('data', (packet: MavLinkPacket) => {
|
16
16
|
if (packet.header.msgid === common.ParamValue.MSG_ID) {
|
17
17
|
const value = packet.protocol.data(packet.payload, common.ParamValue)
|
@@ -19,7 +19,7 @@ async function main() {
|
|
19
19
|
const { ip, sendPort, receivePort } = await port.start()
|
20
20
|
console.log(`Connected to: ${ip}, send port: ${sendPort}, receive port ${receivePort}`)
|
21
21
|
|
22
|
-
// log
|
22
|
+
// log incoming messages
|
23
23
|
port.on('data', (packet: MavLinkPacket) => {
|
24
24
|
if (packet.signature) {
|
25
25
|
if (packet.signature.matches(key)) {
|
@@ -24,7 +24,7 @@ async function main() {
|
|
24
24
|
const { ip, sendPort, receivePort } = await port.start(14551)
|
25
25
|
console.log(`Connected to: ${ip}, send port: ${sendPort}, receive port ${receivePort}`)
|
26
26
|
|
27
|
-
// log
|
27
|
+
// log incoming messages
|
28
28
|
port.on('data', (packet: MavLinkPacket) => {
|
29
29
|
const clazz = REGISTRY[packet.header.msgid]
|
30
30
|
if (clazz) {
|
@@ -44,7 +44,7 @@ async function main() {
|
|
44
44
|
// By convention the intermediate fields that are then serialized
|
45
45
|
// are named with `_` (underscore) prefix and should not be used
|
46
46
|
// directly. That doesn't mean you can't use them, but if there
|
47
|
-
// is
|
47
|
+
// is an equivalent Command class it is just a lot easier and every
|
48
48
|
// parameter not only has a more descriptive names but also in-line
|
49
49
|
// documentation.
|
50
50
|
const command = new common.RequestProtocolVersionCommand()
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "node-mavlink",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.6.0",
|
4
4
|
"author": "Matthias Hryniszak <padcom@gmail.com>",
|
5
5
|
"license": "LGPL",
|
6
6
|
"description": "MavLink definitions and parsing library",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"main": "dist/index.js",
|
23
23
|
"types": "dist/index.d.ts",
|
24
24
|
"dependencies": {
|
25
|
-
"mavlink-mappings": "^1.0.
|
25
|
+
"mavlink-mappings": "^1.0.15-20230328-0"
|
26
26
|
},
|
27
27
|
"scripts": {
|
28
28
|
"clean": "rm -rf dist lib/*.js",
|
@@ -49,4 +49,4 @@
|
|
49
49
|
"xml2js": "^0.4.23",
|
50
50
|
"yargs": "^17.3.1"
|
51
51
|
}
|
52
|
-
}
|
52
|
+
}
|