You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/07/23 19:58:21 UTC

[incubator-nuttx-apps] 18/20: uorb/listener: ignore first get_state failed.

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 3f865c4f9ebd77e53967a51f573bdb2acdbcea60
Author: jihandong <ji...@xiaomi.com>
AuthorDate: Mon Jun 13 15:39:24 2022 +0800

    uorb/listener: ignore first get_state failed.
    
    Signed-off-by: jihandong <ji...@xiaomi.com>
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 system/uorb/listener.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/system/uorb/listener.c b/system/uorb/listener.c
index 284ecfa7f..237e149d8 100644
--- a/system/uorb/listener.c
+++ b/system/uorb/listener.c
@@ -183,16 +183,10 @@ static int listener_add_object(FAR struct list_node *objlist,
     }
 
   ret = listener_get_state(object, &state);
-  if (ret < 0)
-    {
-      free(tmp);
-      return ret;
-    }
-
   tmp->object.meta     = object->meta;
   tmp->object.instance = object->instance;
   tmp->timestamp       = orb_absolute_time();
-  tmp->generation      = state.generation;
+  tmp->generation      = ret < 0 ? 0 : state.generation;
   list_add_tail(objlist, &tmp->node);
   return 0;
 }
@@ -252,7 +246,8 @@ static int listener_update(FAR struct list_node *objlist,
         {
           unsigned long frequency;
 
-          frequency = delta_generation * 1000000 / delta_time;
+          frequency = (state.max_frequency ? state.max_frequency : 1000000)
+                      * delta_generation / delta_time;
           uorbinfo_raw("\033[K" "%-*s %2u %4" PRIu32 " %4lu "
                        "%2" PRIu32 " %4u",
                        ORB_MAX_PRINT_NAME,