Device bussy error

View: New views
7 Messages — Rating Filter:   Alert me  

Device bussy error

by Hüseyin Kozan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am new in libusb. I am porting a win32 application (not
libusb-win32) to linux. I decided to use 0.1 to work on both
platforms. I am using ubuntu karmic.

My problem is reading interrupt from a custom hid device. When I try
to read as user, I got "operation not permitted". When as root,
"Device bussy".

The device have got a development board's product id and vendor id,
but the sub class is 0 (custom class) in interface. I cannot
understand the problem, or does linux uses the device.

Do you have any idea ?


Huseyin

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel

Re: Device bussy error

by Tim Roberts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hüseyin Kozan wrote:

> I am new in libusb. I am porting a win32 application (not
> libusb-win32) to linux. I decided to use 0.1 to work on both
> platforms. I am using ubuntu karmic.
>
> My problem is reading interrupt from a custom hid device. When I try
> to read as user, I got "operation not permitted". When as root,
> "Device bussy".
>
> The device have got a development board's product id and vendor id,
> but the sub class is 0 (custom class) in interface. I cannot
> understand the problem, or does linux uses the device.
>  

If it's HID class, then the Linux HID driver will have claimed it.  You
need to use usb_detach_kernel_driver_np to get it to release.

There is a separate library designed specifically for dealing with HID
devices (libhid).  It might save you some work if that will do the job.

--
Tim Roberts, timr@...
Providenza & Boekelheide, Inc.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel

Parent Message unknown Re: Device bussy error

by Tim Roberts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hüseyin Kozan wrote:
> One more question. I am using 3 threads in my application (QThread).
> First is the main thread, one for reading USB and one for writing to
> USB. Shoul I claim the device in both writing and reading or just
> claim at the starting point of the main thread.
>  

The "claim" applies to the process, so you only need to do it once.

However, you said you are using libusb 0.1, didn't you?  Libusb 0.1 is
not thread-safe.  You can't access two pipes from two different threads.

--
Tim Roberts, timr@...
Providenza & Boekelheide, Inc.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel

Parent Message unknown Re: Device bussy error

by Tim Roberts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hüseyin Kozan wrote:

> 2009/10/29 Tim Roberts <timr@...>:
>  
>> The "claim" applies to the process, so you only need to do it once.
>>
>> However, you said you are using libusb 0.1, didn't you?  Libusb 0.1 is
>> not thread-safe.  You can't access two pipes from two different threads.
>>    
>
> So, how can I use the library to read and write simultaneously ?
> Can't I use threads ?
>  

Not with libusb 0.1.  You would have to open two separate handles.

However, HID devices do not normally need that kind of throughput.
Usually, you can just write, then read, then write, then read.

--
Tim Roberts, timr@...
Providenza & Boekelheide, Inc.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel

Re: Device bussy error

by Graeme Gill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tim Roberts wrote:
> However, you said you are using libusb 0.1, didn't you?  Libusb 0.1 is
> not thread-safe.  You can't access two pipes from two different threads.

My libusb 0.1 happily has threads accessing different end points
on Linux and OS X, and (with libusb-win32) on MSWindows.
The only reason the "official" 0.1 doesn't do this, is
that it hasn't been updated with the appropriate fixes.

Graeme Gill.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel

Re: Device bussy error

by Michael Plante :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

While I don't use libusb in the way you describe, I'm nevertheless curious
to see these patches, just to further my understanding.  Are they posted
publicly anywhere?

Thanks,
Michael



-----Original Message-----
From: Graeme Gill [mailto:graeme2@...]
Sent: Thursday, October 29, 2009 7:59 PM
To: libusb-devel
Subject: Re: [Libusb-devel] Device bussy error


Tim Roberts wrote:
> However, you said you are using libusb 0.1, didn't you?  Libusb 0.1 is
> not thread-safe.  You can't access two pipes from two different threads.

My libusb 0.1 happily has threads accessing different end points
on Linux and OS X, and (with libusb-win32) on MSWindows.
The only reason the "official" 0.1 doesn't do this, is
that it hasn't been updated with the appropriate fixes.

Graeme Gill.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel

Re: Device bussy error

by Graeme Gill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael Plante wrote:
> While I don't use libusb in the way you describe, I'm nevertheless curious
> to see these patches, just to further my understanding.  Are they posted
> publicly anywhere?

In the libusb sub directory of the source archive
<http://www.argyllcms.com/Argyll_V1.0.4_src.zip>

Most of the changes are in the usb_urb_transfer() function
in linux.c.

Graeme Gill.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libusb-devel mailing list
Libusb-devel@...
https://lists.sourceforge.net/lists/listinfo/libusb-devel