diff --git a/CMakeLists.txt b/CMakeLists.txt index 64c73efa67..56aacd2bbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,10 +335,9 @@ foreach(module ${config_module_list}) endforeach() add_subdirectory(src/firmware/${OS}) -add_subdirectory(src/lib/DriverFramework) -if("${OS}" STREQUAL "nuttx") - add_dependencies(df_driver_framework nuttx_export_${BOARD}) +if (NOT "${OS}" STREQUAL "nuttx") + add_subdirectory(src/lib/DriverFramework) endif() if (config_io_board) diff --git a/cmake/nuttx/px4_impl_nuttx.cmake b/cmake/nuttx/px4_impl_nuttx.cmake index 14bd2ee3d6..47a3ea8c5b 100644 --- a/cmake/nuttx/px4_impl_nuttx.cmake +++ b/cmake/nuttx/px4_impl_nuttx.cmake @@ -423,6 +423,7 @@ function(px4_os_add_flags) ${nuttx_export_dir}/include/cxx ${nuttx_export_dir}/arch/chip ${nuttx_export_dir}/arch/common + src/lib/DriverFramework/framework/include ) set(added_link_dirs ${nuttx_export_dir}/libs @@ -490,6 +491,8 @@ function(px4_os_add_flags) #message(STATUS "nuttx: set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)") endforeach() + set(DF_TARGET "nuttx" PARENT_SCOPE) + endfunction() #============================================================================= diff --git a/cmake/qurt/px4_impl_qurt.cmake b/cmake/qurt/px4_impl_qurt.cmake index 87c71b1ecd..01025ce270 100644 --- a/cmake/qurt/px4_impl_qurt.cmake +++ b/cmake/qurt/px4_impl_qurt.cmake @@ -187,7 +187,7 @@ function(px4_os_add_flags) set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") - set(DF_TARGET "qurt") + set(DF_TARGET "qurt" PARENT_SCOPE) # output foreach(var ${inout_vars}) diff --git a/src/firmware/nuttx/CMakeLists.txt b/src/firmware/nuttx/CMakeLists.txt index be6f9b1062..992987f9de 100644 --- a/src/firmware/nuttx/CMakeLists.txt +++ b/src/firmware/nuttx/CMakeLists.txt @@ -13,7 +13,7 @@ add_executable(firmware_nuttx set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) set(link_libs - romfs apps nuttx m gcc + romfs apps nuttx m gcc df_driver_framework ) if(NOT ${BOARD} STREQUAL "sim") diff --git a/src/lib/DriverFramework b/src/lib/DriverFramework index 737d2cbf2c..a759ad3142 160000 --- a/src/lib/DriverFramework +++ b/src/lib/DriverFramework @@ -1 +1 @@ -Subproject commit 737d2cbf2c94210b964cf00d55903f1b9c52b2f6 +Subproject commit a759ad3142b3b30d4e3a3157ec684966f7dcc83c diff --git a/src/modules/commander/PreflightCheck.cpp b/src/modules/commander/PreflightCheck.cpp index c1cbfad910..d542707ba4 100644 --- a/src/modules/commander/PreflightCheck.cpp +++ b/src/modules/commander/PreflightCheck.cpp @@ -197,7 +197,7 @@ static bool accelerometerCheck(int mavlink_fd, unsigned instance, bool optional, if (dynamic) { /* check measurement result range */ struct accel_report acc; - ret = px4_read(fd, &acc, sizeof(acc)); + ret = h.read(&acc, sizeof(acc)); if (ret == sizeof(acc)) { /* evaluate values */ @@ -219,9 +219,7 @@ static bool accelerometerCheck(int mavlink_fd, unsigned instance, bool optional, #endif out: -#ifdef __PX4_NUTTX - px4_close(fd); -#endif + DevMgr::releaseHandle(h); return success; } diff --git a/src/platforms/posix/drivers/gpssim/gpssim.cpp b/src/platforms/posix/drivers/gpssim/gpssim.cpp index 20e929ce88..3241c6c30d 100644 --- a/src/platforms/posix/drivers/gpssim/gpssim.cpp +++ b/src/platforms/posix/drivers/gpssim/gpssim.cpp @@ -510,6 +510,7 @@ reset() { DevHandle h; DevMgr::getHandle(GPSSIM_DEVICE_PATH, h); + if (!h.isValid()) { PX4_ERR("failed "); } diff --git a/src/platforms/posix/drivers/ledsim/led.cpp b/src/platforms/posix/drivers/ledsim/led.cpp index f1d1021e65..161514cd93 100644 --- a/src/platforms/posix/drivers/ledsim/led.cpp +++ b/src/platforms/posix/drivers/ledsim/led.cpp @@ -90,6 +90,7 @@ LED::init() { DEVICE_DEBUG("LED::init"); int ret = VirtDevObj::init(); + if (ret == 0) { led_init(); } diff --git a/src/platforms/posix/drivers/rgbledsim/rgbled.cpp b/src/platforms/posix/drivers/rgbledsim/rgbled.cpp index bf839fbb52..27518f0116 100644 --- a/src/platforms/posix/drivers/rgbledsim/rgbled.cpp +++ b/src/platforms/posix/drivers/rgbledsim/rgbled.cpp @@ -588,7 +588,7 @@ RGBLEDSIM::send_led_rgb() int RGBLEDSIM::get(bool &on, bool &powersave, uint8_t &r, uint8_t &g, uint8_t &b) { - uint8_t result[2]; + uint8_t result[2] = {0, 0}; int ret; ret = transfer(nullptr, 0, &result[0], 2);