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

nrf_log_backend_serial should init the fprintf_ctx.p_user_ctx with p_backend->p_ctx

I have a project where I am implementing an alternative logging backend.  My design is modular so there could be multiple logging backends.  Each backend is initialized with a pointer to the appropriate backend context.  Unfortunately the nrf_log_backend_serial_put function does not properly pass the context when setting up the fprintf_ctx structure.

The fix is quite simple:

nrf_fprintf_ctx_t fprintf_ctx = {
.p_io_buffer = (char *)p_buffer,
.io_buffer_size = length,
.io_buffer_cnt = 0,
.auto_flush = false,
.p_user_ctx = p_backend->p_ctx,    //this line change from NULL to p_backend->p_ctx
.fwrite = tx_func
}

Parents Reply Children
No Data
Related