I am using libusb-1.0 on linux with the mass storage device kingston datatrveler2.0
By using 'lsusb -v' I found that EP_OUT address is 0x02 and EP_IN address is 0x81. My code snippet as follows:
// Get the devHandle for mass storage device.
// Detach kernel driver
// claim the interface
actual = 64;
transferred = 0;
t_data = (char *) malloc(actual);
memset(t_data, 'X', actual);
retVal = libusb_bulk_transfer(devHandle, 0x02, t_data, actual, &transferred, 3000);
// This returns success.
if( retVal < 0)
{
printf("\nBulk transfer to this device failed\n");
dump_error(retVal);
}
if(transferred == actual)
{
printf("Bulk transfer success\n");
printf("Data written : %s\n", t_data);
}
retVal = libusb_bulk_transfer(devHandle, 0x81, t_data, actual, &transferred, 1000);
// This call returns TIMEOUT error.
if( retVal < 0)
{
printf("Bulk read failed\n");
dump_error(retVal);
}
if(retVal >= 0 && transferred == actual)
{
printf("Bulk read success\n");
printf("Data read : %s\n", t_data);
}
Output of the above code:
Bulk transfer success
Data written : XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Bulk read failed
LIBUSB_ERROR_TIMEOUT
My question is where exactly the successful bulk_transfer wrote the data to? How do I read the same data back? Why am I getting TIMEOUT error for read?
Note : I went through the following question, but its not clear to me, still stuck. libusb-1.0 - Where does the data go after a successful libusb_bulk_transfer() call?