Browse Source

mcp2210: Add support for --device-protocol-dump

Luke Dashjr 12 years ago
parent
commit
7a8df14fbe
1 changed files with 11 additions and 1 deletions
  1. 11 1
      mcp2210.c

+ 11 - 1
mcp2210.c

@@ -77,10 +77,20 @@ struct mcp2210_device {
 static
 static
 bool mcp2210_io(hid_device * const hid, uint8_t * const cmd, uint8_t * const buf)
 bool mcp2210_io(hid_device * const hid, uint8_t * const cmd, uint8_t * const buf)
 {
 {
-	return likely(
+	char hexcmd[(0x41 * 2) + 1];
+	if (opt_dev_protocol)
+		bin2hex(hexcmd, cmd, 0x41);
+	const bool rv = likely(
 		0x41 == hid_write(hid, cmd, 0x41) &&
 		0x41 == hid_write(hid, cmd, 0x41) &&
 		64 == hid_read(hid, buf, 64)
 		64 == hid_read(hid, buf, 64)
 	);
 	);
+	if (opt_dev_protocol)
+	{
+		char hexbuf[(0x40 * 2) + 1];
+		bin2hex(hexbuf, buf, 0x40);
+		applog(LOG_DEBUG, "mcp2210_io(%p, %s, %s)", hid, hexcmd, hexbuf);
+	}
+	return rv;
 }
 }
 
 
 static
 static