Skip to content

Commit da50873

Browse files
committed
adapter: list supported transports beside adapter name
Modify the command 'adapter list' to output the list of transports supported by each adapter driver. Drop the line number, as there is no real interest on it. Format the output as a TCL dictionary indexed by the adapter name and containing the transports in a TCL list. E.g: dummy { jtag } ftdi { jtag swd } This format is easily handled by TCL scripts, e.g.: dict get [adapter list] ftdi Document the command output. Change-Id: I69f73b71da2f1756866a63bc2c0ba33459a29063 Signed-off-by: Antonio Borneo <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/8691 Tested-by: jenkins
1 parent c3fae34 commit da50873

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

doc/openocd.texi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,6 +2414,17 @@ target.
24142414
@deffn {Command} {adapter list}
24152415
List the debug adapter drivers that have been built into
24162416
the running copy of OpenOCD.
2417+
2418+
The output is formatted as a Tcl dictionary indexed by the adapter name
2419+
and containing the transports in a Tcl list.
2420+
@example
2421+
dummy @{ jtag @}
2422+
ftdi @{ jtag swd @}
2423+
@end example
2424+
This format is easily handled by Tcl scripts:
2425+
@example
2426+
dict get [adapter list] ftdi
2427+
@end example
24172428
@end deffn
24182429

24192430
@anchor{adapter gpio}

src/jtag/adapter.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,21 @@ COMMAND_HANDLER(handle_adapter_name)
393393

394394
COMMAND_HANDLER(dump_adapter_driver_list)
395395
{
396+
int max_len = 0;
397+
for (unsigned int i = 0; adapter_drivers[i]; i++) {
398+
int len = strlen(adapter_drivers[i]->name);
399+
if (max_len < len)
400+
max_len = len;
401+
}
402+
396403
for (unsigned int i = 0; adapter_drivers[i]; i++) {
397404
const char *name = adapter_drivers[i]->name;
398-
command_print(CMD, "%u: %s", i + 1, name);
405+
const char * const *transports = adapter_drivers[i]->transports;
406+
407+
command_print_sameline(CMD, "%-*s {", max_len, name);
408+
for (unsigned int j = 0; transports[j]; j++)
409+
command_print_sameline(CMD, " %s", transports[j]);
410+
command_print(CMD, " }");
399411
}
400412

401413
return ERROR_OK;

0 commit comments

Comments
 (0)