diff options
author | cpldcpu <cpldcpu@gmail.com> | 2015-03-15 09:36:49 +0100 |
---|---|---|
committer | cpldcpu <cpldcpu@gmail.com> | 2015-03-15 09:36:49 +0100 |
commit | 8dab45135ab6aa69db0708776a989a586ff99b50 (patch) | |
tree | e10d944ae3bec82a6730c13a4d15b2ae7e7b05c1 /commandline | |
parent | a6f4163452ad6faf0dfd64f115a15cdde75c39a8 (diff) | |
download | micronucleus-8dab45135ab6aa69db0708776a989a586ff99b50.tar.gz micronucleus-8dab45135ab6aa69db0708776a989a586ff99b50.tar.bz2 micronucleus-8dab45135ab6aa69db0708776a989a586ff99b50.zip |
commandline: Fixed assert when device was unresponsive
Diffstat (limited to 'commandline')
-rw-r--r-- | commandline/library/micronucleus_lib.c | 8 | ||||
-rw-r--r-- | commandline/library/micronucleus_lib.h | 2 | ||||
-rw-r--r-- | commandline/micronucleus.exe | bin | 0 -> 27662 bytes |
3 files changed, 9 insertions, 1 deletions
diff --git a/commandline/library/micronucleus_lib.c b/commandline/library/micronucleus_lib.c index e2f6791..0569dbe 100644 --- a/commandline/library/micronucleus_lib.c +++ b/commandline/library/micronucleus_lib.c @@ -66,6 +66,10 @@ micronucleus* micronucleus_connect(int fast_mode) { // get nucleus info unsigned char buffer[6]; int res = usb_control_msg(nucleus->device, USB_ENDPOINT_IN| USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, 0, 0, (char *)buffer, 6, MICRONUCLEUS_USB_TIMEOUT); + + // Device descriptor was found, but talking to it was not succesful. This can happen when the device is being reset. + if (res<0) return NULL; + assert(res >= 6); nucleus->flash_size = (buffer[0]<<8) + buffer[1]; @@ -97,6 +101,10 @@ micronucleus* micronucleus_connect(int fast_mode) { // get nucleus info unsigned char buffer[4]; int res = usb_control_msg(nucleus->device, USB_ENDPOINT_IN| USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0, 0, 0, (char *)buffer, 4, MICRONUCLEUS_USB_TIMEOUT); + + // Device descriptor was found, but talking to it was not succesful. This can happen when the device is being reset. + if (res<0) return NULL; + assert(res >= 4); nucleus->flash_size = (buffer[0]<<8) + buffer[1]; diff --git a/commandline/library/micronucleus_lib.h b/commandline/library/micronucleus_lib.h index 2db7b62..b691fa4 100644 --- a/commandline/library/micronucleus_lib.h +++ b/commandline/library/micronucleus_lib.h @@ -60,7 +60,7 @@ typedef struct _micronucleus_version { unsigned char minor; } micronucleus_version; -#define MICRONUCLEUS_COMMANDLINE_VERSION "Commandline tool version: 2.0a4" +#define MICRONUCLEUS_COMMANDLINE_VERSION "Commandline tool version: 2.0a5" // handle representing one micronucleus device typedef struct _micronucleus { diff --git a/commandline/micronucleus.exe b/commandline/micronucleus.exe Binary files differnew file mode 100644 index 0000000..c5aeedc --- /dev/null +++ b/commandline/micronucleus.exe |