application: add action to test all connections
This commit is contained in:
parent
151b7f1c9c
commit
b0441f40c5
|
@ -520,6 +520,48 @@ end:
|
|||
}
|
||||
}
|
||||
|
||||
/** run self test to test board connection to connectors
|
||||
* @param[in] argument no argument required
|
||||
*/
|
||||
static void command_connections(void* argument)
|
||||
{
|
||||
(void)argument; // we won't use the argument
|
||||
|
||||
printf("= checking all pin connections =\n");
|
||||
uint16_t connections_nb = 0;
|
||||
uint8_t (*connections)[2] = (uint8_t (*)[2])usb_cables_check_connections(usb_connectors, LENGTH(usb_connectors), &connections_nb);
|
||||
if (NULL == connections) {
|
||||
if (connections_nb) {
|
||||
printf("no memory available\n");
|
||||
} else {
|
||||
printf("no connections\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
printf("found %u connections:\n", connections_nb);
|
||||
for (uint16_t i = 0; i < connections_nb; i++) {
|
||||
const struct usb_connector_t* connector_from = usb_cables_get_connector(connections[i][0]);
|
||||
const struct usb_connector_t* connector_to = usb_cables_get_connector(connections[i][1]);
|
||||
if (NULL == connector_from || NULL == connector_to) {
|
||||
printf("no connector for a pin pair\n");
|
||||
continue;
|
||||
}
|
||||
printf("%s ", connector_from->name);
|
||||
if (connector_from->variant) {
|
||||
printf("(%s) ", connector_from->variant);
|
||||
}
|
||||
printf("%s to %s ", usb_pins[connections[i][0]].name, connector_to->name);
|
||||
if (connector_to->variant) {
|
||||
printf("(%s) ", connector_from->variant);
|
||||
}
|
||||
printf("%s\n", usb_pins[connections[i][1]].name);
|
||||
}
|
||||
if (connections) {
|
||||
free(connections);
|
||||
connections = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** list of all supported commands */
|
||||
static const struct menu_command_t menu_commands[] = {
|
||||
{
|
||||
|
@ -620,6 +662,14 @@ static const struct menu_command_t menu_commands[] = {
|
|||
.argument_description = NULL,
|
||||
.command_handler = &command_test,
|
||||
},
|
||||
{
|
||||
.shortcut = 'x',
|
||||
.name = "connections",
|
||||
.command_description = "test all pin connections",
|
||||
.argument = MENU_ARGUMENT_NONE,
|
||||
.argument_description = NULL,
|
||||
.command_handler = &command_connections,
|
||||
},
|
||||
};
|
||||
|
||||
static void command_help(void* argument)
|
||||
|
|
Loading…
Reference in New Issue