@canboat/canboatjs 2.4.2 → 2.4.4
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/bin/ikonvert-serial +4 -2
- package/lib/serial.js +7 -4
- package/package.json +1 -1
package/bin/ikonvert-serial
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { Transform } = require('stream');
|
|
4
|
-
const SerialPort = require('serialport')
|
|
4
|
+
const { SerialPort } = require('serialport')
|
|
5
5
|
|
|
6
6
|
if ( process.argv.length < 3 ) {
|
|
7
7
|
console.error('Please specify a device')
|
|
@@ -13,10 +13,12 @@ let device = process.argv[2]
|
|
|
13
13
|
|
|
14
14
|
let baud = process.argv.length > 3 ? Number(process.argv[3]) : 230400
|
|
15
15
|
|
|
16
|
-
let serial = new SerialPort(
|
|
16
|
+
let serial = new SerialPort({
|
|
17
|
+
path:device,
|
|
17
18
|
baudRate: baud
|
|
18
19
|
})
|
|
19
20
|
|
|
21
|
+
|
|
20
22
|
const toStringTr = new Transform({
|
|
21
23
|
objectMode: true,
|
|
22
24
|
|
package/lib/serial.js
CHANGED
|
@@ -112,8 +112,9 @@ SerialStream.prototype.start = function () {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
if ( !this.options.fromFile ) {
|
|
115
|
-
const SerialPort = require('serialport')
|
|
116
|
-
this.serial = new SerialPort(
|
|
115
|
+
const { SerialPort } = require('serialport')
|
|
116
|
+
this.serial = new SerialPort({
|
|
117
|
+
path: this.options.device,
|
|
117
118
|
baudRate: this.options.baudrate || 115200
|
|
118
119
|
})
|
|
119
120
|
|
|
@@ -397,7 +398,9 @@ function processNTGMessage(that, buffer, len)
|
|
|
397
398
|
if ( !that.outAvailable ) {
|
|
398
399
|
if ( command === 0x11 ) {
|
|
399
400
|
that.gotTXPGNList = false
|
|
400
|
-
|
|
401
|
+
setTimeout(() => {
|
|
402
|
+
requestTransmitPGNList(that)
|
|
403
|
+
}, 2000)
|
|
401
404
|
} else if ( command === 0x49 && buffer[3] === 1 ) {
|
|
402
405
|
that.gotTXPGNList = true
|
|
403
406
|
const pgnCount = buffer[14];
|
|
@@ -430,7 +433,7 @@ function processNTGMessage(that, buffer, len)
|
|
|
430
433
|
if ( that.neededTransmitPGNs.length === 0 ) {
|
|
431
434
|
const commitMsg = composeCommitTXPGN()
|
|
432
435
|
debugOut(commitMsg)
|
|
433
|
-
that.serial.write(
|
|
436
|
+
that.serial.write(commitMsg)
|
|
434
437
|
} else {
|
|
435
438
|
enableTXPGN(that.serial, that.neededTransmitPGNs[0])
|
|
436
439
|
}
|