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

printf vs nrf_log vs app_uart_put

I see that nRF52 SDK support the printf(), nrf_log_info() and app_uart_put() that can display data received on PC serial monitor, I'm wondering what's different/advantage between them? If I have a large of data packets send over bluetooth and received on PC serial monitor, which has the fast print speed to able to handle large packets?

  • Hi,

    With regards to transferring data through the UART interface to a serial monitor, there is no difference between using these functions.

    • app_uart_put() is a function from the UART library module used for putting a single byte on the UART line.
    • printf() is a C library function for sending formatted output to stdout. printf can be retargeted to send data to the UART line, by including the retarget library in your application. This will use app_uart_put() to put each of the bytes in the string onto the UART line.
    • NRF_LOG_INFO() is part of the logger module in SDK versions above 12.0.0. This module support many other features, which you can read about in the documentation. If the logger module is configured to use UART as the backend (RTT is also supported), an instance of app_uart will be added to the application.

    For logging large amounts of data, the additional features of the logger module would be useful, especically the option to do deferred logging, which allows you to process the log buffer at a time with no/low BLE activity. It is also simple to set logging level and turn logging on and off on separate modules.

    Best regards,

    Jørgen

Related