iobroker.e3oncan 0.6.9 → 0.6.10

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/README.md CHANGED
@@ -99,6 +99,9 @@ Yes, that is possible under certain conditions:
99
99
  Placeholder for the next version (at the beginning of the line):
100
100
  ### **WORK IN PROGRESS**
101
101
  -->
102
+ ### 0.6.10 (2024-01-15)
103
+ * (MyHomeMyData) Removed code for Rawmode because it's never activated
104
+
102
105
  ### 0.6.9 (2024-01-13)
103
106
  * (MyHomeMyData) Bugfix: Only Linux is supported
104
107
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "e3oncan",
4
- "version": "0.6.9",
4
+ "version": "0.6.10",
5
5
  "news": {
6
+ "0.6.10": {
7
+ "en": "Removed code for Rawmode because it's never activated",
8
+ "de": "Entfernter Code für Rawmode, weil es nie aktiviert ist",
9
+ "ru": "Удаленный код для Rawmode, потому что он никогда не активирован",
10
+ "pt": "Código removido para Rawmode porque nunca foi ativado",
11
+ "nl": "Verwijderde code voor Rawmode omdat het nooit is geactiveerd",
12
+ "fr": "Code supprimé pour Rawmode car il n'est jamais activé",
13
+ "it": "Codice rimosso per Rawmode perché non è mai attivato",
14
+ "es": "Código eliminado para Rawmode porque nunca se activa",
15
+ "pl": "Usunięto kod dla Rawmode ponieważ nigdy nie jest aktywowany",
16
+ "uk": "Видалити код для Rawmode, тому що він ніколи не активований",
17
+ "zh-cn": "删除了Rawmode的代码,因为它从未被激活"
18
+ },
6
19
  "0.6.9": {
7
20
  "en": "Bugfix: Only Linux is supported",
8
21
  "de": "Bugfix: Nur Linux wird unterstützt",
package/lib/canUds.js CHANGED
@@ -43,7 +43,6 @@ class uds {
43
43
  this.config.worker = 'uds';
44
44
  this.storage = new storage.storage(this.config);
45
45
  this.states = ['standby','waitForFFrbd','waitForCFrbd','waitForFFSFwbd','waitForFFMFwbd'];
46
- this.frameFC = [0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00];
47
46
  this.readByDidProt = {
48
47
  'idTx' : this.config.canID,
49
48
  'idRx' : Number(this.config.canID) + 0x10,
@@ -576,7 +575,7 @@ class uds {
576
575
  ctx.log.silly('UDS worker on '+this.config.stateBase+': FF received. candata: '+this.storage.arr2Hex(candata));
577
576
  this.data.databytes = candata.slice(5);
578
577
  this.data.D0 = 0x21;
579
- this.sendFrame(ctx, this.frameFC); // Send request for Consecutive Frames
578
+ this.sendFrame(ctx, this.readByDidProt.FC); // Send request for Consecutive Frames
580
579
  await this.setComState(2); // 'waitForCFrbd'
581
580
  break;
582
581
  } else {
package/lib/codecs.js CHANGED
@@ -1,17 +1,3 @@
1
- class codecOpMode {
2
- constructor(raw=true) {
3
- this.raw = raw;
4
- }
5
-
6
- setOpMode(raw) {
7
- this.raw = raw;
8
- }
9
- getOpMode() {
10
- return this.raw;
11
- }
12
- }
13
-
14
- const rawmode = new codecOpMode(true);
15
1
 
16
2
  const enums = require('./enums');
17
3
 
@@ -124,20 +110,13 @@ class O3EInt {
124
110
  this.signed = _args.signed;
125
111
  }
126
112
  encode(data) {
127
- if (rawmode.getOpMode()) {
128
- return RawEncode(data, this.string_len);
129
- } else {
130
- if (this.offset != 0) {
131
- throw new Error('O3EInt.encode(): offset!=0 not implemented yet');
132
- }
133
- return val2byteArr(data, this.byte_width, this.scale, this.signed);
113
+ if (this.offset != 0) {
114
+ throw new Error('O3EInt.encode(): offset!=0 not implemented yet');
134
115
  }
116
+ return val2byteArr(data, this.byte_width, this.scale, this.signed);
135
117
  }
136
118
 
137
119
  decode(data) {
138
- if (rawmode.getOpMode()) {
139
- return RawDecode(data);
140
- }
141
120
  return int2val(data.slice(this.offset,this.offset+this.byte_width), 0, this.signed) / this.scale;
142
121
  }
143
122
 
@@ -174,20 +153,13 @@ class O3EByteVal {
174
153
  this.offset = _args.offset;
175
154
  }
176
155
  encode(data) {
177
- if (rawmode.getOpMode()) {
178
- return RawEncode(data, this.string_len);
179
- } else {
180
- if (this.offset != 0) {
181
- throw new Error('O3EByteVal.encode(): offset!=0 not implemented yet');
182
- }
183
- return val2byteArr(data, this.string_len, 1, false);
156
+ if (this.offset != 0) {
157
+ throw new Error('O3EByteVal.encode(): offset!=0 not implemented yet');
184
158
  }
159
+ return val2byteArr(data, this.string_len, 1, false);
185
160
  }
186
161
 
187
162
  decode(string_bin) {
188
- if (rawmode.getOpMode()) {
189
- return RawDecode(string_bin);
190
- }
191
163
  let val = 0;
192
164
  for (let i = 0; i < this.string_len; i++) {
193
165
  val += string_bin[i + this.offset] << (i * 8);
@@ -207,17 +179,10 @@ class O3EBool {
207
179
  this.offset = _args.offset;
208
180
  }
209
181
  encode(data) {
210
- if (rawmode.getOpMode()) {
211
- return RawEncode(data, this.string_len);
212
- }
213
182
  return (data == 'off' ? 0 : 1);
214
- //throw new Error('O3EBool.encode(): not implemented yet');
215
183
  }
216
184
 
217
185
  decode(string_bin) {
218
- if (rawmode.getOpMode()) {
219
- return RawDecode(string_bin);
220
- }
221
186
  const val = string_bin[this.offset];
222
187
  return (val == 0 ? 'off' : 'on' );
223
188
  }
@@ -234,9 +199,6 @@ class O3EUtf8 {
234
199
  this.offset = _args.offset;
235
200
  }
236
201
  encode(data) {
237
- if (rawmode.getOpMode()) {
238
- return RawEncode(data, this.string_len);
239
- }
240
202
  const encoder = new TextEncoder();
241
203
  const result = Object.values(encoder.encode(data));
242
204
  if (result.length > this.string_len) throw new Error('O3EUtf8.encode() result too long: '+this.id+' - '+String(result.length)+' > '+String(this.string_len));
@@ -244,9 +206,6 @@ class O3EUtf8 {
244
206
 
245
207
  }
246
208
  decode(string_bin) {
247
- if (rawmode.getOpMode()) {
248
- return RawDecode(string_bin);
249
- }
250
209
  let mystr = '';
251
210
  for (let i=this.offset; i<this.offset+this.string_len;i++) { mystr += String.fromCharCode(string_bin[i]); }
252
211
  // eslint-disable-next-line no-control-regex
@@ -264,9 +223,6 @@ class O3ESoftVers {
264
223
  this.id = idStr;
265
224
  }
266
225
  encode(data) {
267
- if (rawmode.getOpMode()) {
268
- return RawEncode(data, this.string_len);
269
- }
270
226
  let result = [];
271
227
  const arr = data.split('.');
272
228
  for (const v of Object.values(arr)) result = result.concat(val2byteArr(v,2,1,false));
@@ -274,9 +230,6 @@ class O3ESoftVers {
274
230
  return result.concat(Array.from(Array(this.string_len-result.length), () => 0));
275
231
  }
276
232
  decode(string_bin) {
277
- if (rawmode.getOpMode()) {
278
- return RawDecode(string_bin);
279
- }
280
233
  const lstv = [];
281
234
  for (let i = 0; i < this.string_len; i += 2) {
282
235
  lstv.push(string_bin[i] + (string_bin[i+1] << 8));
@@ -294,16 +247,9 @@ class O3EMacAddr {
294
247
  this.id = idStr;
295
248
  }
296
249
  encode(data) {
297
- if (rawmode.getOpMode()) {
298
- return RawEncode(data, this.string_len);
299
- }
300
250
  return(data.split('-').map(function(str) {return parseInt('0x'+str);}));
301
-
302
251
  }
303
252
  decode(string_bin) {
304
- if (rawmode.getOpMode()) {
305
- return RawDecode(string_bin);
306
- }
307
253
  const lstv = [];
308
254
  for (let i = 0; i < this.string_len; i++) {
309
255
  lstv.push(toHex(string_bin[i],2).toUpperCase());
@@ -321,16 +267,9 @@ class O3EIp4Addr {
321
267
  this.id = idStr;
322
268
  }
323
269
  encode(data) {
324
- if (rawmode.getOpMode()) {
325
- return RawEncode(data, this.string_len);
326
- }
327
270
  return(data.split('.').map(function(str) {return parseInt(str);}));
328
-
329
271
  }
330
272
  decode(string_bin) {
331
- if (rawmode.getOpMode()) {
332
- return RawDecode(string_bin);
333
- }
334
273
  const lstv = [];
335
274
  for (let i = 0; i < this.string_len; i++) {
336
275
  lstv.push(string_bin[i].toString().padStart(3,'0'));
@@ -348,18 +287,12 @@ class O3ESdate {
348
287
  this.id = idStr;
349
288
  }
350
289
  encode(data) {
351
- if (rawmode.getOpMode()) {
352
- return RawEncode(data, this.string_len);
353
- }
354
290
  const dt = new Date(data);
355
291
  if (!dt.valueOf()) throw new Error('could not convert date value');
356
292
  return [dt.getDate(),dt.getMonth()+1,dt.getFullYear()%100];
357
293
 
358
294
  }
359
295
  decode(string_bin) {
360
- if (rawmode.getOpMode()) {
361
- return RawDecode(string_bin);
362
- }
363
296
  const dt = new Date(
364
297
  string_bin[2]+2000, // year
365
298
  string_bin[1]-1, // month
@@ -378,9 +311,6 @@ class O3EStime {
378
311
  this.id = idStr;
379
312
  }
380
313
  encode(data) {
381
- if (rawmode.getOpMode()) {
382
- return RawEncode(data, this.string_len);
383
- }
384
314
  if (this.string_len == 1) data += ':00'; // Date() needs at least hour:minute
385
315
  const now = new Date();
386
316
  const dt = new Date(now.toDateString()+' '+data);
@@ -390,9 +320,6 @@ class O3EStime {
390
320
 
391
321
  }
392
322
  decode(string_bin) {
393
- if (rawmode.getOpMode()) {
394
- return RawDecode(string_bin);
395
- }
396
323
  const now = new Date();
397
324
  const dt = new Date(now.getFullYear(), now.getMonth(), now.getDate(),
398
325
  string_bin[0], // hour
@@ -413,9 +340,6 @@ class O3EDateTime {
413
340
  this.timeformat = _args.timeformat;
414
341
  }
415
342
  encode(data) {
416
- if (rawmode.getOpMode()) {
417
- return RawEncode(data, this.string_len);
418
- }
419
343
  if (this.timeformat == 'VM') {
420
344
  const dt = new Date(data.Timestamp);
421
345
  if (!dt.valueOf()) throw new Error('could not convert datetime value');
@@ -428,9 +352,6 @@ class O3EDateTime {
428
352
 
429
353
  }
430
354
  decode(string_bin) {
431
- if (rawmode.getOpMode()) {
432
- return RawDecode(string_bin);
433
- }
434
355
  let dt = new Date();
435
356
  if (this.timeformat == 'VM') {
436
357
  dt = new Date(
@@ -460,18 +381,12 @@ class O3EUtc {
460
381
  this.id = idStr;
461
382
  }
462
383
  encode(data) {
463
- if (rawmode.getOpMode()) {
464
- return RawEncode(data, this.string_len);
465
- }
466
384
  const dt = new Date(data);
467
385
  if (!dt) throw new Error('could not convert Utc date value');
468
386
  return val2byteArr(dt.getTime(),this.string_len,0.001,false);
469
387
 
470
388
  }
471
389
  decode(string_bin) {
472
- if (rawmode.getOpMode()) {
473
- return RawDecode(string_bin);
474
- }
475
390
  const dt = new Date(uint32toVal(string_bin.slice(0,4),0)*1000);
476
391
  return dt.toUTCString();
477
392
  }
@@ -487,16 +402,9 @@ class O3EEnum {
487
402
  this.listStr = _args.listStr;
488
403
  }
489
404
  encode(data) {
490
- if (rawmode.getOpMode()) {
491
- return RawEncode(data, this.string_len);
492
- }
493
405
  return val2byteArr(data.ID, this.string_len, 1, false);
494
-
495
406
  }
496
407
  decode(string_bin) {
497
- if (rawmode.getOpMode()) {
498
- return RawDecode(string_bin);
499
- }
500
408
  const val = int2val(string_bin);
501
409
  let txt = '';
502
410
  if ( (this.listStr in enums.enums) && (String(val) in enums.enums[this.listStr]) ) {
@@ -519,9 +427,6 @@ class O3EList {
519
427
  this.subTypes = _args.subTypes;
520
428
  }
521
429
  encode(data) {
522
- if (rawmode.getOpMode()) {
523
- return RawEncode(data, this.string_len);
524
- }
525
430
  let result = [];
526
431
  for (const cdi of Object.values(this.subTypes)) {
527
432
  const subT = new O3Ecodecs[cdi.codec](cdi.len, cdi.id, cdi.args);
@@ -539,9 +444,6 @@ class O3EList {
539
444
  return result.concat(Array.from(Array(this.string_len-result.length), () => 0));
540
445
  }
541
446
  decode(string_bin) {
542
- if (rawmode.getOpMode()) {
543
- return RawDecode(string_bin);
544
- }
545
447
  const result = {};
546
448
  let index = 0;
547
449
  let count = 0;
@@ -583,16 +485,10 @@ class O3EArray {
583
485
  this.subTypes = _args.subTypes;
584
486
  this.len = _args.arrayLength;
585
487
  }
586
- encode(data) {
587
- if (rawmode.getOpMode()) {
588
- return RawEncode(data, this.string_len);
589
- }
488
+ encode(_data) {
590
489
  throw new Error('not implemented yet');
591
490
  }
592
491
  decode(string_bin) {
593
- if (rawmode.getOpMode()) {
594
- return RawDecode(string_bin);
595
- }
596
492
  const result = {};
597
493
  let index = 0;
598
494
  const count = this.len;
@@ -618,10 +514,6 @@ class O3EComplexType {
618
514
  this.subTypes = _args.subTypes;
619
515
  }
620
516
  encode(data) {
621
- if (rawmode.getOpMode()) {
622
- return RawEncode(data, this.string_len);
623
- }
624
-
625
517
  let result = [];
626
518
  for (const cdi of Object.values(this.subTypes)) {
627
519
  const subT = new O3Ecodecs[cdi.codec](cdi.len, cdi.id, cdi.args);
@@ -631,9 +523,6 @@ class O3EComplexType {
631
523
  return result.concat(Array.from(Array(this.string_len-result.length), () => 0));
632
524
  }
633
525
  decode(string_bin) {
634
- if (rawmode.getOpMode()) {
635
- return RawDecode(string_bin);
636
- }
637
526
  const result = {};
638
527
  let index = 0;
639
528
  for (const cdi of Object.values(this.subTypes)) {
@@ -655,18 +544,11 @@ class O3EcosPhi {
655
544
  this.offset = _args.offset;
656
545
  this.scale = _args.scale;
657
546
  }
658
- encode(data) {
659
- if (rawmode.getOpMode()) {
660
- return RawEncode(data, this.string_len);
661
- } else {
662
- throw new Error('not implemented yet');
663
- }
547
+ encode(_data) {
548
+ throw new Error('not implemented yet');
664
549
  }
665
550
 
666
551
  decode(string_bin) {
667
- if (rawmode.getOpMode()) {
668
- return RawDecode(string_bin);
669
- }
670
552
  let val = string_bin[1+this.offset];
671
553
  if (string_bin[this.offset] == 0x04) {
672
554
  val = -1.0*val;
@@ -704,6 +586,5 @@ const O3Ecodecs = {
704
586
  module.exports = {
705
587
  O3Ecodecs,
706
588
  arr2Hex,
707
- toByteArray,
708
- rawmode
589
+ toByteArray
709
590
  };
package/main.js CHANGED
@@ -12,7 +12,6 @@ const utils = require('@iobroker/adapter-core');
12
12
  // const fs = require("fs");
13
13
 
14
14
  const can = require('socketcan');
15
- const codecs = require('./lib/codecs');
16
15
  const storage = require('./lib/storage');
17
16
  const collect = require('./lib/canCollect');
18
17
  const uds = require('./lib/canUds');
@@ -81,8 +80,6 @@ class E3oncan extends utils.Adapter {
81
80
  this.udsDevStateNames.push(dev.devStateName);
82
81
  }
83
82
 
84
- codecs.rawmode.setOpMode(false);
85
-
86
83
  // Check for required scan for UDS devices
87
84
  this.doUdsDevScan = (this.config.tableUdsDevices.length == 0);
88
85
  if (this.doUdsDevScan) await this.log.info('UDS device scan is required.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.e3oncan",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "description": "Collect data on CAN bus for Viessmann E3 devices, e.g. Vitocal, Vitocharge, Energy Meter E380",
5
5
  "author": {
6
6
  "name": "Juergen",