From: openocd-gerrit <ope...@us...> - 2025-05-01 15:26:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via da50873d5ebe558ee545c1a00f31df9e23f45456 (commit) from c3fae349692c7c2d0eac95a04da648ba95a558a0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit da50873d5ebe558ee545c1a00f31df9e23f45456 Author: Antonio Borneo <bor...@gm...> Date: Sat Jan 4 18:41:41 2025 +0100 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 <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8691 Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 32a2895ec..d85812824 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2414,6 +2414,17 @@ target. @deffn {Command} {adapter list} List the debug adapter drivers that have been built into the running copy of OpenOCD. + +The output is formatted as a Tcl dictionary indexed by the adapter name +and containing the transports in a Tcl list. +@example +dummy @{ jtag @} +ftdi @{ jtag swd @} +@end example +This format is easily handled by Tcl scripts: +@example +dict get [adapter list] ftdi +@end example @end deffn @anchor{adapter gpio} diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index 0bdfe7b13..694721746 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -393,9 +393,21 @@ COMMAND_HANDLER(handle_adapter_name) COMMAND_HANDLER(dump_adapter_driver_list) { + int max_len = 0; + for (unsigned int i = 0; adapter_drivers[i]; i++) { + int len = strlen(adapter_drivers[i]->name); + if (max_len < len) + max_len = len; + } + for (unsigned int i = 0; adapter_drivers[i]; i++) { const char *name = adapter_drivers[i]->name; - command_print(CMD, "%u: %s", i + 1, name); + const char * const *transports = adapter_drivers[i]->transports; + + command_print_sameline(CMD, "%-*s {", max_len, name); + for (unsigned int j = 0; transports[j]; j++) + command_print_sameline(CMD, " %s", transports[j]); + command_print(CMD, " }"); } return ERROR_OK; ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 11 +++++++++++ src/jtag/adapter.c | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |