Stephen Warren wrote:
> Note: This exposed the issue that "usbmon" dumps truncate the data, so
> about 1/2 the flash read/write data is missing. Hopefully, the 5xx FW
> upgrade issue can still be found, even so...
> 
> Checkin comment:
> 
> Fix print_data() to dump the correct number of data bytes based on the
> "length map" dictated by the protocol.

Attached is an updated version that uses the correct txlenmap.
? consnoop-lengths-b.patch
? consnoop-lengths.patch
? writeflash-lengths.patch
? concordance/.deps
? concordance/.libs
? concordance/Makefile
? concordance/Makefile.in
? concordance/aclocal.m4
? concordance/autom4te.cache
? concordance/concordance
? concordance/config.guess
? concordance/config.h
? concordance/config.h.in
? concordance/config.log
? concordance/config.status
? concordance/config.sub
? concordance/configure
? concordance/depcomp
? concordance/install-sh
? concordance/libtool
? concordance/ltmain.sh
? concordance/missing
? concordance/stamp-h1
? consnoop/.consnoop.cpp.swp
? consnoop/consnoop
? libconcord/.deps
? libconcord/.libs
? libconcord/.protocol.h.swp
? libconcord/.remote.cpp.swp
? libconcord/.remote_info.h.swp
? libconcord/Makefile
? libconcord/Makefile.in
? libconcord/aclocal.m4
? libconcord/autom4te.cache
? libconcord/binaryfile.lo
? libconcord/config.guess
? libconcord/config.h
? libconcord/config.h.in
? libconcord/config.log
? libconcord/config.status
? libconcord/config.sub
? libconcord/configure
? libconcord/depcomp
? libconcord/install-sh
? libconcord/libconcord.la
? libconcord/libconcord.lo
? libconcord/libtool
? libconcord/libusbhid.lo
? libconcord/ltmain.sh
? libconcord/missing
? libconcord/remote.lo
? libconcord/remote_z.lo
? libconcord/stamp-h1
? libconcord/usblan.lo
? libconcord/web.lo
? libconcord/bindings/python/libconcord.pyc
? specs/.protocol.txt.swp
Index: consnoop/consnoop.cpp
===================================================================
RCS file: /cvsroot/concordance/concordance/consnoop/consnoop.cpp,v
retrieving revision 1.12
diff -u -p -r1.12 consnoop.cpp
--- consnoop/consnoop.cpp	28 Dec 2008 20:04:46 -0000	1.12
+++ consnoop/consnoop.cpp	4 Feb 2009 04:13:03 -0000
@@ -22,6 +22,7 @@
  */
 
 #include <string>
+#include <string.h>
 #include <fstream>
 #include <stdlib.h>
 #ifdef WIN32
@@ -35,6 +36,15 @@ using namespace std;
 
 #include "../libconcord/protocol.h"
 
+static const unsigned int rxlenmap0[16] =
+	{  0,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14 };
+static const unsigned int rxlenmapx[16] =
+	{  0,  0,  1,  2,  3,  4,  5,  6, 14, 30, 62,  0,  0,  0,  0,  0 };
+static const unsigned int txlenmap0[16] =
+	{  0,  1,  2,  3,  4,  5,  6,  7,  0,  0,  0,  0,  0,  0,  0,  0 };
+static const unsigned int txlenmapx[16] =
+	{  0,  1,  2,  3,  4,  5,  6,  7, 15, 31, 63,  0,  0,  0,  0,  0 };
+
 bool verbose = false;
 bool debug = false;
 
@@ -78,19 +88,20 @@ const char* get_misc(uint8_t x)
 	return "Unknown";
 }
 
-void print_data(const uint8_t * const data)
+void print_data(const uint8_t * const data, unsigned int const * lenmap)
 {
 	if (!verbose)
 		return;
-	const uint8_t length = data[0] & LENGTH_MASK;
+	const uint8_t length_enc = data[0] & LENGTH_MASK;
+	const uint8_t length = lenmap[length_enc];
 	printf("   DATA: ");
-	for (int i = 1; i < length; i++) {
+	for (int i = 1; i <= length; i++) {
 		printf("%02X", data[i]);
 	}
 	printf("\n");
 }
 
-void decode(const uint8_t * const data)
+void decode(const uint8_t * const data, int proto)
 {
 	// Note: The uninteresting stuff is commented out
 	const uint8_t length = data[0] & LENGTH_MASK;
@@ -110,7 +121,7 @@ void decode(const uint8_t * const data)
 			break;
 		case COMMAND_WRITE_FLASH_DATA & COMMAND_MASK:
 			printf("Write Flash Data\n");
-			print_data(data);
+			print_data(data, proto ? txlenmapx : txlenmap0);
 			break;
 		case COMMAND_READ_FLASH & COMMAND_MASK:
 			printf("Read  Flash %06X %i\n",
@@ -119,7 +130,7 @@ void decode(const uint8_t * const data)
 			break;
 		case RESPONSE_READ_FLASH_DATA & COMMAND_MASK:
 			printf("Read  Flash Data\n");
-			print_data(data);
+			print_data(data, proto ? rxlenmapx : rxlenmap0);
 			break;
 		case COMMAND_START_IRCAP & COMMAND_MASK:
 			printf("Start IR capture\n");
@@ -201,6 +212,7 @@ void help()
 int main(int argc, char *argv[])
 {
 	int tmpint = 0;
+	int proto = 1;
 	char *file_name = NULL;
 	while ((tmpint = getopt(argc, argv, "dhf:v")) != EOF) {
 		switch (tmpint) {
@@ -220,6 +232,9 @@ int main(int argc, char *argv[])
 		case 'v':
 			verbose = true;
 			break;
+		case '0':
+			proto = 0;
+			break;
 		}
 	}
 
@@ -233,6 +248,7 @@ int main(int argc, char *argv[])
 		getline(infile,s);
 		if(!s.compare(0, payloadbytes.size(), payloadbytes)) {
 			uint8_t data[260];
+			memset(data, 0xcd, sizeof(data));
 			unsigned int n = 0;
 			for(unsigned int i = payloadbytes.size();
                             i<s.size(); ++i) {
@@ -262,7 +278,7 @@ int main(int argc, char *argv[])
 				}
 				printf("\n");
 			}
-			decode(data);
+			decode(data, proto);
 		}
 	}
 	infile.close();
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
concordance-devel mailing list
concordance-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/concordance-devel

Reply via email to