> Hello wander.lairson:
> First of all,thanks for your contribution for the opensource community
> and the work for libusb, I appricate it very much.
> Currently I want to fetch the serial number of the massive storage
> device,which need the string descriptor. Unfortunately,the python interface
> hasn't wrapped the API yet. I tried to implement it myself and copy some of
> the __read function code. Like this:
>>
>> def get_string_descriptor_ascii(self,dev_handle,desc_index):
>>
>> """Added by GaoHong"""
>>
>> buffer = array.array('B','\x00' * 255)
>>
>> address, length = buffer.buffer_info()
>>
>>
>> _check(_lib.libusb_get_string_descriptor_ascii(dev_handle,desc_index,cast(address,
>> POINTER(c_ubyte)),length))
I am not sure if it is the problem (because I don't know how ctypes
pushes arguments in the stack), but if you haven't supplied the
function prototype, desc_index will be treated as an integer instead
of a 8 bits variable (as in the libusb_get_string_descriptor_ascii
interface). You might try this to see if it is a problem:
_check(_lib.libusb_get_string_descriptor_ascii(dev_handle,c_uint8(desc_index),cast(address,POINTER(c_ubyte)),length))
If not, I am affraid you will have to play with WinDBG to see what's
going on. Also, try to write a little C program that call
libusb_get_string_descriptor_ascii. I may cut off the possiblity of a
bug in libusb.
PS: I could debug it for you, but currently I do have no free time for
it, I am really sorry.
>>
>> return data
>
> but the result always raise WindowsError: exception: access violation
> reading 0x00000010
> File "E:\my_doc\My Dev\python\GWP 0902\usb_finder.py", line 60, in <module>
> print
> 'Manufacturer:',back.get_string_descriptor_ascii(dev._ctx.handle,dev.iManufacturer)
> File "D:\Python26\Lib\site-packages\usb\_debug.py", line 53, in do_trace
> return f(*args, **named_args)
> File "D:\Python26\Lib\site-packages\usb\backend\libusb10.py", line 593, in
> get_string_descriptor_ascii
> _check(_lib.libusb_get_string_descriptor_ascii(dev_handle,desc_index,cast(address,
> POINTER(c_ubyte)),length-1))
> I don't know why,the only difference from __read function:
>>
>> def __read(self, fn, dev_handle, ep, intf, size, timeout):
>>
>> buffer = array.array('B', '\x00' * size)
>>
>> address, length = buffer.buffer_info()
>>
>> transferred = c_int()
>>
>> _check(fn(dev_handle,
>>
>> ep,
>>
>> cast(address, POINTER(c_ubyte)),
>>
>> length,
>>
>> byref(transferred),
>>
>> timeout))
>>
>> return buffer[:transferred.value]
>
> is the called function.
> Can you tell me why? Thank you very much.
> --
> It's a long journey to go! :-)
> Legend since 1985...
>
--
Best Regards,
Wander Lairson Costa
------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful,
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance.
http://p.sf.net/sfu/dell-sfdev2dev
_______________________________________________
pyusb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyusb-users