-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvxi11-test1.js
executable file
·51 lines (38 loc) · 1.14 KB
/
vxi11-test1.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
/*
Rolf Niepraschk, [email protected], 2014-05-13
*/
var vxiTransceiver = require('vxi11').vxiTransceiver
var args = process.argv.slice(2);
if (args.length < 3) {
console.error('Too few arguments!');
console.error('Example: %s %s "172.30.56.65" "gpib0,10" "*IDN?\\n"',
process.argv[0], require('path').basename(process.argv[1]));
process.exit(1);
}
var host = args[0];
var device = args[1];
var tmp = '{ "cmd":"' + args[2] + '"}';
tmp = JSON.parse(tmp);
var cmd = tmp.cmd;
// example call with default parameters (no logging)
vxiTransceiver(host, device, cmd, function(result) {
console.log('*** result 1: »' + result + '«');
});
var options = {
host: host,
device: device,
command: cmd,
readTimeout: 3000, // default: 2000ms
ioTimeout: 6000, // default: 10000ms
lockTimeout: 6000, // default: 10000ms
lockDevice: true,
//termChar: '\n',
logger: { log: console.log, error: console.error }
}
// example call with an option object
vxiTransceiver(options, function(result) {
console.log('*** result: »' + result + '«');
},function(error) {
console.log('*** error: »' + error + '«');
});