Added help function to every cable, closes [1851444] More cable help

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@846 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Kolja Waschk 17 years ago
parent 8a15b610f3
commit dedc872f52

@ -48,6 +48,7 @@ struct cable_driver_t {
int (*transfer)( cable_t *, int, char *, char * );
int (*set_trst)( cable_t *, int );
int (*get_trst)( cable_t * );
void (*help)( char * );
};
struct cable_t {

@ -39,12 +39,35 @@
static int
cmd_cable_run( char *params[] )
{
cable_t *cable = malloc( sizeof *cable );
cable_t *cable;
int i;
int paramc = cmd_params( params );
/* we need at least one parameter for 'cable' command */
if (cmd_params( params ) < 2)
return -1;
if (paramc < 2) return -1;
/* maybe old syntax was used? search connection type driver */
for (i = 0; parport_drivers[i]; i++)
if (strcasecmp( params[1], parport_drivers[i]->type ) == 0)
break;
if (parport_drivers[i] != 0)
{
/* Old syntax was used. Swap params. */
char *tmparam;
printf( _("Note: the 'cable' command syntax changed, please read the help text\n") );
if (paramc >= 4)
{
tmparam = params[3];
params[3] = params[2];
}
else if (paramc >= 3)
{
char *tmparam = params[2];
};
params[2] = params[1];
params[1] = tmparam;
}
/* search cable driver list */
for (i = 0; cable_drivers[i]; i++)
@ -55,6 +78,15 @@ cmd_cable_run( char *params[] )
return 1;
}
if (paramc >= 3)
{
if (strcasecmp( params[2], "help" ) == 0)
{
cable_drivers[i]->help(cable_drivers[i]->name);
return 1;
}
}
if (bus) {
bus_free( bus );
bus = NULL;
@ -62,6 +94,8 @@ cmd_cable_run( char *params[] )
chain_disconnect( chain );
cable = malloc( sizeof(cable_t) );
if (!cable) {
printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__);
return 1;
@ -100,6 +134,8 @@ cmd_cable_help( void )
"DRIVER name of cable\n"
"DRIVER_OPTS options for the selected cable\n"
"\n"
"Type \"cable DRIVER help\" for info about options for cable DRIVER.\n"
"\n"
"List of supported cables:\n"
), "cable" );

@ -111,5 +111,6 @@ cable_driver_t arcom_cable_driver = {
arcom_get_tdo,
generic_transfer,
arcom_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help
};

@ -137,5 +137,6 @@ cable_driver_t byteblaster_cable_driver = {
byteblaster_get_tdo,
generic_transfer,
byteblaster_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help
};

@ -108,5 +108,6 @@ cable_driver_t dlc5_cable_driver = {
dlc5_get_tdo,
generic_transfer,
dlc5_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help
};

@ -111,5 +111,6 @@ cable_driver_t ea253_cable_driver = {
ea253_get_tdo,
generic_transfer,
ea253_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help
};

@ -113,5 +113,6 @@ cable_driver_t ei012_cable_driver = {
ei012_get_tdo,
generic_transfer,
ei012_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help
};

@ -466,6 +466,18 @@ ft2232_transfer( cable_t *cable, int len, char *in, char *out )
return 0;
}
void
ft2232_usbcable_help(char *cablename)
{
printf( _(
"Usage: cable %s ftdi-mpsse VID:PID\n"
"\n"
"VID vendor ID (hex, e.g. 9FB, or empty)\n"
"PID product ID (hex, e.g. 6001, or empty)\n"
"\n"
), cablename );
}
cable_driver_t ft2232_cable_driver = {
"FT2232",
N_("Generic FTDI FT2232 Cable"),
@ -478,7 +490,8 @@ cable_driver_t ft2232_cable_driver = {
ft2232_get_tdo,
ft2232_transfer,
ft2232_set_trst,
generic_get_trst
generic_get_trst,
ft2232_usbcable_help
};
cable_driver_t ft2232_armusbocd_cable_driver = {
@ -493,7 +506,8 @@ cable_driver_t ft2232_armusbocd_cable_driver = {
ft2232_get_tdo,
ft2232_transfer,
ft2232_set_trst,
generic_get_trst
generic_get_trst,
ft2232_usbcable_help
};

@ -123,3 +123,21 @@ generic_get_trst( cable_t *cable )
{
return PARAM_TRST(cable);
}
void
generic_lptcable_help( char *cablename )
{
printf( _(
"Usage: cable %s parallel PORTADDR\n"
#if HAVE_LINUX_PPDEV_H
" or: cable %s ppdev DEV\n"
#endif
"\n"
"PORTADDR parallel port address (e.g. 0x378)\n"
#if HAVE_LINUX_PPDEV_H
"DEV ppdev device (e.g. /dev/parport0)\n"
#endif
"\n"
), cablename, cablename );
}

@ -42,5 +42,6 @@ void generic_cable_free( cable_t *cable );
void generic_done( cable_t *cable );
int generic_transfer( cable_t *cable, int len, char *in, char *out );
int generic_get_trst( cable_t *cable );
void generic_lptcable_help( char *name );
#endif /* GENERIC_H */

@ -120,5 +120,6 @@ cable_driver_t keithkoep_cable_driver = {
keithkoep_get_tdo,
generic_transfer,
keithkoep_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help,
};

@ -103,5 +103,6 @@ cable_driver_t lattice_cable_driver = {
lattice_get_tdo,
generic_transfer,
lattice_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help
};

@ -117,5 +117,6 @@ cable_driver_t mpcbdm_cable_driver = {
mpcbdm_get_tdo,
generic_transfer,
mpcbdm_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help,
};

@ -122,5 +122,6 @@ cable_driver_t triton_cable_driver = {
triton_get_tdo,
generic_transfer,
triton_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help,
};

@ -163,6 +163,18 @@ usbblaster_transfer( cable_t *cable, int len, char *in, char *out )
return 0;
}
void
usbblaster_help(char *cablename)
{
printf( _(
"Usage: cable %s ftdi VID:PID\n"
"\n"
"VID vendor ID (hex, e.g. 9FB, or empty)\n"
"PID product ID (hex, e.g. 6001, or empty)\n"
"\n"
), cablename );
}
cable_driver_t usbblaster_cable_driver = {
"UsbBlaster",
N_("Altera USB-Blaster Cable"),
@ -175,5 +187,6 @@ cable_driver_t usbblaster_cable_driver = {
usbblaster_get_tdo,
usbblaster_transfer,
usbblaster_set_trst,
generic_get_trst
generic_get_trst,
usbblaster_help,
};

@ -135,6 +135,7 @@ cable_driver_t igloo_cable_driver = {
wiggler_get_tdo,
generic_transfer,
wiggler_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help,
};

@ -127,5 +127,6 @@ cable_driver_t wiggler2_cable_driver = {
wiggler2_get_tdo,
generic_transfer,
wiggler2_set_trst,
generic_get_trst
generic_get_trst,
generic_lptcable_help,
};

@ -94,6 +94,18 @@ xpc_set_trst( cable_t *cable, int trst )
return 1;
}
void
xpcu_usbcable_help(char *cablename)
{
printf( _(
"Usage: cable %s xpcu VID:PID\n"
"\n"
"VID vendor ID (hex, e.g. 9FB, or empty)\n"
"PID product ID (hex, e.g. 6001, or empty)\n"
"\n"
), cablename );
}
cable_driver_t xpc_int_cable_driver = {
"xpc_int",
N_("Xilinx Platform Cable USB internal chain"),
@ -106,9 +118,16 @@ cable_driver_t xpc_int_cable_driver = {
xpc_get_tdo,
generic_transfer,
xpc_set_trst,
generic_get_trst
generic_get_trst,
xpcu_usbcable_help
};
void
xpc_ext_usbcable_help()
{
xpcu_usbcable_help("xpc_ext");
}
cable_driver_t xpc_ext_cable_driver = {
"xpc_ext",
N_("Xilinx Platform Cable USB external chain"),
@ -121,6 +140,7 @@ cable_driver_t xpc_ext_cable_driver = {
xpc_get_tdo,
generic_transfer,
xpc_set_trst,
generic_get_trst
generic_get_trst,
xpcu_usbcable_help
};

Loading…
Cancel
Save