Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDK v15.0.0 flashlog read CLI command has issues with the character '%' in the strings.

Hi there,

Seems that the flashlog read processes a log entry from flash using nrf_log_std/hexdump_entry_process, which does take care of the formatting string in the entry, and provides a ready to print buffer... but then it is passed to cli_tx (as part of m_fprintf_ctx), which does pass the buffer to nrd_cli_fprintf as a format string, which seems worng, as the string has already been processed as a format string, and any % resulting from a %% in the original format string (or from %c or %s), will be reinterpreted as a format specifier.

Parents
  • I guess this is the way to fix that... let me know if there is a better way:

    --- a/import/nRF5_SDK/components/libraries/experimental_log/src/nrf_log_backend_flash.c
    +++ b/import/nRF5_SDK/components/libraries/experimental_log/src/nrf_log_backend_flash.c
    ...
     //#include "nrf_delay.h"
     static void cli_tx(void const * p_context, char const * p_buffer, size_t len)
     {
         nrf_cli_t * * pp_cli = (nrf_cli_t * *)p_context;
         char * p_strbuf = (char *)&p_buffer[len];
         *p_strbuf = '\0';
    -    nrf_cli_fprintf((nrf_cli_t const *)*pp_cli, NRF_CLI_DEFAULT, p_buffer);
    +    nrf_cli_fprintf((nrf_cli_t const *) *pp_cli, NRF_CLI_DEFAULT, "%s", p_buffer);
        // nrf_delay_ms(10);
     }
    

Reply
  • I guess this is the way to fix that... let me know if there is a better way:

    --- a/import/nRF5_SDK/components/libraries/experimental_log/src/nrf_log_backend_flash.c
    +++ b/import/nRF5_SDK/components/libraries/experimental_log/src/nrf_log_backend_flash.c
    ...
     //#include "nrf_delay.h"
     static void cli_tx(void const * p_context, char const * p_buffer, size_t len)
     {
         nrf_cli_t * * pp_cli = (nrf_cli_t * *)p_context;
         char * p_strbuf = (char *)&p_buffer[len];
         *p_strbuf = '\0';
    -    nrf_cli_fprintf((nrf_cli_t const *)*pp_cli, NRF_CLI_DEFAULT, p_buffer);
    +    nrf_cli_fprintf((nrf_cli_t const *) *pp_cli, NRF_CLI_DEFAULT, "%s", p_buffer);
        // nrf_delay_ms(10);
     }
    

Children
Related