Ali Asad | 7 Mar 2009 06:11
Favicon

libhid can not open HID device on Ubuntu

Hi ,

I am using libhid on Ubuntu to connect to a composit USB device that enumerates as a mass storage as well as HID device. When using the sample code of libhid, the call hid_force_open() fails with the following printout, and return code of 12. Any ideas what could cause this.

Much appreciate your help.

regards,
--- asad

NOTICE: hid_init(): libhid 0.2.15+20060325.0.0 is being initialized.
  TRACE: hid_init(): initialising USB subsystem...
  TRACE: hid_init(): scanning for USB busses...
  TRACE: hid_init(): scanning for USB devices...
NOTICE: hid_init(): successfully initialised HID library.
  TRACE: hid_new_HIDInterface(): creating a new HIDInterface instance...
  TRACE: hid_force_open(): forcefully opening a device interface according to matching criteria...
  TRACE: hid_get_usb_handle(): acquiring handle for a USB device...
  TRACE: hid_find_usb_device(): enumerating USB busses...
  TRACE: hid_find_usb_device(): enumerating USB devices on bus 004...
  TRACE: hid_find_usb_device(): inspecting USB device 004/001[0]...
  TRACE: hid_compare_usb_device(): comparing match specifications to USB device...
  TRACE: hid_compare_usb_device(): inspecting vendor ID...
  TRACE: hid_compare_usb_device(): no match on vendor ID.
  TRACE: hid_compare_usb_device(): inspecting product ID...
  TRACE: hid_compare_usb_device(): no match on product ID.
  TRACE: hid_compare_usb_device(): no custom matching function supplied.
NOTICE: hid_find_usb_device(): vendor 0x1d6b of USB device 004/001[0] does not match 0x05dc.
  TRACE: hid_find_usb_device(): enumerating USB devices on bus 003...
  TRACE: hid_find_usb_device(): inspecting USB device 003/001[0]...
  TRACE: hid_compare_usb_device(): comparing match specifications to USB device...
  TRACE: hid_compare_usb_device(): inspecting vendor ID...
  TRACE: hid_compare_usb_device(): no match on vendor ID.
  TRACE: hid_compare_usb_device(): inspecting product ID...
  TRACE: hid_compare_usb_device(): no match on product ID.
  TRACE: hid_compare_usb_device(): no custom matching function supplied.
NOTICE: hid_find_usb_device(): vendor 0x1d6b of USB device 003/001[0] does not match 0x05dc.
  TRACE: hid_find_usb_device(): enumerating USB devices on bus 002...
  TRACE: hid_find_usb_device(): inspecting USB device 002/003[0]...
  TRACE: hid_compare_usb_device(): comparing match specifications to USB device...
  TRACE: hid_compare_usb_device(): inspecting vendor ID...
  TRACE: hid_compare_usb_device(): no match on vendor ID.
  TRACE: hid_compare_usb_device(): inspecting product ID...
  TRACE: hid_compare_usb_device(): no match on product ID.
  TRACE: hid_compare_usb_device(): no custom matching function supplied.
NOTICE: hid_find_usb_device(): vendor 0x046d of USB device 002/003[0] does not match 0x05dc.
  TRACE: hid_find_usb_device(): inspecting USB device 002/001[0]...
  TRACE: hid_compare_usb_device(): comparing match specifications to USB device...
  TRACE: hid_compare_usb_device(): inspecting vendor ID...
  TRACE: hid_compare_usb_device(): no match on vendor ID.
  TRACE: hid_compare_usb_device(): inspecting product ID...
  TRACE: hid_compare_usb_device(): no match on product ID.
  TRACE: hid_compare_usb_device(): no custom matching function supplied.
NOTICE: hid_find_usb_device(): vendor 0x1d6b of USB device 002/001[0] does not match 0x05dc.
  TRACE: hid_find_usb_device(): enumerating USB devices on bus 001...
  TRACE: hid_find_usb_device(): inspecting USB device 001/004[0]...
  TRACE: hid_compare_usb_device(): comparing match specifications to USB device...
  TRACE: hid_compare_usb_device(): inspecting vendor ID...
  TRACE: hid_compare_usb_device(): match on vendor ID: 0x05dc.
  TRACE: hid_compare_usb_device(): inspecting product ID...
  TRACE: hid_compare_usb_device(): match on product ID: 0x0802.
  TRACE: hid_compare_usb_device(): no custom matching function supplied.
NOTICE: hid_find_usb_device(): found a matching USB device 001/004[0].
  TRACE: hid_force_open(): claiming USB device 001/004[0].
  TRACE: hid_os_force_claim(): failed to claim USB device 001/004[0], trying 2 more time(s)...
  TRACE: hid_os_force_claim(): detaching kernel driver from USB device 001/004[0]...
WARNING: hid_os_force_claim(): failed to detach kernel driver from USB device 001/004[0]...
WARNING: hid_force_open(): failed to claim USB device 001/004[0].
  TRACE: hid_close(): closing USB device 001/004[0]...
  TRACE: hid_close(): closing handle of USB device 001/004[0]...
NOTICE: hid_close(): successfully closed USB device 001/004[0].
  TRACE: hid_close(): freeing memory allocated for HID parser...
  TRACE: hid_close(): resetting HIDInterface...
hid_force_open failed with return code 12

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
Sarah Mount | 8 Mar 2009 21:44
Picon
Picon
Favicon
Gravatar

Re: libhid can not open HID device on Ubuntu

2009/3/7 Ali Asad <Asad.Ali <at> gemalto.com>:
> Hi ,
>
> I am using libhid on Ubuntu to connect to a composit USB device that
> enumerates as a mass storage as well as HID device. When using the sample
> code of libhid, the call hid_force_open() fails with the following printout,
> and return code of 12. Any ideas what could cause this.
>

Try running your program with sudo.

Sarah

-- 
Sarah Mount, Senior Lecturer, University of Wolverhampton
Web:  http://www.wlv.ac.uk/~in0316/
Book: http://www.pythonforrookies.org/
WSN: http://www.fieldsensing.org.uk/
Photos: http://flickr.com/photos/sarahmount/

This email, together with any attachment, is for the exclusive and
confidential use of the addressee(s) and may contain legally
privileged information.  Any use, disclosure or reproduction without
the sender's explicit consent is unauthorised and may be unlawful.

Any e-mail including its content and any attachments may be monitored
and used by The University of Wolverhampton for reasons of security
and for monitoring internal compliance with the University's policy on
internet use. E-mail blocking software may also be used.  The
University cannot guarantee that this message or any attachment is
virus free or has not been intercepted and amended.

If you believe you have received this message in error please notify
the sender by email, telephone or fax and destroy the message and any
copies.

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Ali Asad | 9 Mar 2009 05:25
Favicon

Re: libhid can not open HID device on Ubuntu


> Try running your program with sudo.

I tried this option from the terminal, but the debug version of the test application when run from Eclipse
IDE still failed. Not sure if sudo rights got translated to the IDE (I am not that familiar with
Linux/Ubuntu behavior), but I am not sure this would be a lasting solution since I do not want to force super
user requirement on end users.

Does the use of libhid require root access?

thanks,
--- asad

-----Original Message-----
From: mount.sarah <at> gmail.com [mailto:mount.sarah <at> gmail.com] On Behalf Of Sarah Mount
Sent: Sunday, March 08, 2009 3:44 PM
To: Ali Asad; libhid-discuss <at> lists.alioth.debian.org
Subject: Re: [libhid-discuss] libhid can not open HID device on Ubuntu

2009/3/7 Ali Asad <Asad.Ali <at> gemalto.com>:
> Hi ,
>
> I am using libhid on Ubuntu to connect to a composit USB device that
> enumerates as a mass storage as well as HID device. When using the
> sample code of libhid, the call hid_force_open() fails with the
> following printout, and return code of 12. Any ideas what could cause this.
>

Try running your program with sudo.

Sarah

--
Sarah Mount, Senior Lecturer, University of Wolverhampton
Web:  http://www.wlv.ac.uk/~in0316/
Book: http://www.pythonforrookies.org/
WSN: http://www.fieldsensing.org.uk/
Photos: http://flickr.com/photos/sarahmount/

This email, together with any attachment, is for the exclusive and confidential use of the addressee(s)
and may contain legally privileged information.  Any use, disclosure or reproduction without the
sender's explicit consent is unauthorised and may be unlawful.

Any e-mail including its content and any attachments may be monitored and used by The University of
Wolverhampton for reasons of security and for monitoring internal compliance with the University's
policy on internet use. E-mail blocking software may also be used.  The University cannot guarantee that
this message or any attachment is virus free or has not been intercepted and amended.

If you believe you have received this message in error please notify the sender by email, telephone or fax
and destroy the message and any copies.

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Charles Lepple | 9 Mar 2009 11:37

Re: libhid can not open HID device on Ubuntu

On Mar 9, 2009, at 12:25 AM, Ali Asad wrote:

> Does the use of libhid require root access?

No, but it does require write access to the USB device node  
corresponding to your device, and that node is recreated every time  
you plug the device in. (This is not something specific to libhid.)

Please check the archives for more on this - it has been covered  
before. You will probably want to write a rules file for udev.

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Gabriel Rossetti | 11 Mar 2009 09:51

Does libhid require a driver installation on windows?

Hello,

I would like to use the HID interface so that I do not have to write a 
driver to control my USB device. I found libhid and it looks interesting 
as it is cross platform. I see that it uses libusb, and the last time I 
had used libusb I had to install a driver on windows. I read on the 
libhid mailing list that libusb-win32 was going to use the native 
windows HID driver in it's future releases, which would require no 
driver installation:

On 4/11/07, Stephan Meyer wrote:
>/ > On 4/10/07, Xiaofan wrote:
/>/ > The thing is that you need to uninstall the kernel HID driver and
/>/ > use the libusb-win32 device driver for this kind of HID device. This
/>/ > significantly reduces the usability of libusb-win32 for HID device
/>/ > under Windows. Yet many USB device disguise them as HID device
/>/ > just to avoid writing a device driver.
/>/ >
/>/ > Just wondering if it is possible to use an alternative backend
/>/ > (Windows HID apli) and make libusb a wrapper on top of it.
/>/ > I understand then it should perhaps be called libhid-win32 then.
/>/
/>/ This sounds like a great idea! I'll add a native HID backend to the
/>/ next version of the DLL. It should be possible to implement most of
/>/ libusb's features on top of Windows' hid.dll such as open, close,
/>/ interrupt-read/write and basic control messages. The rest can be
/>/ emulated/simulated.
/>

(http://lists.alioth.debian.org/pipermail/libhid-discuss/2007-April/000136.html)

I searched both libhid's and libusb's websites and I found nothing 
concerning this, does anyone know what the current status is? Does a 
driver have to be installed to use libhid on windows? Also, what is the 
difference/advantage with using libhid in comparison with directly using 
libusb's hid support?

Thank you,
Gabriel

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Xiaofan Chen | 11 Mar 2009 10:51
Picon

Re: Does libhid require a driver installation on windows?

On Wed, Mar 11, 2009 at 4:51 PM, Gabriel Rossetti
<gabriel.rossetti <at> arimaz.com> wrote:

> On 4/11/07, Stephan Meyer wrote:
>>/ > On 4/10/07, Xiaofan wrote:
> />/ > The thing is that you need to uninstall the kernel HID driver and
> />/ > use the libusb-win32 device driver for this kind of HID device. This
> />/ > significantly reduces the usability of libusb-win32 for HID device
> />/ > under Windows. Yet many USB device disguise them as HID device
> />/ > just to avoid writing a device driver.
> />/ >
> />/ > Just wondering if it is possible to use an alternative backend
> />/ > (Windows HID apli) and make libusb a wrapper on top of it.
> />/ > I understand then it should perhaps be called libhid-win32 then.
> />/
> />/ This sounds like a great idea! I'll add a native HID backend to the
> />/ next version of the DLL. It should be possible to implement most of
> />/ libusb's features on top of Windows' hid.dll such as open, close,
> />/ interrupt-read/write and basic control messages. The rest can be
> />/ emulated/simulated.
> />
>
> (http://lists.alioth.debian.org/pipermail/libhid-discuss/2007-April/000136.html)
>
> I searched both libhid's and libusb's websites and I found nothing
> concerning this, does anyone know what the current status is? Does a
> driver have to be installed to use libhid on windows? Also, what is the
> difference/advantage with using libhid in comparison with directly using
> libusb's hid support?

You can try out the SVN version of libsub-win32 1.0. Last time
I tried it out, it has the HID backend (along with WinUSB backend
and the libusb-win32 device driver backend). It could find the device,
but interrupt read/write did not work.

The SVN version:
http://libusb-win32.svn.sourceforge.net/viewvc/libusb-win32/trunk/libusb1/

It seems to me that this has not been updated for a while. So I guess
it is still not working. But Stephan mentioned that he would try to
finish this with this year.

libhid is right now based on libusb.

Xiaofan

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Gabriel Rossetti | 11 Mar 2009 11:04

Re: Does libhid require a driver installation on windows?

Xiaofan Chen wrote:
> On Wed, Mar 11, 2009 at 4:51 PM, Gabriel Rossetti
> <gabriel.rossetti <at> arimaz.com> wrote:
>
>   
>> On 4/11/07, Stephan Meyer wrote:
>>     
>>> / > On 4/10/07, Xiaofan wrote:
>>>       
>> />/ > The thing is that you need to uninstall the kernel HID driver and
>> />/ > use the libusb-win32 device driver for this kind of HID device. This
>> />/ > significantly reduces the usability of libusb-win32 for HID device
>> />/ > under Windows. Yet many USB device disguise them as HID device
>> />/ > just to avoid writing a device driver.
>> />/ >
>> />/ > Just wondering if it is possible to use an alternative backend
>> />/ > (Windows HID apli) and make libusb a wrapper on top of it.
>> />/ > I understand then it should perhaps be called libhid-win32 then.
>> />/
>> />/ This sounds like a great idea! I'll add a native HID backend to the
>> />/ next version of the DLL. It should be possible to implement most of
>> />/ libusb's features on top of Windows' hid.dll such as open, close,
>> />/ interrupt-read/write and basic control messages. The rest can be
>> />/ emulated/simulated.
>> />
>>
>> (http://lists.alioth.debian.org/pipermail/libhid-discuss/2007-April/000136.html)
>>
>> I searched both libhid's and libusb's websites and I found nothing
>> concerning this, does anyone know what the current status is? Does a
>> driver have to be installed to use libhid on windows? Also, what is the
>> difference/advantage with using libhid in comparison with directly using
>> libusb's hid support?
>>     
>
> You can try out the SVN version of libsub-win32 1.0. Last time
> I tried it out, it has the HID backend (along with WinUSB backend
> and the libusb-win32 device driver backend). It could find the device,
> but interrupt read/write did not work.
>
> The SVN version:
> http://libusb-win32.svn.sourceforge.net/viewvc/libusb-win32/trunk/libusb1/
>
> It seems to me that this has not been updated for a while. So I guess
> it is still not working. But Stephan mentioned that he would try to
> finish this with this year.
>
> libhid is right now based on libusb.
>
> Xiaofan
>   
Ok, thank you,

Gabriel

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Ali Asad | 12 Mar 2009 01:15
Favicon

Using libhid with composit device

Hi,
 
I have two somewhat related questions regarding libhid on Linux (Ubuntu).
 
1. What is the difference betweeen hid_force_open() and hid_open()?
I read from the documentation and code comments that "force" version attempts to unmount the device to take control away from Linux hiddev driver. Is this step necessary? I say this because it may be related to the my second questions.
 
2. Is is possible to unmount only the HID enumeration of a device and leave any additional enunmerations still mounted? In my case, I have a USB memory stick that enumerates as a USB composite device: a mass storage device, and an HID device. When I call hid_force_open(), the mass storage drives on this device disappear. I assume the unmount call in hid_force_open() does this.
 
So, is there a way for me to access the HID part of the device through libhid without unmounting the complete device, or have I reached a dead-end in terms of supporting this device on Linux.
 
Best regards, and thanks for your help,
--- Asad
 
_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/
Peter Stuge | 12 Mar 2009 01:33

Re: Using libhid with composit device

Ali Asad wrote:
> 2. Is is possible to unmount only the HID enumeration of a device
> and leave any additional enunmerations still mounted?

Yes.

> So, is there a way for me to access the HID part of the device
> through libhid without unmounting the complete device, or have I
> reached a dead-end in terms of supporting this device on Linux.

I think neither is the case.

Linux certainly allows userspace programs to detach only a single
interface out of several implemented.

But, you may have to program libusb or even usbfs directly, and not
use libhid.

But it may also be a simple fix for libhid, allowing you to continue
using libhid.

//Peter

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

Ali Asad | 12 Mar 2009 01:50
Favicon

Re: Using libhid with composit device


Peter, thanks for the prompt & to-the-point reply, and for keeping my hopes up. I will investigate further
and see if using libusb provides a faster path for me.

regards,
--- asad

-----Original Message-----
From: libhid-discuss-bounces+asad.ali=gemalto.com <at> lists.alioth.debian.org
[mailto:libhid-discuss-bounces+asad.ali=gemalto.com <at> lists.alioth.debian.org] On Behalf Of
Peter Stuge
Sent: Wednesday, March 11, 2009 7:33 PM
To: libhid-discuss <at> lists.alioth.debian.org
Subject: Re: [libhid-discuss] Using libhid with composit device

Ali Asad wrote:
> 2. Is is possible to unmount only the HID enumeration of a device and
> leave any additional enunmerations still mounted?

Yes.

> So, is there a way for me to access the HID part of the device through
> libhid without unmounting the complete device, or have I reached a
> dead-end in terms of supporting this device on Linux.

I think neither is the case.

Linux certainly allows userspace programs to detach only a single interface out of several implemented.

But, you may have to program libusb or even usbfs directly, and not use libhid.

But it may also be a simple fix for libhid, allowing you to continue using libhid.

//Peter

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/

_______________________________________________
libhid-discuss mailing list
libhid-discuss <at> lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss
http://libhid.alioth.debian.org/


Gmane