joulescope_driver 0.0.0 → 1.5.1
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 +45 -43
- package/binding.gyp +103 -103
- package/{examples → example}/samples.js +66 -66
- package/{examples → example}/statistics.js +63 -63
- package/index.js +99 -99
- package/package.json +36 -36
- package/prebuilds/darwin-arm64/joulescope_driver.node +0 -0
- package/prebuilds/linux-x64/joulescope_driver.node +0 -0
- package/prebuilds/win32-x64/joulescope_driver.node +0 -0
- package/src/addon.cc +25 -25
- package/src/joulescope_driver.cc +412 -412
- package/src/joulescope_driver.h +39 -39
- package/test/test_binding.js +31 -31
package/index.js
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Jetperch LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const addon = require('node-gyp-build')(__dirname);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class JoulescopeDriver {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.jsdrv = new addon.JoulescopeDriver()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Publish a value to a topic.
|
|
27
|
-
*
|
|
28
|
-
* @param topic The topic string.
|
|
29
|
-
* @param value The new value for the topic.
|
|
30
|
-
* @param timeout The optional integer timeout in milliseconds.
|
|
31
|
-
* -1 (default) use the default timeout value.
|
|
32
|
-
* Provide 0 for async operation.
|
|
33
|
-
* @returns Undefined.
|
|
34
|
-
*/
|
|
35
|
-
publish(topic, value, timeout=-1) {
|
|
36
|
-
return this.jsdrv.publish(topic, value, timeout);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Query the current value for a topic.
|
|
41
|
-
*
|
|
42
|
-
* @param topic The topic string.
|
|
43
|
-
* @param timeout The optional integer timeout in milliseconds.
|
|
44
|
-
* -1 (default) use the default timeout value.
|
|
45
|
-
* Provide 0 for async operation.
|
|
46
|
-
* @returns The value for topic.
|
|
47
|
-
*/
|
|
48
|
-
query(topic, timeout = -1) {
|
|
49
|
-
return this.jsdrv.query(topic, timeout);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Finalize the driver instance and free all resources.
|
|
54
|
-
*/
|
|
55
|
-
finalize() {
|
|
56
|
-
return this.jsdrv.finalize();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
device_paths(timeout=-1) {
|
|
60
|
-
var p = this.query("@/list");
|
|
61
|
-
return p.split(',').sort()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Open a Joulescope device.
|
|
66
|
-
*
|
|
67
|
-
* @param topic The device path to open.
|
|
68
|
-
* @param mode The optional open mode. 0=defaults, 1=resume.
|
|
69
|
-
*/
|
|
70
|
-
open(topic, mode=0) {
|
|
71
|
-
topic = topic.concat("/@/!open");
|
|
72
|
-
return this.jsdrv.publish(topic, mode, 2000);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Close a Joulescope device.
|
|
77
|
-
*
|
|
78
|
-
* @param topic The device path to close that was previously openned.
|
|
79
|
-
*/
|
|
80
|
-
close(topic) {
|
|
81
|
-
topic = topic.concat("/@/!close");
|
|
82
|
-
return this.jsdrv.publish(topic, 0, 2000);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Subscribe to a topic.
|
|
87
|
-
*
|
|
88
|
-
* @param topic
|
|
89
|
-
* @param flags
|
|
90
|
-
* @param fn
|
|
91
|
-
* @param timeout
|
|
92
|
-
* @returns Callable to unsubscribe.
|
|
93
|
-
*/
|
|
94
|
-
subscribe(topic, flags, fn, timeout=-1) {
|
|
95
|
-
return this.jsdrv.subscribe(topic, flags, fn, timeout);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
module.exports = JoulescopeDriver
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Jetperch LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const addon = require('node-gyp-build')(__dirname);
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class JoulescopeDriver {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.jsdrv = new addon.JoulescopeDriver()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Publish a value to a topic.
|
|
27
|
+
*
|
|
28
|
+
* @param topic The topic string.
|
|
29
|
+
* @param value The new value for the topic.
|
|
30
|
+
* @param timeout The optional integer timeout in milliseconds.
|
|
31
|
+
* -1 (default) use the default timeout value.
|
|
32
|
+
* Provide 0 for async operation.
|
|
33
|
+
* @returns Undefined.
|
|
34
|
+
*/
|
|
35
|
+
publish(topic, value, timeout=-1) {
|
|
36
|
+
return this.jsdrv.publish(topic, value, timeout);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Query the current value for a topic.
|
|
41
|
+
*
|
|
42
|
+
* @param topic The topic string.
|
|
43
|
+
* @param timeout The optional integer timeout in milliseconds.
|
|
44
|
+
* -1 (default) use the default timeout value.
|
|
45
|
+
* Provide 0 for async operation.
|
|
46
|
+
* @returns The value for topic.
|
|
47
|
+
*/
|
|
48
|
+
query(topic, timeout = -1) {
|
|
49
|
+
return this.jsdrv.query(topic, timeout);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Finalize the driver instance and free all resources.
|
|
54
|
+
*/
|
|
55
|
+
finalize() {
|
|
56
|
+
return this.jsdrv.finalize();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
device_paths(timeout=-1) {
|
|
60
|
+
var p = this.query("@/list");
|
|
61
|
+
return p.split(',').sort()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Open a Joulescope device.
|
|
66
|
+
*
|
|
67
|
+
* @param topic The device path to open.
|
|
68
|
+
* @param mode The optional open mode. 0=defaults, 1=resume.
|
|
69
|
+
*/
|
|
70
|
+
open(topic, mode=0) {
|
|
71
|
+
topic = topic.concat("/@/!open");
|
|
72
|
+
return this.jsdrv.publish(topic, mode, 2000);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Close a Joulescope device.
|
|
77
|
+
*
|
|
78
|
+
* @param topic The device path to close that was previously openned.
|
|
79
|
+
*/
|
|
80
|
+
close(topic) {
|
|
81
|
+
topic = topic.concat("/@/!close");
|
|
82
|
+
return this.jsdrv.publish(topic, 0, 2000);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Subscribe to a topic.
|
|
87
|
+
*
|
|
88
|
+
* @param topic
|
|
89
|
+
* @param flags
|
|
90
|
+
* @param fn
|
|
91
|
+
* @param timeout
|
|
92
|
+
* @returns Callable to unsubscribe.
|
|
93
|
+
*/
|
|
94
|
+
subscribe(topic, flags, fn, timeout=-1) {
|
|
95
|
+
return this.jsdrv.subscribe(topic, flags, fn, timeout);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = JoulescopeDriver
|
package/package.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "joulescope_driver",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Interface with Joulescopes using node.js and Electron",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"Joulescope",
|
|
7
|
-
"Jetperch"
|
|
8
|
-
],
|
|
9
|
-
"main": "./index.js",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"install": "node-gyp-build",
|
|
12
|
-
"test": "node --napi-modules ./test/test_binding.js",
|
|
13
|
-
"prebuild": "prebuildify --napi --strip"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"node-addon-api": "^3.0.0",
|
|
17
|
-
"node-gyp-build": "^4.8.0"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"node-gyp": "^10.1.0",
|
|
21
|
-
"prebuildify": "^6.0.1"
|
|
22
|
-
},
|
|
23
|
-
"gypfile": true,
|
|
24
|
-
"engines": {
|
|
25
|
-
"node": ">=18"
|
|
26
|
-
},
|
|
27
|
-
"repository": {
|
|
28
|
-
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/jetperch/joulescope_driver.git"
|
|
30
|
-
},
|
|
31
|
-
"author": "Jetperch LLC",
|
|
32
|
-
"license": "Apache-2.0",
|
|
33
|
-
"bugs": {
|
|
34
|
-
"url": "https://github.com/jetperch/joulescope_driver/issues"
|
|
35
|
-
},
|
|
36
|
-
"homepage": "https://github.com/jetperch/joulescope_driver#readme"
|
|
1
|
+
{
|
|
2
|
+
"name": "joulescope_driver",
|
|
3
|
+
"version": "1.5.1",
|
|
4
|
+
"description": "Interface with Joulescopes using node.js and Electron",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Joulescope",
|
|
7
|
+
"Jetperch"
|
|
8
|
+
],
|
|
9
|
+
"main": "./index.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"install": "node-gyp-build",
|
|
12
|
+
"test": "node --napi-modules ./test/test_binding.js",
|
|
13
|
+
"prebuild": "prebuildify --napi --strip"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"node-addon-api": "^3.0.0",
|
|
17
|
+
"node-gyp-build": "^4.8.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"node-gyp": "^10.1.0",
|
|
21
|
+
"prebuildify": "^6.0.1"
|
|
22
|
+
},
|
|
23
|
+
"gypfile": true,
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/jetperch/joulescope_driver.git"
|
|
30
|
+
},
|
|
31
|
+
"author": "Jetperch LLC",
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/jetperch/joulescope_driver/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/jetperch/joulescope_driver#readme"
|
|
37
37
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/addon.cc
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Jetperch LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
#include <napi.h>
|
|
18
|
-
#include "joulescope_driver.h"
|
|
19
|
-
|
|
20
|
-
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
21
|
-
JoulescopeDriver::Init(env, exports);
|
|
22
|
-
return exports;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Jetperch LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#include <napi.h>
|
|
18
|
+
#include "joulescope_driver.h"
|
|
19
|
+
|
|
20
|
+
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
21
|
+
JoulescopeDriver::Init(env, exports);
|
|
22
|
+
return exports;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
|