summaryrefslogtreecommitdiffstats
path: root/commandline/library
diff options
context:
space:
mode:
authorBluebie <a@creativepony.com>2013-02-20 14:22:25 +1100
committerBluebie <a@creativepony.com>2013-02-20 14:22:25 +1100
commit58a113df9678b4502f87e0e91fc01d023a59393d (patch)
tree2602007f83540f1e6b6ab727be939110250c8d94 /commandline/library
parent6117fad11dffab29f9d1f71d678d732c453be260 (diff)
downloadmicronucleus-58a113df9678b4502f87e0e91fc01d023a59393d.tar.gz
micronucleus-58a113df9678b4502f87e0e91fc01d023a59393d.tar.bz2
micronucleus-58a113df9678b4502f87e0e91fc01d023a59393d.zip
commandline: bugfixes for -1 error after erase on OS X - auto recover now works
Diffstat (limited to 'commandline/library')
-rw-r--r--commandline/library/micronucleus_lib.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/commandline/library/micronucleus_lib.c b/commandline/library/micronucleus_lib.c
index 462190b..9efbc3d 100644
--- a/commandline/library/micronucleus_lib.c
+++ b/commandline/library/micronucleus_lib.c
@@ -96,13 +96,20 @@ int micronucleus_eraseFlash(micronucleus* deviceHandle, micronucleus_callback pr
and automatically reconnects prior to uploading the program. To get the
the same functionality, we must flag this state (the "-84" error result) by
converting the return to -2 for the upper layer.
+
+ On Mac OS a common error is -34 = epipe, but adding it to this list causes:
+ Assertion failed: (res >= 4), function micronucleus_connect, file library/micronucleus_lib.c, line 63.
*/
- if (res == -5 || res == -84)
- return -2;
- if (res != 0)
- return -1;
- else
- return 0;
+ if (res == -5 || res == -34 || res == -84) {
+ if (res = -34) {
+ usb_close(deviceHandle->device);
+ deviceHandle->device = NULL;
+ }
+
+ return 1; // recoverable errors
+ } else {
+ return res;
+ }
}
int micronucleus_writeFlash(micronucleus* deviceHandle, unsigned int program_size, unsigned char* program, micronucleus_callback prog) {