@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
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2018 Scott Bender (scott@scottbender.net)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.byteString = exports.hexByte = exports.arrBuff = exports.rmChecksum = exports.trimWrap = exports.createDebug = exports.savePersistedData = exports.getPersistedData = void 0;
|
|
22
|
+
exports.getPlainPGNs = getPlainPGNs;
|
|
23
|
+
exports.compute0183Checksum = compute0183Checksum;
|
|
24
|
+
exports.binToActisense = binToActisense;
|
|
25
|
+
const debug_1 = require("debug");
|
|
26
|
+
const fp_1 = require("lodash/fp");
|
|
27
|
+
const fs_1 = __importDefault(require("fs"));
|
|
28
|
+
const getDataPath = (options) => {
|
|
29
|
+
if (options.app?.config?.configPath !== undefined) {
|
|
30
|
+
return `${options.app.config.configPath}/canboatjs-data.json`;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const getPersistedData = (options, id, key) => {
|
|
34
|
+
const path = getDataPath(options);
|
|
35
|
+
if (path !== undefined) {
|
|
36
|
+
const content = fs_1.default.readFileSync(path);
|
|
37
|
+
const data = JSON.parse(content.toString());
|
|
38
|
+
return data[id] !== undefined && data[id][key];
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.getPersistedData = getPersistedData;
|
|
42
|
+
const savePersistedData = (options, id, key, value) => {
|
|
43
|
+
const path = getDataPath(options);
|
|
44
|
+
if (path !== undefined) {
|
|
45
|
+
let content;
|
|
46
|
+
try {
|
|
47
|
+
content = fs_1.default.readFileSync(path).toString();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (err.code === 'ENOENT') {
|
|
51
|
+
content = '{}';
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const data = JSON.parse(content.toString());
|
|
58
|
+
if (data[id] === undefined) {
|
|
59
|
+
data[id] = {};
|
|
60
|
+
}
|
|
61
|
+
data[id][key] = value;
|
|
62
|
+
fs_1.default.writeFileSync(path, JSON.stringify(data, null, 2));
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.savePersistedData = savePersistedData;
|
|
66
|
+
const createDebug = (name, appOptions = undefined) => {
|
|
67
|
+
if (appOptions !== undefined && appOptions.createDebug !== undefined) {
|
|
68
|
+
return appOptions.createDebug(name);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return (0, debug_1.debug)(name);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.createDebug = createDebug;
|
|
75
|
+
function getPlainPGNs(buffer) {
|
|
76
|
+
const res = [];
|
|
77
|
+
let bucket = 0x40; // 64
|
|
78
|
+
const first = Buffer.alloc(8);
|
|
79
|
+
first.writeUInt8(bucket++, 0);
|
|
80
|
+
first.writeUInt8(buffer.length, 1);
|
|
81
|
+
buffer.copy(first, 2, 0, 6);
|
|
82
|
+
res.push(first);
|
|
83
|
+
for (let index = 6; index < buffer.length; index += 7) {
|
|
84
|
+
const next = Buffer.alloc(8);
|
|
85
|
+
next.writeUInt8(bucket++, 0);
|
|
86
|
+
let end = index + 7;
|
|
87
|
+
let fill = 0;
|
|
88
|
+
if (end > buffer.length) {
|
|
89
|
+
fill = end - buffer.length;
|
|
90
|
+
end = buffer.length;
|
|
91
|
+
}
|
|
92
|
+
buffer.copy(next, 1, index, end);
|
|
93
|
+
if (fill > 0) {
|
|
94
|
+
for (let i = end - index + 1; i < 8; i++) {
|
|
95
|
+
next.writeUInt8(0xff, i);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
res.push(next);
|
|
99
|
+
}
|
|
100
|
+
return res;
|
|
101
|
+
}
|
|
102
|
+
const m_hex = [
|
|
103
|
+
'0',
|
|
104
|
+
'1',
|
|
105
|
+
'2',
|
|
106
|
+
'3',
|
|
107
|
+
'4',
|
|
108
|
+
'5',
|
|
109
|
+
'6',
|
|
110
|
+
'7',
|
|
111
|
+
'8',
|
|
112
|
+
'9',
|
|
113
|
+
'A',
|
|
114
|
+
'B',
|
|
115
|
+
'C',
|
|
116
|
+
'D',
|
|
117
|
+
'E',
|
|
118
|
+
'F'
|
|
119
|
+
];
|
|
120
|
+
function toHexString(v) {
|
|
121
|
+
const msn = (v >> 4) & 0x0f;
|
|
122
|
+
const lsn = (v >> 0) & 0x0f;
|
|
123
|
+
return m_hex[msn] + m_hex[lsn];
|
|
124
|
+
}
|
|
125
|
+
function compute0183Checksum(sentence) {
|
|
126
|
+
// skip the $
|
|
127
|
+
let i = 1;
|
|
128
|
+
// init to first character
|
|
129
|
+
let c1 = sentence.charCodeAt(i);
|
|
130
|
+
// process rest of characters, zero delimited
|
|
131
|
+
for (i = 2; i < sentence.length; ++i) {
|
|
132
|
+
c1 = c1 ^ sentence.charCodeAt(i);
|
|
133
|
+
}
|
|
134
|
+
return '*' + toHexString(c1);
|
|
135
|
+
}
|
|
136
|
+
function binToActisense(pgn, timestamp, data, length) {
|
|
137
|
+
const arr = [];
|
|
138
|
+
return (timestamp +
|
|
139
|
+
`,${pgn.prio},${pgn.pgn},${pgn.src},${pgn.dst},${length},` +
|
|
140
|
+
new Uint32Array(data)
|
|
141
|
+
.reduce(function (acc, i) {
|
|
142
|
+
acc.push(i.toString(16));
|
|
143
|
+
return acc;
|
|
144
|
+
}, arr)
|
|
145
|
+
.map((x) => (x.length === 1 ? '0' + x : x))
|
|
146
|
+
.join(','));
|
|
147
|
+
}
|
|
148
|
+
exports.trimWrap = (0, fp_1.trimChars)('()<>[]');
|
|
149
|
+
const rmChecksum = (str) => str.includes('*') ? str.split('*', 1)[0] : str;
|
|
150
|
+
exports.rmChecksum = rmChecksum;
|
|
151
|
+
const arrBuff = (arr, encoding = 'hex') => Buffer.from(arr.join(''), encoding);
|
|
152
|
+
exports.arrBuff = arrBuff;
|
|
153
|
+
const hexByte = (x) => (0, fp_1.padCharsStart)('0', 2, Number(x).toString(16));
|
|
154
|
+
exports.hexByte = hexByte;
|
|
155
|
+
const byteString = (data, separator = ',') =>
|
|
156
|
+
// Uint32Array map method doesn't work as expect. _.map does.
|
|
157
|
+
(0, fp_1.map)(exports.hexByte, new Uint32Array(data)).join(separator);
|
|
158
|
+
exports.byteString = byteString;
|
|
159
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../lib/utilities.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AA0DH,oCA4BC;AA2BD,kDAUC;AAED,wCAkBC;AA7ID,iCAA6B;AAE7B,kCAAyD;AACzD,4CAAmB;AAEnB,MAAM,WAAW,GAAG,CAAC,OAAY,EAAE,EAAE;IACnC,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;QAClD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,sBAAsB,CAAA;IAC/D,CAAC;AACH,CAAC,CAAA;AAEM,MAAM,gBAAgB,GAAG,CAAC,OAAY,EAAE,EAAU,EAAE,GAAW,EAAE,EAAE;IACxE,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IACjC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC3C,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,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,CAAC,EAAE,CAAC,CAAC,CAAA;AADlC,QAAA,OAAO,WAC2B;AACxC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,SAAS,GAAG,GAAG,EAAE,EAAE;AAC1D,6DAA6D;AAC7D,IAAA,QAAG,EAAC,OAAO,CAAC,OAAO,EAAE,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AAFhD,QAAA,UAAU,cAEsC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.test.d.ts","sourceRoot":"","sources":["../lib/utilities.test.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { byteString } = require('./utilities');
|
|
3
|
+
describe('byteString', () => {
|
|
4
|
+
test('Buffer to string', () => {
|
|
5
|
+
const data = Buffer.from('00ff7f520021feff', 'hex');
|
|
6
|
+
expect(byteString(data)).toEqual('00,ff,7f,52,00,21,fe,ff');
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=utilities.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.test.js","sourceRoot":"","sources":["../lib/utilities.test.js"],"names":[],"mappings":";AAAA,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAE7C,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;QACnD,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { MQTTStream as VenusMQTT };
|
|
2
|
+
declare function MQTTStream(options: any): void;
|
|
3
|
+
declare class MQTTStream {
|
|
4
|
+
constructor(options: any);
|
|
5
|
+
options: any;
|
|
6
|
+
discoveryAvailable(): boolean;
|
|
7
|
+
pipe(pipeTo: any): void;
|
|
8
|
+
startDiscovery(): Promise<any>;
|
|
9
|
+
_transform(_data: any, _encoding: any, _callback: any): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=venus-mqtt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"venus-mqtt.d.ts","sourceRoot":"","sources":["../lib/venus-mqtt.js"],"names":[],"mappings":";AAMA,gDAKC;;IALD,0BAKC;IADC,aAAsB;IAKxB,8BAEC;IAED,wBAoDC;IAED,+BA6BC;IAED,6DAA2E"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const Transform = require('stream').Transform;
|
|
3
|
+
const mqtt = require('mqtt');
|
|
4
|
+
const debug = require('debug')('venus-mqtt');
|
|
5
|
+
//const pgns = require('./fromPgn').pgns
|
|
6
|
+
const _ = require('lodash');
|
|
7
|
+
function MQTTStream(options) {
|
|
8
|
+
Transform.call(this, {
|
|
9
|
+
objectMode: true
|
|
10
|
+
});
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
require('util').inherits(MQTTStream, Transform);
|
|
14
|
+
MQTTStream.prototype.discoveryAvailable = function () {
|
|
15
|
+
return moduleAvailable('md' + 'ns');
|
|
16
|
+
};
|
|
17
|
+
MQTTStream.prototype.pipe = function (pipeTo) {
|
|
18
|
+
const that = this;
|
|
19
|
+
this.startDiscovery()
|
|
20
|
+
.then((service) => {
|
|
21
|
+
let url = service.txtRecord.mqtt_broker;
|
|
22
|
+
var client = mqtt.connect(url);
|
|
23
|
+
client.on('connect', function () {
|
|
24
|
+
debug(`connected to ${url}`);
|
|
25
|
+
client.subscribe('n2k/mqtt_n2k/self');
|
|
26
|
+
//client.subscribe('n2k/mqtt_n2k/listenpgns')
|
|
27
|
+
client.publish('n2k/mqtt_n2k/getself');
|
|
28
|
+
client.publish('n2k/mqtt_n2k/addpgn', '129026');
|
|
29
|
+
client.publish('n2k/mqtt_n2k/addpgn', '129025');
|
|
30
|
+
//client.publish('n2k/mqtt_n2k/getlistenpgns')
|
|
31
|
+
client.subscribe('n2k/mqtt_n2k/bus/#');
|
|
32
|
+
/*
|
|
33
|
+
pgns.forEach(key => {
|
|
34
|
+
debug(`adding pgn ${key}`)
|
|
35
|
+
client.publish('n2k/mqtt_n2k/addpgn', key)
|
|
36
|
+
//require('sleep').msleep(100)
|
|
37
|
+
})
|
|
38
|
+
*/
|
|
39
|
+
});
|
|
40
|
+
client.on('error', (error) => {
|
|
41
|
+
this.options.app.setProviderError(`error connecting to mqtt ${error}`);
|
|
42
|
+
});
|
|
43
|
+
client.on('close', () => {
|
|
44
|
+
this.options.app.setProviderError(`mqtt close`);
|
|
45
|
+
});
|
|
46
|
+
client.on('reconnect', () => {
|
|
47
|
+
//this.(`mqtt reconnect`)
|
|
48
|
+
});
|
|
49
|
+
client.on('message', (topic, json) => {
|
|
50
|
+
debug(`${topic}: '${json}'`);
|
|
51
|
+
const pgn = JSON.parse(json);
|
|
52
|
+
if (topic.startsWith('n2k/mqtt_n2k/bus/')) {
|
|
53
|
+
that.push(pgn);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
})
|
|
57
|
+
.catch((error) => {
|
|
58
|
+
debug(error);
|
|
59
|
+
this.options.app.setProviderStatus(error.msg);
|
|
60
|
+
});
|
|
61
|
+
Transform.prototype.pipe.call(this, pipeTo);
|
|
62
|
+
};
|
|
63
|
+
MQTTStream.prototype.startDiscovery = function () {
|
|
64
|
+
var that = this;
|
|
65
|
+
return new Promise(function (resolve, reject) {
|
|
66
|
+
if (!that.discoveryAvailable()) {
|
|
67
|
+
console.log('Discovery requires mdns or specify hostname and port');
|
|
68
|
+
reject('Discovery requires mdns');
|
|
69
|
+
}
|
|
70
|
+
var mdns = require('md' + 'ns');
|
|
71
|
+
function doStart(serviceName) {
|
|
72
|
+
let browser = mdns.createBrowser(mdns.tcp(serviceName), {
|
|
73
|
+
resolverSequence: [mdns.rst.DNSServiceResolve()]
|
|
74
|
+
});
|
|
75
|
+
browser.on('serviceUp', function (service) {
|
|
76
|
+
debug(`Discovered ${serviceName}:` + JSON.stringify(service, null, 2));
|
|
77
|
+
//that.get('/signalk', service.host, service.port, isHttps ? 'https' : 'http').then(function(response) {
|
|
78
|
+
debug(`Service at ${service.host}:${service.port} ${service.txtRecord.base_topic}`);
|
|
79
|
+
resolve(service);
|
|
80
|
+
});
|
|
81
|
+
debug(`Starting ${serviceName} discovery`);
|
|
82
|
+
browser.start();
|
|
83
|
+
return browser;
|
|
84
|
+
}
|
|
85
|
+
this.browser = doStart('mqtt-n2k');
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
MQTTStream.prototype._transform = function (_data, _encoding, _callback) { };
|
|
89
|
+
function moduleAvailable(name) {
|
|
90
|
+
try {
|
|
91
|
+
require.resolve(name);
|
|
92
|
+
return true;
|
|
93
|
+
// eslint-disable-next-line no-empty
|
|
94
|
+
}
|
|
95
|
+
catch (_e) { }
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
module.exports.VenusMQTT = MQTTStream;
|
|
99
|
+
//const pgns = [ '126992','127505','129029','129291','130312','127245','127506','129038','129793','130314','127250','127508','129039','129794','130577','127251','128259','129040','129809','130842','127257','128267','129041','129810','127258','128275','129283','130306','127488','129025','129284','130310','127489','129026','129285','130311']
|
|
100
|
+
//# sourceMappingURL=venus-mqtt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"venus-mqtt.js","sourceRoot":"","sources":["../lib/venus-mqtt.js"],"names":[],"mappings":";AAAA,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAA;AAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM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AAA;QACrB,OAAO,IAAI,CAAA;QACX,oCAAoC;IACtC,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC,CAAA,CAAC;IACf,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,UAAU,CAAA;AAErC,qVAAqV"}
|
package/dist/venus.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function VenusStream(options: any): VenusStream;
|
|
2
|
+
export class VenusStream {
|
|
3
|
+
constructor(options: any);
|
|
4
|
+
options: any;
|
|
5
|
+
fromPgn: FromPgn | undefined;
|
|
6
|
+
_transform(pgn: any, encoding: any, done: any): void;
|
|
7
|
+
end(): void;
|
|
8
|
+
}
|
|
9
|
+
import FromPgn_1 = require("./fromPgn");
|
|
10
|
+
import FromPgn = FromPgn_1.Parser;
|
|
11
|
+
//# sourceMappingURL=venus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"venus.d.ts","sourceRoot":"","sources":["../lib/venus.js"],"names":[],"mappings":"AAqBA,uDA2CC;;IA3CD,0BA2CC;IAlCC,aAAsB;IAEtB,6BAAmC;IAoCrC,qDAeC;IAED,YAA0C;;;2BAnEL,MAAM"}
|
package/dist/venus.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2018 Scott Bender (scott@scottbender.net)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
const debug = require('debug')('canboatjs:venus');
|
|
18
|
+
const Transform = require('stream').Transform;
|
|
19
|
+
const FromPgn = require('./fromPgn').Parser;
|
|
20
|
+
const _ = require('lodash');
|
|
21
|
+
function VenusStream(options) {
|
|
22
|
+
if (!(this instanceof VenusStream)) {
|
|
23
|
+
return new VenusStream(options);
|
|
24
|
+
}
|
|
25
|
+
Transform.call(this, {
|
|
26
|
+
objectMode: true
|
|
27
|
+
});
|
|
28
|
+
this.options = options;
|
|
29
|
+
this.fromPgn = new FromPgn(options);
|
|
30
|
+
debug('created FromPgn');
|
|
31
|
+
/*
|
|
32
|
+
this.fromPgn.on('pgn', pgn => {
|
|
33
|
+
})
|
|
34
|
+
*/
|
|
35
|
+
this.fromPgn.on('warning', (pgn, warning) => {
|
|
36
|
+
debug(`[warning] ${pgn.pgn} ${warning}`);
|
|
37
|
+
});
|
|
38
|
+
this.fromPgn.on('error', (pgn, error) => {
|
|
39
|
+
debug(`[error] ${pgn.pgn} ${error}`);
|
|
40
|
+
});
|
|
41
|
+
/*
|
|
42
|
+
if ( this.options.app ) {
|
|
43
|
+
options.app.on('nmea2000out', (msg) => {
|
|
44
|
+
that.sendActisensePGN(msg)
|
|
45
|
+
})
|
|
46
|
+
options.app.on('nmea2000JsonOut', (msg) => {
|
|
47
|
+
that.sendPGN(msg)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
this.sendString('$PDGY,N2NET_OFFLINE')
|
|
51
|
+
|
|
52
|
+
debug('started')
|
|
53
|
+
//this.options.app.emit('nmea2000OutAvailable')
|
|
54
|
+
}
|
|
55
|
+
*/
|
|
56
|
+
}
|
|
57
|
+
require('util').inherits(VenusStream, Transform);
|
|
58
|
+
VenusStream.prototype._transform = function (pgn, encoding, done) {
|
|
59
|
+
//let line = chunk.toString().trim()
|
|
60
|
+
//line = line.substring(0, line.length) // take off the \r
|
|
61
|
+
this.fromPgn.parseVenusMQTT(pgn, (error, pgn) => {
|
|
62
|
+
if (!error) {
|
|
63
|
+
this.push(pgn);
|
|
64
|
+
this.options.app.emit(this.options.analyzerOutEvent || 'N2KAnalyzerOut', pgn);
|
|
65
|
+
}
|
|
66
|
+
done();
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
VenusStream.prototype.end = function () { };
|
|
70
|
+
module.exports.VenusStream = VenusStream;
|
|
71
|
+
//# sourceMappingURL=venus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"venus.js","sourceRoot":"","sources":["../lib/venus.js"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAAA;AACjD,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAA;AAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAA;AAC3C,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAE3B,SAAS,WAAW,CAAC,OAAO;IAC1B,IAAI,CAAC,CAAC,IAAI,YAAY,WAAW,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;IACjC,CAAC;IAED,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE;QACnB,UAAU,EAAE,IAAI;KACjB,CAAC,CAAA;IAEF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAEtB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IAEnC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAExB;;;IAGA;IAEA,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAC1C,KAAK,CAAC,aAAa,GAAG,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACtC,KAAK,CAAC,WAAW,GAAG,CAAC,GAAG,IAAI,KAAK,EAAE,CAAC,CAAA;IACtC,CAAC,CAAC,CAAA;IAEF;;;;;;;;;;;;;;MAcE;AACJ,CAAC;AAED,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;AAEhD,WAAW,CAAC,SAAS,CAAC,UAAU,GAAG,UAAU,GAAG,EAAE,QAAQ,EAAE,IAAI;IAC9D,oCAAoC;IACpC,0DAA0D;IAE1D,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACd,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CACnB,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,gBAAgB,EACjD,GAAG,CACJ,CAAA;QACH,CAAC;QAED,IAAI,EAAE,CAAA;IACR,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,WAAW,CAAC,SAAS,CAAC,GAAG,GAAG,cAAa,CAAC,CAAA;AAE1C,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,WAAW,CAAA"}
|
package/dist/w2k01.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export declare function W2K01Stream(this: any, options: any, type: string, outEvent: string): any;
|
|
17
|
+
//# sourceMappingURL=w2k01.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"w2k01.d.ts","sourceRoot":"","sources":["../lib/w2k01.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAmBH,wBAAgB,WAAW,CACzB,IAAI,EAAE,GAAG,EACT,OAAO,EAAE,GAAG,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,OAsCjB"}
|
package/dist/w2k01.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2018 Scott Bender (scott@scottbender.net)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.W2K01Stream = W2K01Stream;
|
|
22
|
+
const utilities_1 = require("./utilities");
|
|
23
|
+
const stream_1 = require("stream");
|
|
24
|
+
const toPgn_1 = require("./toPgn");
|
|
25
|
+
const n2k_actisense_1 = require("./n2k-actisense");
|
|
26
|
+
const util_1 = __importDefault(require("util"));
|
|
27
|
+
//const pgnsSent = {}
|
|
28
|
+
const N2K_ASCII = 0;
|
|
29
|
+
const N2K_ACTISENSE = 1;
|
|
30
|
+
function W2K01Stream(options, type, outEvent) {
|
|
31
|
+
if (this === undefined) {
|
|
32
|
+
return new W2K01Stream(options, type, outEvent);
|
|
33
|
+
}
|
|
34
|
+
stream_1.Transform.call(this, {
|
|
35
|
+
objectMode: true
|
|
36
|
+
});
|
|
37
|
+
this.debug = (0, utilities_1.createDebug)('canboatjs:w2k01', options);
|
|
38
|
+
this.debugData = (0, utilities_1.createDebug)('canboatjs:w2k01-data', options);
|
|
39
|
+
this.sentAvailable = false;
|
|
40
|
+
this.options = options;
|
|
41
|
+
this.outEvent = outEvent || 'w2k-1-out';
|
|
42
|
+
this.format = type === 'ascii' ? N2K_ASCII : N2K_ACTISENSE;
|
|
43
|
+
if (this.format === N2K_ASCII) {
|
|
44
|
+
if (options.app) {
|
|
45
|
+
options.app.on(this.options.outEevent || 'nmea2000out', (msg) => {
|
|
46
|
+
if (typeof msg === 'string') {
|
|
47
|
+
this.sendW2KPGN(msg);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.sendPGN(msg);
|
|
51
|
+
}
|
|
52
|
+
options.app.emit('connectionwrite', { providerId: options.providerId });
|
|
53
|
+
});
|
|
54
|
+
options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => {
|
|
55
|
+
this.sendPGN(msg);
|
|
56
|
+
options.app.emit('connectionwrite', { providerId: options.providerId });
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
this.debug('started');
|
|
61
|
+
}
|
|
62
|
+
W2K01Stream.prototype.send = function (msg) {
|
|
63
|
+
this.debug('sending %s', msg);
|
|
64
|
+
this.options.app.emit(this.outEvent, msg);
|
|
65
|
+
};
|
|
66
|
+
W2K01Stream.prototype.sendPGN = function (pgn) {
|
|
67
|
+
//const now = Date.now()
|
|
68
|
+
//let lastSent = pgnsSent[pgn.pgn]
|
|
69
|
+
if (this.format === N2K_ASCII) {
|
|
70
|
+
const ascii = (0, toPgn_1.pgnToActisenseN2KAsciiFormat)(pgn);
|
|
71
|
+
this.send(ascii + '\r\n');
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const buf = (0, toPgn_1.pgnToN2KActisenseFormat)(pgn);
|
|
75
|
+
this.send(buf);
|
|
76
|
+
}
|
|
77
|
+
//pgnsSent[pgn.pgn] = now
|
|
78
|
+
};
|
|
79
|
+
W2K01Stream.prototype.sendW2KPGN = function (msg) {
|
|
80
|
+
if (this.format === N2K_ASCII) {
|
|
81
|
+
const ascii = (0, toPgn_1.actisenseToN2KAsciiFormat)(msg);
|
|
82
|
+
this.send(ascii + '\r\n');
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const buf = toPgn_1.actisenseToN2KActisenseFormat;
|
|
86
|
+
this.send(buf);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
util_1.default.inherits(W2K01Stream, stream_1.Transform);
|
|
90
|
+
W2K01Stream.prototype._transform = function (chunk, encoding, done) {
|
|
91
|
+
if (!this.sentAvailable && this.format === N2K_ASCII) {
|
|
92
|
+
this.debug('emit nmea2000OutAvailable');
|
|
93
|
+
this.options.app.emit('nmea2000OutAvailable');
|
|
94
|
+
this.sentAvailable = true;
|
|
95
|
+
}
|
|
96
|
+
if (this.format === N2K_ASCII) {
|
|
97
|
+
if (this.debugData.enabled) {
|
|
98
|
+
this.debugData('Received: ' + chunk);
|
|
99
|
+
}
|
|
100
|
+
this.push(chunk);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
(0, n2k_actisense_1.readN2KActisense)(chunk, this.plainText, this, (data) => {
|
|
104
|
+
this.push(data);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
done();
|
|
108
|
+
};
|
|
109
|
+
W2K01Stream.prototype.pipe = function (pipeTo) {
|
|
110
|
+
if (!pipeTo.fromPgn) {
|
|
111
|
+
this.plainText = true;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.plainText = false;
|
|
115
|
+
}
|
|
116
|
+
return W2K01Stream.super_.prototype.pipe.call(this, pipeTo);
|
|
117
|
+
};
|
|
118
|
+
W2K01Stream.prototype.end = function () { };
|
|
119
|
+
//# sourceMappingURL=w2k01.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,uBAAW,EAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;IACpD,IAAI,CAAC,SAAS,GAAG,IAAA,uBAAW,EAAC,sBAAsB,EAAE,OAAO,CAAC,CAAA;IAE7D,IAAI,CAAC,aAAa,GAAG,KAAK,CAAA;IAC1B,IAAI,CA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CAAC,sBAAsB,CAAC,CAAA;QAC7C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;IAC3B,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;YAC3B,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,KAAK,CAAC,CAAA;QACtC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC;SAAM,CAAC;QACN,IAAA,gCAAgB,EAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,IAAS,EAAE,EAAE;YAC1D,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,EAAE,CAAA;AACR,CAAC,CAAA;AAED,WAAW,CAAC,SAAS,CAAC,IAAI,GAAG,UAAU,MAAW;IAChD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;IACvB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;IACxB,CAAC;IACD,OAAQ,WAAmB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AACtE,CAAC,CAAA;AAED,WAAW,CAAC,SAAS,CAAC,GAAG,GAAG,cAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025 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
|
+
import { PGN } from '@canboat/ts-pgns';
|
|
17
|
+
import { N2kDevice } from './n2kDevice';
|
|
18
|
+
export declare class YdDevice extends N2kDevice {
|
|
19
|
+
app: any;
|
|
20
|
+
n2kOutEvent: string;
|
|
21
|
+
constructor(options: any);
|
|
22
|
+
sendPGN(pgn: PGN, src?: number | undefined): void;
|
|
23
|
+
sendActisenseFormat(msg: string): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=yddevice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2025 Scott Bender (scott@scottbender.net)
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.YdDevice = void 0;
|
|
19
|
+
const n2kDevice_1 = require("./n2kDevice");
|
|
20
|
+
const toPgn_1 = require("./toPgn");
|
|
21
|
+
class YdDevice extends n2kDevice_1.N2kDevice {
|
|
22
|
+
app;
|
|
23
|
+
n2kOutEvent;
|
|
24
|
+
constructor(options) {
|
|
25
|
+
super(options, 'canboatjs:yddevice');
|
|
26
|
+
this.app = options.app;
|
|
27
|
+
this.n2kOutEvent = options.jsonOutEvent || 'nmea2000JsonOut';
|
|
28
|
+
const analyzerOutEvent = options.analyzerOutEvent || 'N2KAnalyzerOut';
|
|
29
|
+
this.app.on(analyzerOutEvent, this.n2kMessage.bind(this));
|
|
30
|
+
}
|
|
31
|
+
sendPGN(pgn, src = undefined) {
|
|
32
|
+
pgn.src = src || this.address;
|
|
33
|
+
const ppgn = pgn; //FIXME??
|
|
34
|
+
ppgn.ydFullFormat = true;
|
|
35
|
+
this.debug('Sending PGN %j', pgn);
|
|
36
|
+
this.app.emit(this.n2kOutEvent, pgn);
|
|
37
|
+
}
|
|
38
|
+
sendActisenseFormat(msg) {
|
|
39
|
+
this.app.emit('ydFullRawOut', (0, toPgn_1.actisenseToYdgwFullRawFormat)(msg));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.YdDevice = YdDevice;
|
|
43
|
+
//# sourceMappingURL=yddevice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export declare function Ydgw02Stream(this: any, options: any, type: string): any;
|
|
17
|
+
//# sourceMappingURL=ydgw02.d.ts.map
|