Hex dump

Description

Universal memory hex dump function. Use it for debugging purpose. This function makes use of the CPrintf() function. The data is dumped to the output device selceted by CPrintf_select_output().

//******************************************************************************
//
// Dump a buffer.
//
// Parameter mem - Address of buffer to dump.
// bufl - Buffer length in bytes.
// dochar - If nonzero, show ASCII/ISO characters
// as well as hexadecimal.
// address - address-offset
// size - size of buffer element
// Returns -
// Calls -
//
//******************************************************************************
void xd (void *mem, uint32_t bufl, int16_t dochar, uint32_t address, size_t size)




Example

Receive demo ( \D.SignT\Network\DM2DM642EMAC\Projects\UDP\Receive\receive.c ): xd() is used in a callback function:

int32_t udp_call_back (SOCKET *so, void *data, uint32_t len, uint32_t ec)
{
char *udp_data = (char *)data;
switch (ec)
{
//******************************************************************
// dump the data
// void xd (void *mem, uint32_t bufl, int16_t dochar, uint32_t address);
//
// Parameter
// mem - Address of buffer to dump.
// bufl - Buffer length in bytes.
// dochar - If nonzero, show ASCII/ISO characters
// as well as hexadecimal.
// address - address-offset
// size - size of buffer element
//******************************************************************
xd (data, len, TRUE, (uint32_t)data, sizeof(char));
break;
default:
//******************************************************************
// else print error
//******************************************************************
net_print_error (ec, CPrintf);
break;
}
//**************************************************************************
// return true, if message processed
//**************************************************************************
return (1);
}


Any time data is received the data is dumped to the output device:

-------------------------------------------------
| D.SignT receive demo |
| |
| (c) 2017 D.SignT www.dsignt.de |
| |
| netlib revision: 2.91 |
-------------------------------------------------
initialize network... ...success
assigned network configuration:
MAC address: 02-00-c0-41-02-94
IP address: 192.168.168.200
DNS Server: 192.168.168.1
Link status changed: No Link
Link status changed: Linked at 100Mbit half duplex
00000518: 01 | .
00000518: 02 00 | ..
00000518: 01 | .
00000518: 02 00 | ..
00000518: 02 01 | ..
00000518: 02 02 | ..
00000518: 02 03 | ..