nkjnm

Dependencies:   MAX44000 nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ns_trace_stub.c Source File

ns_trace_stub.c

00001 /*
00002  * Copyright (c) 2014-2015 ARM Limited. All rights reserved.
00003  */
00004 #include <stdio.h>
00005 #include <string.h>
00006 #include <stdarg.h>
00007 #include <stdlib.h>
00008 
00009 #include "ns_trace.h"
00010 #include "ip6string.h"
00011 #include "common_functions.h"
00012 
00013 #if defined(_WIN32) || defined(__unix__) || defined(__unix) || defined(unix)
00014 #ifndef MEM_ALLOC
00015 #define MEM_ALLOC malloc
00016 #endif
00017 #ifndef MEM_FREE
00018 #define MEM_FREE free
00019 #endif
00020 #else
00021 #include "nsdynmemLIB.h"
00022 #ifndef MEM_ALLOC
00023 #define MEM_ALLOC ns_dyn_mem_alloc
00024 #endif
00025 #ifndef MEM_FREE
00026 #define MEM_FREE ns_dyn_mem_free
00027 #endif
00028 #endif
00029 
00030 #define VT100_COLOR_ERROR "\x1b[31m"
00031 #define VT100_COLOR_WARN  "\x1b[33m"
00032 #define VT100_COLOR_INFO  "\x1b[39m"
00033 #define VT100_COLOR_DEBUG "\x1b[90m"
00034 
00035 /** default max trace line size in bytes */
00036 #define DEFAULT_TRACE_LINE_LENGTH     1024
00037 /** default max temporary buffer size in bytes, used in
00038     trace_ipv6, trace_array and trace_strn */
00039 #define DEFAULT_TRACE_TMP_LINE_LEN        128
00040 /** default max filters (include/exclude) length in bytes */
00041 #define DEFAULT_TRACE_FILTER_LENGTH       24
00042 
00043 static void default_print(const char *str);
00044 
00045 typedef struct {
00046     /** trace configuration bits */
00047     uint8_t trace_config;
00048     /** exclude filters list, related group name */
00049     char *filters_exclude;
00050     /** include filters list, related group name */
00051     char *filters_include;
00052     /** Filters length */
00053     int filters_length;
00054     /** trace line */
00055     char *line;
00056     /** trace line length */
00057     int line_length;
00058     /** temporary data */
00059     char *tmp_data;
00060     /** temporary data array length */
00061     int tmp_data_length;
00062     /** temporary data pointer */
00063     char *tmp_data_ptr;
00064 
00065     /** prefix function, which can be used to put time to the trace line */
00066     char *(*prefix_f)(size_t);
00067     /** suffix function, which can be used to some string to the end of trace line */
00068     char *(*suffix_f)(void);
00069     /** print out function. Can be redirect to flash for example. */
00070     void (*printf)(const char *);
00071     /** print out function for TRACE_LEVEL_CMD */
00072     void (*cmd_printf)(const char *);
00073 } trace_s;
00074 
00075 static trace_s m_trace = {
00076     .filters_exclude = 0,
00077     .filters_include = 0,
00078     .line = 0,
00079     .tmp_data = 0,
00080     .prefix_f = 0,
00081     .suffix_f = 0,
00082     .printf  = 0,
00083     .cmd_printf = 0
00084 };
00085 
00086 int trace_init(void)
00087 {
00088     return 0;
00089 }
00090 void trace_free(void)
00091 {
00092 
00093 }
00094 
00095 void set_trace_config(uint8_t config)
00096 {
00097 
00098 }
00099 uint8_t get_trace_config(void)
00100 {
00101     return 0;
00102 }
00103 void set_trace_prefix_function(char *(*pref_f)(size_t))
00104 {
00105 }
00106 
00107 void set_trace_suffix_function(char *(*suffix_f)(void))
00108 {
00109 }
00110 
00111 void set_trace_print_function(void (*printf)(const char *))
00112 {
00113 }
00114 
00115 void set_trace_cmdprint_function(void (*printf)(const char *))
00116 {
00117 }
00118 
00119 void set_trace_exclude_filters(char *filters)
00120 {
00121 }
00122 const char *get_trace_exclude_filters(void)
00123 {
00124     return NULL;
00125 }
00126 
00127 const char *get_trace_include_filters(void)
00128 {
00129     return NULL;
00130 }
00131 
00132 void set_trace_include_filters(char *filters)
00133 {
00134 }
00135 
00136 static int8_t trace_skip(int8_t dlevel, const char *grp)
00137 {
00138     return 0;
00139 }
00140 
00141 static void default_print(const char *str)
00142 {
00143 }
00144 
00145 void tracef(uint8_t dlevel, const char *grp, const char *fmt, ...)
00146 {
00147 
00148 }
00149 const char *trace_last(void)
00150 {
00151     return "";
00152 }
00153 
00154 /* Helping functions */
00155 #define tmp_data_left()  m_trace.tmp_data_length-(m_trace.tmp_data_ptr-m_trace.tmp_data)
00156 char *trace_ipv6(const void *addr_ptr)
00157 {
00158     return "";
00159 }
00160 
00161 char *trace_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len)
00162 {
00163     return "";
00164 }
00165 
00166 char *trace_array(const uint8_t *buf, uint16_t len)
00167 {
00168     return "";
00169 }
00170 
00171 // rest of debug print functions will be obsolete and will be overridden with new trace interface..
00172 void debugf(const char *fmt, ...)
00173 {
00174 }
00175 
00176 void debug(const char *s)
00177 {
00178 }
00179 
00180 void debug_put(char c)
00181 {
00182 }
00183 
00184 void debug_hex(uint8_t x)
00185 {
00186 }
00187 
00188 void debug_int(int i)
00189 {
00190 }
00191 
00192 void printf_array(const void *buf , uint16_t len)
00193 {
00194 }
00195 
00196 void printf_ipv6_address(const void *addr_ptr)
00197 {
00198 }
00199 
00200 void printf_string(const void *ptr, uint16_t len)
00201 {
00202 }