-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvxi11-test2.js
More file actions
executable file
·39 lines (31 loc) · 983 Bytes
/
vxi11-test2.js
File metadata and controls
executable file
·39 lines (31 loc) · 983 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
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env node
/*
Rolf Niepraschk, Rolf.Niepraschk@gmx.de, 2014-04-29
*/
var vxiTransceiver = require('vxi11').vxiTransceiver
var http = require('http');
var url = require('url');
var util = require('util');
var PORT = 44444;
http.createServer(function (req, res) {
var query = url.parse(req.url, true).query;
console.log(util.inspect(query));
var headers = {'Content-Type':'text/plain','Access-Control-Allow-Origin':'*'};
if (query.host && query.device && query.command) {
vxiTransceiver(query, function(result) {
res.writeHead(200, headers);
res.write(result);
res.end();
}, function(error) {
res.writeHead(200, headers);
res.write(error);
res.end();
});
} else {
res.writeHead(500, headers);
res.write("Wrong parameter!\n");
res.end();
}
}).listen(PORT);
console.log('Server running at http://127.0.0.1:' + PORT + '/');
// URL: http://localhost:44444/?host=e75481&device=gpib0,5&command=*IDN?