mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-19 19:39:05 +08:00
Modify uORB.cpp main file and CMakeLists.txt for NuttX protected build
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
parent
92877e1f35
commit
e3b024c15d
@ -34,7 +34,9 @@
|
||||
# this includes the generated topics directory
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
px4_add_library(uORB
|
||||
set(SRCS)
|
||||
|
||||
set(SRCS_COMMON
|
||||
ORBSet.hpp
|
||||
Publication.hpp
|
||||
PublicationMulti.hpp
|
||||
@ -47,15 +49,48 @@ px4_add_library(uORB
|
||||
uORB.h
|
||||
uORBCommon.hpp
|
||||
uORBCommunicator.hpp
|
||||
uORBDeviceMaster.cpp
|
||||
uORBDeviceMaster.hpp
|
||||
uORBDeviceNode.cpp
|
||||
uORBDeviceNode.hpp
|
||||
uORBManager.cpp
|
||||
uORBManager.hpp
|
||||
uORBUtils.cpp
|
||||
uORBUtils.hpp
|
||||
)
|
||||
uORBDeviceMaster.hpp
|
||||
uORBDeviceNode.hpp
|
||||
)
|
||||
|
||||
set(SRCS_KERNEL
|
||||
uORBDeviceMaster.cpp
|
||||
uORBDeviceNode.cpp
|
||||
uORBManager.cpp
|
||||
)
|
||||
|
||||
set(SRCS_USER
|
||||
uORBManagerUsr.cpp
|
||||
)
|
||||
|
||||
if (NOT DEFINED CONFIG_BUILD_FLAT AND "${PX4_PLATFORM}" MATCHES "nuttx")
|
||||
# This is the kernel side library in nuttx kernel/protected build
|
||||
px4_add_library(uORB_kernel
|
||||
${SRCS_COMMON}
|
||||
${SRCS_KERNEL}
|
||||
)
|
||||
|
||||
# Sources for the user side library in nuttx kernel/protected build
|
||||
list(APPEND SRCS
|
||||
${SRCS_COMMON}
|
||||
${SRCS_USER}
|
||||
)
|
||||
target_compile_options(uORB_kernel PRIVATE ${MAX_CUSTOM_OPT_LEVEL} -D__KERNEL__)
|
||||
|
||||
else()
|
||||
# Sources for all other targets (flat build, posix...)
|
||||
list(APPEND SRCS
|
||||
${SRCS_COMMON}
|
||||
${SRCS_KERNEL}
|
||||
)
|
||||
endif()
|
||||
|
||||
px4_add_library(uORB
|
||||
${SRCS}
|
||||
)
|
||||
|
||||
target_compile_options(uORB PRIVATE ${MAX_CUSTOM_OPT_LEVEL})
|
||||
target_link_libraries(uORB PRIVATE cdev uorb_msgs)
|
||||
|
||||
@ -41,6 +41,10 @@
|
||||
#include "uORBManager.hpp"
|
||||
#include "uORBCommon.hpp"
|
||||
|
||||
#ifdef __PX4_NUTTX
|
||||
#include <sys/boardctl.h>
|
||||
#endif
|
||||
|
||||
static uORB::DeviceMaster *g_dev = nullptr;
|
||||
|
||||
int uorb_start(void)
|
||||
@ -56,6 +60,7 @@ int uorb_start(void)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#if !defined(__PX4_NUTTX) || defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
/* create the driver */
|
||||
g_dev = uORB::Manager::get_instance()->get_device_master();
|
||||
|
||||
@ -63,11 +68,15 @@ int uorb_start(void)
|
||||
return -errno;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int uorb_status(void)
|
||||
{
|
||||
#if !defined(__PX4_NUTTX) || defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
|
||||
if (g_dev != nullptr) {
|
||||
g_dev->printStatistics();
|
||||
|
||||
@ -75,11 +84,16 @@ int uorb_status(void)
|
||||
PX4_INFO("uorb is not running");
|
||||
}
|
||||
|
||||
#else
|
||||
boardctl(ORBIOCDEVMASTERCMD, ORB_DEVMASTER_STATUS);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int uorb_top(char **topic_filter, int num_filters)
|
||||
{
|
||||
#if !defined(__PX4_NUTTX) || defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
|
||||
if (g_dev != nullptr) {
|
||||
g_dev->showTop(topic_filter, num_filters);
|
||||
|
||||
@ -87,10 +101,12 @@ int uorb_top(char **topic_filter, int num_filters)
|
||||
PX4_INFO("uorb is not running");
|
||||
}
|
||||
|
||||
#else
|
||||
boardctl(ORBIOCDEVMASTERCMD, ORB_DEVMASTER_TOP);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_advertise(meta, data);
|
||||
@ -117,42 +133,42 @@ int orb_unadvertise(orb_advert_t handle)
|
||||
return uORB::Manager::get_instance()->orb_unadvertise(handle);
|
||||
}
|
||||
|
||||
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
|
||||
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_publish(meta, handle, data);
|
||||
}
|
||||
|
||||
int orb_subscribe(const struct orb_metadata *meta)
|
||||
int orb_subscribe(const struct orb_metadata *meta)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_subscribe(meta);
|
||||
}
|
||||
|
||||
int orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
|
||||
int orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_subscribe_multi(meta, instance);
|
||||
}
|
||||
|
||||
int orb_unsubscribe(int handle)
|
||||
int orb_unsubscribe(int handle)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_unsubscribe(handle);
|
||||
}
|
||||
|
||||
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
|
||||
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_copy(meta, handle, buffer);
|
||||
}
|
||||
|
||||
int orb_check(int handle, bool *updated)
|
||||
int orb_check(int handle, bool *updated)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_check(handle, updated);
|
||||
}
|
||||
|
||||
int orb_exists(const struct orb_metadata *meta, int instance)
|
||||
int orb_exists(const struct orb_metadata *meta, int instance)
|
||||
{
|
||||
return uORB::Manager::get_instance()->orb_exists(meta, instance);
|
||||
}
|
||||
|
||||
int orb_group_count(const struct orb_metadata *meta)
|
||||
int orb_group_count(const struct orb_metadata *meta)
|
||||
{
|
||||
unsigned instance = 0;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user