-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_example.js
More file actions
27 lines (25 loc) · 796 Bytes
/
node_example.js
File metadata and controls
27 lines (25 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { RadiaCode } = require('./radiacode');
(async () => {
try {
let device = new RadiaCode();
await device.connect();
const version = await device.fw_version();
const serial = await device.serial_number();
console.log(version);
console.log(serial);
let poll = setInterval(async () => {
const r = await device.real_time_data()
console.log(r)
}, 1000)
const cleanup = async () => {
clearInterval(poll);
try { await device.disconnect(); } catch {}
process.exit(0);
};
process.on('SIGINT', cleanup);
process.on('SIGTERM', cleanup);
} catch (e) {
console.error('Connect failed:', e.message);
process.exit(1);
}
})();