question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

problem with close

See original GitHub issue

It seems that once a ‘data’ listener is added, device can not be closed properly.

I encountered the problem with code like this. ran it in node console

>var HID = require('node-hid');
undefined
>var p = h.devices()[1].path;         // had a bar code scanner connected
undefined
>var dev = new HID.HID(p);
undefined
>dev.on('data', function(d){console.log(d)});
......
>dev.removeAllListeners('data');
......
>dev.close();                               //close the device
undefined
>dev = new HID.HID(p);               //reopen the device, failed, seems like the device is not released
cannot open device with path \\?\hid#vi...blahblahblah

reopen is good when i skip the dev.on('data',...) and dev.removeAllListeners('data') statement.

Is it a bug?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
peitschiecommented, Jun 19, 2019

I had this issue also, and found that I could workaround it by calling setNonBlocking(true) on the HID device prior to subscribing to any data.

There’s an open issue from 2017 about this undocumented function: https://github.com/node-hid/node-hid/issues/216

0reactions
peitschiecommented, Jun 20, 2019

Thanks for looking at this 😺

Changing the driver to libusb had no effect.

The output from lsusb -v is:

root@ubuntu:~# lsusb -v

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         1 Single TT
  bMaxPacketSize0        64
  idVendor           0x1d6b Linux Foundation
  idProduct          0x0002 2.0 root hub
  bcdDevice            3.10
  iManufacturer           3
  iProduct                2
  iSerial                 1
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12

Bus 002 Device 005: ID d209:1200 Ultimarc
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0xd209 Ultimarc
  idProduct          0x1200
  bcdDevice            0.01
  iManufacturer           2
  iProduct                2
  iSerial                 1
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           59
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          2
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              2
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      33
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      1 Keyboard
      iInterface              2
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.11
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     168
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            9 Hub
  bDeviceSubClass         0 Unused
  bDeviceProtocol         1 Single TT
  bMaxPacketSize0        64
  idVendor           0x1d6b Linux Foundation
  idProduct          0x0002 2.0 root hub
  bcdDevice            3.10
  iManufacturer           3
  iProduct                2
  iSerial                 1
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           25
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower                0mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         9 Hub
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      0 Full speed (or root) hub
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              12

Regarding the exact hardware, it is a relatively cheap button purchased from http://usbbutton.com/, running on a proprietary hardware system (though I have no way to discover the exact hardware, sorry).

Regarding LXC usage, I did a quick google and browse, and seems like something such as https://linuxcontainers.org/lxd/getting-started-cli/#creating-and-using-your-first-container is decently straightfoward if you have a linux system somewhere.

I followed https://medium.com/@konpat/usb-passthrough-to-an-lxc-proxmox-15482674f11d to figure out how to allow the USB device through to the container. For the USB button, the exact lines I added to the container’s config were:

lxc.cgroup.devices.allow = c 188:* rwm
lxc.cgroup.devices.allow = c 247:* rwm

I suspect there’s a way to do that for a running, but I don’t know exactly how to do it, unfortunately 😿 . It looks like something akin to https://discuss.linuxcontainers.org/t/providing-access-to-loop-and-other-devices-in-containers/1352… but I have no way of discovering the exact commands, sorry, as I only get access from within the container on the proprietary system.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Close a problem
The Problem Analyst verifies that all related known errors are closed or resolved before closing the problem record. The Problem Analyst then consults...
Read more >
Closing Problem Tickets : TechWeb - Boston University
Closing Problems is a manual process as it does require human intervention to ensure that all steps, tasks and changes have been completed...
Read more >
Close related Incidents upon closing a Problem
Related incident are not closed when the associated problem is closed. ... OOB business rule - "SNC - ITIL - Close Related" is...
Read more >
Reopen the closed problem - SDP help desk guide
Close a problem · Click the Problems tab in the header pane. · Click the Title of the problem in the Problems list...
Read more >
Closing a Problem - Ivanti
1.Log in to the application as a Problem Manager. · 2.Open the Problem workspace. · 3.Open the problem that you want to close....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found