[ 2085244 ] Wrong device chosen by ftd2xx driver

forward and use the desc= paramter


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1350 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Arnim Läuger 17 years ago
parent 742f23acb2
commit b54b2f0c8e

@ -1,3 +1,9 @@
2008-09-04 Arnim Laeuger <arniml@users.sourceforge.net>
* configure.ac, src/tap/usbconn/libftd2xx.c,
src/tap/usbconn/libftdi.c: forward and use the desc= paramter
[ 2085244 ] Wrong device chosen by ftd2xx driver
2008-09-03 Arnim Laeuger <arniml@users.sourceforge.net>
* src/tap/usbconn/libftd2xx.c, src/tap/usbconn/libftdi.c:

@ -209,7 +209,7 @@ AC_ARG_WITH([ftd2xx],
FTD2XXLIB=
AS_IF([test "x$with_ftd2xx" = xyes -o "x$with_ftd2xx" = xcheck], [
AC_CHECK_LIB([ftd2xx], [FT_Open], [
AC_CHECK_LIB([ftd2xx], [FT_OpenEx], [
HAVELIBFTD2XX=yes
LIBS="-lftd2xx $LIBS"
],[

@ -290,7 +290,7 @@ usbconn_ftd2xx_connect( const char **param, int paramc, usbconn_cable_t *templat
p->fc = NULL;
p->pid = template->pid;
p->vid = template->vid;
p->serial = NULL;
p->serial = template->desc ? strdup( template->desc ) : NULL;
c->params = p;
c->driver = &usbconn_ftd2xx_driver;
@ -328,7 +328,23 @@ usbconn_ftd2xx_common_open( usbconn_t *conn )
fprintf( stderr, "Warning: couldn't add %4.4x:%4.4x", p->vid, p->pid );
#endif
if ((status = FT_Open( 0, &(p->fc) )) != FT_OK)
/* try various methods to open a FTDI device */
if (p->serial)
{
/* serial number/description is specified */
/* first try to match against the serial string */
status = FT_OpenEx( p->serial, FT_OPEN_BY_SERIAL_NUMBER, &(p->fc) );
if (status != FT_OK)
/* then try to match against the description string */
status = FT_OpenEx( p->serial, FT_OPEN_BY_DESCRIPTION, &(p->fc) );
}
else
/* give it a plain try */
status = FT_Open( 0, &(p->fc) );
if (status != FT_OK)
{
printf( "Unable to open FTDI device.\n" );
/* mark ftd2xx layer as not initialized */

@ -262,7 +262,7 @@ usbconn_ftdi_connect( const char **param, int paramc, usbconn_cable_t *template
p->fc = fc;
p->pid = template->pid;
p->vid = template->vid;
p->serial = NULL;
p->serial = template->desc ? strdup( template->desc ) : NULL;
c->params = p;
c->driver = &usbconn_ftdi_driver;
@ -293,8 +293,16 @@ usbconn_ftdi_common_open( usbconn_t *conn )
{
ftdi_param_t *p = conn->params;
struct ftdi_context *fc = p->fc;
int status;
if (ftdi_usb_open_desc( fc, p->vid, p->pid, NULL, p->serial ) < 0)
/* use command line string for desc= as serial number and try to
open a matching device */
status = ftdi_usb_open_desc( fc, p->vid, p->pid, NULL, p->serial );
if (status < 0)
/* try again with matching the string against the description */
status = ftdi_usb_open_desc( fc, p->vid, p->pid, p->serial, NULL );
if (status < 0)
{
puts( ftdi_get_error_string( fc ) );
ftdi_deinit( fc );

Loading…
Cancel
Save