debug.c
Go to the documentation of this file.
1 /**
2  * @file debug.c
3  * @brief Debugging facilities
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 2.4.0
27  **/
28 
29 //Dependencies
30 #include "debug.h"
31 
32 
33 /**
34  * @brief Display the contents of an array
35  * @param[in] stream Pointer to a FILE object that identifies an output stream
36  * @param[in] prepend String to prepend to the left of each line
37  * @param[in] data Pointer to the data array
38  * @param[in] length Number of bytes to display
39  **/
40 
41 void debugDisplayArray(FILE *stream,
42  const char_t *prepend, const void *data, size_t length)
43 {
44  uint_t i;
45 
46  //Dump the contents of the array
47  for(i = 0; i < length; i++)
48  {
49  //Beginning of a new line?
50  if((i % 16) == 0)
51  {
52  TRACE_PRINTF("%s", prepend);
53  }
54 
55  //Display current data byte
56  TRACE_PRINTF("%02" PRIX8 " ", *((const uint8_t *) data + i));
57 
58  //End of current line?
59  if((i % 16) == 15 || i == (length - 1))
60  {
61  TRACE_PRINTF("\r\n");
62  }
63  }
64 }
unsigned int uint_t
Definition: compiler_port.h:50
char char_t
Definition: compiler_port.h:48
void debugDisplayArray(FILE *stream, const char_t *prepend, const void *data, size_t length)
Display the contents of an array.
Definition: debug.c:41
Debugging facilities.
#define TRACE_PRINTF(...)
Definition: debug.h:52
uint8_t data[]
Definition: ethernet.h:222
uint8_t length
Definition: tcp.h:368