summaryrefslogtreecommitdiffstats
path: root/commandline
diff options
context:
space:
mode:
Diffstat (limited to 'commandline')
-rw-r--r--commandline/examples/micronucleus.c9
-rw-r--r--commandline/library/micronucleus_lib.c8
-rw-r--r--commandline/library/micronucleus_lib.h9
3 files changed, 20 insertions, 6 deletions
diff --git a/commandline/examples/micronucleus.c b/commandline/examples/micronucleus.c
index 5fb4c32..8bca517 100644
--- a/commandline/examples/micronucleus.c
+++ b/commandline/examples/micronucleus.c
@@ -100,8 +100,8 @@ int main(int argc, char **argv) {
}
setProgressData("waiting", 1);
- printProgress(0.5);
- printf("> Please plug the device ... \n");
+ if (dump_progress) printProgress(0.5);
+ printf("> Please plug in the device ... \n");
printf("> Press CTRL+C to terminate the program.\n");
while (my_device == NULL) {
@@ -221,7 +221,10 @@ static void printProgress(float progress) {
printf("\033[1F\033[2K"); // move cursor to previous line and erase last update in this progress sequence
}
#endif
- printf("%s: %d%% complete\n", progress_friendly_name, (int) (progress * 100.0f));
+
+ float total_progress = ((float) progress_step - 1.0f) / (float) progress_total_steps;
+ total_progress += progress / (float) progress_total_steps;
+ printf("%s: %d%% complete\n", progress_friendly_name, (int) (total_progress * 100.0f));
}
last_step = progress_step;
diff --git a/commandline/library/micronucleus_lib.c b/commandline/library/micronucleus_lib.c
index 2e63425..1c3c179 100644
--- a/commandline/library/micronucleus_lib.c
+++ b/commandline/library/micronucleus_lib.c
@@ -47,6 +47,14 @@ micronucleus* micronucleus_connect() {
nucleus = malloc(sizeof(micronucleus));
nucleus->version.major = (dev->descriptor.bcdUSB >> 8) & 0xFF;
nucleus->version.minor = dev->descriptor.bcdUSB & 0xFF;
+
+ if (nucleus->version.major > MICRONUCLEUS_MAX_MAJOR_VERSION) {
+ fprintf(stderr, "Warning: device with unknown new version of Micronucleus detected.\n");
+ fprintf(stderr, "This tool doesn't know how to upload to this new device. Updates may be available.\n");
+ fprintf(stderr, "Device reports version as: %d.%d\n", nucleus->version.major, nucleus->version.minor);
+ return NULL;
+ }
+
nucleus->device = usb_open(dev);
// get nucleus info
diff --git a/commandline/library/micronucleus_lib.h b/commandline/library/micronucleus_lib.h
index d022877..9118ace 100644
--- a/commandline/library/micronucleus_lib.h
+++ b/commandline/library/micronucleus_lib.h
@@ -34,14 +34,17 @@
#endif
//#include "opendevice.h" // common code moved to separate module
#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
/*******************************************************************************/
/********************************************************************************
* USB details
********************************************************************************/
-#define MICRONUCLEUS_VENDOR_ID 0x16D0
-#define MICRONUCLEUS_PRODUCT_ID 0x0753
-#define MICRONUCLEUS_USB_TIMEOUT 0xFFFF
+#define MICRONUCLEUS_VENDOR_ID 0x16D0
+#define MICRONUCLEUS_PRODUCT_ID 0x0753
+#define MICRONUCLEUS_USB_TIMEOUT 0xFFFF
+#define MICRONUCLEUS_MAX_MAJOR_VERSION 1
/*******************************************************************************/
/********************************************************************************