You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/22 05:59:33 UTC

[GitHub] [incubator-nuttx-apps] Donny9 opened a new pull request, #1230: system/uorb: support uorb, include uorb wraper, unit test, uorb_listener, topic definition

Donny9 opened a new pull request, #1230:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1230

   ## Summary
   system/uorb: support uorb, include uorb wraper, unit test, uorb_listener, topic definition
   
   refer to: https://docs.px4.io/v1.12/en/middleware/uorb.html
   uORB  comes from the open source flight control PX4, is the internal pub-sub messaging system, used for communication between modules. 
   
   About original uORB implementation:
   * No thread or work queue is needed, the module start only makes sure to initialize the shared global state.
   * Communication is done via shared memory.
   * The implementation is asynchronous and lock-free, ie. a publisher does not wait for a subscriber and vice versa.
   * This is achieved by having a separate buffer between a publisher and a subscriber.
   * The code is optimized to minimize the memory footprint and the latency to exchange messages.
   
   About uORB shortcoming:
   * The internal driver of uorb is implemented in user space and cannot run in kernel mode.
   * Uorb is developed in C++ language, and the integration needs to rely on libc++, which is not good for embedded devices with limited resources.
   * There is no relationship between the subscriber and the publisher, and it is impossible to control the publisher according to the status of the subscriber, which is required in many cases.For example, to control whether to open it according to the subscription of the sensor.
   * For weaker sampling support, there is a cumulative error.
   
   For the original design, vela has been enhanced:
   * Enhanced nuttx sensor driver framework, adapted to uorb cdev function.
   * Use c language to implement uorb upper wrapper.
   * The interaction between subscribers and publishers is completed through event POLLPRI, making the whole framework more intelligent.
   * By working with sensor rpmsg, you can subscribe to multi-core topics transparently and without any sense, make the whole system configuration more flexible.
   * Change all interfaces of uorb to file descriptor operations to simplify usage.
   * Keep most of the test cases and test tools with the original uorb.
   
   ## Impact
   Support uorb middleware
   ## Testing
   Vela CI
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] acassis merged pull request #1230: system/uorb: support uorb, include uorb wraper, unit test, uorb_listener, topic definition

Posted by GitBox <gi...@apache.org>.
acassis merged PR #1230:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1230


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1230: system/uorb: support uorb, include uorb wraper, unit test, uorb_listener, topic definition

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #1230:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1230#discussion_r928222373


##########
system/uorb/uORB/uORB.c:
##########
@@ -90,18 +89,16 @@ static int orb_open(FAR const struct orb_metadata *meta, bool advertiser,
           return ret;
         }
 
-      first_open = true;
-    }
-
-  fd = open(path, O_CLOEXEC | (advertiser ? O_WRONLY : O_RDONLY));
-  if (fd < 0)
-    {
-      return fd;
-    }
+      fd = open(path, flags);
+      if (fd < 0)
+        {
+          return fd;
+        }
 
-  if (first_open)
-    {
-      ioctl(fd, SNIOC_SET_USERPRIV, (unsigned long)(uintptr_t)meta);
+      if (ret != -EEXIST)

Review Comment:
   use errno instead



##########
system/uorb/uORB/uORB.c:
##########
@@ -0,0 +1,314 @@
+/****************************************************************************
+ * apps/system/uorb/uORB/uORB.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#include <uORB/uORB.h>
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: orb_open
+ *
+ * Description:
+ *   Open device node as advertiser / subscriber, regist node and save meta
+ *   in driver for first user, set buffer number for advertisers.
+ *
+ * Input Parameters:
+ *   meta         The uORB metadata (usually from the ORB_ID() macro)
+ *   advertiser   Whether advertiser or subscriber.
+ *   instance     Instance number to open.
+ *   queue_size   Maximum number of buffered elements.
+ *
+ * Returned Value:
+ *   fd on success, otherwise returns negative value and set errno.
+ ****************************************************************************/
+
+static int orb_open(FAR const struct orb_metadata *meta, bool advertiser,
+                    int instance, unsigned int queue_size)
+{
+  char path[PATH_MAX];
+  bool first_open = false;
+  int fd;
+  int ret;
+
+  snprintf(path, PATH_MAX, ORB_SENSOR_PATH"%s%d", meta->o_name, instance);
+
+  /* Check existance before open */
+
+  ret = access(path, F_OK);
+  if (ret < 0)
+    {
+      struct sensor_reginfo_s reginfo;
+
+      reginfo.path    = path;
+      reginfo.esize   = meta->o_size;
+      reginfo.nbuffer = queue_size;
+
+      fd = open(ORB_USENSOR_PATH, O_WRONLY);
+      if (fd < 0)
+        {
+          return fd;
+        }
+
+      /* Register new device node */
+
+      ret = ioctl(fd, SNIOC_REGISTER, (unsigned long)(uintptr_t)&reginfo);
+      close(fd);
+      if (ret < 0 && ret != -EEXIST)

Review Comment:
   check errno instead



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org