This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: Log_printf print char array issue

Part Number: CC2340R5

For debug data_stream, I added Log_printf in app_data_stream.c

    char printData[len+1];
    ...
    Log_printf(LogModule_App2, Log_DEBUG, "Data: %s", "Print the incoming data");
    Log_printf(LogModule_App2, Log_DEBUG, "Data len: %d", len);
    Log_printf(LogModule_App2, Log_DEBUG, "Data: %s", printData);

But I found Log_printf couldn't show printData content correctly, it always show "char". If I used larger size sting, it would showed "_AL_POLICY_AL_SCAN_REQ", any idea about thie issue ?

  • One more thing, I try to use anither API, Log_buf, to dump printData array, but I am not sure what value I should fill in "format" parameter.

    /**
     *  @brief Log a continuous block of memory
     *
     *  Use this marco to send out runtime data from the device. This API should be
     *  used when the data is non constant and can only be derived at runtime. It
     *  is the most intrusive in terms of record overhead and instructions used.
     *
     *  @param[in]  module     Log module that the buffer originated from
     *  @param[in]  level      log level of type @ref Log_Level
     *  @param[in]  format     Restricted format string.
     *  @param[in]  data       Pointer to array of bytes (uint8_t *)
     *  @param[in]  size       Size in bytes of array to send
     *
     */
    #define Log_buf(module, level, format, data, size)                             \
                    _Log_GUARD_MACRO(_Log_buf_B(module , level, format, data, size))

  • Hi Dennis, 

    We are able to reproduce to reproduce your issue. I am going to have a look into it tomorrow.

    Regards,

    Alex

  • Hi Dennis,

    With %s it can only print const strings unfortunately.

    As you want to display a dynamic string, this does not work.

    We will be working on a workaround when we have some time. If you want to use the feature now, you can adapt the LogSinkBuf.rov file, located in the log folder of the SDK.

    If you need to print large amounts of dynamic data, I would suggest the Log_buf function-

    But this will just display your message in integer values and not as character string.

    Regards,

    Alex