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

hexview.h

Committer:
dixter1
Date:
2013-12-14
Revision:
1:a7a52d202638
Parent:
0:29e2df9de9f1

File content as of revision 1:a7a52d202638:

/* Function: hexview
 *  Prints an array of char to stdout in hex.
 *  The data is grouped in two 8 byte groups per line.
 *  Each byte is displayed as 2 hex digits and every 
 *  line starts with the address of the first byte.
 *
 *  There is no text view of a line.
 *
 * Variables:
 *  buffer - The array to display.
 *  size - The length of buffer.
 */
inline void hexview(char *buffer, unsigned int size) {
    for(int i = 0; i < size; ++i) {
        if((i%16)!=0) {
            printf(" ");
        } else {
            printf("%04X:  ", (i));
        }
        printf("%02hhx", buffer[i]);
        if((i%16) ==  7) { 
            printf(" ");
        }
        if((i%16) == 15) {
            printf("\n\r");
        }
    }
    printf("\n\r\n\r\n\r");
}