This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Dynamically switching Logs

Hi, 

I am using nrf52840 Preview - DK, with SDK v15.3.0 and Softdevice API 6.1.1

As we need to set NRF_LOG by setting the NRF_LOG_ENABLE and NRF_LOG_BACKEND_URAT_ENABLE  and NRF_FPRINTF to 0 in the sdk_config file to conserver power, which is a compile time procedure.

Is there any run-time solution to turn ON and OFF logs, I need to print some important messages once in a while and then turn OFF the logs to conserve power, is there a solution ?

Thanks.  

Parents
  • Hello,

    It is not possible to turn off the logging module in the SDK. If you turn it on, it stays on. If you want to log only certain parts and turn it off, I suggest that you look into using the UART directly, without the logging module. That way, you can uninitialize it when you are done.

    Best regards,

    Edvin

  • Yes, that is definitely a way. but, I am facing a slightly different problem here. In my system there would be a physical switch which when turned ON will enable critical information to be printed and if it is OFF then nothing should be printed which would be the maximum power saving mode. 

  • I assume that resetting the device whenever you turn the switch off is not a viable solution for you? Because then you can initialize the log based on that. If not, you will have to do this based on UART, and initialize it when you flick the switch on, uninitialize it when you switch it off, and have some function call that will print the log message if the UART is on, and discard the message if it is off.

    That is at least what I can come up with. The NRF_LOG module is not dynamic.

  • I am not sure if call to log_init function makes a difference in power consumption. I mean we have to set NRF_FPRINTF and NRF_BACKEND_UART_ENABLE to 0 for reducing power consumption. I can change the operation of the device to require reset whenever the switch is toggled, but only if the call to log_init function makes a difference in power consumption. can you verify it ? I can't right now, I don't have access to any measurement tools.  

  • I don't have access to the tools myself. I suspect we're in the same home office situation.

    If you insist on using the NRF_LOG_MODULE, then I suggest that you have another layer with a variable deciding whether to print or not.

    If this variable is true, then you call log_init() and call NRF_LOG_INFO();

    But I believe it would be easier for you use the UART directly.

Reply
  • I don't have access to the tools myself. I suspect we're in the same home office situation.

    If you insist on using the NRF_LOG_MODULE, then I suggest that you have another layer with a variable deciding whether to print or not.

    If this variable is true, then you call log_init() and call NRF_LOG_INFO();

    But I believe it would be easier for you use the UART directly.

Children
Related