MHEG5  18.9.0
MHEG5 Documentation
glue_debug.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2011 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
25 /*---includes for this file--------------------------------------------------*/
26 #include "glue_debug.h"
27 #include "stb_os.h"
28 
29 /*---constant definitions for this file--------------------------------------*/
30 
31 
32 #ifdef TRACING
33 U32BIT mheg_trace_debug = TRACE_VAL;
34 unsigned long mheg_trace_time = 0;
35 unsigned long last_trace_time = 0;
36 #endif
37 
38 /*---local typedef structs for this file-------------------------------------*/
39 
40 /*---local (static) variable declarations for this file----------------------*/
41 
42 /*---local function definitions----------------------------------------------*/
43 
44 /*---global function definitions---------------------------------------------*/
45 
51 {
52 #ifdef TRACING
53  return mheg_trace_debug;
54 #else
55  return 0;
56 #endif
57 }
58 
65 {
66 #ifdef TRACING
67  TRACE(TERROR, (" 0x%x", mask))
68  mheg_trace_debug = mask;
69 #endif
70 }
71 
72 #ifdef TRACING
73 
74 void trace_set_time(void)
75 {
76  mheg_trace_time = STB_OSGetClockMilliseconds();
77 }
78 
79 void trace_dump_chars(unsigned char *data, unsigned int len)
80 {
81  const char digits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
82  unsigned int i;
83  for (i = 0; i != len; i++, data++)
84  {
85  DBG_PRINTF("%c%c ", digits[*data >> 4], digits[*data & 0xf]);
86  if ((i & 0xf) == 15)
87  DBG_PRINTF("\n");
88  else if ((i & 0xf) == 7)
89  DBG_PRINTF("\t");
90  }
91  DBG_PRINTF("\n");
92 }
93 
94 void trace_dump_uints(U32BIT *data, unsigned int len, unsigned int pitch)
95 {
96  const char digits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
97  unsigned int i, j;
98  unsigned int tmp;
99  char tmpstr[9];
100  tmpstr[8] = 0;
101  if (pitch > 15)
102  pitch = 16;
103  for (i = 0; i != len; i++, data++)
104  {
105  tmp = *data;
106  j = 8;
107  while (j != 0)
108  {
109  tmpstr[--j] = digits[tmp & 0xf];
110  tmp >>= 4;
111  }
112  if ((i % pitch) == (pitch - 1))
113  DBG_PRINTF("0x%s\n", tmpstr);
114  else
115  DBG_PRINTF("0x%s ", tmpstr);
116  }
117  DBG_PRINTF("\n");
118 }
119 
120 void trace_unicode(U16BIT *data, unsigned int len)
121 {
122  const char digits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
123  unsigned int i;
124  DBG_PRINTF("\n");
125  for (i = 0; i != len; i++, data++)
126  {
127  switch (*data)
128  {
129  case '\t': DBG_PRINTF("\\t"); break;
130  case '\n': DBG_PRINTF("\\n"); break;
131  case '\r': DBG_PRINTF("\\r"); break;
132  case 0x1b: DBG_PRINTF("\\e"); break;
133  default:
134  if (((*data > 0x1f) && (*data < 0x7f)) || ((*data > 0x9f) && (*data <= 0xff)))
135  {
136  DBG_PRINTF("%c", *data);
137  }
138  else
139  {
140  DBG_PRINTF("=%c%c", digits[(*data >> 4) & 0xf], digits[*data & 0xf]);
141  }
142  break;
143  }
144  }
145  DBG_PRINTF("\n");
146  data -= len;
147  for (i = 0; i != len; i++, data++)
148  {
149  if (*data > 0xff)
150  {
151  DBG_PRINTF("%c%c", digits[(*data >> 12) & 0xf], digits[(*data >> 8) & 0xf]);
152  }
153  DBG_PRINTF("%c%c ", digits[(*data >> 4) & 0xf], digits[*data & 0xf]);
154  if ((i & 0xf) == 15)
155  DBG_PRINTF("\n");
156  else if ((i & 0xf) == 7)
157  DBG_PRINTF("\t");
158  }
159 }
160 
161 unsigned long trace_time(void)
162 {
163  return (STB_OSGetClockMilliseconds() - mheg_trace_time) / 10;
164 }
165 
166 #endif
167 
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
U32BIT MHEG5_DebugGetMask(void)
Get the MHEG5 debug mask.
Definition: glue_debug.c:50
#define DBG_PRINTF(...)
Definition: glue_debug.h:127
const char * data
Definition: mh5gate.c:56
Debug tracing.
void MHEG5_DebugSetMask(U32BIT mask)
Set the MHEG5 debug mask.
Definition: glue_debug.c:64
int len
Definition: mh5gate.c:57
uint16_t U16BIT
Definition: techtype.h:84
uint32_t U32BIT
Definition: techtype.h:86
#define TRACE(t, x)
Definition: glue_debug.h:118
Header file - Function prototypes for operating system.