application: add load test to find action

This commit is contained in:
King Kévin 2019-12-12 14:23:52 +01:00
parent 74eeb7d51e
commit ba50a0ec84
1 changed files with 9 additions and 6 deletions

View File

@ -271,12 +271,9 @@ static void command_find(void* argument)
matches++;
}
}
printf("%u matching cable(s) found\n", matches);
printf("%u perfect matching cable(s) found\n", matches);
// find best matching cable
if (matches > 0) { // we already found a perfect matching cable
return;
}
uint8_t best_score = 0xff;
for (uint8_t cable = 0; cable < LENGTH(usb_cables); cable++) {
if (!cable_connectors[cable]) { // skip if the cable connectors do not match
@ -286,14 +283,21 @@ static void command_find(void* argument)
best_score = cable_score[cable];
}
}
printf("closest matching cable(s):\n");
printf("%smatching cable(s):\n", 0 == best_score ? "" : "closest ");
for (uint8_t cable = 0; cable < LENGTH(usb_cables); cable++) {
if (!cable_connectors[cable]) { // skip if the cable connectors do not match
continue;
}
if (cable_score[cable] == best_score) {
// print cable connections
printf("- %s\n", usb_cables[cable].name);
usb_cables_check_cable(&usb_cables[cable], NULL, NULL, true);
// test if there is a load
bool loaded = false;
for (uint8_t connector = 0; connector < usb_cables[cable].connectors_nb; connector++) {
loaded |= usb_cables_check_load(usb_cables[cable].connectors[connector]);
}
printf("there is %s load on the cable\n", loaded ? "a" : "no");
}
}
@ -488,7 +492,6 @@ end:
}
}
/** list of all supported commands */
static const struct menu_command_t menu_commands[] = {
{