@canboat/canboatjs 3.0.2 → 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/.github/workflows/test.yml +2 -2
- package/.github/workflows/test_canboat_changes.yml +91 -0
- package/.husky/pre-commit +4 -0
- package/.mocharc.js +7 -0
- package/.prettierrc.json +5 -0
- package/README.md +5 -14
- package/dist/actisense-serial.d.ts +17 -0
- package/dist/actisense-serial.d.ts.map +1 -0
- package/dist/actisense-serial.js +569 -0
- package/dist/actisense-serial.js.map +1 -0
- package/dist/bin/actisense-file.d.ts +3 -0
- package/dist/bin/actisense-file.d.ts.map +1 -0
- package/dist/bin/actisense-file.js +49 -0
- package/dist/bin/actisense-file.js.map +1 -0
- package/dist/bin/actisense-n2k-tcp.d.ts +3 -0
- package/dist/bin/actisense-n2k-tcp.d.ts.map +1 -0
- package/dist/bin/actisense-n2k-tcp.js +46 -0
- package/dist/bin/actisense-n2k-tcp.js.map +1 -0
- package/dist/bin/actisense-serialjs.d.ts +3 -0
- package/dist/bin/actisense-serialjs.d.ts.map +1 -0
- package/dist/bin/actisense-serialjs.js +51 -0
- package/dist/bin/actisense-serialjs.js.map +1 -0
- package/dist/bin/analyzerjs.d.ts +3 -0
- package/dist/bin/analyzerjs.d.ts.map +1 -0
- package/dist/bin/analyzerjs.js +61 -0
- package/dist/bin/analyzerjs.js.map +1 -0
- package/dist/bin/candumpjs.d.ts +3 -0
- package/dist/bin/candumpjs.d.ts.map +1 -0
- package/dist/bin/candumpjs.js +73 -0
- package/dist/bin/candumpjs.js.map +1 -0
- package/dist/bin/cansend.d.ts +3 -0
- package/dist/bin/cansend.d.ts.map +1 -0
- package/dist/bin/cansend.js +123 -0
- package/dist/bin/cansend.js.map +1 -0
- package/dist/bin/ikonvert-serial.d.ts +3 -0
- package/dist/bin/ikonvert-serial.d.ts.map +1 -0
- package/dist/bin/ikonvert-serial.js +36 -0
- package/dist/bin/ikonvert-serial.js.map +1 -0
- package/dist/bin/to-pgn.d.ts +3 -0
- package/dist/bin/to-pgn.d.ts.map +1 -0
- package/dist/bin/to-pgn.js +57 -0
- package/dist/bin/to-pgn.js.map +1 -0
- package/dist/canId.d.ts +21 -0
- package/dist/canId.d.ts.map +1 -0
- package/dist/canId.js +66 -0
- package/dist/canId.js.map +1 -0
- package/dist/canId.test.d.ts +2 -0
- package/dist/canId.test.d.ts.map +1 -0
- package/dist/canId.test.js +58 -0
- package/dist/canId.test.js.map +1 -0
- package/dist/canbus.d.ts +17 -0
- package/dist/canbus.d.ts.map +1 -0
- package/dist/canbus.js +261 -0
- package/dist/canbus.js.map +1 -0
- package/dist/candevice.d.ts +23 -0
- package/dist/candevice.d.ts.map +1 -0
- package/dist/candevice.js +36 -0
- package/dist/candevice.js.map +1 -0
- package/dist/codes.d.ts +2 -0
- package/dist/codes.d.ts.map +1 -0
- package/dist/codes.js +24 -0
- package/dist/codes.js.map +1 -0
- package/dist/discovery.d.ts +17 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +119 -0
- package/dist/discovery.js.map +1 -0
- package/dist/fromPgn.d.ts +51 -0
- package/dist/fromPgn.d.ts.map +1 -0
- package/dist/fromPgn.js +989 -0
- package/dist/fromPgn.js.map +1 -0
- package/dist/fromPgnStream.d.ts +17 -0
- package/dist/fromPgnStream.d.ts.map +1 -0
- package/dist/fromPgnStream.js +47 -0
- package/dist/fromPgnStream.js.map +1 -0
- package/dist/ikonvert.d.ts +17 -0
- package/dist/ikonvert.d.ts.map +1 -0
- package/dist/ikonvert.js +224 -0
- package/dist/ikonvert.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/n2k-actisense.d.ts +24 -0
- package/dist/n2k-actisense.d.ts.map +1 -0
- package/dist/n2k-actisense.js +126 -0
- package/dist/n2k-actisense.js.map +1 -0
- package/dist/n2k-actisense.test.d.ts +2 -0
- package/dist/n2k-actisense.test.d.ts.map +1 -0
- package/dist/n2k-actisense.test.js +49 -0
- package/dist/n2k-actisense.test.js.map +1 -0
- package/dist/n2kDevice.d.ts +44 -0
- package/dist/n2kDevice.d.ts.map +1 -0
- package/dist/n2kDevice.js +436 -0
- package/dist/n2kDevice.js.map +1 -0
- package/dist/pgns.d.ts +22 -0
- package/dist/pgns.d.ts.map +1 -0
- package/dist/pgns.js +157 -0
- package/dist/pgns.js.map +1 -0
- package/dist/pgns.test.d.ts +2 -0
- package/dist/pgns.test.d.ts.map +1 -0
- package/dist/pgns.test.js +14 -0
- package/dist/pgns.test.js.map +1 -0
- package/dist/simpleCan.d.ts +17 -0
- package/dist/simpleCan.d.ts.map +1 -0
- package/dist/simpleCan.js +125 -0
- package/dist/simpleCan.js.map +1 -0
- package/dist/stringMsg.d.ts +33 -0
- package/dist/stringMsg.d.ts.map +1 -0
- package/dist/stringMsg.js +359 -0
- package/dist/stringMsg.js.map +1 -0
- package/dist/stringMsg.test.d.ts +2 -0
- package/dist/stringMsg.test.d.ts.map +1 -0
- package/dist/stringMsg.test.js +244 -0
- package/dist/stringMsg.test.js.map +1 -0
- package/dist/toPgn.d.ts +34 -0
- package/dist/toPgn.d.ts.map +1 -0
- package/dist/toPgn.js +500 -0
- package/dist/toPgn.js.map +1 -0
- package/dist/utilities.d.ts +28 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/utilities.js +159 -0
- package/dist/utilities.js.map +1 -0
- package/dist/utilities.test.d.ts +2 -0
- package/dist/utilities.test.d.ts.map +1 -0
- package/dist/utilities.test.js +9 -0
- package/dist/utilities.test.js.map +1 -0
- package/dist/venus-mqtt.d.ts +11 -0
- package/dist/venus-mqtt.d.ts.map +1 -0
- package/dist/venus-mqtt.js +100 -0
- package/dist/venus-mqtt.js.map +1 -0
- package/dist/venus.d.ts +11 -0
- package/dist/venus.d.ts.map +1 -0
- package/dist/venus.js +71 -0
- package/dist/venus.js.map +1 -0
- package/dist/w2k01.d.ts +17 -0
- package/dist/w2k01.d.ts.map +1 -0
- package/dist/w2k01.js +119 -0
- package/dist/w2k01.js.map +1 -0
- package/dist/yddevice.d.ts +25 -0
- package/dist/yddevice.d.ts.map +1 -0
- package/dist/yddevice.js +43 -0
- package/dist/yddevice.js.map +1 -0
- package/dist/ydgw02.d.ts +17 -0
- package/dist/ydgw02.d.ts.map +1 -0
- package/dist/ydgw02.js +163 -0
- package/dist/ydgw02.js.map +1 -0
- package/dist/ydvr.d.ts +17 -0
- package/dist/ydvr.d.ts.map +1 -0
- package/dist/ydvr.js +120 -0
- package/dist/ydvr.js.map +1 -0
- package/eslint.config.js +58 -0
- package/jest.config.js +5 -0
- package/lib/actisense-serial.ts +644 -0
- package/lib/bin/actisense-file.ts +53 -0
- package/lib/bin/actisense-n2k-tcp.ts +50 -0
- package/lib/bin/actisense-serialjs.ts +55 -0
- package/{bin/analyzerjs → lib/bin/analyzerjs.ts} +16 -15
- package/{bin/candumpjs → lib/bin/candumpjs.ts} +19 -20
- package/lib/bin/cansend.ts +131 -0
- package/lib/bin/ikonvert-serial.ts +44 -0
- package/{bin/to-pgn → lib/bin/to-pgn.ts} +23 -17
- package/lib/bin/ydvr-file +33 -0
- package/lib/canId.test.js +35 -15
- package/lib/canId.ts +84 -0
- package/lib/canbus.ts +293 -0
- package/lib/candevice.ts +41 -0
- package/lib/codes.ts +21 -0
- package/lib/{discovery.js → discovery.ts} +32 -30
- package/lib/fromPgn.ts +1207 -0
- package/lib/{fromPgnStream.js → fromPgnStream.ts} +17 -12
- package/lib/{ikonvert.js → ikonvert.ts} +99 -94
- package/lib/index.ts +48 -0
- package/lib/n2k-actisense.test.js +31 -32
- package/lib/n2k-actisense.ts +152 -0
- package/lib/n2kDevice.ts +516 -0
- package/lib/pgns.test.ts +12 -0
- package/lib/pgns.ts +191 -0
- package/lib/simpleCan.ts +140 -0
- package/lib/stringMsg.test.js +58 -41
- package/lib/stringMsg.ts +464 -0
- package/lib/toPgn.ts +597 -0
- package/lib/utilities.ts +169 -0
- package/lib/venus-mqtt.js +69 -73
- package/lib/venus.js +8 -8
- package/lib/w2k01.ts +142 -0
- package/lib/{yddevice.js → yddevice.ts} +18 -16
- package/lib/{ydgw02.js → ydgw02.ts} +58 -51
- package/lib/ydvr.js +65 -147
- package/package.json +54 -18
- package/tsconfig.json +19 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/CHANGELOG.md +0 -101
- package/bin/actisense-file +0 -47
- package/bin/actisense-n2k-tcp +0 -45
- package/bin/actisense-serialjs +0 -52
- package/bin/candumpanalyzerjs +0 -29
- package/bin/cansend +0 -130
- package/bin/ikonvert-serial +0 -50
- package/bin/ydgw-analyzerjs +0 -36
- package/bin/ydvr-file +0 -33
- package/index.js +0 -53
- 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/lib/canId.js +0 -64
- package/lib/canbus.js +0 -278
- package/lib/candevice.js +0 -51
- package/lib/codes.js +0 -69
- package/lib/codes.test.js +0 -17
- package/lib/codesMfgs.json +0 -166
- package/lib/fromPgn.js +0 -1027
- package/lib/n2k-actisense.js +0 -108
- package/lib/n2kDevice.js +0 -390
- package/lib/pgns.js +0 -196
- package/lib/pgns.test.js +0 -13
- package/lib/serial.js +0 -647
- package/lib/simpleCan.js +0 -105
- package/lib/stringMsg.js +0 -339
- package/lib/toPgn.js +0 -518
- package/lib/utilities.js +0 -111
- package/lib/w2k01.js +0 -129
package/lib/w2k01.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2018 Scott Bender (scott@scottbender.net)
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const debug = require('debug')('canboatjs:w2k01')
|
|
18
|
-
const debugData = require('debug')('canboatjs:w2k01-data')
|
|
19
|
-
const Transform = require('stream').Transform
|
|
20
|
-
const _ = require('lodash')
|
|
21
|
-
const { pgnToActisenseN2KAsciiFormat, actisenseToN2KAsciiFormat, pgnToN2KActisenseFormat, actisenseToN2KActisenseFormat } = require('./toPgn')
|
|
22
|
-
const { readN2KActisense, encodeN2KActisense } = require('./n2k-actisense')
|
|
23
|
-
|
|
24
|
-
const pgnsSent = {}
|
|
25
|
-
|
|
26
|
-
const N2K_ASCII = 0
|
|
27
|
-
const N2K_ACTISENSE = 1
|
|
28
|
-
|
|
29
|
-
function W2K01Stream (options, type, outEvent) {
|
|
30
|
-
if (!(this instanceof W2K01Stream)) {
|
|
31
|
-
return new W2K01Stream(options)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Transform.call(this, {
|
|
35
|
-
objectMode: true
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
this.sentAvailable = false
|
|
39
|
-
this.options = options
|
|
40
|
-
this.outEvent = outEvent || 'w2k-1-out'
|
|
41
|
-
|
|
42
|
-
this.format = type === 'ascii' ? N2K_ASCII : N2K_ACTISENSE
|
|
43
|
-
|
|
44
|
-
if ( this.format === N2K_ASCII ) {
|
|
45
|
-
if ( options.app ) {
|
|
46
|
-
options.app.on(this.options.outEevent || 'nmea2000out', (msg) => {
|
|
47
|
-
if ( typeof msg === 'string' ) {
|
|
48
|
-
this.sendW2KPGN(msg)
|
|
49
|
-
} else {
|
|
50
|
-
this.sendPGN(msg)
|
|
51
|
-
}
|
|
52
|
-
options.app.emit('connectionwrite', { providerId: options.providerId })
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => {
|
|
56
|
-
this.sendPGN(msg)
|
|
57
|
-
options.app.emit('connectionwrite', { providerId: options.providerId })
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
debug('started')
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
W2K01Stream.prototype.send = function (msg) {
|
|
66
|
-
debug('sending %s', msg)
|
|
67
|
-
this.options.app.emit(this.outEvent, msg)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
W2K01Stream.prototype.sendPGN = function (pgn) {
|
|
71
|
-
let now = Date.now()
|
|
72
|
-
let lastSent = pgnsSent[pgn.pgn]
|
|
73
|
-
if ( this.format === N2K_ASCII ) {
|
|
74
|
-
let ascii = pgnToActisenseN2KAsciiFormat(pgn)
|
|
75
|
-
this.send(ascii + '\r\n')
|
|
76
|
-
} else {
|
|
77
|
-
let buf = pgnToN2KActisenseFormat(pgn)
|
|
78
|
-
this.send(buf)
|
|
79
|
-
}
|
|
80
|
-
pgnsSent[pgn.pgn] = now
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
W2K01Stream.prototype.sendW2KPGN = function (msg) {
|
|
84
|
-
if ( this.format === N2K_ASCII ) {
|
|
85
|
-
let ascii = actisenseToN2KAsciiFormat(msg)
|
|
86
|
-
this.send(ascii + '\r\n')
|
|
87
|
-
} else {
|
|
88
|
-
let buf = actisenseToN2KActisenseFormat
|
|
89
|
-
this.send(buf)
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
require('util').inherits(W2K01Stream, Transform)
|
|
94
|
-
|
|
95
|
-
W2K01Stream.prototype._transform = function (chunk, encoding, done) {
|
|
96
|
-
if ( !this.sentAvailable && this.format === N2K_ASCII ) {
|
|
97
|
-
debug('emit nmea2000OutAvailable')
|
|
98
|
-
this.options.app.emit('nmea2000OutAvailable')
|
|
99
|
-
this.sentAvailable = true
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if ( this.format === N2K_ASCII ) {
|
|
103
|
-
if ( debugData.enabled ) {
|
|
104
|
-
debugData('Received: ' + chunk)
|
|
105
|
-
}
|
|
106
|
-
this.push(chunk)
|
|
107
|
-
} else {
|
|
108
|
-
readN2KActisense(chunk, this.plainText, this, (data) => {
|
|
109
|
-
this.push(data)
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
done()
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
W2K01Stream.prototype.pipe = function (pipeTo) {
|
|
117
|
-
if ( !pipeTo.fromPgn ) {
|
|
118
|
-
this.plainText = true
|
|
119
|
-
} else {
|
|
120
|
-
this.plainText = false
|
|
121
|
-
}
|
|
122
|
-
return W2K01Stream.super_.prototype.pipe.call(this, pipeTo)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
W2K01Stream.prototype.end = function () {
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
module.exports = W2K01Stream
|