-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.js
31 lines (24 loc) · 844 Bytes
/
test.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
var IbusInterface = require('./index.js').IbusInterface;
var IbusDevices = require('./index.js').IbusDevices;
// config
//var device = '/dev/ttys003';
var device = '/dev/cu.usbserial-A601HPGR';
// data
var ibusInterface = new IbusInterface(device);
// events
//process.on('SIGINT', onSignalInt);
ibusInterface.on('data', onIbusData);
// implementation
function onSignalInt() {
ibusInterface.shutdown(function() {
process.exit();
});
}
function onIbusData(data) {
console.log('[IbusReader]', 'Id: ', data.id);
console.log('[IbusReader]', 'From: ', IbusDevices.getDeviceName(data.src));
console.log('[IbusReader]', 'To: ', IbusDevices.getDeviceName(data.dst));
console.log('[IbusReader]', 'Message: ', data.msg.toString('ascii'), data.msg, '\n');
}
// main start
//ibusInterface.startup();