Add sleeps so teensy_loader_cli works reliably for me
The whole idea of this program's "wait for all the Teensys we can find"
operation is fundamentally racy. At some point, I should really redo it
completely... For now though, just add sleeps to make it work on
machines where people care.
Change-Id: Iad8ad2c2dc7a95ac75bdf43950ff344a05923d8d
diff --git a/motors/teensy_loader_cli/teensy_loader_cli.c b/motors/teensy_loader_cli/teensy_loader_cli.c
index 311712a..ca8064e 100644
--- a/motors/teensy_loader_cli/teensy_loader_cli.c
+++ b/motors/teensy_loader_cli/teensy_loader_cli.c
@@ -128,9 +128,13 @@
for (int i = 0; i <= 0xF; ++i) {
printf_verbose("Rebooting %x\n", i);
- if (soft_reboot(i)) usb_find_devices();
+ if (soft_reboot(i)) {
+ usleep(10000);
+ usb_find_devices();
+ }
}
int number = 0;
+ usleep(10000);
usb_find_devices();
while (teensy_open()) {
printf_verbose("Found HalfKay Bootloader\n");
@@ -179,6 +183,7 @@
// reboot to the user's new code
if (reboot_after_programming) {
+ usleep(10000);
boot(buf, write_size);
}
teensy_close();
@@ -315,6 +320,7 @@
return 0;
}
+ printf_verbose("Rebooted %x\n", number);
return 1;
}