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

LOG_INF print in debug terminal and printf / printk in uart terminal

Hi,

I am interfacing the Peripheral_hids_keyboard + peripheral_uart code

I code can print all the log info data printk and printf data in uart console

I want to separate the printing that LOG_INF,LOG_WAR and LOG_ERR should be print only in Debug RTT Terminal

and Printk / printf function should print in Uart terminal

Before merging the two example code

I tested the NUS code/  Peripheral_uart code there it prints  some data in debug terminal as well as Uart terminal

but after combining the two codes

it print only in Uart terminal

the kconfig file

source "Kconfig.zephyr"

menu "Nordic BLE HIDS Keyboard sample"

config NFC_OOB_PAIRING
	bool "Enable NFC OOB pairing"
	default y if BOARD_NRF5340PDK_NRF5340_CPUAPP
	default y if BOARD_NRF52840DK_NRF52840
	default y if BOARD_NRF52DK_NRF52832
	select NFC_T2T_NRFXLIB
	select NFC_NDEF
	select NFC_NDEF_MSG
	select NFC_NDEF_RECORD
	select NFC_NDEF_LE_OOB_REC

config BT_NUS_THREAD_STACK_SIZE
	int "Thread stack size"
	default 1024
	help
	  Stack size used in each of the two threads

config BT_NUS_UART_BUFFER_SIZE
	int "UART payload buffer element size"
	default 20
	help
	  Size of the payload buffer in each RX and TX FIFO element

config BT_NUS_SECURITY_ENABLED
	bool "Enable security"
	default y
	select BT_SMP
	help
	  "Enable BLE security for the UART service"

config BT_NUS_UART_RX_WAIT_TIME
	int "Timeout for UART RX complete event"
	default 50
	help
	  Wait for RX complete event time in milliseconds
endmenu

prj.conf file

CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_LOG_DEFAULT_LEVEL=3

CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_MAX_CONN=2
CONFIG_BT_MAX_PAIRED=2
CONFIG_BT_SMP=y
CONFIG_BT_L2CAP_TX_BUF_COUNT=5
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Glosdex Headset"
CONFIG_BT_DEVICE_APPEARANCE=961

CONFIG_BT_BAS=y
CONFIG_BT_HIDS=y
CONFIG_BT_HIDS_MAX_CLIENT_COUNT=1
CONFIG_BT_HIDS_DEFAULT_PERM_RW_ENCRYPT=y
CONFIG_BT_GATT_UUID16_POOL_SIZE=40
CONFIG_BT_GATT_CHRC_POOL_SIZE=20

CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y

CONFIG_BT_CONN_CTX=y

# Enable the NUS service
CONFIG_BT_NUS=y

CONFIG_BT_DIS=y
CONFIG_BT_DIS_PNP=y
CONFIG_BT_DIS_MANUF="NordicSemiconductor"
CONFIG_BT_DIS_PNP_VID_SRC=2
CONFIG_BT_DIS_PNP_VID=0x1915
CONFIG_BT_DIS_PNP_PID=0xEEEF
CONFIG_BT_DIS_PNP_VER=0x0100

# Enable bonding
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y

CONFIG_GPIO=y

# Make sure printk is not printing to the UART console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_PRINTK=n

CONFIG_HEAP_MEM_POOL_SIZE=2048

# Enable DK LED and Buttons library
CONFIG_DK_LIBRARY=y

# This example requires more workqueue stack
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

# Config logger
CONFIG_LOG=y
CONFIG_LOG_BUFFER_SIZE=2048
CONFIG_LOG_PRINTK=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n

CONFIG_ASSERT=y

# Clock configuration
CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y

# NFC configuration
CONFIG_NFC_OOB_PAIRING=n

# Added
CONFIG_BT_GATT_CLIENT=y


1. How to separate the Log print in debug terminal and printk / printf in uart terminal?

2. How to disable printk only but need to print the PRINTF and others ?

Parents
  • Hi,

     

    You have setup the log module to print on RTT:

    CONFIG_LOG=y
    CONFIG_LOG_BUFFER_SIZE=2048
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n

     

    In addition, this routes printk() to the log module:

    CONFIG_LOG_PRINTK=y

     

    Setting this to 'n', will cause it to use the CONSOLE backend (see configs UART_CONSOLE and RTT_CONSOLE)

     

    2. How to disable printk only but need to print the PRINTF and others ?

     set PRINTK=n

Reply
  • Hi,

     

    You have setup the log module to print on RTT:

    CONFIG_LOG=y
    CONFIG_LOG_BUFFER_SIZE=2048
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n

     

    In addition, this routes printk() to the log module:

    CONFIG_LOG_PRINTK=y

     

    Setting this to 'n', will cause it to use the CONSOLE backend (see configs UART_CONSOLE and RTT_CONSOLE)

     

    2. How to disable printk only but need to print the PRINTF and others ?

     set PRINTK=n

Children
Related