node-mavlink 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mavlink",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "author": "Matthias Hryniszak <padcom@gmail.com>",
5
5
  "license": "LGPL",
6
6
  "description": "MavLink definitions and parsing library",
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { join } = require('node:path')
4
+ const { createReadStream } = require('node:fs')
5
+ const { createMavLinkStream } = require('.')
6
+
7
+ const port = createReadStream(join(__dirname, 'examples/GH-5.bin'))
8
+ const parser = createMavLinkStream(port)
9
+ parser.on('data', packet => console.log(packet.debug()))
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { join } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+ import { createReadStream } from 'node:fs'
6
+ import { createMavLinkStream } from './dist/index.js'
7
+
8
+ const __dirname = fileURLToPath(new URL('.', import.meta.url))
9
+ const port = createReadStream(join(__dirname, 'examples/GH-5.bin'))
10
+ const parser = createMavLinkStream(port)
11
+ parser.on('data', packet => console.log(packet.debug()))
package/sanity-check.cjs CHANGED
@@ -3,7 +3,22 @@
3
3
  const { join } = require('node:path')
4
4
  const { createReadStream } = require('node:fs')
5
5
  const { createMavLinkStream } = require('.')
6
+ const { minimal, common, ardupilotmega } = require('.')
7
+
8
+ const REGISTRY = {
9
+ ...minimal.REGISTRY,
10
+ ...common.REGISTRY,
11
+ ...ardupilotmega.REGISTRY,
12
+ }
6
13
 
7
14
  const port = createReadStream(join(__dirname, 'examples/GH-5.bin'))
8
15
  const parser = createMavLinkStream(port)
9
- parser.on('data', packet => console.log(packet.debug()))
16
+ parser.on('data', packet => {
17
+ const clazz = REGISTRY[packet.header.msgid]
18
+ if (clazz) {
19
+ const data = packet.protocol.data(packet.payload, clazz)
20
+ console.log('Received packet:', data)
21
+ } else {
22
+ console.log(packet.debug())
23
+ }
24
+ })
package/sanity-check.mjs CHANGED
@@ -4,8 +4,21 @@ import { join } from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
5
  import { createReadStream } from 'node:fs'
6
6
  import { createMavLinkStream } from './dist/index.js'
7
+ import { minimal, common, ardupilotmega } from './dist/index.js'
8
+
9
+ const REGISTRY = {
10
+ ...minimal.REGISTRY,
11
+ ...common.REGISTRY,
12
+ ...ardupilotmega.REGISTRY,
13
+ }
7
14
 
8
15
  const __dirname = fileURLToPath(new URL('.', import.meta.url))
9
16
  const port = createReadStream(join(__dirname, 'examples/GH-5.bin'))
10
17
  const parser = createMavLinkStream(port)
11
- parser.on('data', packet => console.log(packet.debug()))
18
+ parser.on('data', packet => {
19
+ const clazz = REGISTRY[packet.header.msgid]
20
+ if (clazz) {
21
+ const data = packet.protocol.data(packet.payload, clazz)
22
+ console.log('Received packet:', data)
23
+ }
24
+ })