From: Michael Gernoth Date: Sat, 12 Apr 2008 15:49:32 +0000 (+0200) Subject: improve debug output X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/commitdiff_plain/325556c9337c3c645fa965a8d1b35a13457e029b?hp=8949e420b64291b56a8c1875104b7dc92156f627 improve debug output --- diff --git a/jtagkey.c b/jtagkey.c index fc9587c..d068cf5 100644 --- a/jtagkey.c +++ b/jtagkey.c @@ -293,10 +293,8 @@ int jtagkey_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, pthread_join(reader_thread, NULL); #ifdef DEBUG - DPRINTF("write: "); - hexdump(writebuf, writepos-writebuf); - DPRINTF("read: "); - hexdump(readbuf, i); + hexdump(writebuf, writepos-writebuf, "->"); + hexdump(readbuf, i, "<-"); #endif writepos = writebuf; diff --git a/usb-driver.c b/usb-driver.c index ddb2570..26ce16b 100644 --- a/usb-driver.c +++ b/usb-driver.c @@ -56,13 +56,14 @@ static int modules_read = 0; #define NO_WINDRVR 1 -void hexdump(unsigned char *buf, int len) { +void hexdump(unsigned char *buf, int len, char *prefix) { int i; + fprintf(stderr, "%s ", prefix); for(i=0; idwUniqueID, ut->dwPipeNum, ut->fRead, ut->dwOptions, ut->dwBufferSize, ut->dwTimeout); if (ut->dwPipeNum == 0) { - DPRINTF("-> setup packet: "); - hexdump(ut->SetupPacket, 8); + DPRINTF("-> setup packet:"); + hexdump(ut->SetupPacket, 8, ""); } if (!ut->fRead && ut->dwBufferSize) { - hexdump(ut->pBuffer, ut->dwBufferSize); + hexdump(ut->pBuffer, ut->dwBufferSize, "->"); } #endif @@ -162,8 +163,7 @@ static int do_wdioctl(int fd, unsigned int request, unsigned char *wdioctl) { DPRINTF("Transferred: %lu (%s)\n",ut->dwBytesTransferred, (ut->fRead?"read":"write")); if (ut->fRead && ut->dwBytesTransferred) { - DPRINTF("<- Read: "); - hexdump(ut->pBuffer, ut->dwBytesTransferred); + hexdump(ut->pBuffer, ut->dwBytesTransferred, "<-"); } #endif } diff --git a/usb-driver.h b/usb-driver.h index 534f68f..b484897 100644 --- a/usb-driver.h +++ b/usb-driver.h @@ -44,7 +44,7 @@ #define DPRINTF(format, args...) #endif -void __attribute__ ((visibility ("hidden"))) hexdump(unsigned char *buf, int len); +void __attribute__ ((visibility ("hidden"))) hexdump(unsigned char *buf, int len, char *prefix); #define WDU_GET_MAX_PACKET_SIZE(x) ((unsigned short) (((x) & 0x7ff) * (1 + (((x) & 0x1800) >> 11))))