Logging functions disabled for nRF52 DK board

I have the nRF52 DK board and I am loading the peripheral_uart example. All works fine I can compile and flash and connect to iPhone. There is no problem with the application. I just want to be able to turn on logging. there is a line in log.h as shown below that shows _CDT_PARSER_ as "#define _CDT_PARSER_ 1". I do not see how or where this is set and how I undefine or disable it.

if _CDT_PARSER_ is defined as a 1 then all logging functions will be 0. What am I doing wrong? I am new to nRF52 DK tools so I am sure it is operator error.

/*
 * Eclipse CDT or JetBrains Clion parser is sometimes confused by logging API
 * code and freezes the whole IDE. Following lines hides LOG_x macros from them.
 */
#if defined(__CDT_PARSER__) || defined(__JETBRAINS_IDE__)
#undef LOG_ERR
#undef LOG_WRN
#undef LOG_INF
#undef LOG_DBG

#undef LOG_HEXDUMP_ERR
#undef LOG_HEXDUMP_WRN
#undef LOG_HEXDUMP_INF
#undef LOG_HEXDUMP_DBG

#define LOG_ERR(...) (void) 0
#define LOG_WRN(...) (void) 0
#define LOG_DBG(...) (void) 0
#define LOG_INF(...) (void) 0

#define LOG_HEXDUMP_ERR(...) (void) 0
#define LOG_HEXDUMP_WRN(...) (void) 0
#define LOG_HEXDUMP_DBG(...) (void) 0
#define LOG_HEXDUMP_INF(...) (void) 0
#endif
Parents Reply
  • Hi again,

    Which IDE are you using? Are you actually using CLion? Or just VS Code with our extension?

    Timothy said:
    this is what is printed
    V 0.01 Temp/Humidity BLE Sensor 11/11/23 (Bd 1.0 DK)
    Bluetooth initialized

    Thanks for sharing. It looks to me like your LOG_INF statement is actually printing, so that's a good sign.

    But just to be clear, is it cutting off the "INF" at the end of that log statement? And is it not printing the other two statements? Or did you just give me an excerpt?

    I need to understand exactly what issue you are seeing.

    Also, have you tried logging with UART? Or do you have to use RTT?

    Best regards,

    Raoul

Children
  • the LOG_INF is NOT printing. my printf statement is printing. none of the LOG_XXX are printing as I show above. I am using VS Code for all development. the __CDT_PARSER__ is defined somewhere which cause all of the logging statement to be NULL (0). I have no idea where that is defined and why it is blocking things.

    this is my code shown below.

    printf("V %d.%02d %s%s\r\n",VERSION_MAJOR, VERSION_MINOR, VERSION_DATE,VERSION_DATE_EXT);
        LOG_INF("Bluetooth initialized INF");
        LOG_WRN("Bluetooth initialized WRN");
        LOG_ERR("Bluetooth initialized ERR");
        printf("Bluetooth initialized\r\n");
  • Tim,

    I don't know what gave you the idea that __CDT_PARSER__ is defined. You are not using Eclipse so that explains why you cannot find it defined. The nRF Connect SDK documentation describes every sample application in the SDK and shows you how to get a logging console for the sample you are working with. There is a lot of Zephyr code included in the logging subsystem; apparently the printf function which is a C library function bypasses all that and goes directly to UART. All we have to know is that there is a bunch of logging subsystem code--the easiest way to deal with that is to simply follow the directions in the sample in which case we never have to know anything much about that logging subsystem. Maybe it helps to know that it has separate "backends" for UART and for RTT. Definitely for you and I who have come from a nRF9160 background it is unexpected that printf and LOG messages go to different places, but it is what it is! 

    Burt

  • Hi,

    Sorry Timothy, my last reply was a bit nonsensical - I missed the printf on the very last line, and so got the impression that logging was partially working.

    Burt is right in that looking at a lot of the underlying code won't always make sense as Zephyr makes heavy use of macros and compile time configuration of the implementation files. So if your editor thinks __CDT_PARSER__ is defined, I wouldn't worry too much about it.

    I would still recommend you to consult the Dev Academy to get some basic printing and logging set up over uart/rtt. I wasn't able to spot any issues with the config you shared.

    Best regards,

    Raoul

Related