node-mavlink 1.0.11 → 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.
@@ -0,0 +1,196 @@
1
+ /* eslint-disable */
2
+ var addSorting = (function() {
3
+ 'use strict';
4
+ var cols,
5
+ currentSort = {
6
+ index: 0,
7
+ desc: false
8
+ };
9
+
10
+ // returns the summary table element
11
+ function getTable() {
12
+ return document.querySelector('.coverage-summary');
13
+ }
14
+ // returns the thead element of the summary table
15
+ function getTableHeader() {
16
+ return getTable().querySelector('thead tr');
17
+ }
18
+ // returns the tbody element of the summary table
19
+ function getTableBody() {
20
+ return getTable().querySelector('tbody');
21
+ }
22
+ // returns the th element for nth column
23
+ function getNthColumn(n) {
24
+ return getTableHeader().querySelectorAll('th')[n];
25
+ }
26
+
27
+ function onFilterInput() {
28
+ const searchValue = document.getElementById('fileSearch').value;
29
+ const rows = document.getElementsByTagName('tbody')[0].children;
30
+ for (let i = 0; i < rows.length; i++) {
31
+ const row = rows[i];
32
+ if (
33
+ row.textContent
34
+ .toLowerCase()
35
+ .includes(searchValue.toLowerCase())
36
+ ) {
37
+ row.style.display = '';
38
+ } else {
39
+ row.style.display = 'none';
40
+ }
41
+ }
42
+ }
43
+
44
+ // loads the search box
45
+ function addSearchBox() {
46
+ var template = document.getElementById('filterTemplate');
47
+ var templateClone = template.content.cloneNode(true);
48
+ templateClone.getElementById('fileSearch').oninput = onFilterInput;
49
+ template.parentElement.appendChild(templateClone);
50
+ }
51
+
52
+ // loads all columns
53
+ function loadColumns() {
54
+ var colNodes = getTableHeader().querySelectorAll('th'),
55
+ colNode,
56
+ cols = [],
57
+ col,
58
+ i;
59
+
60
+ for (i = 0; i < colNodes.length; i += 1) {
61
+ colNode = colNodes[i];
62
+ col = {
63
+ key: colNode.getAttribute('data-col'),
64
+ sortable: !colNode.getAttribute('data-nosort'),
65
+ type: colNode.getAttribute('data-type') || 'string'
66
+ };
67
+ cols.push(col);
68
+ if (col.sortable) {
69
+ col.defaultDescSort = col.type === 'number';
70
+ colNode.innerHTML =
71
+ colNode.innerHTML + '<span class="sorter"></span>';
72
+ }
73
+ }
74
+ return cols;
75
+ }
76
+ // attaches a data attribute to every tr element with an object
77
+ // of data values keyed by column name
78
+ function loadRowData(tableRow) {
79
+ var tableCols = tableRow.querySelectorAll('td'),
80
+ colNode,
81
+ col,
82
+ data = {},
83
+ i,
84
+ val;
85
+ for (i = 0; i < tableCols.length; i += 1) {
86
+ colNode = tableCols[i];
87
+ col = cols[i];
88
+ val = colNode.getAttribute('data-value');
89
+ if (col.type === 'number') {
90
+ val = Number(val);
91
+ }
92
+ data[col.key] = val;
93
+ }
94
+ return data;
95
+ }
96
+ // loads all row data
97
+ function loadData() {
98
+ var rows = getTableBody().querySelectorAll('tr'),
99
+ i;
100
+
101
+ for (i = 0; i < rows.length; i += 1) {
102
+ rows[i].data = loadRowData(rows[i]);
103
+ }
104
+ }
105
+ // sorts the table using the data for the ith column
106
+ function sortByIndex(index, desc) {
107
+ var key = cols[index].key,
108
+ sorter = function(a, b) {
109
+ a = a.data[key];
110
+ b = b.data[key];
111
+ return a < b ? -1 : a > b ? 1 : 0;
112
+ },
113
+ finalSorter = sorter,
114
+ tableBody = document.querySelector('.coverage-summary tbody'),
115
+ rowNodes = tableBody.querySelectorAll('tr'),
116
+ rows = [],
117
+ i;
118
+
119
+ if (desc) {
120
+ finalSorter = function(a, b) {
121
+ return -1 * sorter(a, b);
122
+ };
123
+ }
124
+
125
+ for (i = 0; i < rowNodes.length; i += 1) {
126
+ rows.push(rowNodes[i]);
127
+ tableBody.removeChild(rowNodes[i]);
128
+ }
129
+
130
+ rows.sort(finalSorter);
131
+
132
+ for (i = 0; i < rows.length; i += 1) {
133
+ tableBody.appendChild(rows[i]);
134
+ }
135
+ }
136
+ // removes sort indicators for current column being sorted
137
+ function removeSortIndicators() {
138
+ var col = getNthColumn(currentSort.index),
139
+ cls = col.className;
140
+
141
+ cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
142
+ col.className = cls;
143
+ }
144
+ // adds sort indicators for current column being sorted
145
+ function addSortIndicators() {
146
+ getNthColumn(currentSort.index).className += currentSort.desc
147
+ ? ' sorted-desc'
148
+ : ' sorted';
149
+ }
150
+ // adds event listeners for all sorter widgets
151
+ function enableUI() {
152
+ var i,
153
+ el,
154
+ ithSorter = function ithSorter(i) {
155
+ var col = cols[i];
156
+
157
+ return function() {
158
+ var desc = col.defaultDescSort;
159
+
160
+ if (currentSort.index === i) {
161
+ desc = !currentSort.desc;
162
+ }
163
+ sortByIndex(i, desc);
164
+ removeSortIndicators();
165
+ currentSort.index = i;
166
+ currentSort.desc = desc;
167
+ addSortIndicators();
168
+ };
169
+ };
170
+ for (i = 0; i < cols.length; i += 1) {
171
+ if (cols[i].sortable) {
172
+ // add the click event handler on the th so users
173
+ // dont have to click on those tiny arrows
174
+ el = getNthColumn(i).querySelector('.sorter').parentElement;
175
+ if (el.addEventListener) {
176
+ el.addEventListener('click', ithSorter(i));
177
+ } else {
178
+ el.attachEvent('onclick', ithSorter(i));
179
+ }
180
+ }
181
+ }
182
+ }
183
+ // adds sorting functionality to the UI
184
+ return function() {
185
+ if (!getTable()) {
186
+ return;
187
+ }
188
+ cols = loadColumns();
189
+ loadData();
190
+ addSearchBox();
191
+ addSortIndicators();
192
+ enableUI();
193
+ };
194
+ })();
195
+
196
+ window.addEventListener('load', addSorting);
File without changes
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.MavEsp8266 = void 0;
13
4
  const events_1 = require("events");
@@ -41,21 +32,19 @@ class MavEsp8266 extends events_1.EventEmitter {
41
32
  * @param receivePort port to receive messages on (default: 14550)
42
33
  * @param sendPort port to send messages to (default: 14555)
43
34
  */
44
- start(receivePort = 14550, sendPort = 14555) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- this.sendPort = sendPort;
47
- // Create a UDP socket
48
- this.socket = (0, dgram_1.createSocket)({ type: 'udp4', reuseAddr: true });
49
- this.socket.on('message', this.processIncommingUDPData);
50
- // Start listening on the socket
51
- return new Promise((resolve, reject) => {
52
- this.socket.bind(receivePort, () => {
53
- // Wait for the first package to be returned to read the ip address
54
- // of the controller
55
- (0, utils_1.waitFor)(() => this.ip !== '')
56
- .then(() => { resolve(this.ip); })
57
- .catch(e => { reject(e); });
58
- });
35
+ async start(receivePort = 14550, sendPort = 14555) {
36
+ this.sendPort = sendPort;
37
+ // Create a UDP socket
38
+ this.socket = (0, dgram_1.createSocket)({ type: 'udp4', reuseAddr: true });
39
+ this.socket.on('message', this.processIncommingUDPData);
40
+ // Start listening on the socket
41
+ return new Promise((resolve, reject) => {
42
+ this.socket.bind(receivePort, () => {
43
+ // Wait for the first package to be returned to read the ip address
44
+ // of the controller
45
+ (0, utils_1.waitFor)(() => this.ip !== '')
46
+ .then(() => { resolve(this.ip); })
47
+ .catch(e => { reject(e); });
59
48
  });
60
49
  });
61
50
  }
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.sendSigned = exports.send = exports.createMavLinkStream = exports.MavLinkPacketParser = exports.MavLinkPacketSplitter = exports.MavLinkPacket = exports.MavLinkPacketSignature = exports.MavLinkProtocolV2 = exports.MavLinkProtocolV1 = exports.MavLinkProtocol = exports.MavLinkPacketHeader = void 0;
13
4
  const stream_1 = require("stream");
@@ -596,7 +587,7 @@ exports.MavLinkPacketSplitter = MavLinkPacketSplitter;
596
587
  */
597
588
  class MavLinkPacketParser extends stream_1.Transform {
598
589
  constructor(opts = {}) {
599
- super(Object.assign(Object.assign({}, opts), { objectMode: true }));
590
+ super({ ...opts, objectMode: true });
600
591
  this.log = logger_1.Logger.getLogger(this);
601
592
  }
602
593
  getProtocol(buffer) {
@@ -643,17 +634,15 @@ let seq = 0;
643
634
  * @param protocol protocol to use (default: MavLinkProtocolV1)
644
635
  * @returns number of bytes sent
645
636
  */
646
- function send(stream, msg, protocol = new MavLinkProtocolV1()) {
647
- return __awaiter(this, void 0, void 0, function* () {
648
- return new Promise((resolve, reject) => {
649
- const buffer = protocol.serialize(msg, seq++);
650
- seq &= 255;
651
- stream.write(buffer, err => {
652
- if (err)
653
- reject(err);
654
- else
655
- resolve(buffer.length);
656
- });
637
+ async function send(stream, msg, protocol = new MavLinkProtocolV1()) {
638
+ return new Promise((resolve, reject) => {
639
+ const buffer = protocol.serialize(msg, seq++);
640
+ seq &= 255;
641
+ stream.write(buffer, err => {
642
+ if (err)
643
+ reject(err);
644
+ else
645
+ resolve(buffer.length);
657
646
  });
658
647
  });
659
648
  }
@@ -670,19 +659,17 @@ exports.send = send;
670
659
  * @param timestamp optional timestamp for packet signing (default: Date.now())
671
660
  * @returns number of bytes sent
672
661
  */
673
- function sendSigned(stream, msg, key, linkId = 1, sysid = MavLinkProtocol.SYS_ID, compid = MavLinkProtocol.COMP_ID, timestamp = Date.now()) {
674
- return __awaiter(this, void 0, void 0, function* () {
675
- return new Promise((resolve, reject) => {
676
- const protocol = new MavLinkProtocolV2(sysid, compid, MavLinkProtocolV2.IFLAG_SIGNED);
677
- const b1 = protocol.serialize(msg, seq++);
678
- seq &= 255;
679
- const b2 = protocol.sign(b1, linkId, key, timestamp);
680
- stream.write(b2, err => {
681
- if (err)
682
- reject(err);
683
- else
684
- resolve(b2.length);
685
- });
662
+ async function sendSigned(stream, msg, key, linkId = 1, sysid = MavLinkProtocol.SYS_ID, compid = MavLinkProtocol.COMP_ID, timestamp = Date.now()) {
663
+ return new Promise((resolve, reject) => {
664
+ const protocol = new MavLinkProtocolV2(sysid, compid, MavLinkProtocolV2.IFLAG_SIGNED);
665
+ const b1 = protocol.serialize(msg, seq++);
666
+ seq &= 255;
667
+ const b2 = protocol.sign(b1, linkId, key, timestamp);
668
+ stream.write(b2, err => {
669
+ if (err)
670
+ reject(err);
671
+ else
672
+ resolve(b2.length);
686
673
  });
687
674
  });
688
675
  }
package/dist/lib/utils.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.waitFor = exports.sleep = exports.dump = exports.hex = void 0;
13
4
  /**
@@ -64,25 +55,23 @@ exports.sleep = sleep;
64
55
  * @param timeout number of miliseconds that need to pass before the Timeout exception is thrown
65
56
  * @param interval number of miliseconds before re-running the callback
66
57
  */
67
- function waitFor(cb, timeout = 10000, interval = 100) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- return new Promise((resolve, reject) => {
70
- const timeoutTimer = setTimeout(() => {
58
+ async function waitFor(cb, timeout = 10000, interval = 100) {
59
+ return new Promise((resolve, reject) => {
60
+ const timeoutTimer = setTimeout(() => {
61
+ cleanup();
62
+ reject('Timeout');
63
+ }, timeout);
64
+ const intervalTimer = setInterval(() => {
65
+ const result = cb();
66
+ if (result) {
71
67
  cleanup();
72
- reject('Timeout');
73
- }, timeout);
74
- const intervalTimer = setInterval(() => {
75
- const result = cb();
76
- if (result) {
77
- cleanup();
78
- resolve(result);
79
- }
80
- });
81
- const cleanup = () => {
82
- clearTimeout(timeoutTimer);
83
- clearTimeout(intervalTimer);
84
- };
68
+ resolve(result);
69
+ }
85
70
  });
71
+ const cleanup = () => {
72
+ clearTimeout(timeoutTimer);
73
+ clearTimeout(intervalTimer);
74
+ };
86
75
  });
87
76
  }
88
77
  exports.waitFor = waitFor;
@@ -7,14 +7,10 @@ import {
7
7
  asluav, development, ualberta,
8
8
  } from '..'
9
9
 
10
- const file = createReadStream('./GH-5.bin')
11
-
12
10
  const splitter = new MavLinkPacketSplitter()
13
-
14
- const reader = file
15
- .pipe(splitter)
16
- .pipe(new MavLinkPacketParser())
17
-
11
+ const parser = new MavLinkPacketParser()
12
+ const file = createReadStream('./GH-5.bin')
13
+ const reader = file.pipe(splitter).pipe(parser)
18
14
 
19
15
  // create a registry of mappings between a message id and a data class
20
16
  const REGISTRY = {
@@ -41,4 +37,3 @@ file.on('close', () => {
41
37
  console.log('Number of unknown packages:', splitter.unknownPackagesCount)
42
38
  console.log('\nTotal number of consumed packets:', splitter.validPackages)
43
39
  })
44
-
@@ -1,12 +1,18 @@
1
1
  #!/usr/bin/env -S npx ts-node
2
2
 
3
- import * as SerialPort from 'serialport'
4
- import { MavLinkPacketSplitter, MavLinkPacketParser, MavLinkPacket } from '..'
5
- import { common, waitFor, send } from '..'
3
+ import { SerialPort } from 'serialport'
4
+ import { MavLinkPacketRegistry, MavLinkPacketSplitter, MavLinkPacketParser, MavLinkPacket } from '..'
5
+ import { minimal, common, ardupilotmega, waitFor, send } from '..'
6
+
7
+ const REGISTRY: MavLinkPacketRegistry = {
8
+ ...minimal.REGISTRY,
9
+ ...common.REGISTRY,
10
+ ...ardupilotmega.REGISTRY,
11
+ }
6
12
 
7
13
  async function main() {
8
14
  // Create an output stream to write data to the controller
9
- const port = new SerialPort('/dev/ttyACM0')
15
+ const port = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200 })
10
16
 
11
17
  // Create the reader as usual by piping the source stream through the splitter
12
18
  // and packet parser
@@ -21,7 +27,13 @@ async function main() {
21
27
  // This is the place where all your application-level logic will exist
22
28
  reader.on('data', (packet: MavLinkPacket) => {
23
29
  online = true
24
- console.log(packet.debug())
30
+ const clazz = REGISTRY[packet.header.msgid]
31
+ if (clazz) {
32
+ const data = packet.protocol.data(packet.payload, clazz)
33
+ console.log('>', data)
34
+ } else {
35
+ console.log('!', packet.debug())
36
+ }
25
37
  })
26
38
 
27
39
  // Wait for the remote system to be available
@@ -1,16 +1,22 @@
1
1
  #!/usr/bin/env -S npx ts-node
2
2
 
3
- import * as SerialPort from 'serialport'
3
+ import { SerialPort } from 'serialport'
4
4
  import { MavLinkPacketSplitter, MavLinkPacketParser } from '..'
5
- import { MavLinkPacket, MavLinkPacketSignature } from '..'
6
- import { common, waitFor, sendSigned } from '..'
5
+ import { MavLinkPacket, MavLinkPacketSignature, MavLinkPacketRegistry } from '..'
6
+ import { minimal, common, ardupilotmega, waitFor, sendSigned } from '..'
7
+
8
+ const REGISTRY: MavLinkPacketRegistry = {
9
+ ...minimal.REGISTRY,
10
+ ...common.REGISTRY,
11
+ ...ardupilotmega.REGISTRY,
12
+ }
7
13
 
8
14
  // Use your own secret passphrase in place of 'qwerty'
9
15
  const key = MavLinkPacketSignature.key('qwerty')
10
16
 
11
17
  async function main() {
12
18
  // Create an output stream to write data to the controller
13
- const port = new SerialPort('/dev/ttyACM0')
19
+ const port = new SerialPort({ path: '/dev/ttyACM0', baudRate: 115200 })
14
20
 
15
21
  // Create the reader as usual by piping the source stream through the splitter
16
22
  // and packet parser
@@ -25,7 +31,6 @@ async function main() {
25
31
  // This is the place where all your application-level logic will exist
26
32
  reader.on('data', (packet: MavLinkPacket) => {
27
33
  online = true
28
- console.log(packet.debug())
29
34
  if (packet.signature) {
30
35
  if (packet.signature.matches(key)) {
31
36
  console.log('Signature check OK')
@@ -35,6 +40,13 @@ async function main() {
35
40
  } else {
36
41
  console.log('Packet not signed')
37
42
  }
43
+ const clazz = REGISTRY[packet.header.msgid]
44
+ if (clazz) {
45
+ const data = packet.protocol.data(packet.payload, clazz)
46
+ console.log('>', data)
47
+ } else {
48
+ console.log('!', packet.debug())
49
+ }
38
50
  })
39
51
 
40
52
  // Wait for the remote system to be available
@@ -1,7 +1,13 @@
1
1
  #!/usr/bin/env -S npx ts-node
2
2
 
3
- import { MavEsp8266, common } from '../dist'
4
- import { MavLinkPacket, MavLinkPacketSignature } from '../dist'
3
+ import { MavEsp8266, minimal, common, ardupilotmega } from '..'
4
+ import { MavLinkPacketSignature, MavLinkPacket, MavLinkPacketRegistry } from '..'
5
+
6
+ const REGISTRY: MavLinkPacketRegistry = {
7
+ ...minimal.REGISTRY,
8
+ ...common.REGISTRY,
9
+ ...ardupilotmega.REGISTRY,
10
+ }
5
11
 
6
12
  // Use your own secret passphrase in place of 'qwerty'
7
13
  const key = MavLinkPacketSignature.key('qwerty')
@@ -14,8 +20,6 @@ async function main() {
14
20
 
15
21
  // log incomming messages
16
22
  port.on('data', (packet: MavLinkPacket) => {
17
- console.log(packet.debug())
18
- console.log(packet.debug())
19
23
  if (packet.signature) {
20
24
  if (packet.signature.matches(key)) {
21
25
  console.log('Signature check OK')
@@ -25,6 +29,13 @@ async function main() {
25
29
  } else {
26
30
  console.log('Packet not signed')
27
31
  }
32
+ const clazz = REGISTRY[packet.header.msgid]
33
+ if (clazz) {
34
+ const data = packet.protocol.data(packet.payload, clazz)
35
+ console.log('>', data)
36
+ } else {
37
+ console.log('!', packet.debug())
38
+ }
28
39
  })
29
40
 
30
41
  // You're now ready to send messages to the controller using the socket
@@ -1,7 +1,13 @@
1
1
  #!/usr/bin/env -S npx ts-node
2
2
 
3
- import { MavEsp8266, common } from '..'
4
- import { MavLinkPacket } from '..'
3
+ import { MavEsp8266, minimal, common, ardupilotmega } from '..'
4
+ import { MavLinkPacket, MavLinkPacketRegistry } from '..'
5
+
6
+ const REGISTRY: MavLinkPacketRegistry = {
7
+ ...minimal.REGISTRY,
8
+ ...common.REGISTRY,
9
+ ...ardupilotmega.REGISTRY,
10
+ }
5
11
 
6
12
  async function main() {
7
13
  const port = new MavEsp8266()
@@ -13,7 +19,13 @@ async function main() {
13
19
 
14
20
  // log incomming messages
15
21
  port.on('data', (packet: MavLinkPacket) => {
16
- console.log(packet.debug())
22
+ const clazz = REGISTRY[packet.header.msgid]
23
+ if (clazz) {
24
+ const data = packet.protocol.data(packet.payload, clazz)
25
+ console.log('>', data)
26
+ } else {
27
+ console.log('!', packet.debug())
28
+ }
17
29
  })
18
30
 
19
31
  // You're now ready to send messages to the controller using the socket
@@ -162,6 +162,52 @@ describe('serialization', () => {
162
162
  })
163
163
  })
164
164
 
165
+ describe('uint64_t', () => {
166
+ it('will serialize 64-bit unsigned int', () => {
167
+ const b = Buffer.from([0, -1, -2, -3, -4, -5, -6, -7])
168
+ SERIALIZERS['uint64_t'](2n, b, 0)
169
+ expect(b).toStrictEqual(Buffer.from([2, 0, 0, 0, 0, 0, 0, 0]))
170
+ })
171
+ it('will deserialize 64-bit unsigned int', () => {
172
+ const b = Buffer.from([2, 0, 0, 0, 0, 0, 0, 0])
173
+ const result = DESERIALIZERS['uint64_t'](b, 0)
174
+ expect(result).toBe(2n)
175
+ })
176
+ it('will serialize array of 64-bit unsigned int', () => {
177
+ const b = Buffer.from(new Array(24))
178
+ SERIALIZERS['uint64_t[]']([ 1n, 2n, 4n ], b, 0, 3)
179
+ expect(b).toStrictEqual(Buffer.from([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]))
180
+ })
181
+ it('will deserialize array of 64-bit unsigned int', () => {
182
+ const b = Buffer.from([1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0])
183
+ const result = DESERIALIZERS['uint64_t[]'](b, 0, 3)
184
+ expect(result).toEqual([1n, 2n, 5n])
185
+ })
186
+ })
187
+
188
+ describe('int64_t', () => {
189
+ it('will serialize 64-bit signed int', () => {
190
+ const b = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0])
191
+ SERIALIZERS['int64_t'](-2n, b, 0)
192
+ expect(b).toStrictEqual(Buffer.from([254, 255, 255, 255, 255, 255, 255, 255]))
193
+ })
194
+ it('will deserialize 64-bit signed int', () => {
195
+ const b = Buffer.from([254, 255, 255, 255, 255, 255, 255, 255])
196
+ const result = DESERIALIZERS['int64_t'](b, 0)
197
+ expect(result).toBe(-2n)
198
+ })
199
+ it('will serialize array of 64-bit signed int', () => {
200
+ const b = Buffer.from(new Array(24))
201
+ SERIALIZERS['int64_t[]']([ 1n, -2n, -5n ], b, 0, 3)
202
+ expect(b).toStrictEqual(Buffer.from([1, 0, 0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 255, 251, 255, 255, 255, 255, 255, 255, 255]))
203
+ })
204
+ it('will deserialize array of 64-bit signed int', () => {
205
+ const b = Buffer.from([1, 0, 0, 0, 0, 0, 0, 0, 254, 255, 255, 255, 255, 255, 255, 255, 250, 255, 255, 255, 255, 255, 255, 255])
206
+ const result = DESERIALIZERS['int64_t[]'](b, 0, 3)
207
+ expect(result).toEqual([1n, -2n, -6n])
208
+ })
209
+ })
210
+
165
211
  describe('float', () => {
166
212
  it('will serialize float', () => {
167
213
  const b = Buffer.from([0, -1, -2, -3])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-mavlink",
3
- "version": "1.0.11",
3
+ "version": "1.1.0",
4
4
  "author": "Matthias Hryniszak <padcom@gmail.com>",
5
5
  "license": "LGPL",
6
6
  "description": "MavLink definitions and parsing library",
@@ -22,23 +22,22 @@
22
22
  "main": "dist/index.js",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "mavlink-mappings": "^1.0.8-20220318"
25
+ "mavlink-mappings": "^1.0.9-20220424"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsc",
29
29
  "test": "jest",
30
30
  "dev": "jest --watch",
31
31
  "test:e2e": "cd tests && ./main.ts e2e --input data.mavlink",
32
- "prepublishOnly": "rm -rf dist && npm install && npm test && npm run build"
32
+ "prepublishOnly": "rm -rf dist && npm install && npm test && npm run test:e2e && npm run build"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/jest": "^27.4.1",
36
36
  "@types/node": "^15.14.9",
37
- "@types/serialport": "^8.0.1",
38
37
  "@types/xml2js": "^0.4.8",
39
38
  "@types/yargs": "^17.0.8",
40
39
  "jest": "^27.5.1",
41
- "serialport": "^9.0.7",
40
+ "serialport": "^10.0.0",
42
41
  "ts-jest": "^27.1.4",
43
42
  "ts-node": "^9.1.1",
44
43
  "typescript": "^4.4.3",
package/tsconfig.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "module": "commonjs",
4
4
  "lib": ["ES2020", "DOM"],
5
- "target": "es2015",
5
+ "target": "es2020",
6
6
  "declaration": true,
7
7
  "outDir": "./dist",
8
8
  "esModuleInterop": true