r1114 - trunk/src/host/dfu-util/src

laforge at sita.openmoko.org laforge at sita.openmoko.org
Sun Feb 25 16:18:35 CET 2007


Author: laforge
Date: 2007-02-25 16:18:34 +0100 (Sun, 25 Feb 2007)
New Revision: 1114

Modified:
   trunk/src/host/dfu-util/src/main.c
Log:
gracefully restart from beginning (by issuing DFU_ABORT) if the device is left
in found in an 'incomplete {down,up}load' state


Modified: trunk/src/host/dfu-util/src/main.c
===================================================================
--- trunk/src/host/dfu-util/src/main.c	2007-02-25 11:02:02 UTC (rev 1113)
+++ trunk/src/host/dfu-util/src/main.c	2007-02-25 15:18:34 UTC (rev 1114)
@@ -535,6 +535,7 @@
 		exit(1);
 	}
 
+status_again:
 	printf("Determining device status: ");
 	if (dfu_get_status(dif->dev_handle, dif->interface, &status ) < 0) {
 		fprintf(stderr, "error get_status: %s\n", usb_strerror());
@@ -543,18 +544,28 @@
 	printf("state = %s, status = %d\n", dfu_state_to_string(status.bState), status.bStatus);
 
 	switch (status.bState) {
-	case STATE_APP_IDLE:
+	case DFU_STATE_appIDLE:
+	case DFU_STATE_appDETACH:
 		fprintf(stderr, "Device still in Runtime Mode!\n");
 		exit(1);
 		break;
-	case STATE_DFU_ERROR:
+	case DFU_STATE_dfuERROR:
 		printf("dfuERROR, clearing status\n");
 		if (dfu_clear_status(dif->dev_handle, dif->interface) < 0) {
 			fprintf(stderr, "error clear_status: %s\n", usb_strerror());
 			exit(1);
 		}
 		break;
-	case STATE_DFU_IDLE:
+	case DFU_STATE_dfuDNLOAD_IDLE:
+	case DFU_STATE_dfuUPLOAD_IDLE:
+		printf("aborting previous incomplete transfer\n");
+		if (dfu_abort(dif->dev_handle, dif->interface) < 0) {
+			fprintf(stderr, "can't send DFU_ABORT: %s\n", usb_strerror());
+			exit(1);
+		}
+		goto status_again;
+		break;
+	case DFU_STATE_dfuIDLE:
 		printf("dfuIDLE, continuing\n");
 		break;
 	}





More information about the commitlog mailing list