2013/11/5 Andreas Doering <acd_a...@web.de>: > Hello, > Hi
> (I am using an anonymous email address to avoid spam, but I > do not intend to anonymous. ) > No problem. > I have been using libusb + pyusb in spring with a first version of our > board, > and now the second version arrived an nothing is working anymore. > However, I have the same problems with the develoment board, and that is > unchanged. > Furthermore, a small C program works (which accesses the same libusb), > so I see the reason on the PyUSB side. > I guess so. > My device is a Cypress PSoC 3, and the problem already happens with the > small > demo (wrapback) that they provide. > > Here is the simplest test, and it fails with an IO-error: > >>>>> > import usb > wrdev = usb.core.find(idVendor=0x04b4,idProduct=0x8051) > wrdev.set_configuration() > usb.util.claim_interface(wrdev,0) > You don't need to explicitly claim the interface, you can if you want to, but it is not necessary. > written = wrdev.write(2,"hello",0,3000) > <<<< > > Hence I tried a simpler test and replaced the last line by: > >>>>> > wrdev._ctx.backend.bulk_write(wrdev._ctx.handle,1,0,usb._interop.as_array("hallo"),1000) > <<<< > > I have not seen a packet on wireshark, so I guess it fails before in the > libusb or linux kernel stack. > However the simple C test program works. > I show only the relevant calls: > > > #define DMA_EP_OUT 2 > #define DMA_EP_IN 0x81 > #define write_timeout 500 > #define read_timeout 800 > err = libusb_init(NULL); > handle = libusb_open_device_with_vid_pid(NULL, 0x04b4, 0x8051); > err = libusb_claim_interface(handle, 0); > err = > libusb_bulk_transfer(handle,DMA_EP_OUT,combuf+1,cblen-1,&sent_len,write_timeout); > I noticed that in your C code you don't issue a SET_CONFIGURATION, any reason to not doing so? Would you mind enabling LIBUSB_DEBUG environment variable for both tests and posting the logs here? Also, you can enable the PYUSB_DEBUG=debug environment variable on pyusb. > The buffer is filled from keyboard. > The detailed libusb debug messages were not very helpful to me, as they did > not show the parameters (such as end points). > > What particularly puzzles me is the interface parameter in the back end: > > #int libusb_bulk_transfer( > # struct libusb_device_handle *dev_handle, > # unsigned char endpoint, > # unsigned char *data, > # int length, > # int *transferred, > # unsigned int timeout > # ) > lib.libusb_bulk_transfer.argtypes = [ > _libusb_device_handle, > c_ubyte, > POINTER(c_ubyte), > c_int, > POINTER(c_int), > c_uint > ] > > > def bulk_write(self, dev_handle, ep, intf, data, timeout): > return self.__write(self.lib.libusb_bulk_transfer, > dev_handle, > ep, > intf, > data, > timeout) > > How does the data pointer interface get mixed up? > I mean, I am not very familiar with the way Python interacts with > C-libraries but in the libusb declaration (and in my > operational C code) the interface is not passed to libusb_bulk_transfer. > The way I understand the core.py call of bulk_write, the interface is used. > The *intf* parameter is ignored on libusb backend. I have updated the documentation recently point that. Currently, it is only necessary for openusb backend. > Hence, I am quite confused. > Do I mix with the wrong version of libusb? > I freshly installed libusb-1.0.9 > I would guess that something as basic as bulk transfers are well tested. > Before release I always test all four transfers with all backends marked as stable, of course it is impossible to test with all devices available so some tricky cases may pass. -- Best Regards, Wander Lairson Costa ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users