diff --git a/system/uorb/Kconfig b/system/uorb/Kconfig index 71f06e50469..15421c795c5 100644 --- a/system/uorb/Kconfig +++ b/system/uorb/Kconfig @@ -16,10 +16,15 @@ config UORB_PRIORITY config UORB_STACKSIZE int "stack size" + default 4096 if UORB_FORMAT default DEFAULT_TASK_STACKSIZE + ---help--- + UORB_FORMAT needs around 2.2KB of stack for the listener, which + does not fit in a DEFAULT_TASK_STACKSIZE of 2048. config UORB_FORMAT bool + select LIBC_PRINT_EXTENSION default n config UORB_LISTENER diff --git a/system/uorb/listener.c b/system/uorb/listener.c index 2fd1e532d1e..2fd76eeebb3 100644 --- a/system/uorb/listener.c +++ b/system/uorb/listener.c @@ -200,15 +200,31 @@ static int listener_create_dir(FAR char *dir, size_t size) static int listener_subscribe(FAR struct listen_object_s *tmp, bool nonwakeup) { + int flags; + int fd; + if (nonwakeup) { - return orb_subscribe_multi_nonwakeup(tmp->object.meta, - tmp->object.instance); + fd = orb_subscribe_multi_nonwakeup(tmp->object.meta, + tmp->object.instance); } else { - return orb_subscribe_multi(tmp->object.meta, tmp->object.instance); + fd = orb_subscribe_multi(tmp->object.meta, tmp->object.instance); + } + + if (fd < 0) + { + return fd; + } + + flags = fcntl(fd, F_GETFL, 0); + if (flags >= 0) + { + fcntl(fd, F_SETFL, flags | O_NONBLOCK); } + + return fd; } /**************************************************************************** @@ -897,6 +913,8 @@ static void listener_monitor(FAR struct listen_list_s *objlist, while ((!nb_msgs || nb_recv_msgs < nb_msgs) && !g_should_exit) { + orb_abstime start = orb_absolute_time(); + if (poll(&fds[0], nb_objects, timeout * 1000) > 0) { i = 0; @@ -939,6 +957,16 @@ static void listener_monitor(FAR struct listen_list_s *objlist, "Giving up. err:%d", timeout, errno); break; } + + if (interval != 0) + { + orb_abstime elapsed = orb_absolute_time() - start; + + if (elapsed < (orb_abstime)interval) + { + usleep((unsigned)((orb_abstime)interval - elapsed)); + } + } } i = 0;