@canboat/canboatjs 1.26.3 → 1.27.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.
- package/bin/ydvr-file +0 -0
- package/lib/canbus.js +1 -1
- package/lib/candevice.js +1 -1
- package/lib/ikonvert.js +1 -1
- package/lib/serial.js +1 -1
- package/lib/venus.js +1 -1
- package/lib/w2k01.js +1 -1
- package/lib/ydgw02.js +2 -2
- package/lib/ydvr.js +17 -2
- package/package.json +1 -1
package/bin/ydvr-file
CHANGED
|
File without changes
|
package/lib/canbus.js
CHANGED
|
@@ -84,7 +84,7 @@ function CanbusStream (options) {
|
|
|
84
84
|
options.app.on(options.outEvent || 'nmea2000out', (msg) => {
|
|
85
85
|
that.sendPGN(msg)
|
|
86
86
|
})
|
|
87
|
-
options.app.on('nmea2000JsonOut', (msg) => {
|
|
87
|
+
options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => {
|
|
88
88
|
that.sendPGN(msg)
|
|
89
89
|
})
|
|
90
90
|
}
|
package/lib/candevice.js
CHANGED
package/lib/ikonvert.js
CHANGED
package/lib/serial.js
CHANGED
|
@@ -163,7 +163,7 @@ SerialStream.prototype.start = function () {
|
|
|
163
163
|
}
|
|
164
164
|
})
|
|
165
165
|
|
|
166
|
-
this.options.app.on('nmea2000JsonOut', msg => {
|
|
166
|
+
this.options.app.on(this.options.jsonOutEvent || 'nmea2000JsonOut', msg => {
|
|
167
167
|
if ( this.outAvailable ) {
|
|
168
168
|
writeObject(msg)
|
|
169
169
|
}
|
package/lib/venus.js
CHANGED
|
@@ -75,7 +75,7 @@ VenusStream.prototype._transform = function (pgn, encoding, done) {
|
|
|
75
75
|
this.fromPgn.parseVenusMQTT(pgn, (error, pgn) => {
|
|
76
76
|
if ( !error ) {
|
|
77
77
|
this.push(pgn)
|
|
78
|
-
this.options.app.emit('N2KAnalyzerOut', pgn)
|
|
78
|
+
this.options.app.emit(this.options.analyzerOutEvent || 'N2KAnalyzerOut', pgn)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
done()
|
package/lib/w2k01.js
CHANGED
package/lib/ydgw02.js
CHANGED
|
@@ -57,7 +57,7 @@ function Ydgw02Stream (options, type) {
|
|
|
57
57
|
}
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
options.app.on('nmea2000JsonOut', (msg) => {
|
|
60
|
+
options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => {
|
|
61
61
|
this.sendPGN(msg)
|
|
62
62
|
})
|
|
63
63
|
|
|
@@ -133,7 +133,7 @@ Ydgw02Stream.prototype._transform = function (chunk, encoding, done) {
|
|
|
133
133
|
const pgn = this.fromPgn.parseYDGW02(line)
|
|
134
134
|
if ( !_.isUndefined(pgn) ) {
|
|
135
135
|
this.push(pgn)
|
|
136
|
-
this.options.app.emit('N2KAnalyzerOut', pgn)
|
|
136
|
+
this.options.app.emit(this.options.analyzerOutEvent || 'N2KAnalyzerOut', pgn)
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
done()
|
package/lib/ydvr.js
CHANGED
|
@@ -108,6 +108,10 @@ function YdvrStream() {
|
|
|
108
108
|
|
|
109
109
|
this.parser = new FromPgn();
|
|
110
110
|
|
|
111
|
+
this.messageCount = 0;
|
|
112
|
+
this.errorCount = 0;
|
|
113
|
+
this.timerResetCount = 0;
|
|
114
|
+
|
|
111
115
|
this.parser.on('error', (pgn, error) => {
|
|
112
116
|
console.error(`Error parsing ${pgn.pgn} ${error}`);
|
|
113
117
|
console.error(error.stack);
|
|
@@ -141,7 +145,8 @@ YdvrStream.prototype.parseNextRecord = function () {
|
|
|
141
145
|
let timeAbsolute;
|
|
142
146
|
if (this.lastTime != null && time < this.lastTime) {
|
|
143
147
|
this.timeOffset = (this.timeOffset || 0) + 60000;
|
|
144
|
-
timeAbsolute = time + timeOffset;
|
|
148
|
+
timeAbsolute = time + this.timeOffset;
|
|
149
|
+
this.timerResetCount += 1;
|
|
145
150
|
} else {
|
|
146
151
|
timeAbsolute = time;
|
|
147
152
|
}
|
|
@@ -150,6 +155,9 @@ YdvrStream.prototype.parseNextRecord = function () {
|
|
|
150
155
|
var identifier = this.bs.readUint32();
|
|
151
156
|
if (identifier === 0xffffffff) {
|
|
152
157
|
// service record
|
|
158
|
+
if (this.bs.bitsLeft < 8 * 8) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
153
161
|
var srData = this.bs.readArrayBuffer(8);
|
|
154
162
|
} else {
|
|
155
163
|
const pgn = parseCanId(identifier);
|
|
@@ -163,6 +171,9 @@ YdvrStream.prototype.parseNextRecord = function () {
|
|
|
163
171
|
} else {
|
|
164
172
|
bodyLen = 8;
|
|
165
173
|
}
|
|
174
|
+
if (this.bs.bitsLeft < bodyLen * 8) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
166
177
|
var body = this.bs.readArrayBuffer(bodyLen);
|
|
167
178
|
|
|
168
179
|
const parsed = this.parser.parsePgnData(
|
|
@@ -177,6 +188,7 @@ YdvrStream.prototype.parseNextRecord = function () {
|
|
|
177
188
|
}
|
|
178
189
|
}
|
|
179
190
|
|
|
191
|
+
this.messageCount += 1;
|
|
180
192
|
return true;
|
|
181
193
|
}
|
|
182
194
|
|
|
@@ -192,7 +204,10 @@ YdvrStream.prototype._transform = function (chunk, encoding, done) {
|
|
|
192
204
|
let parsed = false;
|
|
193
205
|
try {
|
|
194
206
|
parsed = this.parseNextRecord();
|
|
195
|
-
} catch (ex) {
|
|
207
|
+
} catch (ex) {
|
|
208
|
+
console.error(ex);
|
|
209
|
+
this.errorCount += 1;
|
|
210
|
+
}
|
|
196
211
|
if (!parsed) {
|
|
197
212
|
this.bs.byteIndex = startIndex;
|
|
198
213
|
break;
|