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

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

commit ffb963147debb6e99e5e8b839aae0f9e04e52212
Author: dongjiuzhu1 <[email protected]>
AuthorDate: Fri May 9 20:57:55 2025 +0800

    !system/uorb: Replace the nonwakeup subscribe API with wakeup.
    
    The sensor driver now opens every user in non-wakeup mode and replaced
    SNIOC_SET_NONWAKEUP with SNIOC_SET_WAKEUP, whose argument is true to
    enable wakeup. orb_subscribe_nonwakeup() and
    orb_subscribe_multi_nonwakeup() only repeat the default, and uORB still
    issues SNIOC_SET_NONWAKEUP, which no longer exists.
    
    * Remove orb_subscribe_nonwakeup() and orb_subscribe_multi_nonwakeup().
    * Pass a "wakeup" flag to orb_advsub_open() and issue SNIOC_SET_WAKEUP
      only for orb_subscribe_multi_wakeup().
    * uorb_listener: subscribe in non-wakeup mode by default, and replace
      the "-u" option with "-w" to subscribe in wakeup mode.
    
    This change requires the nuttx change that introduces SNIOC_SET_WAKEUP.
    
    BREAKING CHANGE: orb_subscribe_nonwakeup() and
    orb_subscribe_multi_nonwakeup() are removed; call orb_subscribe() or
    orb_subscribe_multi() instead, the behavior is identical. uorb_listener
    no longer accepts "-u"; drop it, since non-wakeup is the default, and
    use "-w" for wakeup subscriptions. system/uorb now needs a nuttx tree
    that provides SNIOC_SET_WAKEUP.
    
    Signed-off-by: dongjiuzhu1 <[email protected]>
---
 system/uorb/listener.c  | 52 ++++++++++++++++++++++++-------------------------
 system/uorb/uORB/uORB.c | 14 ++++++-------
 system/uorb/uORB/uORB.h | 42 ---------------------------------------
 3 files changed, 32 insertions(+), 76 deletions(-)

diff --git a/system/uorb/listener.c b/system/uorb/listener.c
index a5a462567..38f3d8a81 100644
--- a/system/uorb/listener.c
+++ b/system/uorb/listener.c
@@ -84,7 +84,7 @@ static int listener_print(FAR const struct orb_metadata 
*meta, int fd);
 static void listener_monitor(FAR struct listen_list_s *objlist,
                              int nb_objects, float topic_rate,
                              int topic_latency, int nb_msgs,
-                             int timeout, bool record, bool nonwakeup);
+                             int timeout, bool record, bool wakeup);
 static int listener_update(FAR struct listen_list_s *objlist,
                            FAR struct orb_object *object);
 static void listener_top(FAR struct listen_list_s *objlist,
@@ -140,7 +140,7 @@ listener <command> [arguments...]\n\
 \t[-l       ]  Top only execute once.\n\
 \t[-i       ]  Get sensor device information based on topic.\n\
 \t[-f       ]  Flush sensor drive data.\n\
-\t[-u       ]  Subscribe in non-wakeup mode to save power.\n\
+\t[-w       ]  Subscribe in wakeup mode.\n\
   ");
 }
 
@@ -187,28 +187,26 @@ static int listener_create_dir(FAR char *dir, size_t size)
  * Name: listener_subscribe
  *
  * Description:
- *   Subscribe topic according to non wakeup mode.
+ *   Subscribe topic according to wakeup mode.
  *
  * Input Parameters:
  *   tmp          Given object
- *   nonwakeup    State of nonwakeup.
+ *   wakeup       State of wakeup.
  *
  * Returned Value:
  *   fd on success, otherwise -1.
  ****************************************************************************/
 
 static int listener_subscribe(FAR struct listen_object_s *tmp,
-                              bool nonwakeup)
+                              bool wakeup)
 {
-  if (nonwakeup)
+  if (wakeup)
     {
-      return orb_subscribe_multi_nonwakeup(tmp->object.meta,
-                                           tmp->object.instance);
-    }
-  else
-    {
-      return orb_subscribe_multi(tmp->object.meta, tmp->object.instance);
+      return orb_subscribe_multi_wakeup(tmp->object.meta,
+                                        tmp->object.instance);
     }
+
+  return orb_subscribe_multi(tmp->object.meta, tmp->object.instance);
 }
 
 /****************************************************************************
@@ -574,14 +572,14 @@ static int listener_print(FAR const struct orb_metadata 
*meta, int fd)
  *   objlist      Topic object list.
  *   nb_objects   Length of objects list.
  *   timeout      Maximum poll waiting time(microsecond).
- *   nonwakeup    The state of non wakeup
+ *   wakeup       The state of wakeup
  *
  * Returned Value:
  *   void
  ****************************************************************************/
 
 static void listener_flush_topic(FAR const struct listen_list_s *objlist,
-                                 int nb_objects, int timeout, bool nonwakeup)
+                                 int nb_objects, int timeout, bool wakeup)
 {
   FAR struct listen_object_s *tmp;
   FAR struct pollfd *fds;
@@ -610,7 +608,7 @@ static void listener_flush_topic(FAR const struct 
listen_list_s *objlist,
     {
       int fd;
 
-      fd = listener_subscribe(tmp, nonwakeup);
+      fd = listener_subscribe(tmp, wakeup);
       if (fd < 0)
         {
           fds[i].fd     = -1;
@@ -710,14 +708,14 @@ static void listener_flush_topic(FAR const struct 
listen_list_s *objlist,
  *
  * Input Parameters:
  *   objlist      topic object list.
- *   nonwakeup    The state of non wakeup
+ *   wakeup       The state of wakeup
  *
  * Returned Value:
  *   void
  ****************************************************************************/
 
 static void listener_print_info(FAR const struct listen_list_s *objlist,
-                                bool nonwakeup)
+                                bool wakeup)
 {
   FAR struct listen_object_s *tmp;
   orb_info_t info;
@@ -726,7 +724,7 @@ static void listener_print_info(FAR const struct 
listen_list_s *objlist,
 
   SLIST_FOREACH(tmp, objlist, node)
     {
-      fd = listener_subscribe(tmp, nonwakeup);
+      fd = listener_subscribe(tmp, wakeup);
       if (fd < 0)
         {
           continue;
@@ -814,7 +812,7 @@ static int listener_record(FAR const struct orb_metadata 
*meta, int fd,
 static void listener_monitor(FAR struct listen_list_s *objlist,
                              int nb_objects, float topic_rate,
                              int topic_latency, int nb_msgs,
-                             int timeout, bool record, bool nonwakeup)
+                             int timeout, bool record, bool wakeup)
 {
   FAR struct pollfd *fds;
   char path[PATH_MAX];
@@ -845,7 +843,7 @@ static void listener_monitor(FAR struct listen_list_s 
*objlist,
     {
       int fd;
 
-      fd = listener_subscribe(tmp, nonwakeup);
+      fd = listener_subscribe(tmp, wakeup);
       if (fd < 0)
         {
           fds[i].fd     = -1;
@@ -1086,7 +1084,7 @@ int main(int argc, FAR char *argv[])
   bool info         = false;
   bool flush        = false;
   bool record       = false;
-  bool nonwakeup    = false;
+  bool wakeup       = false;
   bool only_once    = false;
   FAR char *filter  = NULL;
   int ret;
@@ -1100,7 +1098,7 @@ int main(int argc, FAR char *argv[])
 
   /* Pasrse Argument */
 
-  while ((ch = getopt(argc, argv, "r:b:n:t:Tfslhiu")) != EOF)
+  while ((ch = getopt(argc, argv, "r:b:n:t:Tfslhiw")) != EOF)
     {
       switch (ch)
         {
@@ -1158,8 +1156,8 @@ int main(int argc, FAR char *argv[])
             info = true;
             break;
 
-          case 'u':
-            nonwakeup = true;
+          case 'w':
+            wakeup = true;
             break;
 
           case 'h':
@@ -1184,13 +1182,13 @@ int main(int argc, FAR char *argv[])
 
   if (flush)
     {
-      listener_flush_topic(&objlist, ret, timeout, nonwakeup);
+      listener_flush_topic(&objlist, ret, timeout, wakeup);
       goto exit;
     }
 
   if (info)
     {
-      listener_print_info(&objlist, nonwakeup);
+      listener_print_info(&objlist, wakeup);
       goto exit;
     }
 
@@ -1209,7 +1207,7 @@ int main(int argc, FAR char *argv[])
         }
 
       listener_monitor(&objlist, ret, topic_rate, topic_latency,
-                       nb_msgs, timeout, record, nonwakeup);
+                       nb_msgs, timeout, record, wakeup);
     }
 
 exit:
diff --git a/system/uorb/uORB/uORB.c b/system/uorb/uORB/uORB.c
index 3c715f38e..9e3d37772 100644
--- a/system/uorb/uORB/uORB.c
+++ b/system/uorb/uORB/uORB.c
@@ -66,7 +66,7 @@
  *   flag         The open flag.
  *   instance     Instance number to open.
  *   queue_size   Maximum number of buffered elements.
- *   non_wakeup   The non wakeup flag.
+ *   wakeup       The wakeup flag.
  *
  * Returned Value:
  *   fd on success, otherwise returns a negated errno value on failure.
@@ -74,7 +74,7 @@
 
 static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags,
                            int instance, unsigned int queue_size,
-                           FAR orb_info_t *info, bool non_wakeup)
+                           FAR orb_info_t *info, bool wakeup)
 {
   char path[ORB_PATH_MAX];
   int fd;
@@ -140,9 +140,9 @@ static int orb_advsub_open(FAR const struct orb_metadata 
*meta, int flags,
       ioctl(fd, SNIOC_SET_BUFFER_NUMBER, (unsigned long)queue_size);
     }
 
-  if (!non_wakeup)
+  if (wakeup)
     {
-      ioctl(fd, SNIOC_SET_NONWAKEUP, (unsigned long)non_wakeup);
+      ioctl(fd, SNIOC_SET_WAKEUP, (unsigned long)wakeup);
     }
 
   return fd;
@@ -161,7 +161,7 @@ orb_advertise_multi_queue_flags(FAR const struct 
orb_metadata *meta,
 
   inst = instance ? *instance : orb_group_count(meta);
 
-  fd = orb_advsub_open(meta, flags, inst, queue_size, info, true);
+  fd = orb_advsub_open(meta, flags, inst, queue_size, info, false);
   if (fd < 0)
     {
       uorberr("%s advertise failed (%i)", meta->o_name, fd);
@@ -255,13 +255,13 @@ ssize_t orb_publish_multi(int fd, FAR const void *data, 
size_t len)
 int orb_subscribe_multi(FAR const struct orb_metadata *meta,
                         unsigned instance)
 {
-  return orb_advsub_open(meta, O_RDONLY, instance, 0, NULL, true);
+  return orb_advsub_open(meta, O_RDONLY, instance, 0, NULL, false);
 }
 
 int orb_subscribe_multi_wakeup(FAR const struct orb_metadata *meta,
                                unsigned instance)
 {
-  return orb_advsub_open(meta, O_RDONLY, instance, 0, NULL, false);
+  return orb_advsub_open(meta, O_RDONLY, instance, 0, NULL, true);
 }
 
 ssize_t orb_copy_multi(int fd, FAR void *buffer, size_t len)
diff --git a/system/uorb/uORB/uORB.h b/system/uorb/uORB/uORB.h
index 89071630a..4b9e7b63e 100644
--- a/system/uorb/uORB/uORB.h
+++ b/system/uorb/uORB/uORB.h
@@ -484,48 +484,6 @@ static inline int orb_subscribe(FAR const struct 
orb_metadata *meta)
   return orb_subscribe_multi(meta, 0);
 }
 
-/****************************************************************************
- * Name: orb_subscribe_multi_nonwakeup/orb_subscribe_nonwakeup
- *
- * Description:
- *   Subscribe to a topic in a non-wakeup ways.
- *
- *   The usage of orb_subscribe_multi_nonwakeup is same to that of
- *   orb_subscribe_multi, with the key difference lying in whether the
- *   system's wakeup status needs to be concerned. This distinction is
- *   particularly beneficial for low-power consumption scenarios.
- *   If the subscription is in a non-wakeup mode, the subscriber will not
- *   receive data while the system is in sleep mode. In such cases, new data
- *   will overwrite old data until the system is awakened, at which point
- *   the subscriber will be notified. Typically, the subscriber and
- *   publisher of a topic reside in two separate systems.
- *
- * Input Parameters:
- *   meta       The uORB metadata (usually from the ORB_ID() macro)
- *   instance   The instance of the topic. Instance 0 matches the topic of
- *              the orb_subscribe() call.
- *
- * Returned Value:
- *   -1 on error, otherwise returns a fd
- *   that can be used to read and update the topic.
- *   If the topic in question is not known (due to an
- *   ORB_DEFINE_OPTIONAL with no corresponding ORB_DECLARE)
- *   this function will return -1 and set errno to ENOENT.
- ****************************************************************************/
-
-static inline
-int orb_subscribe_multi_nonwakeup(FAR const struct orb_metadata *meta,
-                                  unsigned instance)
-{
-  return orb_subscribe_multi(meta, instance);
-}
-
-static inline
-int orb_subscribe_nonwakeup(FAR const struct orb_metadata *meta)
-{
-  return orb_subscribe(meta);
-}
-
 /****************************************************************************
  * Name: orb_subscribe_multi_wakeup/orb_subscribe_wakeup
  *

Reply via email to