On 23 August 2016 at 16:40, Tormod Volden <[email protected]> wrote:
> On Tue, Aug 23, 2016 at 8:31 AM, Jay Aurabind wrote:
>> On 23 August 2016 at 02:18, Tormod Volden wrote:
>>> I am a bit confused here, did you really want to manipulate the root
>>> hub with pyusb, or did something go wrong here?
>>>
>>
>> Absolutely not, only reason I wanted to try giving write permission to
>> that device, which happens to be the root hub was because that's the
>> only permission error I see in the LIBUSB debug messages, as you can
>> see from the logs I showed. If I run pyusb as root, I do not see those
>> permission errors.
>
> OK, I see.
>
>>
>> I suspect that pyusb reads certain data commonly for all available
>> devices, may to figure out whether that is really the device it needs
>> to work on ?
>
> It usually shouldn't try to retrieve descriptor strings from other
> devices than the ones targeted. The device descriptor (retrieved and
> cached by the OS) is usually enough to filter out the right devices
> (e.g. filtering on vid/pid). How are the devices filtered in your
> program?
Here is the code which creates the error:
all_devices = usb.core.find(find_all=True)
if not all_devices:
logging.debug("No device connected")
return []
boards = []
# iterate on all devices found
for board in all_devices:
interface_number = -1
try:
# The product string is read over USB when accessed.
# This can cause an exception to be thrown if the device
# is malfunctioning.
product = board.product
This is how pyusb is used. The program doesn't go beyond the last line
shown above, if run as normal user. See full source github[1].
[1]:https://github.com/mbedmicro/pyOCD/blob/master/pyOCD/pyDAPAccess/interface/pyusb_backend.py#L88
>
>>> Some devices can be released from the kernel, and then be available
>>> for you to manipulate it through the device node (and thus via e.g
>>> libusb and pyusb). See for instance the libusb_detach_kernel_driver()
>>> function in libusb. However, in most cases people use libusb and pyusb
>>> to access devices that have no kernel driver.
>>
>> In that case, even the root should not be able to write to those
>> devices, since its exclusively managed by kernel. Then how come I get
>> no errors when I run pyocd with root permissions ?
>
> You won't be able to claim any of its interfaces, but I suppose some
> control transfers are still allowed.
>
> Tormod
>
> ------------------------------------------------------------------------------
> _______________________________________________
> pyusb-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
--
Thanks and Regards,
Aurabindo J
------------------------------------------------------------------------------
_______________________________________________
pyusb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyusb-users