FW: Bulk read write in libusb-win 0.1.12.1
Chaitanya Joshi <chaitanya.b.joshi <at> gmail.com>
2008-08-20 07:28:31 GMT
Hello,
I am testing libusb-win with intention to use it with USB Mass Storage Flash
Drives. I had downloaded the source and compiled it with DDK. I also succeeded
in installing driver for my flash drive. The next thing I wanted to do is to
test its data transfer features and capacity. While looking for some example, I
got your bulk read/write transfer program. So I took it and run it with VS 2005
environment. I have also turned on debug output for program. But somehow it is
failing.
The typical output is
>LIBUSB_DLL: info: usb_os_init: dll
version: 0.1.12.1
>LIBUSB_DLL: info: usb_os_init: driver
version: 0.1.12.1
>LIBUSB_DLL: info: usb_os_find_busses:
found bus-0
>LIBUSB_DLL: info: usb_os_find_devices:
found \\.\libusb0-0001--0x058f-0x6387 on
>bus-0
>Found and opened the device
>LIBUSB_DLL: error: usb_reap: reaping
request failed, win error: A device attached to the system is not functioning.
>
>error: bulk read failed
When I checked through device manager, it shows the device
under libusb-win32 devices as USB
Drive which I had installed the driver for. The
test utility that comes with the source also works with the same setup. So what
can be problem??
Thanks for your time, in advance.
Regards,
Chaitanya Joshi
P.S.: I have attached my code file as well.
// TestReadWrite.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "usb.h"
/* the device's vendor and product id */
#define MY_VID 0x058F
#define MY_PID 0x6387
/* the device's endpoints */
#define EP_IN 0x82
#define EP_OUT 0x01
#define BUF_SIZE 64
usb_dev_handle *open_dev(void);
usb_dev_handle *open_dev(void)
{
struct usb_bus *bus;
struct usb_device *dev;
for(bus = usb_get_busses(); bus; bus = bus->next)
{
for(dev = bus->devices; dev; dev = dev->next)
{
if(dev->descriptor.idVendor == MY_VID
&& dev->descriptor.idProduct == MY_PID)
{
printf("Found and opened the device\n");
return usb_open(dev);
}
}
}
return NULL;
}
int _tmain(int argc, _TCHAR* argv[])
{
usb_set_debug(255);
usb_dev_handle *dev = NULL; /* the device handle */
char tmp[BUF_SIZE];
usb_init(); /* initialize the library */
usb_find_busses(); /* find all busses */
usb_find_devices(); /* find all connected devices */
if(!(dev = open_dev()))
{
printf("error: device not found!\n");
return 0;
}
if(usb_set_configuration(dev, 1) < 0)
{
printf("error: setting config 1 failed\n");
usb_close(dev);
return 0;
}
if(usb_claim_interface(dev, 0) < 0)
{
printf("error: claiming interface 0 failed\n");
usb_close(dev);
return 0;
}
if(usb_bulk_write(dev, EP_OUT, tmp, sizeof(tmp), 5000)
!= sizeof(tmp))
{
printf("error: bulk write failed\n");
}
if(usb_bulk_read(dev, EP_IN, tmp, sizeof(tmp), 5000)
!= sizeof(tmp))
{
printf("error: bulk read failed\n");
}
usb_release_interface(dev, 0);
usb_close(dev);
return 0;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libusb-win32-devel mailing list
Libusb-win32-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel