Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of 6_songs-from-the-cloud by
ns_trace.h File Reference
Trace interface for NanoStack library as well as application. More...
Go to the source code of this file.
Functions | |
int | trace_init (void) |
Possible to skip all traces in compile time. | |
void | trace_free (void) |
Free trace memory. | |
void | set_trace_config (uint8_t config) |
Set trace configurations Possible parameters: | |
uint8_t | get_trace_config (void) |
get trace configurations | |
void | set_trace_prefix_function (char *(*pref_f)(size_t)) |
Set trace prefix function pref_f -function return string with null terminated Can be used for e.g. | |
void | set_trace_suffix_function (char *(*suffix_f)(void)) |
Set trace suffix function suffix -function return string with null terminated Can be used for e.g. | |
void | set_trace_print_function (void(*print_f)(const char *)) |
Set trace print function By default, trace module print using printf() function, but with this you can write own print function, for e.g. | |
void | set_trace_cmdprint_function (void(*printf)(const char *)) |
Set trace print function for tr_cmdline() | |
void | set_trace_exclude_filters (char *filters) |
When trace group contains text in filters, trace print will be ignored. | |
const char * | get_trace_exclude_filters (void) |
get trace exclude filters | |
void | set_trace_include_filters (char *filters) |
When trace group contains text in filter, trace will be printed. | |
const char * | get_trace_include_filters (void) |
get trace include filters | |
void | tracef (uint8_t dlevel, const char *grp, const char *fmt,...) __attribute__((__format__(__printf__ |
General trace function This should be used every time when user want to print out something important thing Usage e.g. | |
void const char * | trace_last (void) |
Get last trace from buffer. | |
char * | trace_ipv6 (const void *addr_ptr) |
tracef helping function for convert ipv6 table to human readable string. | |
char * | trace_ipv6_prefix (const uint8_t *prefix, uint8_t prefix_len) |
tracef helping function for print ipv6 prefix usage e.g. | |
char * | trace_array (const uint8_t *buf, uint16_t len) |
tracef helping function for convert hex-array to string. | |
void | debugf (const char *fmt,...) __attribute__((__format__(__printf__ |
obsolete function | |
void void | debug (const char *s) |
void | debug_put (char c) |
obsolete function | |
void | debug_hex (uint8_t x) |
obsolete function | |
void | debug_int (int i) |
obsolete function | |
void | printf_array (const void *buf, uint16_t len) |
obsolete function | |
void | printf_string (const void *buf, uint16_t len) |
obsolete function | |
void | printf_ipv6_address (const void *addr) |
obsolete function |
Detailed Description
Trace interface for NanoStack library as well as application.
This file provide simple but flexible way to handle software traces. Trace library are abstract layer, which use stdout (printf) by default, but outputs can be easily redirect to custom function, for example to store traces to memory or other interfaces.
usage example:
(main.c:) #include "ns_trace.h" #define TRACE_GROUP "main" int main(void){ trace_init(); // initialize trace library tr_debug("this is debug msg"); //print debug message to stdout: "[DBG] tr_err("this is error msg"); tr_warn("this is warning msg"); tr_info("this is info msg"); return 0; }
Definition in file ns_trace.h.
Function Documentation
void debug | ( | const char * | s ) |
obsolete function
Definition at line 495 of file ns_trace.c.
void debug_hex | ( | uint8_t | x ) |
obsolete function
Definition at line 505 of file ns_trace.c.
void debug_int | ( | int | i ) |
obsolete function
Definition at line 509 of file ns_trace.c.
void debug_put | ( | char | c ) |
obsolete function
Definition at line 500 of file ns_trace.c.
void debugf | ( | const char * | fmt, |
... | |||
) |
obsolete function
uint8_t get_trace_config | ( | void | ) |
get trace configurations
- Returns:
- trace configuration byte
Definition at line 169 of file ns_trace.c.
const char * get_trace_exclude_filters | ( | void | ) |
get trace exclude filters
Definition at line 197 of file ns_trace.c.
const char * get_trace_include_filters | ( | void | ) |
get trace include filters
Definition at line 201 of file ns_trace.c.
void printf_array | ( | const void * | buf, |
uint16_t | len | ||
) |
obsolete function
Definition at line 513 of file ns_trace.c.
void printf_ipv6_address | ( | const void * | addr ) |
obsolete function
Definition at line 526 of file ns_trace.c.
void printf_string | ( | const void * | buf, |
uint16_t | len | ||
) |
obsolete function
Definition at line 532 of file ns_trace.c.
void set_trace_cmdprint_function | ( | void(*)(const char *) | printf ) |
Set trace print function for tr_cmdline()
Definition at line 185 of file ns_trace.c.
void set_trace_config | ( | uint8_t | config ) |
Set trace configurations Possible parameters:
TRACE_MODE_COLOR TRACE_MODE_PLAIN (this exclude color mode) TRACE_CARRIAGE_RETURN (print CR before trace line)
TRACE_ACTIVE_LEVEL_ALL - to activate all trace levels or TRACE_ACTIVE_LEVEL_DEBUG (alternative) TRACE_ACTIVE_LEVEL_INFO TRACE_ACTIVE_LEVEL_WARN TRACE_ACTIVE_LEVEL_ERROR TRACE_ACTIVE_LEVEL_CMD TRACE_LEVEL_NONE - to deactivate all traces
- Parameters:
-
config Byte size Bit-mask. Bits are descripted above. usage e.g. set_trace_config( TRACE_ACTIVE_LEVEL_ALL|TRACE_MODE_COLOR );
Definition at line 165 of file ns_trace.c.
void set_trace_exclude_filters | ( | char * | filters ) |
When trace group contains text in filters, trace print will be ignored.
e.g.: set_trace_exclude_filters("mygr"); tracef(TRACE_ACTIVE_LEVEL_DEBUG, "ougr", "This is not printed");
Definition at line 189 of file ns_trace.c.
void set_trace_include_filters | ( | char * | filters ) |
When trace group contains text in filter, trace will be printed.
e.g.: set_trace_include_filters("mygr"); tracef(TRACE_ACTIVE_LEVEL_DEBUG, "mygr", "Hi There"); tracef(TRACE_ACTIVE_LEVEL_DEBUG, "grp2", "This is not printed");
Definition at line 205 of file ns_trace.c.
void set_trace_prefix_function | ( | char *(*)(size_t) | pref_f ) |
Set trace prefix function pref_f -function return string with null terminated Can be used for e.g.
time string e.g. char* trace_time(){ return "rtc-time-in-string"; } set_trace_prefix_function( &trace_time );
Definition at line 173 of file ns_trace.c.
void set_trace_print_function | ( | void(*)(const char *) | print_f ) |
Set trace print function By default, trace module print using printf() function, but with this you can write own print function, for e.g.
to other IO device.
Definition at line 181 of file ns_trace.c.
void set_trace_suffix_function | ( | char *(*)(void) | suffix_f ) |
Set trace suffix function suffix -function return string with null terminated Can be used for e.g.
time string e.g. char* trace_suffix(){ return " END"; } set_trace_suffix_function( &trace_suffix );
Definition at line 177 of file ns_trace.c.
char * trace_array | ( | const uint8_t * | buf, |
uint16_t | len | ||
) |
tracef helping function for convert hex-array to string.
usage e.g. char myarr[] = {0x10, 0x20}; tracef(TRACE_LEVEL_INFO, "mygr", "arr: %s", trace_array(myarr, 2));
- Parameters:
-
buf hex array pointer len buffer length
- Returns:
- temporary buffer where string copied
Definition at line 454 of file ns_trace.c.
void trace_free | ( | void | ) |
Free trace memory.
This method must be called from application process.
Definition at line 142 of file ns_trace.c.
int trace_init | ( | void | ) |
Possible to skip all traces in compile time.
Initialize trace functionality. This method must be called from application process.
- Returns:
- 0 when all success, otherwise non zero
Definition at line 102 of file ns_trace.c.
char * trace_ipv6 | ( | const void * | addr_ptr ) |
tracef helping function for convert ipv6 table to human readable string.
usage e.g. char ipv6[16] = {...}; // ! array length is 16 bytes ! tracef(TRACE_LEVEL_INFO, "mygr", "ipv6 addr: %s", trace_ipv6(ipv6));
- Parameters:
-
add_ptr IPv6 Address pointer
- Returns:
- temporary buffer where ipv6 is in string format
Definition at line 407 of file ns_trace.c.
char * trace_ipv6_prefix | ( | const uint8_t * | prefix, |
uint8_t | prefix_len | ||
) |
tracef helping function for print ipv6 prefix usage e.g.
char ipv6[16] = {...}; // ! array length is 16 bytes ! tracef(TRACE_LEVEL_INFO, "mygr", "ipv6 addr: %s", trace_ipv6_prefix(ipv6, 4));
- Parameters:
-
prefix IPv6 Address pointer prefix_len prefix length
- Returns:
- temporary buffer where ipv6 is in string format
Definition at line 424 of file ns_trace.c.
void const char* trace_last | ( | void | ) |
Get last trace from buffer.
Definition at line 401 of file ns_trace.c.
void tracef | ( | uint8_t | dlevel, |
const char * | grp, | ||
const char * | fmt, | ||
... | |||
) |
General trace function This should be used every time when user want to print out something important thing Usage e.g.
tracef( TRACE_LEVEL_INFO, "mygr", "Hello world!");
- Parameters:
-
dlevel debug level grp trace group fmt trace format (like printf) ... variable arguments related to fmt
Generated on Tue Jul 12 2022 12:47:52 by
