>
> SOLVED
>
> > Now it is my turn. First of all thank you Xiaofan for all support you have
> > given here in the mailing list!
>
> My thanks too.
>
> > 1) Don't trust on get_active_configuration and get_interface_altsetting,
> > they are not doing what they are supposed to yet.. Menawhile, they are
> > returning the values set or the first one found if you haven't set. But I
> > think this is not the issue.
>
> get_active_configuration is working ok with my device.
> It has a bootloader when numConfigurations == 1 and when the firmware
> is loaded by the linu driver, it has 2 configurations and i need to
> set it to the second.
> This IS working for the case that the active configuration is 1 or the
> case that it is already 2. But in but cases i could just always set it
> to be the second.
>
>
> > 2) What seems to be the problem is how you are using directly constants from
> > usb.util to build the Request Type field. Some constants may require bit
> > shift, so try to use the usb.util.build_request_type function (I must add
> > this to the tutorial..). Test it and report us the results...
>
> This solved the problem.
>
> The types are defined as:
> CTRL_TYPE_STANDARD = 0
> CTRL_TYPE_CLASS = 1
> CTRL_TYPE_VENDOR = 2
> CTRL_TYPE_RESERVED = 3
>
> as oposed to the libusb definitions.
> #define LIBUSB_TYPE_STANDARD            (0x00 << 5)
> #define LIBUSB_TYPE_CLASS                    (0x01 << 5)
> #define LIBUSB_TYPE_VENDOR                 (0x02 << 5)
> #define LIBUSB_TYPE_RESERVED            (0x03 << 5)
>
> Now i am curious about this decision.
> Most supported libraries are libusb versions so everyone will have to
> shift bits with python or call this function which makes it less
> readable than in normal C libusb.
> Will this way of calling stay or should i redownload pyusb in a few weeks?
>

Well, I created the functions just because I wouldn't like  the users
having to worry about bitwise operations.
Remember that PyUSB 1.0 is not an wrapper around libusb 1.0, it is an
USB library for Python, supporting
more than one C library as backend (at this moment, my plan is to to
libusb 0.1, libusb 1.0 and OpenUSB).

>
> This is the working pyusb-example code:
>
>    print "Going for reading: REQUEST_LINE "
>    requesttype =
> usb.util.build_request_type(usb.util.CTRL_RECIPIENT_DEVICE,
> usb.util.CTRL_TYPE_VENDOR, usb.util.CTRL_IN)
>    command = REQUEST_LINE
>    value = 0
>    moduleid = 0 #USBCTRL_UART1_PORT#USBCTRL_RAM_PORT
>    msg = 8
>    print dev.ctrl_transfer(bmRequestType=requesttype,
>                             bRequest=command,
>                             wValue=value,
>                             wIndex=moduleid,
>                             data_or_wLength=msg,
>                             timeout=1000)
>
>    print "Going for reading: USB_REQ_GPIO "
>    requesttype =
> usb.util.build_request_type(usb.util.CTRL_RECIPIENT_DEVICE,
> usb.util.CTRL_TYPE_VENDOR, usb.util.CTRL_IN)
>    command = USB_REQ_GPIO
>    value = 0
>    moduleid = 0 #USBCTRL_UART1_PORT#USBCTRL_RAM_PORT
>    msg = 1
>    print dev.ctrl_transfer(bmRequestType=requesttype,
>                             bRequest=command,
>                             wValue=value,
>                             wIndex=moduleid,
>                             data_or_wLength=msg,
>                             timeout=1000)
>
>    print "Going for writing: USB_REQ_GPIO "
>    requesttype =
> usb.util.build_request_type(usb.util.CTRL_RECIPIENT_DEVICE,
> usb.util.CTRL_TYPE_VENDOR, usb.util.CTRL_OUT)
>    command = USB_REQ_GPIO
>    value = 0x33
>    moduleid = 0 #USBCTRL_UART1_PORT#USBCTRL_RAM_PORT
>    msg = None
>    print dev.ctrl_transfer(bmRequestType=requesttype,
>                             bRequest=command,
>                             wValue=value,
>                             wIndex=moduleid,
>                             data_or_wLength=msg,
>                             timeout=1000)
>
>
>
>
> Thanks for making this new pyusb.
> I was getting tired of using the old libusb-0.1 api to program
> multiplatform software.
>
> Diego.
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users



--
Best Regards,
Wander Lairson Costa

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to