node-mavlink 1.0.6 → 1.0.7

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.
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { createReadStream } from 'fs'
4
4
  import { MavLinkPacketSplitter, MavLinkPacketParser, MavLinkPacket } from '..'
5
+ import { minimal, common, ardupilotmega, uavionix, icarous } from '..'
5
6
 
6
7
  const file = createReadStream('./mavlink-v2-3412-packets.bin')
7
8
 
@@ -11,8 +12,22 @@ const reader = file
11
12
  .pipe(splitter)
12
13
  .pipe(new MavLinkPacketParser())
13
14
 
14
- reader.on('data', (packet: MavLinkPacket) => {
15
- console.log(packet.debug())
15
+
16
+ // create a registry of mappings between a message id and a data class
17
+ const REGISTRY = {
18
+ ...minimal.REGISTRY,
19
+ ...common.REGISTRY,
20
+ ...ardupilotmega.REGISTRY,
21
+ ...uavionix.REGISTRY,
22
+ ...icarous.REGISTRY,
23
+ }
24
+
25
+ reader.on('data', packet => {
26
+ const clazz = REGISTRY[packet.header.msgid]
27
+ if (clazz) {
28
+ const data = packet.protocol.data(packet.payload, clazz)
29
+ console.log(data)
30
+ }
16
31
  })
17
32
 
18
33
  file.on('close', () => {
@@ -20,3 +35,4 @@ file.on('close', () => {
20
35
  console.log('Number of unknown packages:', splitter.unknownPackagesCount)
21
36
  console.log('\nTotal number of consumed packets:', splitter.validPackages)
22
37
  })
38
+
package/lib/mavlink.ts CHANGED
@@ -6,7 +6,6 @@ import { MSG_ID_MAGIC_NUMBER } from 'mavlink-mappings'
6
6
  import { MavLinkData, MavLinkDataConstructor } from 'mavlink-mappings'
7
7
 
8
8
  import { SERIALIZERS, DESERIALIZERS } from './serialization'
9
- import { start } from 'repl'
10
9
 
11
10
  /**
12
11
  * Header definition of the MavLink packet
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mavlink",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
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.0"
25
+ "mavlink-mappings": "^1.0.6-20220104"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsc"