|
From: eric t. <et...@ou...> - 2020-03-14 17:17:13
|
Hi all,
I have working hardware with a FTDI601 chip.
Using FTDI's libraries (which use libusb) I have no problem reading and writing using FT_ReadPipe and FT_WritePipe.
However, the end application is to run on a ARM processes, which is not supported by FTDI. So I will be calling libusb directly.
I am able to do libusb_transfer_control to read and write to the FTDI configuration EEPROM,
I am trying to to libusb_bulk_transfers using enpoint 0x82 but get the LIBUSB_ERROR_TIMEOUT every time.
Code:
_______________________________________________________________
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <libusb-1.0/libusb.h>
#define BULK_EP_OUT 0x02
#define BULK_EP_IN 0x82
#define VID 0x0403
#define PID 0x601F
#define READ_BUFFER_SIZE 1024
int main ( int argc, char *argv[] )
{
int ret,iface;
struct libusb_device_handle *handle = NULL;
libusb_device *dev;
struct libusb_config_descriptor *desc;
int interfaces;
unsigned char read_buffer[READ_BUFFER_SIZE];
int bytes_received;
ret = libusb_init(NULL);
if(ret < 0 )
{
printf("\nFailed to init\n");
return -1;
}
handle = libusb_open_device_with_vid_pid(NULL, VID, PID);
if( handle == NULL )
{
printf("Could not open device\n");
}
dev = libusb_get_device(handle);
libusb_get_config_descriptor(dev,0, &desc);
interfaces = desc->bNumInterfaces;
libusb_free_config_descriptor(desc);
libusb_set_auto_detach_kernel_driver(handle,1);
for(iface = 0; iface < interfaces; iface++ )
{
printf("\nClaiming interface %d..\n",iface);
ret = libusb_claim_interface(handle, iface);
if ( ret != LIBUSB_SUCCESS )
{
printf(" Failed, could not claim interface: %d\n",iface);
}
}
libusb_clear_halt(handle, BULK_EP_OUT);
libusb_clear_halt(handle, BULK_EP_IN);
while(1)
{
ret = libusb_bulk_transfer(handle, BULK_EP_IN, &read_buffer[0], 4, &bytes_received, 100);
if ( ret < 0 )
{
printf("Bulk transfer failed, error code: %d\n",ret);
printf("Did we receive any bytes? bytes_received: %d\n",bytes_received);
}
else
{
printf("Bulk read successful\n");
}
}
return 0;
}
______________________________________________________________
when running here is the output:
Claiming interface 0..
Claiming interface 1..
Bulk transfer failed, error code: -7
Did we recive any bytes? bytes_recived: 0
Bulk transfer failed, error code: -7
Did we recive any bytes? bytes_recived: 0
Bulk transfer failed, error code: -7
Did we recive any bytes? bytes_recived: 0
here is what usbmon shows while running:
ffffffc18f5d5d80 623043173 S Co:2:030:0 s 02 01 0000 0002 0000 0
ffffffc18f5d5d80 623043710 C Co:2:030:0 0 0
ffffffc1a6d20b40 623043748 S Co:2:030:0 s 02 01 0000 0082 0000 0
ffffffc1a6d20b40 623043998 C Co:2:030:0 0 0
ffffffc1a6d20b40 623044073 S Bi:2:030:2 -115 4 <
ffffffc1a6d20b40 623144606 C Bi:2:030:2 -2 0
ffffffc1a6d20b40 623144951 S Bi:2:030:2 -115 4 <
ffffffc1a6d20b40 623245446 C Bi:2:030:2 -2 0
ffffffc1a6d20b40 623245687 S Bi:2:030:2 -115 4 <
ffffffc1a6d20b40 623346160 C Bi:2:030:2 -2 0
ffffffc1a6d20b40 623346394 S Bi:2:030:2 -115 4 <
ffffffc1a6d20b40 623446897 C Bi:2:030:2 -2 0
here is the output of lsusb -v
______________________________________________________________
Bus 002 Device 030: ID 0403:601f Future Technology Devices International, Ltd
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 3.10
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 ?
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 9
idVendor 0x0403 Future Technology Devices International, Ltd
idProduct 0x601f
bcdDevice 0.00
iManufacturer 1 FTDI
iProduct 2 FTDI SuperSpeed-FIFO Bridge
iSerial 3 000000000001
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 87
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 24mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 255 Vendor Specific Class
bFunctionSubClass 255 Vendor Specific Subclass
bFunctionProtocol 255 Vendor Specific Protocol
iFunction 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 9
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 15
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 15
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 22
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000006
Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000e
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 2
Lowest fully-functional device speed is High Speed (480Mbps)
bU1DevExitLat 10 micro seconds
bU2DevExitLat 2047 micro seconds
Device Status: 0x000d
Self Powered
U1 Enabled
U2 Enabled
I have tried messing around with bytes to length and buffer size, with the same results.
Thanks for your time.
Eric
|