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

Committer:
dixter1
Date:
Sat Dec 14 00:53:08 2013 +0000
Revision:
1:a7a52d202638
Parent:
0:29e2df9de9f1
First Version C027 Ethernet Sniff Test to Validate Ethernet Capability.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rolf 0:29e2df9de9f1 1 /* Function: hexview
rolf 0:29e2df9de9f1 2 * Prints an array of char to stdout in hex.
rolf 0:29e2df9de9f1 3 * The data is grouped in two 8 byte groups per line.
rolf 0:29e2df9de9f1 4 * Each byte is displayed as 2 hex digits and every
rolf 0:29e2df9de9f1 5 * line starts with the address of the first byte.
rolf 0:29e2df9de9f1 6 *
rolf 0:29e2df9de9f1 7 * There is no text view of a line.
rolf 0:29e2df9de9f1 8 *
rolf 0:29e2df9de9f1 9 * Variables:
rolf 0:29e2df9de9f1 10 * buffer - The array to display.
rolf 0:29e2df9de9f1 11 * size - The length of buffer.
rolf 0:29e2df9de9f1 12 */
rolf 0:29e2df9de9f1 13 inline void hexview(char *buffer, unsigned int size) {
rolf 0:29e2df9de9f1 14 for(int i = 0; i < size; ++i) {
rolf 0:29e2df9de9f1 15 if((i%16)!=0) {
rolf 0:29e2df9de9f1 16 printf(" ");
rolf 0:29e2df9de9f1 17 } else {
rolf 0:29e2df9de9f1 18 printf("%04X: ", (i));
rolf 0:29e2df9de9f1 19 }
rolf 0:29e2df9de9f1 20 printf("%02hhx", buffer[i]);
rolf 0:29e2df9de9f1 21 if((i%16) == 7) {
rolf 0:29e2df9de9f1 22 printf(" ");
rolf 0:29e2df9de9f1 23 }
rolf 0:29e2df9de9f1 24 if((i%16) == 15) {
dixter1 1:a7a52d202638 25 printf("\n\r");
rolf 0:29e2df9de9f1 26 }
rolf 0:29e2df9de9f1 27 }
dixter1 1:a7a52d202638 28 printf("\n\r\n\r\n\r");
rolf 0:29e2df9de9f1 29 }