From 5bf367e1d06bf04cd66632123c75bfe2b33a68e0 Mon Sep 17 00:00:00 2001 From: likun17 Date: Tue, 12 Nov 2024 20:58:57 +0800 Subject: [PATCH 1/3] system/uorb:Loop bug fix Fixed the epoll issue that when multiple events come only the first POLLIN is entered. Signed-off-by: likun17 --- system/uorb/uORB/epoll.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/system/uorb/uORB/epoll.c b/system/uorb/uORB/epoll.c index 147831d3f60..e82c483aa39 100644 --- a/system/uorb/uORB/epoll.c +++ b/system/uorb/uORB/epoll.c @@ -105,7 +105,8 @@ static int orb_loop_epoll_run(FAR struct orb_loop_s *loop) uorberr("epoll wait data in error! fd:%d", handle->fd); } } - else if (et[i].events & EPOLLOUT) + + if (et[i].events & EPOLLOUT) { if (handle->dataout_cb != NULL) { @@ -116,7 +117,8 @@ static int orb_loop_epoll_run(FAR struct orb_loop_s *loop) uorberr("epoll wait data out error! fd:%d", handle->fd); } } - else if (et[i].events & EPOLLPRI) + + if (et[i].events & EPOLLPRI) { if (handle->eventpri_cb != NULL) { @@ -127,7 +129,8 @@ static int orb_loop_epoll_run(FAR struct orb_loop_s *loop) uorberr("epoll wait events pri error! fd:%d", handle->fd); } } - else if (et[i].events & EPOLLERR) + + if (et[i].events & EPOLLERR) { if (handle->eventerr_cb != NULL) { From fa29e6e50416e804c6659ac4b4b3db35e5608cb4 Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Wed, 13 Nov 2024 13:22:11 +0800 Subject: [PATCH 2/3] system/uorb: merge set_info to orb_advertise_multi_queue_info. support new api: orb_advertise_multi_queue_info to advertise topic with info Signed-off-by: dongjiuzhu1 --- system/uorb/uORB/uORB.c | 46 ++++++++++++++++++++++++----------------- system/uorb/uORB/uORB.h | 46 ++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 38 deletions(-) diff --git a/system/uorb/uORB/uORB.c b/system/uorb/uORB/uORB.c index fd3f704af31..63adb4b6421 100644 --- a/system/uorb/uORB/uORB.c +++ b/system/uorb/uORB/uORB.c @@ -57,7 +57,8 @@ ****************************************************************************/ static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags, - int instance, unsigned int queue_size) + int instance, unsigned int queue_size, + FAR orb_info_t *info) { char path[ORB_PATH_MAX]; int fd; @@ -78,6 +79,14 @@ static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags, reginfo.esize = meta->o_size; reginfo.nbuffer = queue_size; reginfo.persist = !!(flags & SENSOR_PERSIST); + if (info != NULL) + { + memcpy(®info.devinfo, info, sizeof(*info)); + } + else + { + memset(®info.devinfo, 0, sizeof(*info)); + } fd = open(ORB_USENSOR_PATH, O_WRONLY | O_CLOEXEC); if (fd < 0) @@ -120,7 +129,8 @@ static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags, static int orb_advertise_multi_queue_flags(FAR const struct orb_metadata *meta, FAR const void *data, FAR int *instance, - unsigned int queue_size, int flags) + unsigned int queue_size, int flags, + FAR orb_info_t *info) { int inst; int fd; @@ -129,7 +139,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); + fd = orb_advsub_open(meta, flags, inst, queue_size, info); if (fd < 0) { uorberr("%s advertise failed (%i)", meta->o_name, fd); @@ -172,24 +182,27 @@ int orb_close(int fd) return close(fd); } -int orb_advertise_multi_queue(FAR const struct orb_metadata *meta, - FAR const void *data, FAR int *instance, - unsigned int queue_size) +int orb_advertise_multi_queue_info(FAR const struct orb_metadata *meta, + FAR const void *data, FAR int *instance, + unsigned int queue_size, + FAR orb_info_t *info) { return orb_advertise_multi_queue_flags(meta, data, instance, - queue_size, O_WRONLY); + queue_size, O_WRONLY, info); } -int orb_advertise_multi_queue_persist(FAR const struct orb_metadata *meta, - FAR const void *data, - FAR int *instance, - unsigned int queue_size) +int +orb_advertise_multi_queue_persist_info(FAR const struct orb_metadata *meta, + FAR const void *data, + FAR int *instance, + unsigned int queue_size, + FAR orb_info_t *info) { return orb_advertise_multi_queue_flags(meta, data, instance, queue_size, - O_WRONLY | SENSOR_PERSIST); + O_WRONLY | SENSOR_PERSIST, info); } -ssize_t orb_publish_multi(int fd, const void *data, size_t len) +ssize_t orb_publish_multi(int fd, FAR const void *data, size_t len) { return write(fd, data, len); } @@ -197,7 +210,7 @@ ssize_t orb_publish_multi(int fd, 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); + return orb_advsub_open(meta, O_RDONLY, instance, 0, NULL); } ssize_t orb_copy_multi(int fd, FAR void *buffer, size_t len) @@ -276,11 +289,6 @@ int orb_get_interval(int fd, FAR unsigned *interval) return ret; } -int orb_set_info(int fd, FAR const orb_info_t *info) -{ - return ioctl(fd, SNIOC_SET_INFO, (unsigned long)(uintptr_t)info); -} - int orb_get_info(int fd, FAR orb_info_t *info) { return ioctl(fd, SNIOC_GET_INFO, (unsigned long)(uintptr_t)info); diff --git a/system/uorb/uORB/uORB.h b/system/uorb/uORB/uORB.h index 5e0bc6c67b1..f1b9c27b0ed 100644 --- a/system/uorb/uORB/uORB.h +++ b/system/uorb/uORB/uORB.h @@ -266,7 +266,7 @@ int orb_open(FAR const char *name, int instance, int flags); int orb_close(int fd); /**************************************************************************** - * Name: orb_advertise_multi_queue + * Name: orb_advertise_multi_queue_info * * Description: * This performs the initial advertisement of a topic; it creates the topic @@ -278,6 +278,7 @@ int orb_close(int fd); * instance Pointer to an integer which yield the instance ID, * (has default 0 if pointer is NULL). * queue_size Maximum number of buffered elements. + * info A pointer to the orb_info_t. * * Returned Value: * -1 on error, otherwise returns an file descriptor @@ -287,10 +288,21 @@ int orb_close(int fd); * this function will return -1 and set errno to ENOENT. ****************************************************************************/ +int orb_advertise_multi_queue_info(FAR const struct orb_metadata *meta, + FAR const void *data, + FAR int *instance, + unsigned int queue_size, + FAR orb_info_t *info); + +static inline int orb_advertise_multi_queue(FAR const struct orb_metadata *meta, FAR const void *data, FAR int *instance, - unsigned int queue_size); + unsigned int queue_size) +{ + return orb_advertise_multi_queue_info(meta, data, instance, + queue_size, NULL); +} static inline int orb_advertise(FAR const struct orb_metadata *meta, FAR const void *data) @@ -338,10 +350,22 @@ static inline int orb_advertise_multi(FAR const struct orb_metadata *meta, * this function will return -1 and set errno to ENOENT. ****************************************************************************/ +int +orb_advertise_multi_queue_persist_info(FAR const struct orb_metadata *meta, + FAR const void *data, + FAR int *instance, + unsigned int queue_size, + FAR orb_info_t *info); + +static inline int orb_advertise_multi_queue_persist(FAR const struct orb_metadata *meta, FAR const void *data, FAR int *instance, - unsigned int queue_size); + unsigned int queue_size) +{ + return orb_advertise_multi_queue_persist_info(meta, data, instance, + queue_size, NULL); +} /**************************************************************************** * Name: orb_unadvertise @@ -691,22 +715,6 @@ int orb_set_interval(int fd, unsigned interval); int orb_get_interval(int fd, FAR unsigned *interval); -/**************************************************************************** - * Name: orb_set_info - * - * Description: - * Set topic information. - * - * Input Parameters: - * fd A fd returned from orb_subscribe. - * info Data to be transmitted. - * - * Returned Value: - * 0 on success, -1 otherwise with ERRNO set accordingly. - ****************************************************************************/ - -int orb_set_info(int fd, FAR const orb_info_t *info); - /**************************************************************************** * Name: orb_get_info * From 6ef21daaceb33019411ac397393ff96cc758036f Mon Sep 17 00:00:00 2001 From: likun17 Date: Mon, 3 Mar 2025 18:29:18 +0800 Subject: [PATCH 3/3] system/uorb:unit_test bug fix Fixed the error message caused by inconsistent definitions of pthread_t on different platforms. Signed-off-by: likun17 --- system/uorb/test/unit_test.c | 6 ------ system/uorb/uORB/uORB.c | 4 ++-- system/uorb/uORB/uORB.h | 10 +++++----- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/system/uorb/test/unit_test.c b/system/uorb/test/unit_test.c index fc28daee573..70cd059dfe3 100644 --- a/system/uorb/test/unit_test.c +++ b/system/uorb/test/unit_test.c @@ -235,12 +235,6 @@ static int latency_test(bool print) usleep(1000); /* simulate >800 Hz system operation */ } - if (pubsub_task < 0) - { - test_fail("failed launching task"); - goto out; - } - ret = OK; out: diff --git a/system/uorb/uORB/uORB.c b/system/uorb/uORB/uORB.c index 63adb4b6421..333fc09e0f4 100644 --- a/system/uorb/uORB/uORB.c +++ b/system/uorb/uORB/uORB.c @@ -43,7 +43,7 @@ * Name: orb_advsub_open * * Description: - * Open device node as advertiser / subscriber, regist node and save meta + * Open device node as advertiser / subscriber, register node and save meta * in driver for first user, set buffer number for advertisers. * * Input Parameters: @@ -68,7 +68,7 @@ static int orb_advsub_open(FAR const struct orb_metadata *meta, int flags, snprintf(path, ORB_PATH_MAX, ORB_SENSOR_PATH"%s%d", meta->o_name, instance); - /* Check existance before open */ + /* Check existence before open */ flags |= O_CLOEXEC; fd = open(path, flags); diff --git a/system/uorb/uORB/uORB.h b/system/uorb/uORB/uORB.h index f1b9c27b0ed..205edffb1c5 100644 --- a/system/uorb/uORB/uORB.h +++ b/system/uorb/uORB/uORB.h @@ -108,10 +108,10 @@ struct orb_handle_s int events; /* Events of interest. */ int fd; /* Topic fd. */ FAR void *arg; /* Callback parameter. */ - orb_datain_cb_t datain_cb; /* User EPOLLIN callback funtion. */ - orb_dataout_cb_t dataout_cb; /* User EPOLLOUT callback funtion. */ - orb_eventpri_cb_t eventpri_cb; /* User EPOLLPRI callback funtion. */ - orb_eventerr_cb_t eventerr_cb; /* User EPOLLERR callback funtion. */ + orb_datain_cb_t datain_cb; /* User EPOLLIN callback function. */ + orb_dataout_cb_t dataout_cb; /* User EPOLLOUT callback function. */ + orb_eventpri_cb_t eventpri_cb; /* User EPOLLPRI callback function. */ + orb_eventerr_cb_t eventerr_cb; /* User EPOLLERR callback function. */ }; struct orb_loop_ops_s; @@ -806,7 +806,7 @@ orb_abstime orb_absolute_time(void); * then Past system time. * * Returned Value: - * Bewteen time. + * Between time. ****************************************************************************/ static inline orb_abstime orb_elapsed_time(FAR const orb_abstime *then)