This performs an ethernet sniff test. Copied from an existing ethernet sniff test and updated to work properly with the LISA, supporting output of content to the USB console. See also: http://mbed.org/users/rolf/code/ethsnif/

Dependencies:   C027-REVB mbed

Fork of ethsnif by Rolf Meyer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers hexview.h Source File

hexview.h

00001 /* Function: hexview
00002  *  Prints an array of char to stdout in hex.
00003  *  The data is grouped in two 8 byte groups per line.
00004  *  Each byte is displayed as 2 hex digits and every 
00005  *  line starts with the address of the first byte.
00006  *
00007  *  There is no text view of a line.
00008  *
00009  * Variables:
00010  *  buffer - The array to display.
00011  *  size - The length of buffer.
00012  */
00013 inline void hexview(char *buffer, unsigned int size) {
00014     for(int i = 0; i < size; ++i) {
00015         if((i%16)!=0) {
00016             printf(" ");
00017         } else {
00018             printf("%04X:  ", (i));
00019         }
00020         printf("%02hhx", buffer[i]);
00021         if((i%16) ==  7) { 
00022             printf(" ");
00023         }
00024         if((i%16) == 15) {
00025             printf("\n\r");
00026         }
00027     }
00028     printf("\n\r\n\r\n\r");
00029 }