pipe is not a function

1

I'm trying to use the module node-ds4

my code is this:

var HID = require('node-hid');
var ds4 = require('ds4');
var through = require('through');

var hid = new HID.HID('\\?\hid#vid_054c&pid_05c4#6&22a63115&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}');

hid.pipe(through(ds4.parseDS4HIDData)).pipe(process.stdout);

Running the program tells me that hid.pipe is not a function

I was reading a bit and pipe is a node function that reads buffers. Following the documentation of node-hid I can read the data using:

hid.on('data', function(data){ console.log(data); });

and the console shows something like this:

<Buffer 01 79 80 83 79 08 00 b8 00 00 d1 b3 0f 05 00 fd ff 00 00 25 ff e3 1e 05 07 00 00 00 00 00 1b 00 00 00 00 80 00 00 00 80 00 00 00 00 80 00 00 00 80 00 ... >
<Buffer 01 79 80 83 79 08 00 bc 00 00 b2 b6 0f 06 00 fd ff fc ff 0d ff 2f 1f 41 07 00 00 00 00 00 1b 00 00 00 00 80 00 00 00 80 00 00 00 00 80 00 00 00 80 00 ... >
<Buffer 01 79 80 83 79 08 00 c0 00 00 a2 b9 0f 01 00 ff ff ff ff fd fe fb 1e 05 07 00 00 00 00 00 1b 00 00 00 00 80 00 00 00 80 00 00 00 00 80 00 00 00 80 00 ... >

Why is the pipe not working, since hid is a buffer? Do I need to install another module that allows me to use the pipe?

extra question: How can I make console.log () NOT create another line with data and replace the one that already exists?

    
asked by Rodrigo Martín 12.01.2017 в 07:58
source

1 answer

2

Are you sure you installed the lib?

$ npm install -g ds4

did you generate the dump?

$ ds4-dump

Be sure to use -g when you install the library

    
answered by 12.01.2017 / 14:01
source