diff --git a/.gitmodules b/.gitmodules index cb9a6ccf05..2820e68539 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,8 +4,8 @@ [submodule "NuttX"] path = NuttX url = git://github.com/PX4/NuttX.git -[submodule "src/lib/uavcan"] - path = src/lib/uavcan +[submodule "src/modules/uavcan/libuavcan"] + path = src/modules/uavcan/libuavcan url = git://github.com/UAVCAN/libuavcan.git [submodule "Tools/genmsg"] path = Tools/genmsg diff --git a/CMakeLists.txt b/CMakeLists.txt index 948959ca32..6aec7f2e0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,7 +224,7 @@ px4_add_git_submodule(TARGET git_genmsg PATH "Tools/genmsg") px4_add_git_submodule(TARGET git_gencpp PATH "Tools/gencpp") px4_add_git_submodule(TARGET git_mavlink PATH "mavlink/include/mavlink/v1.0") px4_add_git_submodule(TARGET git_gtest PATH "unittets/gtest") -px4_add_git_submodule(TARGET git_uavcan PATH "src/lib/uavcan") +px4_add_git_submodule(TARGET git_uavcan PATH "src/modules/uavcan/libuavcan") px4_add_git_submodule(TARGET git_eigen PATH "src/lib/eigen") px4_add_git_submodule(TARGET git_nuttx PATH "NuttX") px4_add_git_submodule(TARGET git_dspal PATH "src/lib/dspal") diff --git a/Makefile b/Makefile index 2505c75711..a507be0826 100644 --- a/Makefile +++ b/Makefile @@ -177,9 +177,9 @@ distclean: clean @cd NuttX @git clean -d -f -x @cd .. - @cd src/lib/uavcan + @cd src/modules/uavcan/libuavcan @git clean -d -f -x - @cd ../../.. + @cd ../../../.. # targets handled by cmake cmake_targets = test upload package package_source debug debug_tui debug_ddd debug_io debug_io_tui debug_io_ddd check_weak libuavcan diff --git a/Tools/check_code_style.sh b/Tools/check_code_style.sh index db140fca45..bc59128317 100755 --- a/Tools/check_code_style.sh +++ b/Tools/check_code_style.sh @@ -25,7 +25,7 @@ for fn in $(find src/examples \ -path './NuttX' -prune -o \ -path './src/lib/eigen' -prune -o \ -path './src/lib/mathlib/CMSIS' -prune -o \ - -path './src/lib/uavcan' -prune -o \ + -path './src/modules/uavcan/libuavcan' -prune -o \ -path './src/modules/attitude_estimator_ekf/codegen' -prune -o \ -path './src/modules/ekf_att_pos_estimator' -prune -o \ -path './src/modules/sdlog2' -prune -o \ diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index fe07a67666..9a0b17b7a2 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -138,8 +138,7 @@ function(px4_add_git_submodule) string(REPLACE "/" "_" NAME ${PATH}) add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git_${NAME}.stamp WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND git submodule init ${PATH} - COMMAND git submodule update -f ${PATH} + COMMAND git submodule update --init --recursive -f ${PATH} COMMAND touch ${CMAKE_BINARY_DIR}/git_${NAME}.stamp ) add_custom_target(${TARGET} @@ -544,7 +543,6 @@ function(px4_add_common_flags) endif() set(c_warnings - -Wbad-function-cast -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs diff --git a/cmake/configs/nuttx_px4fmu-v2_default.cmake b/cmake/configs/nuttx_px4fmu-v2_default.cmake index 89910bbd95..a242f4f736 100644 --- a/cmake/configs/nuttx_px4fmu-v2_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v2_default.cmake @@ -168,8 +168,8 @@ set(config_io_board set(config_extra_libs ${CMAKE_SOURCE_DIR}/src/lib/mathlib/CMSIS/libarm_cortexM4lf_math.a - libuavcan.a - libuavcan_stm32_driver.a + uavcan + uavcan_stm32_driver ) set(config_io_extra_libs diff --git a/nuttx-configs/px4fmu-v2/nsh/defconfig b/nuttx-configs/px4fmu-v2/nsh/defconfig index db7c41dae0..871b214f49 100644 --- a/nuttx-configs/px4fmu-v2/nsh/defconfig +++ b/nuttx-configs/px4fmu-v2/nsh/defconfig @@ -1064,3 +1064,5 @@ CONFIG_SYSTEM_SYSINFO=y # # USB Monitor # + +CONFIG_NSOCKET_DESCRIPTORS=0 diff --git a/src/lib/uavcan b/src/lib/uavcan deleted file mode 160000 index 86c3397b1b..0000000000 --- a/src/lib/uavcan +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 86c3397b1b423eeed86f21c8b08c8acfbd5add96 diff --git a/src/modules/uavcan/CMakeLists.txt b/src/modules/uavcan/CMakeLists.txt index 476acc5dd4..3c7ad32998 100644 --- a/src/modules/uavcan/CMakeLists.txt +++ b/src/modules/uavcan/CMakeLists.txt @@ -31,65 +31,30 @@ # ############################################################################ -# uavcan project -set(uavcan_c_flags ${c_flags}) -list(REMOVE_ITEM uavcan_c_flags -std=gnu++0x -D__CUSTOM_FILE_IO__) -set(uavcan_cxx_flags ${cxx_flags}) -list(REMOVE_ITEM uavcan_cxx_flags -std=gnu++0x -std=c++11 -Wundef -Werror -D__CUSTOM_FILE_IO__) -set(uavcan_deps git_uavcan) -set(uavcan_platform generic) - -set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) +set(UAVCAN_USE_CPP03 ON CACHE BOOL "uavcan cpp03") +set(UAVCAN_PLATFORM stm32 CACHE STRING "uavcan platform") string(TOUPPER "${OS}" OS_UPPER) - -set(uavcan_definitions - -DUAVCAN_NO_ASSERTIONS - -DUAVCAN_STM32_NUM_IFACES=2 - -DUAVCAN_USE_EXTERNAL_SNPRINT - -DUAVCAN_MEM_POOL_BLOCK_SIZE=48 - -DUAVCAN_MAX_NETWORK_SIZE_HINT=16 - -DUAVCAN_STM32_TIMER_NUMBER=5 - -DUAVCAN_STM32_${OS_UPPER}=1 - -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 - ) -set(uavcan_extra_flags ${uavcan_definitions} -I${CMAKE_SOURCE_DIR}/src/include) - -if (${OS} STREQUAL "nuttx") - set(uavcan_platform stm32) - list(APPEND uavcan_extra_flags - -I${nuttx_export_dir}/include - -I${nuttx_export_dir}/include/cxx - -I${nuttx_export_dir}/arch/chip - -I${nuttx_export_dir}/arch/common - ) - list(APPEND uavcan_deps nuttx_export_${BOARD}) -endif() - -list(APPEND uavcan_c_flags ${uavcan_extra_flags}) -list(APPEND uavcan_cxx_flags ${uavcan_extra_flags}) - -px4_join(OUT uavcan_c_flags LIST "${uavcan_c_flags}" GLUE " ") -px4_join(OUT uavcan_cxx_flags LIST "${uavcan_cxx_flags}" GLUE " ") - -externalproject_add(libuavcan - DEPENDS ${uavcan_deps} - DOWNLOAD_COMMAND "" - UPDATE_COMMAND git submodule update --init - LOG_INSTALL 1 - SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/lib/uavcan - CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} +add_definitions( + -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 + -DUAVCAN_MAX_NETWORK_SIZE_HINT=16 + -DUAVCAN_MEM_POOL_BLOCK_SIZE=48 + -DUAVCAN_NO_ASSERTIONS + -DUAVCAN_PLATFORM=stm32 + -DUAVCAN_STM32_${OS_UPPER}=1 + -DUAVCAN_STM32_NUM_IFACES=2 + -DUAVCAN_STM32_TIMER_NUMBER=5 -DUAVCAN_USE_CPP03=ON - -DUAVCAN_PLATFORM=${uavcan_platform} - -DUAVCAN_OS=${OS} - -DCMAKE_CXX_FLAGS=${uavcan_cxx_flags} - -DCMAKE_C_FLAGS=${uavcan_c_flags} - -DCMAKE_INSTALL_PREFIX=${ep_base}/Install -) + -DUAVCAN_USE_EXTERNAL_SNPRINT + ) -string(TOUPPER ${OS} OS_UPPER) +add_subdirectory(libuavcan EXCLUDE_FROM_ALL) +add_dependencies(uavcan platforms__nuttx) -add_definitions(${uavcan_definitions}) +include_directories(libuavcan/libuavcan/include) +include_directories(libuavcan/libuavcan/include/dsdlc_generated) +include_directories(libuavcan/libuavcan_drivers/posix/include) +include_directories(libuavcan/libuavcan_drivers/stm32/driver/include) px4_add_module( MODULE modules__uavcan @@ -100,7 +65,6 @@ px4_add_module( -Wno-deprecated-declarations -O3 SRCS - # Main uavcan_main.cpp uavcan_servers.cpp @@ -117,7 +81,7 @@ px4_add_module( DEPENDS platforms__common - libuavcan + uavcan ) ## vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/uavcan/libuavcan b/src/modules/uavcan/libuavcan new file mode 160000 index 0000000000..0643879922 --- /dev/null +++ b/src/modules/uavcan/libuavcan @@ -0,0 +1 @@ +Subproject commit 0643879922239930cf7482777356f06891c26616