diff options
Diffstat (limited to 'commandline/library')
-rw-r--r-- | commandline/library/micronucleus_lib.c | 13 | ||||
-rw-r--r-- | commandline/library/micronucleus_lib.h | 6 |
2 files changed, 13 insertions, 6 deletions
diff --git a/commandline/library/micronucleus_lib.c b/commandline/library/micronucleus_lib.c index 58ed10a..6cddb7c 100644 --- a/commandline/library/micronucleus_lib.c +++ b/commandline/library/micronucleus_lib.c @@ -148,17 +148,12 @@ int micronucleus_eraseFlash(micronucleus* deviceHandle, micronucleus_callback pr is disconnecting and reconnecting. Under Windows, micronucleus can see this 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. + converting the return to 1 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 == -34 || res == -84) { - if (res == -34) { - libusb_close(deviceHandle->device); - deviceHandle->device = NULL; - } - return 1; // recoverable errors } else { return res; @@ -319,3 +314,9 @@ int micronucleus_startApp(micronucleus* deviceHandle) { else return 0; } + +void micronucleus_disconnect(micronucleus* deviceHandle) { + libusb_close(deviceHandle->device); + libusb_exit(NULL); + free(deviceHandle); +} diff --git a/commandline/library/micronucleus_lib.h b/commandline/library/micronucleus_lib.h index 9e1e0f6..ce31f97 100644 --- a/commandline/library/micronucleus_lib.h +++ b/commandline/library/micronucleus_lib.h @@ -107,4 +107,10 @@ int micronucleus_writeFlash(micronucleus* deviceHandle, unsigned int program_len int micronucleus_startApp(micronucleus* deviceHandle); /*******************************************************************************/ +/******************************************************************************** +* Disconnects from the device and deinitializes libusb +********************************************************************************/ +void micronucleus_disconnect(micronucleus* deviceHandle); +/*******************************************************************************/ + #endif |