Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any known problems with Raspberry Pi? #54

Closed
cwilling opened this issue Nov 11, 2021 · 2 comments
Closed

Any known problems with Raspberry Pi? #54

cwilling opened this issue Nov 11, 2021 · 2 comments

Comments

@cwilling
Copy link
Contributor

I'm using the xkeys library for a project on Raspberry Pi. Everything is going well but recently have wanted to use rebootDevice() function which doesn't seem to do anything on the Raspberry Pi. I've added some logging statements directly in the library code and see them executed when rebootDevice() is called but the watcher registers no 'disconnected' and 'connected' events triggered by the reboot (as would occur on a normal, non-raspberrypi, machine). I use those events to track what devices are currently attached to the machine, so missing those events is a big problem.

In case it's a hardware issue due to running on a Raspberry Pi 3 which is now not so recent, I've ordered a Raspberry Pi 4 in the hope that the newer hardware may have better USB implementation.

In the meantime I thought of refactoring my app so that after such a rebootDevice() call, I could just restart the watcher and therefore have an accurate accounting of the attached devices. However there is then a problem with stopping the current watcher. Here is CLI output of setting up a watcher, then immediately stopping it:

xkeys@pi3b:~/xkeys-server $ node
Welcome to Node.js v14.18.1.
Type ".help" for more information.
> const { XKeysWatcher } = require('xkeys')
undefined
> const watcher = new XKeysWatcher()
undefined
> watcher.on('connected', (xkeysPanel) => {
...     console.log(`X-keys panel of type ${xkeysPanel.info.name} connected`)
... })
XKeysWatcher {
  _events: [Object: null prototype] { connected: [Function (anonymous)] },
  _eventsCount: 1,
  _maxListeners: undefined,
  options: undefined,
  seenDevicePaths: { '/dev/hidraw0': { xkeys: [XKeys] } },
  isMonitoring: true,
  updateConnectedDevicesTimeout: null,
  shouldFindChangedReTries: 0,
  debug: false,
  setupXkeysPanels: [
    XKeys {
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      device: [NodeHIDDevice],
      deviceInfo: [Object],
      _devicePath: '/dev/hidraw0',
      _buttonStates: [Map],
      _analogStates: [Object],
      _initialized: true,
      _unidId: 13,
      _firmwareVersion: 14,
      _disconnected: false,
      product: [Object],
      receivedVersionResolve: [Function (anonymous)],
      receivedGenerateDataResolve: [Function (anonymous)],
      [Symbol(kCapture)]: false
    }
  ],
  prevConnectedIdentifiers: {},
  uniqueIds: Map(0) {},
  onAddedUSBDevice: [Function (anonymous)],
  onRemovedUSBDevice: [Function (anonymous)],
  [Symbol(kCapture)]: false
}
> watcher.stop().then( ()=> { console.log("stopping..."); }).catch(console.error)
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 120,
  [Symbol(trigger_async_id_symbol)]: 5,
  [Symbol(destroyed)]: { destroyed: false }
}
> Segmentation fault

whereas, if I run the same node commands on a non-raspberrypi machine, the .stop() function works as expected:

> watcher.stop().then( ()=> { console.log("stopping..."); }).catch(console.error)
Promise { <pending> }
> stopping...

>

Any ideas, insights on either of these issues?

@cwilling
Copy link
Contributor Author

I found this possibly related issue where someone suggested a patch which I applied and rebuilt the usb-detection module. It helped somewhat in that there is now no Segmentation fault when running that CLI example, also now see the "Stopping..." logged, but still have all those Symbol entries pending.

@cwilling
Copy link
Contributor Author

Today I tried exactly the same (unpatched) code on a Raspberry Pi v4 (previously using Pi v3) and all worked perfectly. I'm putting this one down to hardware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant