optolink-bridge 1.0.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/.editorconfig +10 -0
- package/.gitattributes +4 -0
- package/.vscode/extensions.json +5 -0
- package/.vscode/settings.json +11 -0
- package/.yarn/sdks/integrations.yml +5 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +13 -0
- package/README.md +429 -0
- package/config.toml +292 -0
- package/discovery.js +74 -0
- package/docs/device_list.pdf +0 -0
- package/docs/intercept-mode.png +0 -0
- package/docs/logo.png +0 -0
- package/docs/packet-flow.png +0 -0
- package/docs/pass-through-mode.png +0 -0
- package/docs/raspberry-pi-cp2102.png +0 -0
- package/index.js +317 -0
- package/package.json +63 -0
- package/parse_vs2.js +249 -0
- package/serial.js +88 -0
- package/tools/analyze_trace.js +486 -0
- package/tools/analyze_trace_example.txt +671 -0
- package/tools/convert_data_points.js +86 -0
- package/tools/convert_data_points_example.txt +3198 -0
- package/tools/convert_poll_items.js +91 -0
- package/tools/convert_poll_items_example.txt +42 -0
- package/utils.js +141 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Use this script to convert data points in the "InsideViessmann" / "DP_Listen.zip" format into a optolink-bridge data points format.
|
|
3
|
+
*
|
|
4
|
+
* See 'convert_data_points_example.txt' and use the filename as an input to this script:
|
|
5
|
+
*
|
|
6
|
+
* yarn node convert_data_points.js convert_data_points_example.txt
|
|
7
|
+
*
|
|
8
|
+
* Input data format from:
|
|
9
|
+
*
|
|
10
|
+
* https://github.com/sarnau/InsideViessmannVitosoft
|
|
11
|
+
* https://github.com/philippoo66/ViessData21/blob/master/DP_Listen_2.zip
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import fs from 'node:fs/promises';
|
|
15
|
+
import readline from 'node:readline';
|
|
16
|
+
import { basename } from 'node:path';
|
|
17
|
+
import { exists } from '../utils.js';
|
|
18
|
+
import { snakeCase } from 'change-case';
|
|
19
|
+
|
|
20
|
+
let warnings = [];
|
|
21
|
+
const path = process.argv[2];
|
|
22
|
+
if (!path || !(await exists(path))) {
|
|
23
|
+
console.error(`Usage: ${basename(process.argv[1])} <dps-file>`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const file = await fs.open(path, 'r');
|
|
28
|
+
const lines = readline.createInterface({
|
|
29
|
+
input: file.createReadStream(),
|
|
30
|
+
crlfDelay: Infinity,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const addrs = new Set(), names = new Set();
|
|
34
|
+
for await (let line of lines) {
|
|
35
|
+
var match = /-\s*(?:\([a-f\d]+\)\s*)?(.*?) \(.*?(0x[a-f\d]{4}).*?\((.*?)\)/i.exec(line);
|
|
36
|
+
if (!match) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let [, name, addr, type] = match;
|
|
41
|
+
|
|
42
|
+
if (addrs.has(addr)) {
|
|
43
|
+
continue; // duplicate address, sometimes addresses are repeated in order to e.g. describe that they also contain a status bit
|
|
44
|
+
} addrs.add(addr);
|
|
45
|
+
|
|
46
|
+
name = snakeCase(name);
|
|
47
|
+
for (let orgName = name, i = 2; names.has(name); name = `${orgName} ${i}`, i++) {}
|
|
48
|
+
names.add(name);
|
|
49
|
+
|
|
50
|
+
switch (type) {
|
|
51
|
+
case 'Array':
|
|
52
|
+
type = 'raw';
|
|
53
|
+
break;
|
|
54
|
+
case 'String':
|
|
55
|
+
type = 'utf8';
|
|
56
|
+
break;
|
|
57
|
+
case 'Byte':
|
|
58
|
+
type = 'raw';
|
|
59
|
+
break;
|
|
60
|
+
case 'Int': case 'Int4':
|
|
61
|
+
type = 'uint';
|
|
62
|
+
break;
|
|
63
|
+
case 'SByte': case 'SInt': case 'SInt4':
|
|
64
|
+
type = 'int';
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
warnings.push(`Unknown type "${type}" for attribute "${name}", using "raw" instead`);
|
|
68
|
+
type = 'raw';
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log(` ["${name}", ${addr}, "${type}"],`)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
await file.close();
|
|
77
|
+
} catch {
|
|
78
|
+
// nothing to do here
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (warnings.length) {
|
|
82
|
+
console.log();
|
|
83
|
+
for (const warning of warnings) {
|
|
84
|
+
console.warn(warning);
|
|
85
|
+
}
|
|
86
|
+
}
|