Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Logs ,a simple introduce in Wiced release

Logs ,a simple introduce in Wiced release

Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked
  • SUMMARY:

  We divide the SDK code into different module or library for specific function, and Hierarchical software design also is useful for the code maintenance. This blog is to show the log setting for different module.  Please see below architecture from SDK release document. Our aim is to print useful logs when issue happens,  upload one module picture from SDK release .

pastedImage_2.png

 

  • HOW TO Print LOGS
  1. To use “printf” directly, this is very convenient for the debug, but not easy to make a good management for the logs added. Some basic knowledge of print is in this link

https://fresh2refresh.com/c-programming/c-printf-and-scanf/

 

     #include <stdio.h>

     int main()

     {

        char ch = 'A';

        char str[20] = "fresh2refresh.com";

        float flt = 10.234;

        int no = 150;

        double dbl = 20.123456;                         

        printf("Character is %c \n", ch);

        printf("String is %s \n" , str);

        printf("Float value is %f \n", flt);

        printf("Integer value is %d\n" , no);

        printf("Double value is %lf \n", dbl);

        printf("Octal value is %o \n", no);

        printf("Hexadecimal value is %x \n", no);

        return 0;

     }

 

·    %d got replaced by value of an integer variable  (no),

·       %c got replaced by value of a character variable  (ch),

·       %f got replaced by value of a float variable  (flt),

·       %lf got replaced by value of a double variable  (dbl),

·       %s got replaced by value of a string variable  (str),

·       %o got replaced by a octal value corresponding to integer variable  (no),

·       %x got replaced by a hexadecimal value corresponding to integer variable

·       \n got replaced by a newline.

 

2.     In wwd_debug.h, wwd_debug.c , wiced_defaults.h

We defined Macros to control the log output for different MODULE.

Modules are Application, library, Webserver , Network, RTOS,

Security , WPS, Supplicant, Wiced , WWD(Wiced wi-fi Driver) .

 

We have good instructions and warnings for the log setting:

* ** WARNING for PRINTING **

*  If printing is enabled, the stack of each thread that uses printing

* must be increased to at least 4 kBytes since the printf function uses

a lot of memory (including dynamic memory)

/* Select which group of functions are allowed to print */

/* WPRINT_ENABLE_<MODULE>_ERROR - Enable print messages in the respective <MODULE> that are present

* as WPRINT_<MODULE>_ERROR.

* For instance, if WPRINT_ENABLE_WWD_ERROR is enabled, then trace messages that are under

* WPRINT_WWD_ERROR will be printed. This directive shall also result in an ASSERT if the target is built in DEBUG                                 mode.

* WPRINT_ENABLE_<MODULE>_DEBUG - Enable print messages in the respective module that are present as

* WPRINT_<MODULE>_DEBUG.

* For instance, if WPRINT_ENABLE_WWD_DEBUG is enabled, then trace messages that are under

* WPRINT_WWD_DEBUG will be printed.

 

* WPRINT_ENABLE_<MODULE>_INFO - Enable print messages in the respective module that are present as

* WPRINT_<MODULE>_INFO.

* For instance, if WPRINT_ENABLE_WWD_INFO is enabled, then trace messages that are under

* WPRINT_WWD_INFO will be printed.

 

If you disable all the logs, there will have a compiled error, so please keep this one at least:

#define WPRINT_ENABLE_APP_INFO           /* Application prints */

 

pastedImage_10.png

 

So general debug sequence for log enable:

    • Enable WPRINT_ENABLE_MODULE_INFO to track the process.
    • If found an error was printed out, check which module , then enable DEBUG and ERROR mode also. Be noted, Debug compile will go to an assert if enable ERROR layer .
    • Find the bug position , add more debug info by using the same level log print.

I think if you want to manage the log clearly , you can define one MACRO to just add your debug info ,like           #define WPRINT_ENABLE_BUG_DEBUG_INFO , after issue is fixed you can disable it .Another log print mode :

 

 

3.     Wiced_log_setting, it is often used on application area.

If you want to close the log , please change the log to WICED_LOG_OFF, the logs added in      the application will be disabled. And strongly suggest to use this debug info in application debug stage.

Log initialize at application_start and enum structure.

         wiced_log_init(WICED_LOG_INFO, render_log_output, wiced_time_get_time);

         wiced_log_msg(WLF_DEF, WICED_LOG_NOTICE, "wiced logging system is initialized\n");

 

typedef enum

{

    WICED_LOG_OFF = 0,

    WICED_LOG_ERR,

    WICED_LOG_WARNING,

    WICED_LOG_NOTICE,

    WICED_LOG_INFO,

    WICED_LOG_DEBUG0,

    WICED_LOG_DEBUG1,

    WICED_LOG_DEBUG2,

    WICED_LOG_DEBUG3,

    WICED_LOG_DEBUG4,

 

    WICED_LOG_PRINTF, /* Identifies log messages generated by wiced_log_printf calls */

 

    WICED_LOG_MAX

} WICED_LOG_LEVEL_T;

 

b: How to write to STDOUT .

use this function:

pastedImage_91.png

Enable time output with log together.

pastedImage_96.png

954 Views