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