@signalk/vedirect-serial-usb 1.4.0 → 1.6.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/LICENSE +201 -0
- package/README.md +13 -24
- package/dist/Parser.d.ts +50 -0
- package/dist/Parser.d.ts.map +1 -0
- package/dist/Parser.js +350 -0
- package/dist/Parser.js.map +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/fields.d.ts +14 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +438 -0
- package/dist/fields.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +209 -0
- package/dist/index.js.map +1 -0
- package/dist/productIds.d.ts +9 -0
- package/dist/productIds.d.ts.map +1 -0
- package/dist/productIds.js +95 -0
- package/dist/productIds.js.map +1 -0
- package/dist/serial.d.ts +5 -0
- package/dist/serial.d.ts.map +1 -0
- package/dist/serial.js +78 -0
- package/dist/serial.js.map +1 -0
- package/dist/standalone.d.ts +22 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/standalone.js +69 -0
- package/dist/standalone.js.map +1 -0
- package/dist/tcp.d.ts +5 -0
- package/dist/tcp.d.ts.map +1 -0
- package/dist/tcp.js +106 -0
- package/dist/tcp.js.map +1 -0
- package/dist/types.d.ts +159 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/udp.d.ts +5 -0
- package/dist/udp.d.ts.map +1 -0
- package/dist/udp.js +67 -0
- package/dist/udp.js.map +1 -0
- package/docs/screenshots/1_config.png +0 -0
- package/logo.svg +46 -0
- package/package.json +79 -19
- package/.github/FUNDING.yml +0 -1
- package/.travis.yml +0 -13
- package/index.js +0 -154
- package/lib/Parser.js +0 -391
- package/lib/fields.js +0 -501
- package/lib/filestream.js +0 -38
- package/lib/productIds.json +0 -84
- package/lib/serial.js +0 -48
- package/lib/tcp.js +0 -47
- package/lib/udp.js +0 -26
- package/log/one.txt +0 -18
- package/log/run-log.js +0 -7
- package/log/sampleOutput.txt +0 -297
- package/migration.js +0 -54
- package/run.js +0 -10
- package/standalone.js +0 -67
- package/test/index.js +0 -52
- package/todo.md +0 -14
package/lib/fields.js
DELETED
|
@@ -1,501 +0,0 @@
|
|
|
1
|
-
const common = {
|
|
2
|
-
number (value) {
|
|
3
|
-
if (typeof value !== 'number') {
|
|
4
|
-
value = parseInt(value, 10)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
if (isNaN(value)) {
|
|
8
|
-
return null
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return value
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
// 0.01 kWh
|
|
15
|
-
kWh (value) {
|
|
16
|
-
if (typeof value !== 'number') {
|
|
17
|
-
value = parseInt(value, 10)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (isNaN(value)) {
|
|
21
|
-
return null
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// value is in units of 0.01 kWh each
|
|
25
|
-
return value / 100
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
mV (value) {
|
|
29
|
-
if (typeof value !== 'number') {
|
|
30
|
-
value = parseInt(value, 10)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (isNaN(value)) {
|
|
34
|
-
return null
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return value / 1000
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
mA (value) {
|
|
41
|
-
if (typeof value !== 'number') {
|
|
42
|
-
value = parseInt(value, 10)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (isNaN(value)) {
|
|
46
|
-
return null
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return Math.floor(value / 10) / 100
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
mAh (value) {
|
|
53
|
-
if (typeof value !== 'number') {
|
|
54
|
-
value = parseInt(value, 10)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (isNaN(value)) {
|
|
58
|
-
return null
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return Math.floor(value / 10) / 100 * 3600
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
promille (value) {
|
|
65
|
-
if (typeof value !== 'number') {
|
|
66
|
-
value = parseInt(value, 10)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (isNaN(value)) {
|
|
70
|
-
return null
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return value / 1000
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
module.exports = {
|
|
78
|
-
V: {
|
|
79
|
-
name: 'mainBattVoltage',
|
|
80
|
-
path: 'electrical.batteries.*.voltage',
|
|
81
|
-
unitId: 'mainBatt',
|
|
82
|
-
value: common.mV,
|
|
83
|
-
units: 'V',
|
|
84
|
-
type: 'metric'
|
|
85
|
-
},
|
|
86
|
-
V2: {
|
|
87
|
-
name: 'auxBattVoltage',
|
|
88
|
-
path: 'electrical.batteries.*.voltage',
|
|
89
|
-
unitId: 'auxBatt',
|
|
90
|
-
value: common.mV,
|
|
91
|
-
units: 'V',
|
|
92
|
-
type: 'metric'
|
|
93
|
-
},
|
|
94
|
-
V3: {
|
|
95
|
-
name: 'aux2BattVoltage',
|
|
96
|
-
path: 'electrical.batteries.*.voltage',
|
|
97
|
-
unitId: 'aux2Batt',
|
|
98
|
-
value: common.mV,
|
|
99
|
-
units: 'V',
|
|
100
|
-
type: 'metric'
|
|
101
|
-
},
|
|
102
|
-
VS: {
|
|
103
|
-
name: 'auxBatteryVoltage',
|
|
104
|
-
path: 'electrical.batteries.*.voltage',
|
|
105
|
-
unitId: 'auxBatt',
|
|
106
|
-
value: common.mV,
|
|
107
|
-
units: 'V',
|
|
108
|
-
type: 'metric'
|
|
109
|
-
},
|
|
110
|
-
VM: {
|
|
111
|
-
name: 'midPointVoltage',
|
|
112
|
-
value: common.mV,
|
|
113
|
-
units: 'V',
|
|
114
|
-
type: 'metric'
|
|
115
|
-
},
|
|
116
|
-
DM: {
|
|
117
|
-
name: 'midPointDeviation',
|
|
118
|
-
value: common.promille,
|
|
119
|
-
type: 'ratio'
|
|
120
|
-
},
|
|
121
|
-
VPV: {
|
|
122
|
-
name: 'panelVoltage',
|
|
123
|
-
path: 'electrical.solar.*.panelVoltage',
|
|
124
|
-
unitId: 'solar',
|
|
125
|
-
value: common.mV,
|
|
126
|
-
units: 'V',
|
|
127
|
-
type: 'metric'
|
|
128
|
-
},
|
|
129
|
-
PPV: {
|
|
130
|
-
name: 'panelPower',
|
|
131
|
-
path: 'electrical.solar.*.panelPower',
|
|
132
|
-
unitId: 'solar',
|
|
133
|
-
value: common.number,
|
|
134
|
-
units: 'W',
|
|
135
|
-
type: 'metric'
|
|
136
|
-
},
|
|
137
|
-
I: {
|
|
138
|
-
name: 'batteryCurrent',
|
|
139
|
-
path: 'electrical.batteries.*.current',
|
|
140
|
-
unitId: 'mainBatt',
|
|
141
|
-
value: common.mA,
|
|
142
|
-
units: 'A',
|
|
143
|
-
type: 'metric'
|
|
144
|
-
},
|
|
145
|
-
I2: {
|
|
146
|
-
name: 'auxbatteryCurrent',
|
|
147
|
-
path: 'electrical.batteries.*.current',
|
|
148
|
-
unitId: 'auxBatt',
|
|
149
|
-
value: common.mA,
|
|
150
|
-
units: 'A',
|
|
151
|
-
type: 'metric'
|
|
152
|
-
},
|
|
153
|
-
I3: {
|
|
154
|
-
name: 'aux2batteryCurrent',
|
|
155
|
-
path: 'electrical.batteries.*.current',
|
|
156
|
-
unitId: 'aux2Batt',
|
|
157
|
-
value: common.mA,
|
|
158
|
-
units: 'A',
|
|
159
|
-
type: 'metric'
|
|
160
|
-
},
|
|
161
|
-
IL: {
|
|
162
|
-
name: 'loadCurrent',
|
|
163
|
-
path: 'electrical.solar.*.loadCurrent',
|
|
164
|
-
unitId: 'solar',
|
|
165
|
-
value: common.mA,
|
|
166
|
-
units: 'A',
|
|
167
|
-
type: 'metric'
|
|
168
|
-
},
|
|
169
|
-
LOAD: {
|
|
170
|
-
name: 'loadOutputState',
|
|
171
|
-
path: 'electrical.solar.*.load',
|
|
172
|
-
unitId: 'solar',
|
|
173
|
-
type: 'text',
|
|
174
|
-
value (value) {
|
|
175
|
-
value = value.toLowerCase()
|
|
176
|
-
return value
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
T: {
|
|
180
|
-
name: 'batteryTemperature',
|
|
181
|
-
path: 'electrical.batteries.*.temperature',
|
|
182
|
-
unitId: 'mainBatt',
|
|
183
|
-
units: 'K',
|
|
184
|
-
type: 'metric',
|
|
185
|
-
value (value, instance) {
|
|
186
|
-
if (typeof value !== 'number') {
|
|
187
|
-
value = parseInt(value, 10)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (isNaN(value)) {
|
|
191
|
-
return null
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return (value + 273.15)
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
P: {
|
|
198
|
-
name: 'instantPower',
|
|
199
|
-
value: common.number,
|
|
200
|
-
units: 'W',
|
|
201
|
-
type: 'metric'
|
|
202
|
-
},
|
|
203
|
-
CE: {
|
|
204
|
-
name: 'consumedAh',
|
|
205
|
-
path: 'electrical.batteries.*.capacity.consumedCharge',
|
|
206
|
-
unitId: 'mainBatt',
|
|
207
|
-
value: common.mAh,
|
|
208
|
-
units: 'C',
|
|
209
|
-
type: 'metric'
|
|
210
|
-
},
|
|
211
|
-
SOC: {
|
|
212
|
-
name: 'stateOfCharge',
|
|
213
|
-
path: 'electrical.batteries.*.capacity.stateOfCharge',
|
|
214
|
-
unitId: 'mainBatt',
|
|
215
|
-
value: common.promille,
|
|
216
|
-
type: 'ratio'
|
|
217
|
-
},
|
|
218
|
-
TTG: {
|
|
219
|
-
name: 'timeToGo',
|
|
220
|
-
path: 'electrical.batteries.*.capacity.timeRemaining',
|
|
221
|
-
unitId: 'mainBatt',
|
|
222
|
-
value: value => {
|
|
223
|
-
value = common.number(value)
|
|
224
|
-
if (value === null) {
|
|
225
|
-
return null
|
|
226
|
-
}
|
|
227
|
-
// value is minutes
|
|
228
|
-
return value * 60
|
|
229
|
-
},
|
|
230
|
-
units: 's',
|
|
231
|
-
type: 'metric'
|
|
232
|
-
},
|
|
233
|
-
ALARM: {
|
|
234
|
-
name: 'alarm',
|
|
235
|
-
type: 'boolean',
|
|
236
|
-
value (value) {
|
|
237
|
-
value = value.toUpperCase()
|
|
238
|
-
return value === 'ON' ? 1 : 0
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
RELAY: {
|
|
242
|
-
name: 'relay',
|
|
243
|
-
type: 'boolean',
|
|
244
|
-
value (value) {
|
|
245
|
-
value = value.toUpperCase()
|
|
246
|
-
return value === 'ON' ? 1 : 0
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
AR: {
|
|
250
|
-
name: 'alarmReason',
|
|
251
|
-
type: 'text',
|
|
252
|
-
value (value, instance) {
|
|
253
|
-
return instance.getAlarmReason(value)
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
H1: {
|
|
257
|
-
name: 'depthOfDeepestDischarge',
|
|
258
|
-
value: common.mAh,
|
|
259
|
-
units: 'C',
|
|
260
|
-
type: 'metric'
|
|
261
|
-
},
|
|
262
|
-
H2: {
|
|
263
|
-
name: 'depthOfLastDischarge',
|
|
264
|
-
value: common.mAh,
|
|
265
|
-
units: 'C',
|
|
266
|
-
type: 'metric'
|
|
267
|
-
},
|
|
268
|
-
H3: {
|
|
269
|
-
name: 'depthOfAverageDischarge',
|
|
270
|
-
value: common.mAh,
|
|
271
|
-
units: 'C',
|
|
272
|
-
type: 'metric'
|
|
273
|
-
},
|
|
274
|
-
H4: {
|
|
275
|
-
name: 'numberOfChargeCycles',
|
|
276
|
-
value: common.number,
|
|
277
|
-
type: 'count'
|
|
278
|
-
},
|
|
279
|
-
H5: {
|
|
280
|
-
name: 'numberOfFullDischarges',
|
|
281
|
-
value: common.number,
|
|
282
|
-
type: 'count'
|
|
283
|
-
},
|
|
284
|
-
H6: {
|
|
285
|
-
name: 'cumulativeAhDrawn',
|
|
286
|
-
path: 'electrical.batteries.*.lifetimeDischarge',
|
|
287
|
-
unitId: 'mainBatt',
|
|
288
|
-
value: common.mAh,
|
|
289
|
-
units: 'C',
|
|
290
|
-
type: 'metric'
|
|
291
|
-
},
|
|
292
|
-
H7: {
|
|
293
|
-
name: 'minimumMainBattVoltage',
|
|
294
|
-
value: common.mV,
|
|
295
|
-
units: 'V',
|
|
296
|
-
type: 'metric'
|
|
297
|
-
},
|
|
298
|
-
H8: {
|
|
299
|
-
name: 'maximumMainBattVoltage',
|
|
300
|
-
value: common.mV,
|
|
301
|
-
units: 'V',
|
|
302
|
-
type: 'metric'
|
|
303
|
-
},
|
|
304
|
-
H9: {
|
|
305
|
-
name: 'secondsSinceLastFullCharge',
|
|
306
|
-
value: common.number,
|
|
307
|
-
units: 's',
|
|
308
|
-
type: 'metric'
|
|
309
|
-
},
|
|
310
|
-
H10: {
|
|
311
|
-
name: 'numberOfAutoSync',
|
|
312
|
-
value: common.number,
|
|
313
|
-
type: 'count'
|
|
314
|
-
},
|
|
315
|
-
H11: {
|
|
316
|
-
name: 'numberOfLowMainVoltageAlarms',
|
|
317
|
-
value: common.number,
|
|
318
|
-
type: 'count'
|
|
319
|
-
},
|
|
320
|
-
H12: {
|
|
321
|
-
name: 'numberOfHighMainVoltageAlarms',
|
|
322
|
-
value: common.number,
|
|
323
|
-
type: 'count'
|
|
324
|
-
},
|
|
325
|
-
H13: {
|
|
326
|
-
name: 'numberOfLowAuxVoltageAlarms',
|
|
327
|
-
value: common.number,
|
|
328
|
-
type: 'count'
|
|
329
|
-
},
|
|
330
|
-
H14: {
|
|
331
|
-
name: 'numberOfHighAuxVoltageAlarms',
|
|
332
|
-
value: common.number,
|
|
333
|
-
type: 'count'
|
|
334
|
-
},
|
|
335
|
-
H15: {
|
|
336
|
-
name: 'minimumAuxBattVoltage',
|
|
337
|
-
value: common.mV,
|
|
338
|
-
units: 'V',
|
|
339
|
-
type: 'metric'
|
|
340
|
-
},
|
|
341
|
-
H16: {
|
|
342
|
-
name: 'maximumAuxBattVoltage',
|
|
343
|
-
value: common.mV,
|
|
344
|
-
units: 'V',
|
|
345
|
-
type: 'metric'
|
|
346
|
-
},
|
|
347
|
-
H17: {
|
|
348
|
-
name: 'dischargedEnergy',
|
|
349
|
-
value: common.kWh,
|
|
350
|
-
units: 'J',
|
|
351
|
-
type: 'metric'
|
|
352
|
-
},
|
|
353
|
-
H18: {
|
|
354
|
-
name: 'chargedEnergy',
|
|
355
|
-
value: common.kWh,
|
|
356
|
-
units: 'J',
|
|
357
|
-
type: 'metric'
|
|
358
|
-
},
|
|
359
|
-
H19: {
|
|
360
|
-
name: 'yieldTotal',
|
|
361
|
-
path: 'electrical.solar.*.yieldTotal',
|
|
362
|
-
unitId: 'solar',
|
|
363
|
-
value: common.kWh,
|
|
364
|
-
units: 'J',
|
|
365
|
-
type: 'metric'
|
|
366
|
-
},
|
|
367
|
-
H20: {
|
|
368
|
-
name: 'yieldToday',
|
|
369
|
-
path: 'electrical.solar.*.yieldToday',
|
|
370
|
-
unitId: 'solar',
|
|
371
|
-
value: common.kWh,
|
|
372
|
-
units: 'J',
|
|
373
|
-
type: 'metric'
|
|
374
|
-
},
|
|
375
|
-
H21: {
|
|
376
|
-
name: 'maximumPowerToday',
|
|
377
|
-
path: 'electrical.solar.*.maximumPowerToday',
|
|
378
|
-
unitId: 'solar',
|
|
379
|
-
value: common.number,
|
|
380
|
-
units: 'W',
|
|
381
|
-
type: 'metric'
|
|
382
|
-
},
|
|
383
|
-
H22: {
|
|
384
|
-
name: 'yieldYesterday',
|
|
385
|
-
path: 'electrical.solar.*.yieldYesterday',
|
|
386
|
-
unitId: 'solar',
|
|
387
|
-
value: common.kWh,
|
|
388
|
-
units: 'J',
|
|
389
|
-
type: 'metric'
|
|
390
|
-
},
|
|
391
|
-
H23: {
|
|
392
|
-
name: 'maximumPowerYesterday',
|
|
393
|
-
path: 'electrical.solar.*.maximumPowerYesterday',
|
|
394
|
-
unitId: 'solar',
|
|
395
|
-
value: common.number,
|
|
396
|
-
units: 'W',
|
|
397
|
-
type: 'metric'
|
|
398
|
-
},
|
|
399
|
-
ERR: {
|
|
400
|
-
name: 'errorCode',
|
|
401
|
-
path: 'electrical.batteries.*.errorCode',
|
|
402
|
-
unitId: 'mainBatt',
|
|
403
|
-
type: 'text',
|
|
404
|
-
value (value, instance) {
|
|
405
|
-
return instance.getErrorString(value)
|
|
406
|
-
}
|
|
407
|
-
},
|
|
408
|
-
CS: {
|
|
409
|
-
name: 'stateOfOperation',
|
|
410
|
-
path: 'electrical.charger.*.chargingMode',
|
|
411
|
-
unitId: 'mainBatt',
|
|
412
|
-
type: 'text',
|
|
413
|
-
value (value, instance) {
|
|
414
|
-
return instance.getStateOfOperation(value)
|
|
415
|
-
}
|
|
416
|
-
},
|
|
417
|
-
FW: {
|
|
418
|
-
name: 'firmwareVersion',
|
|
419
|
-
type: 'text'
|
|
420
|
-
},
|
|
421
|
-
PID: {
|
|
422
|
-
name: 'productId',
|
|
423
|
-
value (value, instance) {
|
|
424
|
-
value = String(value)
|
|
425
|
-
if (!value.includes('0x')) {
|
|
426
|
-
value = `0x${value}`
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
instance.set('productId', { name: 'productId', value })
|
|
430
|
-
instance.set('productName', { name: 'productId', value: instance.getProductLongname(value) })
|
|
431
|
-
return null
|
|
432
|
-
}
|
|
433
|
-
},
|
|
434
|
-
'SER#': {
|
|
435
|
-
name: 'serialNumber',
|
|
436
|
-
type: 'text'
|
|
437
|
-
},
|
|
438
|
-
HSDS: {
|
|
439
|
-
name: 'daySequenceNumber',
|
|
440
|
-
value: common.number,
|
|
441
|
-
type: 'count'
|
|
442
|
-
},
|
|
443
|
-
MODE: {
|
|
444
|
-
name: 'deviceMode',
|
|
445
|
-
type: 'text',
|
|
446
|
-
value (value, instance) {
|
|
447
|
-
return instance.getMode(value)
|
|
448
|
-
}
|
|
449
|
-
},
|
|
450
|
-
AC_OUT_V: {
|
|
451
|
-
name: 'acOutputVoltage',
|
|
452
|
-
path: 'electrical.ac.*.phase.A.lineLineVoltage',
|
|
453
|
-
unitId: 'inverter',
|
|
454
|
-
units: 'V',
|
|
455
|
-
type: 'metric',
|
|
456
|
-
value (value, instance) {
|
|
457
|
-
value = common.number(value)
|
|
458
|
-
|
|
459
|
-
if (value === null) {
|
|
460
|
-
return
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// AC OUT V is reported in units of 0.01 V each.
|
|
464
|
-
return value / 100
|
|
465
|
-
}
|
|
466
|
-
},
|
|
467
|
-
AC_OUT_I: {
|
|
468
|
-
name: 'acOutputCurrent',
|
|
469
|
-
path: 'electrical.ac.*.phase.A.current',
|
|
470
|
-
unitId: 'inverter',
|
|
471
|
-
units: 'A',
|
|
472
|
-
type: 'metric',
|
|
473
|
-
value (value, instance) {
|
|
474
|
-
value = common.number(value)
|
|
475
|
-
|
|
476
|
-
if (value === null) {
|
|
477
|
-
return
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// AC OUT I is reported in units of 0.1 A each.
|
|
481
|
-
return value / 10
|
|
482
|
-
}
|
|
483
|
-
},
|
|
484
|
-
WARN: {
|
|
485
|
-
name: 'warningReason',
|
|
486
|
-
type: 'text'
|
|
487
|
-
},
|
|
488
|
-
BMV: {
|
|
489
|
-
name: 'batteryMonitorName',
|
|
490
|
-
type: 'text'
|
|
491
|
-
},
|
|
492
|
-
MPPT: {
|
|
493
|
-
name: 'trackerOperationMode',
|
|
494
|
-
path: 'electrical.solar.*.trackerOperationMode',
|
|
495
|
-
unitId: 'solar',
|
|
496
|
-
type: 'text',
|
|
497
|
-
value (value, instance) {
|
|
498
|
-
return instance.getTrackerOperationMode(value)
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
}
|
package/lib/filestream.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const debug = require('debug')('signalk-vedirect-parser')
|
|
3
|
-
let port = null
|
|
4
|
-
|
|
5
|
-
exports.open = function openFileStream (path, parser) {
|
|
6
|
-
if (port !== null) {
|
|
7
|
-
try {
|
|
8
|
-
port.close()
|
|
9
|
-
port = null
|
|
10
|
-
} catch (e) {}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
port = fs.createReadStream(path, 'ascii')
|
|
14
|
-
|
|
15
|
-
port.on('data', chunk => {
|
|
16
|
-
if (Buffer.isBuffer(chunk)) {
|
|
17
|
-
chunk = chunk.toString('ascii')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
parser.addChunk(chunk)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
// @NOTE FT: should we implement reconenct/back-off code like TCP wrappers?
|
|
24
|
-
// I assume the serial port only closes if the physical line is broken/disconnected?
|
|
25
|
-
|
|
26
|
-
port.on('error', err => {
|
|
27
|
-
debug('file stream error: ' + err.message)
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.close = function (device) {
|
|
32
|
-
if (port !== null) {
|
|
33
|
-
try {
|
|
34
|
-
port.close()
|
|
35
|
-
port = null
|
|
36
|
-
} catch (e) {}
|
|
37
|
-
}
|
|
38
|
-
}
|
package/lib/productIds.json
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"0x203": "BMV-700",
|
|
3
|
-
"0x204": "BMV-702",
|
|
4
|
-
"0x205": "BMV-700H",
|
|
5
|
-
"0x300": "BlueSolar MPPT 70/15",
|
|
6
|
-
"0xA040": "BlueSolar MPPT 75/50",
|
|
7
|
-
"0xA041": "BlueSolar MPPT 150/35",
|
|
8
|
-
"0xA042": "BlueSolar MPPT 75/15",
|
|
9
|
-
"0xA043": "BlueSolar MPPT 100/15",
|
|
10
|
-
"0xA044": "BlueSolar MPPT 100/30",
|
|
11
|
-
"0xA045": "BlueSolar MPPT 100/50",
|
|
12
|
-
"0xA046": "BlueSolar MPPT 150/70",
|
|
13
|
-
"0xA047": "BlueSolar MPPT 150/100",
|
|
14
|
-
"0xA049": "BlueSolar MPPT 100/50 rev2",
|
|
15
|
-
"0xA04A": "BlueSolar MPPT 100/30 rev2",
|
|
16
|
-
"0xA04B": "BlueSolar MPPT 150/35 rev2",
|
|
17
|
-
"0xA04C": "BlueSolar MPPT 75/10",
|
|
18
|
-
"0xA04D": "BlueSolar MPPT 150/45",
|
|
19
|
-
"0xA04E": "BlueSolar MPPT 150/60",
|
|
20
|
-
"0xA04F": "BlueSolar MPPT 150/85",
|
|
21
|
-
"0xA050": "SmartSolar MPPT 250/100",
|
|
22
|
-
"0xA051": "SmartSolar MPPT 150/100*",
|
|
23
|
-
"0xA052": "SmartSolar MPPT 150/85*",
|
|
24
|
-
"0xA053": "SmartSolar MPPT 75/15",
|
|
25
|
-
"0xA054": "SmartSolar MPPT 75/10",
|
|
26
|
-
"0xA055": "SmartSolar MPPT 100/15",
|
|
27
|
-
"0xA056": "SmartSolar MPPT 100/30",
|
|
28
|
-
"0xA057": "SmartSolar MPPT 100/50",
|
|
29
|
-
"0xA058": "SmartSolar MPPT 150/35",
|
|
30
|
-
"0xA059": "SmartSolar MPPT 150/100 rev2",
|
|
31
|
-
"0xA05A": "SmartSolar MPPT 150/85 rev2",
|
|
32
|
-
"0xA05B": "SmartSolar MPPT 250/70",
|
|
33
|
-
"0xA05C": "SmartSolar MPPT 250/85",
|
|
34
|
-
"0xA05D": "SmartSolar MPPT 250/60",
|
|
35
|
-
"0xA05E": "SmartSolar MPPT 250/45",
|
|
36
|
-
"0xA05F": "SmartSolar MPPT 100/20",
|
|
37
|
-
"0xA060": "SmartSolar MPPT 100/20 48V",
|
|
38
|
-
"0xA061": "SmartSolar MPPT 150/45",
|
|
39
|
-
"0xA062": "SmartSolar MPPT 150/60",
|
|
40
|
-
"0xA063": "SmartSolar MPPT 150/70",
|
|
41
|
-
"0xA064": "SmartSolar MPPT 250/85 rev2",
|
|
42
|
-
"0xA065": "SmartSolar MPPT 250/100 rev2",
|
|
43
|
-
"0xA201": "Phoenix Inverter 12V 250VA 230V*",
|
|
44
|
-
"0xA202": "Phoenix Inverter 24V 250VA 230V*",
|
|
45
|
-
"0xA204": "Phoenix Inverter 48V 250VA 230V*",
|
|
46
|
-
"0xA211": "Phoenix Inverter 12V 375VA 230V*",
|
|
47
|
-
"0xA212": "Phoenix Inverter 24V 375VA 230V*",
|
|
48
|
-
"0xA214": "Phoenix Inverter 48V 375VA 230V*",
|
|
49
|
-
"0xA221": "Phoenix Inverter 12V 500VA 230V*",
|
|
50
|
-
"0xA222": "Phoenix Inverter 24V 500VA 230V*",
|
|
51
|
-
"0xA224": "Phoenix Inverter 48V 500VA 230V*",
|
|
52
|
-
"0xA231": "Phoenix Inverter 12V 250VA 230V",
|
|
53
|
-
"0xA232": "Phoenix Inverter 24V 250VA 230V",
|
|
54
|
-
"0xA234": "Phoenix Inverter 48V 250VA 230V",
|
|
55
|
-
"0xA239": "Phoenix Inverter 12V 250VA 120V",
|
|
56
|
-
"0xA23A": "Phoenix Inverter 24V 250VA 120V",
|
|
57
|
-
"0xA23C": "Phoenix Inverter 48V 250VA 120V",
|
|
58
|
-
"0xA241": "Phoenix Inverter 12V 375VA 230V",
|
|
59
|
-
"0xA242": "Phoenix Inverter 24V 375VA 230V",
|
|
60
|
-
"0xA244": "Phoenix Inverter 48V 375VA 230V",
|
|
61
|
-
"0xA249": "Phoenix Inverter 12V 375VA 120V",
|
|
62
|
-
"0xA24A": "Phoenix Inverter 24V 375VA 120V",
|
|
63
|
-
"0xA24C": "Phoenix Inverter 48V 375VA 120V",
|
|
64
|
-
"0xA251": "Phoenix Inverter 12V 500VA 230V",
|
|
65
|
-
"0xA252": "Phoenix Inverter 24V 500VA 230V",
|
|
66
|
-
"0xA254": "Phoenix Inverter 48V 500VA 230V",
|
|
67
|
-
"0xA259": "Phoenix Inverter 12V 500VA 120V",
|
|
68
|
-
"0xA25A": "Phoenix Inverter 24V 500VA 120V",
|
|
69
|
-
"0xA25C": "Phoenix Inverter 48V 500VA 120V",
|
|
70
|
-
"0xA261": "Phoenix Inverter 12V 800VA 230V",
|
|
71
|
-
"0xA262": "Phoenix Inverter 24V 800VA 230V",
|
|
72
|
-
"0xA264": "Phoenix Inverter 48V 800VA 230V",
|
|
73
|
-
"0xA269": "Phoenix Inverter 12V 800VA 120V",
|
|
74
|
-
"0xA26A": "Phoenix Inverter 24V 800VA 120V",
|
|
75
|
-
"0xA26C": "Phoenix Inverter 48V 800VA 120V",
|
|
76
|
-
"0xA271": "Phoenix Inverter 12V 1200VA 230V",
|
|
77
|
-
"0xA272": "Phoenix Inverter 24V 1200VA 230V",
|
|
78
|
-
"0xA274": "Phoenix Inverter 48V 1200VA 230V",
|
|
79
|
-
"0xA279": "Phoenix Inverter 12V 1200VA 120V",
|
|
80
|
-
"0xA27A": "Phoenix Inverter 24V 1200VA 120V",
|
|
81
|
-
"0xA27C": "Phoenix Inverter 48V 1200VA 120V",
|
|
82
|
-
"0xA345": "Phoenix Smart Charger 12V 30A 3 rev2",
|
|
83
|
-
"0xA381": "BMV-712 Smart"
|
|
84
|
-
}
|
package/lib/serial.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const { SerialPort } = require('serialport')
|
|
2
|
-
const { DelimiterParser } = require('@serialport/parser-delimiter')
|
|
3
|
-
let port = []
|
|
4
|
-
let delim = []
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
open: (device, parser, debug, items) => {
|
|
8
|
-
if (typeof port[items] !== 'undefined' ) {
|
|
9
|
-
try {
|
|
10
|
-
port[items].close()
|
|
11
|
-
port[items] = undefined
|
|
12
|
-
} catch (e) {}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
debug(`Serial: connecting to ${device}`)
|
|
16
|
-
|
|
17
|
-
port[items] = new SerialPort({ path: device, baudRate: 19200 }) // @NOTE FT: should this be configurable?
|
|
18
|
-
|
|
19
|
-
port[items].on('open', function() {
|
|
20
|
-
debug(`Connected to ${device}`)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
port[items].on('data', chunk => {
|
|
24
|
-
debug(`${chunk}`)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
delim[items] = port[items].pipe(new DelimiterParser({ delimiter: '\r', includeDelimiter: true }))
|
|
28
|
-
|
|
29
|
-
delim[items].on('data', chunk => {
|
|
30
|
-
// Chunk is a node.js Buffer
|
|
31
|
-
parser[items].addChunk(chunk, items)
|
|
32
|
-
debug(`${chunk}`)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
port[items].on('error', err => {
|
|
36
|
-
debug(`SerialPort error: ` + err.message)
|
|
37
|
-
})
|
|
38
|
-
},
|
|
39
|
-
close: (debug, items) => {
|
|
40
|
-
if (port[items]) {
|
|
41
|
-
try {
|
|
42
|
-
port[items].close()
|
|
43
|
-
port[items] = undefined
|
|
44
|
-
debug(`Serial port closed`);
|
|
45
|
-
} catch (e) {}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
package/lib/tcp.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const Net = require('net');
|
|
2
|
-
let client = [];
|
|
3
|
-
|
|
4
|
-
function makeConnection(host, port, debug, items) {
|
|
5
|
-
client[items] = new Net.Socket();
|
|
6
|
-
client[items].connect({ port: port, host: host });
|
|
7
|
-
debug(`Connection to ${host}:${port}`);
|
|
8
|
-
return client[items]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function onData(msg, parser, debug, items) {
|
|
12
|
-
parser[items].addChunk(msg, items);
|
|
13
|
-
debug(`${msg}`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function onClose(host, port, parser, debug, items) {
|
|
17
|
-
if(client[items]) {
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
debug('Trying to reconnect');
|
|
20
|
-
client[items].destroy();
|
|
21
|
-
module.exports.connect(host, port, parser, debug, items);
|
|
22
|
-
}, 10000)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
module.exports = {
|
|
27
|
-
connect: (host, port, parser, debug, items) => {
|
|
28
|
-
client[items] = makeConnection(host, port, debug, items);
|
|
29
|
-
client[items].on('data', (msg) => {
|
|
30
|
-
onData(msg, parser, debug, items);
|
|
31
|
-
});
|
|
32
|
-
client[items].on('close', () => {
|
|
33
|
-
debug('TCP connection closed');
|
|
34
|
-
onClose(host, port, parser, debug, items);
|
|
35
|
-
});
|
|
36
|
-
client[items].on('error', () => {
|
|
37
|
-
debug('TCP connection error');
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
close: (debug, items) => {
|
|
41
|
-
if (client[items]) {
|
|
42
|
-
client[items].destroy();
|
|
43
|
-
client[items] = null;
|
|
44
|
-
debug(`TCP port closed`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|