I'm working on an Intel Edison with Yoctoo 3.10, I have a barcode scanner on /dev/hidraw0 and I want to use the exact lines that are output when I run hexdump /dev/hidraw0
as the input for a program written in node js.
The node js program is the following:
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function(line){
console.log(line);
})
I have tried piping it normally:
hexdump /dev/hidraw0 | node program.js
But I get nothing, I think it has to do with the fact that hexdump doesn't write \n so the buffer doesn't write it's content.
I have also tried opening /dev/hidraw0 as a file, like this:
var fs = require('fs');
fs.open('/dev/hidraw0', 'r', function(status, fd) {
if (status) {
console.log(status.message);
return;
}
var buffer = new Buffer(100);
fs.read(fd, buffer, 0, 100, 0, function(err, num) {
console.log(buffer.toString('hex'));
});
});
And using some hex dumpers like hexy but in this case I get some hex lines but not the same ones as with hexdump, which are the ones I need.
Just using hexdump /dev/hidraw0
gives me the following
(when I use a card)
0000000 0000 0020 0000 0000 0000 0000 0000 0000
0000010 0000 0020 0000 0000 0000 001f 0000 0000
0000020 0000 0027 0000 0000 0000 0026 0000 0000
0000030 0000 0025 0000 0000 0000 0000 0000 0000
0000040 0000 0025 0000 0000 0000 0024 0000 0000
0000050 0000 0021 0000 0000 0000 0025 0000 0000
0000060 0000 0028 0000 0000 0000 0000 0000 0000