events: Move implementation of events::send() to lib/events

Events have a global, system-wide sequence number, which must be handled
atomically, (fetching and incrementing the sequence AND sending the event
to uORB must be atomic). Currently in FLAT mode, only one instance of this
sequence number exists, so it is OK to have it in px4_platform.

However, in PROTECTED mode px4_platform is instantiated both in kernel-
and user spaces, which makes two instances of this sequence number, which
causes problems in the mavlink event handling logic.

When mavlink receives and handles events, it expects that:
- The sequence numbers arrive in order (seq n is followed by n+1 etc)
- It increments by 1
- There is only one instance of the sequence number

In PROTECTED mode this is violated, as the kernel and user sequence
numbers run freely on their own. This patch fixes the issue by moving
the event backend to the kernel and by providing user access to it via
ioctl.
This commit is contained in:
Ville Juven
2023-09-25 09:54:11 +02:00
committed by Beat Küng
parent fafec397e8
commit 6cb2c176d5
13 changed files with 233 additions and 4 deletions
+1
View File
@@ -107,6 +107,7 @@ function(px4_add_functional_gtest)
px4_daemon
work_queue
parameters
events
perf
tinybson
uorb_msgs
+3 -2
View File
@@ -168,10 +168,11 @@ function(px4_add_module)
if(NOT DYNAMIC)
target_link_libraries(${MODULE} PRIVATE prebuild_targets px4_platform systemlib perf)
if (${PX4_PLATFORM} STREQUAL "nuttx" AND NOT CONFIG_BUILD_FLAT AND KERNEL)
target_link_libraries(${MODULE} PRIVATE kernel_parameters_interface px4_kernel_layer uORB_kernel)
target_link_libraries(${MODULE} PRIVATE
kernel_events_interface kernel_parameters_interface px4_kernel_layer uORB_kernel)
set_property(GLOBAL APPEND PROPERTY PX4_KERNEL_MODULE_LIBRARIES ${MODULE})
else()
target_link_libraries(${MODULE} PRIVATE parameters_interface px4_layer uORB)
target_link_libraries(${MODULE} PRIVATE events_interface parameters_interface px4_layer uORB)
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_LIBRARIES ${MODULE})
endif()
set_property(GLOBAL APPEND PROPERTY PX4_MODULE_PATHS ${CMAKE_CURRENT_SOURCE_DIR})