tessel / t2-start

Tessel 2 start docs! Open for contributions.
http://tessel.io/start
35 stars 31 forks source link

Reading from a keyboard? #170

Open danawoodman opened 6 years ago

danawoodman commented 6 years ago

Is it possible to read from a keyboard connected to the USB port?

I would like to use a USB RFID reader that sends data over as a keyboard. Is this possible?

HipsterBrown commented 6 years ago

Yes, you should be able to use something like node-hid to read data events from the USB stack .

danawoodman commented 6 years ago

@HipsterBrown thanks! Does node-hid support the tessel platform?

HipsterBrown commented 6 years ago

Yes, we have compiled binaries for the native dependencies of node-hid version 0.5.4 to work on Tessel's architecture (mipsel).

I can push compiled binaries for the latest release of node-hid (v0.7.2) sometime this week.

danawoodman commented 6 years ago

@HipsterBrown thanks, does that mean I have to wait to use node-hid until that binary is released?

HipsterBrown commented 6 years ago

@danawoodman No. If you install version 0.5.4 (npm install node-hid@v0.5.4) then you can use it now. Otherwise, yes, you will need to wait.

danawoodman commented 6 years ago

I installed that version and setup their "hello world":

const HID = require('node-hid')
const devices = HID.devices()

console.log('DEVICES:', devices)

Getting this with a keyboard connected:

node: can't resolve symbol 'libiconv_open'

If I unplug the keyboard I get and empty array (which makes sense)

Any ideas?

danawoodman commented 6 years ago

@HipsterBrown do you have time to push the v0.7.2 version? Maybe that is the issue?

rwaldron commented 6 years ago

@danawoodman I've cross compiled v0.7.2 and uploaded it just now

danawoodman commented 6 years ago

I updated to the newest version but I am still getting:

path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at dirname (path.js:1324:5)
    at Function.exports.getRoot (/tmp/remote-script/node_modules/node-hid/node_modules/bindings/bindings.js:1:1834)
    at exports (/tmp/remote-script/node_modules/node-hid/node_modules/bindings/bindings.js:1:1000)
    at e (/tmp/remote-script/node_modules/node-hid/nodehid.js:1:101)
    at Object.exports.devices (/tmp/remote-script/node_modules/node-hid/nodehid.js:1:1171)
    at Function.devices (/tmp/remote-script/src/models/rfid-reader.js:1:198)
    at s.initializeRFIDReader (/tmp/remote-script/src/models/doorlock.js:1:358)
    at new s (/tmp/remote-script/src/models/doorlock.js:1:259)
    at Object.<anonymous> (/tmp/remote-script/src/boot.js:1:63)

With this code:

const hid = require('node-hid')
console.log(hid.devices())

Any suggestions?

danawoodman commented 6 years ago

Has anyone ever been able to get node-hid working on a Tessel? This is becoming really frustrating because I bought the Tessel specifically to use a USB RFID reader (the module won't work as it is the wrong frequency). Someone please save my day! 😚