Hi Nordic:
Test with board nrf5340-dk ncs v1.9.1
prj.conf
Hi Nordic:
Test with board nrf5340-dk ncs v1.9.1
prj.conf
Hi Simon:
Thanks for the quick reply. I test your case and the console output was OK.
But if i keep Suspend & Resume the console device. The consle will have no output.
Below is my change on the main.c of your code.
#include <zephyr.h> #include <sys/printk.h> #include <pm/device.h> #define TEST_DELAY 500 #define UART_DEVICE_NAME DT_LABEL(DT_CHOSEN(zephyr_console)) void main(void) { const struct device *console_dev; console_dev = device_get_binding(UART_DEVICE_NAME); printk("output1\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output2\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output3\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output4\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output5\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output6\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("disable_console\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); printk("console disabled\n"); k_sleep(K_MSEC(TEST_DELAY)); }
If i increase the TEST_DELAY to 2000ms , The Console Output will be Normal.
Thanks
Best Regards
Chen
Hi Simon:
Thanks for the quick reply. I test your case and the console output was OK.
But if i keep Suspend & Resume the console device. The consle will have no output.
Below is my change on the main.c of your code.
#include <zephyr.h> #include <sys/printk.h> #include <pm/device.h> #define TEST_DELAY 500 #define UART_DEVICE_NAME DT_LABEL(DT_CHOSEN(zephyr_console)) void main(void) { const struct device *console_dev; console_dev = device_get_binding(UART_DEVICE_NAME); printk("output1\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output2\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output3\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output4\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output5\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("output6\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_RESUME); printk("disable_console\n"); k_sleep(K_MSEC(TEST_DELAY)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND); printk("console disabled\n"); k_sleep(K_MSEC(TEST_DELAY)); }
If i increase the TEST_DELAY to 2000ms , The Console Output will be Normal.
Thanks
Best Regards
Chen
Hi Simon:
Thanks .
And we found that there was a API That can make the consle output without delay.
#include <logging/log_ctrl.h> printk("disable_console\n"); while(log_process(false)); pm_device_action_run(console_dev, PM_DEVICE_ACTION_SUSPEND);