Skip to content

Commit 0f5c633

Browse files
committed
[nrf fromlist] samples: boards: nordic: system_off: delay systemoff until logs are printed
Wait until console printed all data. Upstream PR #: 81706 Signed-off-by: Piotr Kosycarz <[email protected]>
1 parent a7ef942 commit 0f5c633

File tree

1 file changed

+13
-0
lines changed
  • samples/boards/nordic/system_off/src

1 file changed

+13
-0
lines changed

samples/boards/nordic/system_off/src/main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ int main(void)
8787
retained_update();
8888
}
8989

90+
/* Wait until all logs are printed into console */
91+
if (IS_ENABLED(CONFIG_PM_DEVICE) && IS_ENABLED(CONFIG_SERIAL)) {
92+
static const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
93+
int err;
94+
enum pm_device_state state;
95+
96+
if (dev) {
97+
do {
98+
err = pm_device_state_get(dev, &state);
99+
} while ((err == 0) && (state == PM_DEVICE_STATE_ACTIVE));
100+
}
101+
}
102+
90103
sys_poweroff();
91104

92105
return 0;

0 commit comments

Comments
 (0)