condense print_packet output

This commit is contained in:
Mariano Alvira 2010-03-07 16:50:32 -05:00
parent 667b238148
commit 8421031d4a

View File

@ -32,16 +32,15 @@ void print_packet(volatile packet_t *p) {
#define PER_ROW 16 #define PER_ROW 16
if(p) { if(p) {
printf("len 0x%02x\n\r",p->length); printf("len 0x%02x\n\r",p->length);
for(j=0, k=0; j < ((p->length)%PER_ROW)-1; j++) { for(j=0, k=0; j <= ((p->length)%PER_ROW); j++) {
for(i=0; i < PER_ROW; i++, k++) { for(i=0; i < PER_ROW; i++, k++) {
if(k >= (p->length + 1) ) { goto out; } /* + 1 since first byte is len+2 */ if(k >= (p->length + 1) ) { goto out; } /* + 1 since first byte is len+2 */
printf("%02x ",p->data[j*PER_ROW+i]); printf("%02x ",p->data[j*PER_ROW+i]);
} }
printf("\n\r"); printf("\n\r");
} }
out:
printf("\n\r");
} }
out:
return; return;
} }