aes70 1.5.2 → 1.5.4
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/.prettierignore +5 -0
- package/.prettierrc +4 -0
- package/Changelog +4 -0
- package/README.md +7 -7
- package/bin/printDevice.js +149 -39
- package/dist/AES70.es5.js +1 -1
- package/package.json +5 -7
- package/src/OCP1/IEncoder.d.ts +26 -0
- package/src/OCP1.js +162 -162
- package/src/bigint.js +0 -1
- package/src/connection.js +28 -50
- package/src/events.js +9 -17
- package/src/types/Enum.js +4 -0
- package/src/utf8.js +11 -15
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/Changelog
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes and version updates will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.5.3] - 2024-06-29
|
|
6
|
+
|
|
7
|
+
- Fixed an error in keepalive handling and timeout detection.
|
|
8
|
+
|
|
5
9
|
## [1.5.2] - 2023-10-17
|
|
6
10
|
|
|
7
11
|
- Fixed an error in how duplicate role names were handled in get_role_map()
|
package/README.md
CHANGED
|
@@ -9,11 +9,11 @@ be used to build AES70 devices.
|
|
|
9
9
|
|
|
10
10
|
# Contents
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
- [AES70](#aes70)
|
|
13
|
+
- [Basics](#basics)
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Getting started](#getting-started)
|
|
16
|
+
- [License](#license)
|
|
17
17
|
|
|
18
18
|
# AES70
|
|
19
19
|
|
|
@@ -68,7 +68,7 @@ file `dist/AES70.es5.js`. To build this file run
|
|
|
68
68
|
npm ci
|
|
69
69
|
make dist/AES70.es5.js
|
|
70
70
|
|
|
71
|
-
Alternatively, the version of AES70 published to NPM already contains the
|
|
71
|
+
Alternatively, the version of AES70 published to NPM already contains the
|
|
72
72
|
generated source file. After installing `aes70` using NPM a version of AES70.js
|
|
73
73
|
for the browser will be at `node_modules/aes70/dist/AES70.es5.js`.
|
|
74
74
|
|
|
@@ -163,7 +163,7 @@ A full working example:
|
|
|
163
163
|
|
|
164
164
|
The tree returned by `RemoteDevice.get_device_tree` returns all objects of the
|
|
165
165
|
device below the root block. They represent all objects defined inside of the
|
|
166
|
-
AES70 device aside from the manager objects.
|
|
166
|
+
AES70 device aside from the manager objects.
|
|
167
167
|
|
|
168
168
|
# Documentation
|
|
169
169
|
|
package/bin/printDevice.js
CHANGED
|
@@ -3,67 +3,180 @@
|
|
|
3
3
|
import { argv, exit } from 'process';
|
|
4
4
|
import { RemoteDevice } from '../src/controller/remote_device.js';
|
|
5
5
|
import { TCPConnection } from '../src/controller/tcp_connection.js';
|
|
6
|
+
import { OcaBlock } from '../src/controller/ControlClasses/OcaBlock.js';
|
|
7
|
+
import { Arguments } from '../src/controller/arguments.js';
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
console.log('Usage: node print_tree.js <ip> <port>');
|
|
9
|
+
function badArguments() {
|
|
10
|
+
console.log('Usage: node print_tree.js [--json] <ip> <port>');
|
|
10
11
|
exit(1);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
const
|
|
14
|
+
let jsonMode = false;
|
|
15
|
+
const rest = [];
|
|
16
|
+
|
|
17
|
+
argv.slice(2).forEach((option) => {
|
|
18
|
+
switch (option) {
|
|
19
|
+
case '--json':
|
|
20
|
+
jsonMode = true;
|
|
21
|
+
break;
|
|
22
|
+
case '-h':
|
|
23
|
+
case '--help':
|
|
24
|
+
badArguments();
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
rest.push(option);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (rest.length < 2) badArguments();
|
|
33
|
+
|
|
34
|
+
const host = rest[0];
|
|
35
|
+
const port = parseInt(rest[1]);
|
|
36
|
+
|
|
37
|
+
if (!(port > 0 && port <= 0xffff)) badArguments();
|
|
38
|
+
|
|
39
|
+
function formatPropertyValue(name, value) {
|
|
40
|
+
if (typeof value === 'object') {
|
|
41
|
+
if (value instanceof Arguments) {
|
|
42
|
+
return {
|
|
43
|
+
[name]: value.item(0),
|
|
44
|
+
['min' + name]: value.item(1),
|
|
45
|
+
['max' + name]: value.item(2),
|
|
46
|
+
};
|
|
47
|
+
} else if (value !== null && value.isEnum) {
|
|
48
|
+
value = value.name;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
[name]: value,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
15
56
|
|
|
16
57
|
TCPConnection.connect({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.then(function(connection) {
|
|
58
|
+
host: host,
|
|
59
|
+
port: port,
|
|
60
|
+
})
|
|
61
|
+
.then(function (connection) {
|
|
21
62
|
return new RemoteDevice(connection);
|
|
22
63
|
})
|
|
23
64
|
.then(printDevice);
|
|
24
65
|
|
|
25
|
-
async function
|
|
26
|
-
{
|
|
66
|
+
async function fetchObjectInfo(o) {
|
|
67
|
+
const info = {
|
|
68
|
+
type: o.ClassName,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const classIdentification = await o.GetClassIdentification();
|
|
72
|
+
|
|
73
|
+
Object.assign(info, classIdentification);
|
|
74
|
+
|
|
75
|
+
await Promise.all(
|
|
76
|
+
o.get_properties().forEach(async (p) => {
|
|
77
|
+
const { name } = p;
|
|
78
|
+
if (name === 'ClassID' || name === 'ClassVersion') return;
|
|
79
|
+
if (o instanceof OcaBlock && name === 'Members') return;
|
|
80
|
+
const getter = p.getter(o);
|
|
81
|
+
if (!getter) return;
|
|
82
|
+
try {
|
|
83
|
+
const currentValue = await getter();
|
|
84
|
+
|
|
85
|
+
Object.assign(info, formatPropertyValue(name, currentValue));
|
|
86
|
+
} catch (err) {
|
|
87
|
+
if (err.status != 8)
|
|
88
|
+
console.error(
|
|
89
|
+
'Fetching property',
|
|
90
|
+
o.ClassName,
|
|
91
|
+
p.name,
|
|
92
|
+
'failed:',
|
|
93
|
+
err
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return info;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function printTree(objects, prefix) {
|
|
27
103
|
if (!prefix) prefix = [];
|
|
28
104
|
|
|
29
105
|
let lastPath;
|
|
30
106
|
|
|
31
|
-
for (let i = 0; i < objects.length; i++)
|
|
32
|
-
{
|
|
107
|
+
for (let i = 0; i < objects.length; i++) {
|
|
33
108
|
const o = objects[i];
|
|
34
109
|
|
|
35
|
-
if (Array.isArray(o))
|
|
36
|
-
{
|
|
110
|
+
if (Array.isArray(o)) {
|
|
37
111
|
await printTree(o, lastPath);
|
|
38
112
|
continue;
|
|
39
113
|
}
|
|
40
114
|
|
|
41
115
|
const roleName = await o.GetRole();
|
|
42
116
|
|
|
43
|
-
const path = prefix.concat([
|
|
117
|
+
const path = prefix.concat([roleName]);
|
|
44
118
|
|
|
45
119
|
lastPath = path;
|
|
46
120
|
|
|
47
|
-
console.log('Path: %s', path.join('
|
|
121
|
+
console.log('Path: %s', path.join('/'));
|
|
48
122
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
123
|
+
const info = await fetchObjectInfo(o);
|
|
124
|
+
|
|
125
|
+
for (const name in info) {
|
|
126
|
+
console.log(' %s: %O ', name, info[name]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function managerExists(manager) {
|
|
132
|
+
try {
|
|
133
|
+
await manager.GetClassIdentification();
|
|
134
|
+
return true;
|
|
135
|
+
} catch (err) {
|
|
136
|
+
if (err.status != 5) {
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function generateJson(objects) {
|
|
145
|
+
const result = [];
|
|
146
|
+
|
|
147
|
+
for (let i = 0; i < objects.length; i++) {
|
|
148
|
+
const o = objects[i];
|
|
149
|
+
|
|
150
|
+
if (Array.isArray(o)) {
|
|
151
|
+
await printTreeJson(o, lastPath);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const info = await fetchObjectInfo(o);
|
|
156
|
+
|
|
157
|
+
if (o instanceof OcaBlock) {
|
|
158
|
+
const members = objects[i + 1];
|
|
159
|
+
if (!Array.isArray(members)) {
|
|
160
|
+
throw new Error('Member missing for OcaBlock.');
|
|
58
161
|
}
|
|
59
|
-
|
|
162
|
+
info.Members = await generateJson(members);
|
|
163
|
+
i++;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
result.push(info);
|
|
60
167
|
}
|
|
168
|
+
|
|
169
|
+
return result;
|
|
61
170
|
}
|
|
62
171
|
|
|
63
|
-
async function
|
|
64
|
-
|
|
172
|
+
async function printTreeJson(objects) {
|
|
173
|
+
console.log(JSON.stringify(await generateJson(objects), undefined, 2));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function printDevice(device) {
|
|
177
|
+
const print = jsonMode ? printTreeJson : printTree;
|
|
65
178
|
try {
|
|
66
|
-
|
|
179
|
+
const objects = await device.GetDeviceTree();
|
|
67
180
|
const managers = [
|
|
68
181
|
device.DeviceManager,
|
|
69
182
|
device.SecurityManager,
|
|
@@ -77,17 +190,14 @@ async function printDevice(device)
|
|
|
77
190
|
device.DeviceTimeManager,
|
|
78
191
|
device.TaskManager,
|
|
79
192
|
device.CodingManager,
|
|
80
|
-
device.DiagnosticManager
|
|
193
|
+
device.DiagnosticManager,
|
|
81
194
|
];
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
} catch (err) {
|
|
86
|
-
if (err.status != 5) {
|
|
87
|
-
throw err;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
195
|
+
|
|
196
|
+
for (const manager of managers) {
|
|
197
|
+
if (await managerExists(manager)) objects.push(manager);
|
|
90
198
|
}
|
|
199
|
+
|
|
200
|
+
await print(objects);
|
|
91
201
|
exit(0);
|
|
92
202
|
} catch (error) {
|
|
93
203
|
if (error.status) {
|