sdumetz / node-evdev

pure nodejs evdev reader
16 stars 14 forks source link

Error: ESPIPE: invalid seek #6

Open djthread opened 6 years ago

djthread commented 6 years ago

This is likely not a library issue, but user error. I'm really not sure what I'm missing here, though.

I'm trying to recognize events coming from a simple USB gamepad under linux. I've got things working with the legacy, "jsdev" method via the node-joystick package, but I'm trying to switch to the evdev method.

I can cat /dev/input/by-id/usb-0810_usb_gamepad-event-joystick and see output as I press buttons, so it seems that the kernel is functioning properly, but when I run the index.js in this package, the output is as follows:

root@DietPi ~/t/n/evdev# ./index.js
searching for event streams matching undefined in : /dev/input/by-path
found 4 inputs
{ bustype: 3, vendor: 2064, product: 58625, version: 272 }
reader error :  { Error: ESPIPE: invalid seek, read errno: -29, code: 'ESPIPE', syscall: 'read' }
root@DietPi ~/t/n/evdev#

I would love a hint on this. What might be going wrong and what can I do about it?

Any help would be very much appreciated! Thanks!

sdumetz commented 6 years ago

Looks like you forgot to add a filter. Try with ./index.js event-joystick.

Good thing you reported that thoug. It points out that

I'll correct it. Thanks.

djthread commented 6 years ago

@sdumetz, thank you so much for the reply!

It seems I forgot to tell the whole story. I had first duplicated your index.js code into my own file and changed the process.argv[2] bit to be "event-joystick" where I got the same error. I forgot to use the argument on the command line when invoking your script, but it didn't seem to help much:

root@DietPi ~/t/n/evdev# ./index.js event-joystick
searching for event streams matching event-joystick in : /dev/input/by-path
found 1 inputs
{ bustype: 3, vendor: 2064, product: 58625, version: 272 }
reader error :  { Error: ESPIPE: invalid seek, read errno: -29, code: 'ESPIPE', syscall: 'read' }

Any idea what I might be missing here?

Thank you so very much!

sdumetz commented 6 years ago

No idea at all then, sorry.

Will look into it further to see if I can reproduce. Could you tell me more infos about your system? Joystick used, active distro, ...

djthread commented 6 years ago

This is DietPi[1] running on a USBridge[2] with a very cheap USB gamepad[3] connected.

Thank you very much for looking into this! I'd very much appreciate any thoughts. Happy to try things if you need me to test a theory.

[1] https://dietpi.com/ [2] https://www.allo.com/sparky/usbridge.html [3] https://www.ebay.com/itm/2-PCS-USB-NES-Retro-Classic-Controller-Gamepad-For-Windows-PC-MAC-Nintendo-Games-/132668831670?hash=item1ee3adb7b6

sdumetz commented 6 years ago

Your setup looks fine, the event-joystick device being there means the gamepad + USBBridge works and dietpi shouldn't be a problem either.

I've done some research and ESPIPE is not a documented error upon read. I'll check my cpp error handling code and come back to you.

sdumetz commented 6 years ago

Looks like a documented error on fs.createReadStream. https://github.com/nodejs/node/commit/a653f23dfc2ac7c0717ffcb87bb4a7f5981169df which should have been merged in node 6 and above. What's your exact nodejs version?

If v6.xor v8.x, could you try one of the following :

Thanks

djthread commented 6 years ago

Hm! This is node v9.7.1, so perhaps this does not explain the issue?

sdumetz commented 6 years ago

OK then I have no idea why createReadStream would try to seek in your file.

I'll try to set up a similar environment to check if I can reproduce.