@canboat/canboatjs 3.1.0 → 3.2.2
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/.github/workflows/publish.yml +18 -9
- package/README.md +3 -7
- package/dist/actisense-serial.d.ts.map +1 -1
- package/dist/actisense-serial.js +39 -39
- package/dist/actisense-serial.js.map +1 -1
- package/dist/bin/actisense-file.js +0 -0
- package/dist/bin/actisense-n2k-tcp.js +0 -0
- package/dist/bin/actisense-serialjs.js +0 -0
- package/dist/bin/analyzerjs.js +0 -0
- package/dist/bin/candumpjs.js +0 -0
- package/dist/bin/cansend.js +0 -0
- package/dist/bin/ikonvert-serial.js +0 -0
- package/dist/bin/to-pgn.js +0 -0
- package/dist/canbus.d.ts.map +1 -1
- package/dist/canbus.js +5 -5
- package/dist/canbus.js.map +1 -1
- package/dist/candevice.d.ts.map +1 -1
- package/dist/candevice.js +2 -4
- package/dist/candevice.js.map +1 -1
- package/dist/ikonvert.d.ts.map +1 -1
- package/dist/ikonvert.js +10 -10
- package/dist/ikonvert.js.map +1 -1
- package/dist/n2kDevice.d.ts +5 -1
- package/dist/n2kDevice.d.ts.map +1 -1
- package/dist/n2kDevice.js +80 -31
- package/dist/n2kDevice.js.map +1 -1
- package/dist/utilities.d.ts +3 -1
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +50 -3
- package/dist/utilities.js.map +1 -1
- package/dist/w2k01.d.ts.map +1 -1
- package/dist/w2k01.js +7 -7
- package/dist/w2k01.js.map +1 -1
- package/dist/yddevice.d.ts.map +1 -1
- package/dist/yddevice.js +2 -4
- package/dist/yddevice.js.map +1 -1
- package/dist/ydgw02.d.ts.map +1 -1
- package/dist/ydgw02.js +5 -5
- package/dist/ydgw02.js.map +1 -1
- package/lib/actisense-serial.ts +40 -40
- package/lib/canbus.ts +6 -6
- package/lib/candevice.ts +2 -5
- package/lib/ikonvert.ts +11 -11
- package/lib/n2kDevice.ts +90 -32
- package/lib/utilities.ts +50 -3
- package/lib/w2k01.ts +8 -8
- package/lib/yddevice.ts +2 -5
- package/lib/ydgw02.ts +5 -6
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +0 -101
- package/dist/bin/candumpanalyzerjs.d.ts +0 -3
- package/dist/bin/candumpanalyzerjs.d.ts.map +0 -1
- package/dist/bin/candumpanalyzerjs.js +0 -31
- package/dist/bin/candumpanalyzerjs.js.map +0 -1
- package/dist/ncanbus.d.ts +0 -17
- package/dist/ncanbus.d.ts.map +0 -1
- package/dist/ncanbus.js +0 -92
- package/dist/ncanbus.js.map +0 -1
- package/ios_canboat.js/main.js +0 -2
- package/ios_canboat.js/main.js.LICENSE.txt +0 -17
- package/ios_canboat.js/main.js.map +0 -1
package/dist/w2k01.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"w2k01.js","sourceRoot":"","sources":["../lib/w2k01.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;
|
|
1
|
+
{"version":3,"file":"w2k01.js","sourceRoot":"","sources":["../lib/w2k01.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;AAmBH,kCA0CC;AA1DD,2CAAyC;AACzC,mCAAkC;AAClC,mCAKgB;AAChB,mDAAkD;AAClD,gDAAuB;AAEvB,qBAAqB;AAErB,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,MAAM,aAAa,GAAG,CAAC,CAAA;AAEvB,SAAgB,WAAW,CAEzB,OAAY,EACZ,IAAY,EACZ,QAAgB;IAEhB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,IAAK,WAAmB,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC1D,CAAC;IAED,kBAAS,CAAC,IAAI,CAAC,IAAI,EAAE;QACnB,UAAU,EAAE,IAAI;KACjB,CAAC,CAAA;IAEF,IAAI,CAAC,KAAK,GAAG,IAAA,uBAA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Root":"","sources":["../lib/yddevice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"yddevice.d.ts","sourceRoot":"","sources":["../lib/yddevice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC,qBAAa,QAAS,SAAQ,SAAS;IACrC,GAAG,EAAE,GAAG,CAAA;IACR,WAAW,EAAE,MAAM,CAAA;gBAEP,OAAO,EAAE,GAAG;IAUxB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,MAAM,GAAG,SAAqB;IAUrD,mBAAmB,CAAC,GAAG,EAAE,MAAM;CAGhC"}
|
package/dist/yddevice.js
CHANGED
|
@@ -18,13 +18,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.YdDevice = void 0;
|
|
19
19
|
const n2kDevice_1 = require("./n2kDevice");
|
|
20
20
|
const toPgn_1 = require("./toPgn");
|
|
21
|
-
const utilities_1 = require("./utilities");
|
|
22
|
-
const debug = (0, utilities_1.createDebug)('canboatjs:n2kdevice');
|
|
23
21
|
class YdDevice extends n2kDevice_1.N2kDevice {
|
|
24
22
|
app;
|
|
25
23
|
n2kOutEvent;
|
|
26
24
|
constructor(options) {
|
|
27
|
-
super(options);
|
|
25
|
+
super(options, 'canboatjs:yddevice');
|
|
28
26
|
this.app = options.app;
|
|
29
27
|
this.n2kOutEvent = options.jsonOutEvent || 'nmea2000JsonOut';
|
|
30
28
|
const analyzerOutEvent = options.analyzerOutEvent || 'N2KAnalyzerOut';
|
|
@@ -34,7 +32,7 @@ class YdDevice extends n2kDevice_1.N2kDevice {
|
|
|
34
32
|
pgn.src = src || this.address;
|
|
35
33
|
const ppgn = pgn; //FIXME??
|
|
36
34
|
ppgn.ydFullFormat = true;
|
|
37
|
-
debug('Sending PGN %j', pgn);
|
|
35
|
+
this.debug('Sending PGN %j', pgn);
|
|
38
36
|
this.app.emit(this.n2kOutEvent, pgn);
|
|
39
37
|
}
|
|
40
38
|
sendActisenseFormat(msg) {
|
package/dist/yddevice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yddevice.js","sourceRoot":"","sources":["../lib/yddevice.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,2CAAuC;AACvC,mCAAsD;
|
|
1
|
+
{"version":3,"file":"yddevice.js","sourceRoot":"","sources":["../lib/yddevice.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,2CAAuC;AACvC,mCAAsD;AAEtD,MAAa,QAAS,SAAQ,qBAAS;IACrC,GAAG,CAAK;IACR,WAAW,CAAQ;IAEnB,YAAY,OAAY;QACtB,KAAK,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAA;QACpC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,IAAI,iBAAiB,CAAA;QAE5D,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,gBAAgB,CAAA;QAErE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED,OAAO,CAAC,GAAQ,EAAE,MAA0B,SAAS;QACnD,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC,OAAO,CAAA;QAE7B,MAAM,IAAI,GAAG,GAAU,CAAA,CAAC,SAAS;QACjC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QAExB,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;QACjC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;IACtC,CAAC;IAED,mBAAmB,CAAC,GAAW;QAC7B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,IAAA,oCAA4B,EAAC,GAAG,CAAC,CAAC,CAAA;IAClE,CAAC;CACF;AA3BD,4BA2BC"}
|
package/dist/ydgw02.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ydgw02.d.ts","sourceRoot":"","sources":["../lib/ydgw02.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"ydgw02.d.ts","sourceRoot":"","sources":["../lib/ydgw02.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH,wBAAgB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,OA2DjE"}
|
package/dist/ydgw02.js
CHANGED
|
@@ -25,7 +25,6 @@ const fromPgn_1 = require("./fromPgn");
|
|
|
25
25
|
const yddevice_1 = require("./yddevice");
|
|
26
26
|
const toPgn_1 = require("./toPgn");
|
|
27
27
|
const util_1 = __importDefault(require("util"));
|
|
28
|
-
const debug = (0, utilities_1.createDebug)('canboatjs:ydgw02');
|
|
29
28
|
//const pgnsSent = {}
|
|
30
29
|
function Ydgw02Stream(options, type) {
|
|
31
30
|
if (this === undefined) {
|
|
@@ -34,6 +33,7 @@ function Ydgw02Stream(options, type) {
|
|
|
34
33
|
stream_1.Transform.call(this, {
|
|
35
34
|
objectMode: true
|
|
36
35
|
});
|
|
36
|
+
this.debug = (0, utilities_1.createDebug)('canboatjs:ydgw02', options);
|
|
37
37
|
this.sentAvailable = false;
|
|
38
38
|
this.options = options;
|
|
39
39
|
this.outEvent = options.ydgwOutEvent || 'ydwg02-out';
|
|
@@ -43,7 +43,7 @@ function Ydgw02Stream(options, type) {
|
|
|
43
43
|
//debug(`[warning] ${pgn.pgn} ${warning}`)
|
|
44
44
|
});
|
|
45
45
|
this.fromPgn.on('error', (pgn, error) => {
|
|
46
|
-
debug(`[error] ${pgn.pgn} ${error}`);
|
|
46
|
+
this.debug(`[error] ${pgn.pgn} ${error}`);
|
|
47
47
|
});
|
|
48
48
|
if (options.app) {
|
|
49
49
|
options.app.on(this.options.outEevent || 'nmea2000out', (msg) => {
|
|
@@ -72,7 +72,7 @@ function Ydgw02Stream(options, type) {
|
|
|
72
72
|
this.device = new yddevice_1.YdDevice(options);
|
|
73
73
|
this.device.start();
|
|
74
74
|
}
|
|
75
|
-
debug('started');
|
|
75
|
+
this.debug('started');
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
Ydgw02Stream.prototype.cansend = function (_msg) {
|
|
@@ -80,7 +80,7 @@ Ydgw02Stream.prototype.cansend = function (_msg) {
|
|
|
80
80
|
};
|
|
81
81
|
Ydgw02Stream.prototype.sendString = function (msg, forceSend) {
|
|
82
82
|
if (this.cansend() || forceSend === true) {
|
|
83
|
-
debug('sending %s', msg);
|
|
83
|
+
this.debug('sending %s', msg);
|
|
84
84
|
this.options.app.emit(this.outEvent, msg);
|
|
85
85
|
}
|
|
86
86
|
};
|
|
@@ -148,7 +148,7 @@ Ydgw02Stream.prototype._transform = function (chunk, encoding, done) {
|
|
|
148
148
|
const line = chunk.toString().trim();
|
|
149
149
|
//line = line.substring(0, line.length) // take off the \r
|
|
150
150
|
if (this.device === undefined && !this.sentAvailable) {
|
|
151
|
-
debug('emit nmea2000OutAvailable');
|
|
151
|
+
this.debug('emit nmea2000OutAvailable');
|
|
152
152
|
this.options.app.emit('nmea2000OutAvailable');
|
|
153
153
|
this.sentAvailable = true;
|
|
154
154
|
}
|
package/dist/ydgw02.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ydg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aAAa,EAAE,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAA;QACvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;QAC7C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;IAC3B,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IAC1C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACd,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CACnB,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,gBAAgB,EACjD,GAAG,CACJ,CAAA;IACH,CAAC;IAED,IAAI,EAAE,CAAA;AACR,CAAC,CAAA;AAED,YAAY,CAAC,SAAS,CAAC,GAAG,GAAG,cAAa,CAAC,CAAA"}
|
package/lib/actisense-serial.ts
CHANGED
|
@@ -25,9 +25,6 @@ import { defaultTransmitPGNs } from './codes'
|
|
|
25
25
|
import _ from 'lodash'
|
|
26
26
|
import { Parser as FromPgn } from './fromPgn'
|
|
27
27
|
|
|
28
|
-
const debugOut = createDebug('signalk:actisense-out')
|
|
29
|
-
const debug = createDebug('signalk:actisense-serial')
|
|
30
|
-
|
|
31
28
|
/* ASCII characters used to mark packet start/stop */
|
|
32
29
|
|
|
33
30
|
const STX = 0x02 /* Start packet */
|
|
@@ -62,11 +59,14 @@ export function ActisenseStream(this: any, options: any) {
|
|
|
62
59
|
return new (ActisenseStream as any)(options)
|
|
63
60
|
}
|
|
64
61
|
|
|
62
|
+
this.debugOut = createDebug('canboatjs:actisense-out', options)
|
|
63
|
+
this.debug = createDebug('canboatjs:actisense-serial', options)
|
|
64
|
+
|
|
65
65
|
Transform.call(this, {
|
|
66
66
|
objectMode: true
|
|
67
67
|
})
|
|
68
68
|
|
|
69
|
-
debug('options: %j', options)
|
|
69
|
+
this.debug('options: %j', options)
|
|
70
70
|
|
|
71
71
|
this.reconnect = options.reconnect || true
|
|
72
72
|
this.serial = null
|
|
@@ -151,10 +151,10 @@ ActisenseStream.prototype.start = function (this: any) {
|
|
|
151
151
|
|
|
152
152
|
if (this.options.app) {
|
|
153
153
|
const writeString = (msg: string) => {
|
|
154
|
-
debugOut(`sending ${msg}`)
|
|
154
|
+
this.debugOut(`sending ${msg}`)
|
|
155
155
|
let buf = parseInput(msg)
|
|
156
156
|
buf = composeMessage(N2K_MSG_SEND, buf, buf.length)
|
|
157
|
-
debugOut(buf)
|
|
157
|
+
this.debugOut(buf)
|
|
158
158
|
this.serial.write(buf)
|
|
159
159
|
this.options.app.emit('connectionwrite', {
|
|
160
160
|
providerId: this.options.providerId
|
|
@@ -164,10 +164,10 @@ ActisenseStream.prototype.start = function (this: any) {
|
|
|
164
164
|
const writeObject = (msg: PGN) => {
|
|
165
165
|
const data = toPgn(msg)
|
|
166
166
|
const actisense = encodeActisense({ pgn: msg.pgn, data, dst: msg.dst })
|
|
167
|
-
debugOut(`sending ${actisense}`)
|
|
167
|
+
this.debugOut(`sending ${actisense}`)
|
|
168
168
|
let buf = parseInput(actisense)
|
|
169
169
|
buf = composeMessage(N2K_MSG_SEND, buf, buf.length)
|
|
170
|
-
debugOut(buf)
|
|
170
|
+
this.debugOut(buf)
|
|
171
171
|
this.serial.write(buf)
|
|
172
172
|
this.options.app.emit('connectionwrite', {
|
|
173
173
|
providerId: this.options.providerId
|
|
@@ -218,17 +218,17 @@ ActisenseStream.prototype.start = function (this: any) {
|
|
|
218
218
|
Buffer.from(NGT_STARTUP_MSG),
|
|
219
219
|
NGT_STARTUP_MSG.length
|
|
220
220
|
)
|
|
221
|
-
debugOut(buf)
|
|
221
|
+
this.debugOut(buf)
|
|
222
222
|
this.serial.write(buf)
|
|
223
|
-
debug('sent startup message')
|
|
223
|
+
this.debug('sent startup message')
|
|
224
224
|
this.gotStartupResponse = false
|
|
225
225
|
if (this.options.disableSetTransmitPGNs) {
|
|
226
226
|
enableOutput(this)
|
|
227
227
|
} else {
|
|
228
228
|
setTimeout(() => {
|
|
229
229
|
if (this.gotStartupResponse === false) {
|
|
230
|
-
debug('retry startup message...')
|
|
231
|
-
debugOut(buf)
|
|
230
|
+
this.debug('retry startup message...')
|
|
231
|
+
this.debugOut(buf)
|
|
232
232
|
this.serial.write(buf)
|
|
233
233
|
}
|
|
234
234
|
}, 5000)
|
|
@@ -247,7 +247,7 @@ ActisenseStream.prototype.scheduleReconnect = function () {
|
|
|
247
247
|
const msg = `Not connected (retry delay ${(
|
|
248
248
|
this.reconnectDelay / 1000
|
|
249
249
|
).toFixed(0)} s)`
|
|
250
|
-
debug(msg)
|
|
250
|
+
this.debug(msg)
|
|
251
251
|
this.setProviderStatus(msg)
|
|
252
252
|
setTimeout(this.start.bind(this), this.reconnectDelay)
|
|
253
253
|
}
|
|
@@ -308,15 +308,15 @@ function read1Byte(that: any, c: any) {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
function enableTXPGN(
|
|
312
|
-
debug('enabling pgn %d', pgn)
|
|
311
|
+
function enableTXPGN(that: any, pgn: number) {
|
|
312
|
+
that.debug('enabling pgn %d', pgn)
|
|
313
313
|
const msg = composeEnablePGN(pgn)
|
|
314
|
-
debugOut(msg)
|
|
315
|
-
serial.write(msg)
|
|
314
|
+
that.debugOut(msg)
|
|
315
|
+
that.serial.write(msg)
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
function enableOutput(that: any) {
|
|
319
|
-
debug('outputEnabled')
|
|
319
|
+
that.debug('outputEnabled')
|
|
320
320
|
that.outAvailable = true
|
|
321
321
|
if (that.options.app) {
|
|
322
322
|
that.options.app.emit('nmea2000OutAvailable')
|
|
@@ -324,14 +324,14 @@ function enableOutput(that: any) {
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
function requestTransmitPGNList(that: any) {
|
|
327
|
-
debug('request tx pgns...')
|
|
327
|
+
that.debug('request tx pgns...')
|
|
328
328
|
const requestMsg = composeRequestTXPGNList()
|
|
329
|
-
debugOut(requestMsg)
|
|
329
|
+
that.debugOut(requestMsg)
|
|
330
330
|
that.serial.write(requestMsg)
|
|
331
331
|
setTimeout(() => {
|
|
332
332
|
if (!that.gotTXPGNList) {
|
|
333
333
|
if (that.transmitPGNRetries-- > 0) {
|
|
334
|
-
debug('did not get tx pgn list, retrying...')
|
|
334
|
+
that.debug('did not get tx pgn list, retrying...')
|
|
335
335
|
requestTransmitPGNList(that)
|
|
336
336
|
} else {
|
|
337
337
|
const msg = 'could not set transmit pgn list'
|
|
@@ -353,11 +353,11 @@ function processNTGMessage(that: any, buffer: Buffer, len: number) {
|
|
|
353
353
|
const command = buffer[2]
|
|
354
354
|
|
|
355
355
|
if (checksum != 0) {
|
|
356
|
-
debug('received message with invalid checksum (%d,%d)', command, len)
|
|
356
|
+
that.debug('received message with invalid checksum (%d,%d)', command, len)
|
|
357
357
|
return
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
if (that.options.sendNetworkStats || debug.enabled) {
|
|
360
|
+
if (that.options.sendNetworkStats || that.debug.enabled) {
|
|
361
361
|
const newbuf = Buffer.alloc(len + 7)
|
|
362
362
|
const bs = new BitStream(newbuf)
|
|
363
363
|
const pgn = 0x40000 + buffer[2]
|
|
@@ -376,14 +376,14 @@ function processNTGMessage(that: any, buffer: Buffer, len: number) {
|
|
|
376
376
|
} else {
|
|
377
377
|
that.push(bs.view.buffer, len + 7)
|
|
378
378
|
}
|
|
379
|
-
if (debug.enabled && command != 0xf2) {
|
|
379
|
+
if (that.debug.enabled && command != 0xf2) {
|
|
380
380
|
//don't log system status
|
|
381
381
|
if (!that.parser) {
|
|
382
382
|
that.parser = new FromPgn({})
|
|
383
383
|
}
|
|
384
384
|
const js = that.parser.parseBuffer(bs.view.buffer)
|
|
385
385
|
if (js) {
|
|
386
|
-
debug('got ntg message: %j', js)
|
|
386
|
+
that.debug('got ntg message: %j', js)
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
}
|
|
@@ -391,7 +391,7 @@ function processNTGMessage(that: any, buffer: Buffer, len: number) {
|
|
|
391
391
|
if (command === 0x11) {
|
|
392
392
|
//confirm startup
|
|
393
393
|
that.gotStartupResponse = true
|
|
394
|
-
debug('got startup response')
|
|
394
|
+
that.debug('got startup response')
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
if (!that.outAvailable) {
|
|
@@ -409,17 +409,17 @@ function processNTGMessage(that: any, buffer: Buffer, len: number) {
|
|
|
409
409
|
for (let i = 0; i < pgnCount; i++) {
|
|
410
410
|
pgns.push(bs.readUint32())
|
|
411
411
|
}
|
|
412
|
-
debug('tx pgns: %j', pgns)
|
|
412
|
+
that.debug('tx pgns: %j', pgns)
|
|
413
413
|
|
|
414
414
|
that.neededTransmitPGNs = that.transmitPGNs.filter((pgn: number) => {
|
|
415
415
|
return pgns.indexOf(pgn) == -1
|
|
416
416
|
})
|
|
417
|
-
debug('needed pgns: %j', that.neededTransmitPGNs)
|
|
417
|
+
that.debug('needed pgns: %j', that.neededTransmitPGNs)
|
|
418
418
|
} else if (command === 0x49 && buffer[3] === 4) {
|
|
419
419
|
//I think this means done receiving the pgns list
|
|
420
420
|
if (that.neededTransmitPGNs) {
|
|
421
421
|
if (that.neededTransmitPGNs.length) {
|
|
422
|
-
enableTXPGN(that
|
|
422
|
+
enableTXPGN(that, that.neededTransmitPGNs[0])
|
|
423
423
|
} else {
|
|
424
424
|
enableOutput(that)
|
|
425
425
|
}
|
|
@@ -427,25 +427,25 @@ function processNTGMessage(that: any, buffer: Buffer, len: number) {
|
|
|
427
427
|
} else if (command === 0x47) {
|
|
428
428
|
//response from enable a pgn
|
|
429
429
|
if (buffer[3] === 1) {
|
|
430
|
-
debug('enabled %d', that.neededTransmitPGNs[0])
|
|
430
|
+
that.debug('enabled %d', that.neededTransmitPGNs[0])
|
|
431
431
|
that.neededTransmitPGNs = that.neededTransmitPGNs.slice(1)
|
|
432
432
|
if (that.neededTransmitPGNs.length === 0) {
|
|
433
433
|
const commitMsg = composeCommitTXPGN()
|
|
434
|
-
debugOut(commitMsg)
|
|
434
|
+
that.debugOut(commitMsg)
|
|
435
435
|
that.serial.write(commitMsg)
|
|
436
436
|
} else {
|
|
437
437
|
enableTXPGN(that.serial, that.neededTransmitPGNs[0])
|
|
438
438
|
}
|
|
439
439
|
} else {
|
|
440
|
-
debug('bad response from Enable TX: %d', buffer[3])
|
|
440
|
+
that.debug('bad response from Enable TX: %d', buffer[3])
|
|
441
441
|
}
|
|
442
442
|
} else if (command === 0x01) {
|
|
443
|
-
debug('commited tx list')
|
|
443
|
+
that.debug('commited tx list')
|
|
444
444
|
const activateMsg = composeActivateTXPGN()
|
|
445
|
-
debugOut(activateMsg)
|
|
445
|
+
that.debugOut(activateMsg)
|
|
446
446
|
that.serial.write(activateMsg)
|
|
447
447
|
} else if (command === 0x4b) {
|
|
448
|
-
debug('activated tx list')
|
|
448
|
+
that.debug('activated tx list')
|
|
449
449
|
enableOutput(that)
|
|
450
450
|
}
|
|
451
451
|
}
|
|
@@ -468,7 +468,7 @@ function processN2KMessage(that: any, buffer: Buffer, len: number) {
|
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
if (checksum != 0) {
|
|
471
|
-
debug('received message with invalid checksum')
|
|
471
|
+
that.debug('received message with invalid checksum')
|
|
472
472
|
return
|
|
473
473
|
}
|
|
474
474
|
|
|
@@ -534,7 +534,7 @@ function composeMessage(command: number, buffer: Buffer, len: number) {
|
|
|
534
534
|
|
|
535
535
|
out.view.buffer.writeUInt8(len, lenPos)
|
|
536
536
|
|
|
537
|
-
//debug(`command ${out.view.buffer[2]} ${lenPos} ${len} ${out.view.buffer[lenPos]} ${out.view.buffer.length} ${out.byteIndex}`)
|
|
537
|
+
//that.debug(`command ${out.view.buffer[2]} ${lenPos} ${len} ${out.view.buffer[lenPos]} ${out.view.buffer.length} ${out.byteIndex}`)
|
|
538
538
|
|
|
539
539
|
return out.view.buffer.slice(0, out.byteIndex)
|
|
540
540
|
}
|
|
@@ -600,7 +600,7 @@ function composeEnablePGN(pgn: number) {
|
|
|
600
600
|
out.byteIndex
|
|
601
601
|
)
|
|
602
602
|
|
|
603
|
-
//debug('composeEnablePGN: %o', res)
|
|
603
|
+
//that.debug('composeEnablePGN: %o', res)
|
|
604
604
|
|
|
605
605
|
return res
|
|
606
606
|
}
|
|
@@ -621,7 +621,7 @@ function composeDisablePGN(pgn) {
|
|
|
621
621
|
|
|
622
622
|
let res = composeMessage(NGT_MSG_SEND, out.view.buffer.slice(0, out.byteIndex), out.byteIndex)
|
|
623
623
|
|
|
624
|
-
debug('composeDisablePGN: %o', res)
|
|
624
|
+
that.debug('composeDisablePGN: %o', res)
|
|
625
625
|
|
|
626
626
|
return res;
|
|
627
627
|
}
|
|
@@ -638,7 +638,7 @@ ActisenseStream.prototype._transform = function (
|
|
|
638
638
|
encoding: string,
|
|
639
639
|
done: any
|
|
640
640
|
) {
|
|
641
|
-
debug(`got data ${typeof chunk}`)
|
|
641
|
+
this.debug(`got data ${typeof chunk}`)
|
|
642
642
|
readData(this, chunk)
|
|
643
643
|
done()
|
|
644
644
|
}
|
package/lib/canbus.ts
CHANGED
|
@@ -25,13 +25,13 @@ import { CanID, encodeCanId, parseCanId } from './canId'
|
|
|
25
25
|
import { toActisenseSerialFormat, parseActisense } from './stringMsg'
|
|
26
26
|
import util from 'util'
|
|
27
27
|
|
|
28
|
-
const debug = createDebug('canboatjs:canbus')
|
|
29
|
-
|
|
30
28
|
export function CanbusStream(this: any, options: any) {
|
|
31
29
|
if (this === undefined) {
|
|
32
30
|
return new (CanbusStream as any)(options)
|
|
33
31
|
}
|
|
34
32
|
|
|
33
|
+
this.debug = createDebug('canboatjs:canbus', options)
|
|
34
|
+
|
|
35
35
|
Transform.call(this, {
|
|
36
36
|
objectMode: true
|
|
37
37
|
})
|
|
@@ -185,7 +185,7 @@ CanbusStream.prototype.sendPGN = function (msg: any, force: boolean) {
|
|
|
185
185
|
return
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
debug('sending %j', msg)
|
|
188
|
+
this.debug('sending %j', msg)
|
|
189
189
|
|
|
190
190
|
if (this.options.app) {
|
|
191
191
|
this.options.app.emit('connectionwrite', {
|
|
@@ -236,13 +236,13 @@ CanbusStream.prototype.sendPGN = function (msg: any, force: boolean) {
|
|
|
236
236
|
buffer = pgn.data
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
if (debug.enabled) {
|
|
239
|
+
if (this.debug.enabled) {
|
|
240
240
|
const str = toActisenseSerialFormat(pgn.pgn, buffer, pgn.dst, pgn.src)
|
|
241
|
-
debug(str)
|
|
241
|
+
this.debug(str)
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
if (buffer === undefined) {
|
|
245
|
-
debug("can't convert %j", msg)
|
|
245
|
+
this.debug("can't convert %j", msg)
|
|
246
246
|
return
|
|
247
247
|
}
|
|
248
248
|
|
package/lib/candevice.ts
CHANGED
|
@@ -16,16 +16,13 @@
|
|
|
16
16
|
|
|
17
17
|
import { PGN } from '@canboat/ts-pgns'
|
|
18
18
|
import { N2kDevice } from './n2kDevice'
|
|
19
|
-
import { createDebug } from './utilities'
|
|
20
19
|
import _ from 'lodash'
|
|
21
20
|
|
|
22
|
-
const debug = createDebug('canboatjs:candevice')
|
|
23
|
-
|
|
24
21
|
export class CanDevice extends N2kDevice {
|
|
25
22
|
canbus: any
|
|
26
23
|
|
|
27
24
|
constructor(canbus: any, options: any) {
|
|
28
|
-
super(options)
|
|
25
|
+
super(options, 'canboatjs:candevice')
|
|
29
26
|
this.canbus = canbus
|
|
30
27
|
|
|
31
28
|
if (options.app) {
|
|
@@ -38,7 +35,7 @@ export class CanDevice extends N2kDevice {
|
|
|
38
35
|
|
|
39
36
|
sendPGN(pgn: PGN, src: number | undefined = undefined) {
|
|
40
37
|
pgn.src = src || this.address
|
|
41
|
-
debug('Sending PGN %j', pgn)
|
|
38
|
+
this.debug('Sending PGN %j', pgn)
|
|
42
39
|
this.canbus.sendPGN(pgn, true)
|
|
43
40
|
}
|
|
44
41
|
}
|
package/lib/ikonvert.ts
CHANGED
|
@@ -23,8 +23,6 @@ import _ from 'lodash'
|
|
|
23
23
|
import { defaultTransmitPGNs } from './codes'
|
|
24
24
|
import util from 'util'
|
|
25
25
|
|
|
26
|
-
const debug = createDebug('canboatjs:ikonvert')
|
|
27
|
-
|
|
28
26
|
//const pgnsSent = {}
|
|
29
27
|
|
|
30
28
|
export function iKonvertStream(this: any, options: any) {
|
|
@@ -32,6 +30,8 @@ export function iKonvertStream(this: any, options: any) {
|
|
|
32
30
|
return new (iKonvertStream as any)(options)
|
|
33
31
|
}
|
|
34
32
|
|
|
33
|
+
this.debug = createDebug('canboatjs:ikonvert', options)
|
|
34
|
+
|
|
35
35
|
Transform.call(this, {
|
|
36
36
|
objectMode: true
|
|
37
37
|
})
|
|
@@ -89,7 +89,7 @@ export function iKonvertStream(this: any, options: any) {
|
|
|
89
89
|
this.setupCommands = this.getSetupCommands()
|
|
90
90
|
this.expecting = false
|
|
91
91
|
|
|
92
|
-
debug('started')
|
|
92
|
+
this.debug('started')
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -98,7 +98,7 @@ util.inherits(iKonvertStream, Transform)
|
|
|
98
98
|
iKonvertStream.prototype.start = function () {}
|
|
99
99
|
|
|
100
100
|
iKonvertStream.prototype.sendString = function (msg: string) {
|
|
101
|
-
debug('sending %s', msg)
|
|
101
|
+
this.debug('sending %s', msg)
|
|
102
102
|
if (this.isTcp) {
|
|
103
103
|
msg = msg + '\n\r'
|
|
104
104
|
}
|
|
@@ -144,7 +144,7 @@ iKonvertStream.prototype.setup = function () {
|
|
|
144
144
|
this.transmitPGNs.forEach((pgn: number) => {
|
|
145
145
|
txPgns = txPgns + `,${pgn}`
|
|
146
146
|
})
|
|
147
|
-
debug('sending pgn tx list')
|
|
147
|
+
this.debug('sending pgn tx list')
|
|
148
148
|
this.sendString(txPgns)
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -176,7 +176,7 @@ iKonvertStream.prototype._transform = function (
|
|
|
176
176
|
line = line.substring(0, line.length) // take off the \r
|
|
177
177
|
|
|
178
178
|
if (line.startsWith('$PDGY,TEXT')) {
|
|
179
|
-
debug(line)
|
|
179
|
+
this.debug(line)
|
|
180
180
|
} else if (line.startsWith('$PDGY,000000,')) {
|
|
181
181
|
const parts = line.split(',')
|
|
182
182
|
|
|
@@ -211,13 +211,13 @@ iKonvertStream.prototype._transform = function (
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
if (!this.isSetup) {
|
|
214
|
-
debug(line)
|
|
214
|
+
this.debug(line)
|
|
215
215
|
let command = this.setupCommands[this.state].split(':')
|
|
216
216
|
if (!this.expecting) {
|
|
217
217
|
this.sendString(command[0])
|
|
218
218
|
this.expecting = true
|
|
219
219
|
this.sentTime = Date.now()
|
|
220
|
-
debug(`Waiting for ${command[1]}`)
|
|
220
|
+
this.debug(`Waiting for ${command[1]}`)
|
|
221
221
|
} else {
|
|
222
222
|
if (line.startsWith(command[1])) {
|
|
223
223
|
this.state = this.state + 1
|
|
@@ -226,16 +226,16 @@ iKonvertStream.prototype._transform = function (
|
|
|
226
226
|
this.isSetup = true
|
|
227
227
|
this.cansend = true
|
|
228
228
|
this.options.app.emit('nmea2000OutAvailable')
|
|
229
|
-
debug('Setup completed')
|
|
229
|
+
this.debug('Setup completed')
|
|
230
230
|
} else {
|
|
231
231
|
command = this.setupCommands[this.state].split(':')
|
|
232
232
|
this.sendString(command[0])
|
|
233
233
|
this.expecting = true
|
|
234
234
|
this.sentTime = Date.now()
|
|
235
|
-
debug(`Waiting for ${command[1]}`)
|
|
235
|
+
this.debug(`Waiting for ${command[1]}`)
|
|
236
236
|
}
|
|
237
237
|
} else if (Date.now() - this.sentTime > 5000) {
|
|
238
|
-
debug(`Did not receive expected: ${command[1]}, retrying...`)
|
|
238
|
+
this.debug(`Did not receive expected: ${command[1]}, retrying...`)
|
|
239
239
|
this.sendString(command[0])
|
|
240
240
|
this.sentTime = Date.now()
|
|
241
241
|
}
|