[PATCH] dfu_load.c: Print sent/received bytes in verbose mode

Tormod Volden lists.tormod at gmail.com
Tue May 24 23:21:13 CEST 2011


From: Tormod Volden <debian.tormod at gmail.com>

For this the verbose variable was made global.
---

This is for the libusb-1.0 branch.

Can be useful to verify proper parsing of DFU files etc.

Tormod

 src/dfu_load.c |    6 ++++++
 src/main.c     |    2 +-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/dfu_load.c b/src/dfu_load.c
index cc4b1be..85da452 100644
--- a/src/dfu_load.c
+++ b/src/dfu_load.c
@@ -37,6 +37,8 @@
 #include "dfu_load.h"
 #include "quirks.h"
 
+extern int verbose;
+
 int dfuload_do_upload(struct dfu_if *dif, int xfer_size, struct dfu_file file)
 {
 	int total_bytes = 0;
@@ -82,6 +84,8 @@ int dfuload_do_upload(struct dfu_if *dif, int xfer_size, struct dfu_file file)
 
 out_free:
 	free(buf);
+	if (verbose)
+		printf("Received a total of %i bytes\n", total_bytes);
 
 	return ret;
 }
@@ -175,6 +179,8 @@ int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file file)
 
 	printf("] finished!\n");
 	fflush(stdout);
+	if (verbose)
+		printf("Sent a total of %i bytes\n", bytes_sent);
 
 get_status:
 	/* Transition to MANIFEST_SYNC state */
diff --git a/src/main.c b/src/main.c
index d51b816..22cd98a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -57,7 +57,7 @@ unsigned short get_int16_le(const void *p)
 }
 
 int debug;
-static int verbose = 0;
+int verbose = 0;
 
 static int _get_first_cb(struct dfu_if *dif, void *v)
 {
-- 
1.7.0.4




More information about the devel mailing list