mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 08:40:30 +08:00
feat(uORB): Add an own type, orb_sub_t, for subscription handles (#27457)
* platforms/common/uORB/uORB.h: Add definition for orb_sub_t and handle check functions Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae> * uORB: Change subscriber id:s from int to orb_sub_t Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae> * uxrce_dds_client: Change polling of transport device from px4_poll to poll Use posix poll directly, there is no need to use px4_poll unless uORBs are being polled. The one used here is a normal filesystem/device poll, so we can use normal "poll", this is the common pattern in the codebase. Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae> * Fix linking for protected build This fixes errors for memalign not linking on some configurations. Memalign exists in nuttx kernel-side mm library and it may fail in configurations where kernel and userspace are separated. This has no effect on other than "CONFIG_BUILD_PROTECTED" or "CONFIG_BUILD_KERNEL" NuttX builds. Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae> --------- Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae> Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae> Co-authored-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
1 parent
e24cda2fd9
commit
3042f906ab
47 files changed
+173
-158
No files matched your search
@@ -56,7 +56,7 @@ int uORBTest::UnitTest::pubsublatency_main()
|
||||
/* wakeup source(s) */
|
||||
px4_pollfd_struct_t fds[1] {};
|
||||
|
||||
int test_multi_sub = orb_subscribe_multi(ORB_ID(orb_test_medium), 0);
|
||||
orb_sub_t test_multi_sub = orb_subscribe_multi(ORB_ID(orb_test_medium), 0);
|
||||
|
||||
orb_test_medium_s t{};
|
||||
|
||||
@@ -269,9 +269,9 @@ int uORBTest::UnitTest::test_single()
|
||||
return test_fail("advertise failed: %d", errno);
|
||||
}
|
||||
|
||||
int sfd = orb_subscribe(ORB_ID(orb_test));
|
||||
orb_sub_t sfd = orb_subscribe(ORB_ID(orb_test));
|
||||
|
||||
if (sfd < 0) {
|
||||
if (!orb_sub_valid(sfd)) {
|
||||
return test_fail("subscribe failed: %d", errno);
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ int uORBTest::UnitTest::test_multi()
|
||||
}
|
||||
|
||||
/* subscribe to both topics and ensure valid data is received */
|
||||
int sfd0 = orb_subscribe_multi(ORB_ID(orb_multitest), 0);
|
||||
orb_sub_t sfd0 = orb_subscribe_multi(ORB_ID(orb_multitest), 0);
|
||||
|
||||
if (PX4_OK != orb_copy(ORB_ID(orb_multitest), sfd0, &u)) {
|
||||
return test_fail("sub #0 copy failed: %d", errno);
|
||||
@@ -372,7 +372,7 @@ int uORBTest::UnitTest::test_multi()
|
||||
return test_fail("sub #0 val. mismatch: %d", u.val);
|
||||
}
|
||||
|
||||
int sfd1 = orb_subscribe_multi(ORB_ID(orb_multitest), 1);
|
||||
orb_sub_t sfd1 = orb_subscribe_multi(ORB_ID(orb_multitest), 1);
|
||||
|
||||
if (PX4_OK != orb_copy(ORB_ID(orb_multitest), sfd1, &u)) {
|
||||
return test_fail("sub #1 copy failed: %d", errno);
|
||||
@@ -456,7 +456,7 @@ int uORBTest::UnitTest::test_multi2()
|
||||
|
||||
_thread_should_exit = false;
|
||||
const int num_instances = 3;
|
||||
int orb_data_fd[num_instances] {-1, -1, -1};
|
||||
orb_sub_t orb_data_fd[num_instances] {ORB_SUB_INVALID, ORB_SUB_INVALID, ORB_SUB_INVALID};
|
||||
int orb_data_next = 0;
|
||||
|
||||
for (int i = 0; i < num_instances; ++i) {
|
||||
@@ -483,7 +483,7 @@ int uORBTest::UnitTest::test_multi2()
|
||||
px4_usleep(1000);
|
||||
|
||||
bool updated = false;
|
||||
int orb_data_cur_fd = orb_data_fd[orb_data_next];
|
||||
orb_sub_t orb_data_cur_fd = orb_data_fd[orb_data_next];
|
||||
orb_check(orb_data_cur_fd, &updated);
|
||||
|
||||
if (updated) {
|
||||
@@ -515,9 +515,9 @@ int uORBTest::UnitTest::test_multi_reversed()
|
||||
/* For these tests 0 and 1 instances are taken from before, therefore continue with 2 and 3. */
|
||||
|
||||
/* Subscribe first and advertise afterwards. */
|
||||
int sfd2 = orb_subscribe_multi(ORB_ID(orb_multitest), 2);
|
||||
orb_sub_t sfd2 = orb_subscribe_multi(ORB_ID(orb_multitest), 2);
|
||||
|
||||
if (sfd2 < 0) {
|
||||
if (!orb_sub_valid(sfd2)) {
|
||||
return test_fail("sub. id2: ret: %d", sfd2);
|
||||
}
|
||||
|
||||
@@ -558,7 +558,7 @@ int uORBTest::UnitTest::test_multi_reversed()
|
||||
return test_fail("sub #3 val. mismatch: %d", u.val);
|
||||
}
|
||||
|
||||
int sfd3 = orb_subscribe_multi(ORB_ID(orb_multitest), 3);
|
||||
orb_sub_t sfd3 = orb_subscribe_multi(ORB_ID(orb_multitest), 3);
|
||||
|
||||
if (PX4_OK != orb_copy(ORB_ID(orb_multitest), sfd3, &u)) {
|
||||
return test_fail("sub #3 copy failed: %d", errno);
|
||||
@@ -607,9 +607,9 @@ int uORBTest::UnitTest::test_wrap_around()
|
||||
t.val = 0;
|
||||
orb_publish(ORB_ID(orb_test_medium_wrap_around), ptopic, &t);
|
||||
|
||||
int sfd = orb_subscribe(ORB_ID(orb_test_medium_wrap_around));
|
||||
orb_sub_t sfd = orb_subscribe(ORB_ID(orb_test_medium_wrap_around));
|
||||
|
||||
if (sfd < 0) {
|
||||
if (!orb_sub_valid(sfd)) {
|
||||
return test_fail("subscribe failed: %d", errno);
|
||||
}
|
||||
|
||||
@@ -829,9 +829,9 @@ int uORBTest::UnitTest::test_queue()
|
||||
orb_advert_t ptopic{nullptr};
|
||||
bool updated{false};
|
||||
|
||||
int sfd = orb_subscribe(ORB_ID(orb_test_medium_queue));
|
||||
orb_sub_t sfd = orb_subscribe(ORB_ID(orb_test_medium_queue));
|
||||
|
||||
if (sfd < 0) {
|
||||
if (!orb_sub_valid(sfd)) {
|
||||
return test_fail("subscribe failed: %d", errno);
|
||||
}
|
||||
|
||||
@@ -981,9 +981,9 @@ int uORBTest::UnitTest::test_queue_poll_notify()
|
||||
test_note("Testing orb queuing (poll & notify)");
|
||||
|
||||
orb_test_medium_s t{};
|
||||
int sfd = orb_subscribe(ORB_ID(orb_test_medium_queue_poll));
|
||||
orb_sub_t sfd = orb_subscribe(ORB_ID(orb_test_medium_queue_poll));
|
||||
|
||||
if (sfd < 0) {
|
||||
if (!orb_sub_valid(sfd)) {
|
||||
return test_fail("subscribe failed: %d", errno);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user