I haven't had much problem with Set_Configuration, partially because (IRC), the 
actual set_configuration command isn't required for most devices.  (Most only 
have one configuration, which is set by default.)

I also haven't used Mac, but here's what I've got right off:

It sounds like you've got a permissions error.  A couple things to check for 
that, extrapolating from SuSe Linux:

Make sure the device is being attached with a user or group corresponding to 
your user.  If not, try running the code as root.  Assuming that you can access 
it as root and not as user, you almost definitely have a basic permissions 
error.

Unfortunately, as I found out last year, "basic permissions error" covers a lot 
of territory.  On my system, I had to 1)  Create a "usb" group; 2) Add the 
necessary users to the "usb" group; 3)  Make sure there was an appropriate rule 
for my device in /etc/udev/rules.d (Check the linux-hotplug group for details 
there.);  4)  Make sure that rule used ATTRS to access the device instead of 
SYSFS (which was my initial guess);  5)  Make sure the devices I was trying to 
reach were configured to obey the USB port rather than try to control it; and 
6) Put a USB hub between the PC and the device.  No idea why that should 
matter, but for some reason, it improved communication substantially.

Anyhow,  below is the text from my last post on the libusb-devel and 
linux-hotplug groups.  Since pyusb is (mostly) a wrapper for libusb functions 
and linux-hotplug handles most of the permissions aspects of talking to USB 
devices, those groups will likely be good places for follow-up questions.


Cc: "libusb-devel" <libusb-de...@lists.sourceforge.net>, 
linux-hotp...@vger.kernel.org
Date: Monday, January 5, 2009, 9:58 AM

Changing SYSFS -> ATTRS in 55-libsane.rules worked.  Thanks

For the record, the command sequence I use (in pyusb) is:

import usb        #sets up libusb
...
allBus=usb.busses()   #read in a list of available USB busses
...
bus=allBus[bIndex]       #focus on bus number bIndex
dev=bus.devices[dIndex]   #focus on device number dIndex on that bus
hand=dev.open()            #open that device and return the DeviceHandle
                #read the device serial number as a string
                #prepend 'USB' to distinguish this from RS-232 equipment
                #on the same system
thisSerNum='USB'+hand.getString(dev.iSerialNumber, USB_SHORT_BUFF)   
...

Ellipsis marks omitted code which sets up variables and is not directly related 
to the usb managment. 

The code fails at the hand.getString() call (with SYSFS in the .rules file).

This code is part of a device-identification loop, and so there is no 
claimInterface() command.  Device-descriptor queries like the above are 
necessary to determine which interfaces are available for claiming.

Thanks for your help.

-Sarah


--- On Sun, 4/5/09, George Wright <georg...@bigpond.net.au> wrote:

> From: George Wright <georg...@bigpond.net.au>
> Subject: [Pyusb-users] New to pyusb & 'exclusive access' Problems
> To: pyusb-users@lists.sourceforge.net
> Date: Sunday, April 5, 2009, 7:28 AM
> Gidday
> I installed libusb 0.1.12 and pyusb 0.4.1 on Mac OSX 10.5.6
> I get samples/usbenum.py to run OK
> but Isusb.py will only run if I remove the
> dev.open().getString(1, 30)
> item.
> Following the interactive steps the Readme I get to the
> step  
> 'handle.setConfiguration(0)'
> which produces the error
>  >>> import usb
>  >>> bus = usb.busses()
>  >>> dev = bus[0].devices[0]
>  >>> handle = dev.open()
>  >>> handle.setConfiguration(0)
> Traceback (most recent call last):
>    File "<stdin>", line 1, in
> <module>
> usb.USBError: usb_set_configuration(SetConfiguration):
> device not  
> opened for exclusive access
>  >>>
> 
> I followed some threads on this list relating to the
> exclusive access  
> error  (in darwin.c?) but have been unable to discover if
> someone has  
> found a solution.
> What's the latest on this?
> 
> George Wright
> georg...@bigpond.net.au
> http://mywebsite.bigpond.net.au/georgewr/
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Pyusb-users mailing list
> Pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users



      

------------------------------------------------------------------------------
_______________________________________________
Pyusb-users mailing list
Pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to