diff --git a/.gitignore b/.gitignore index 4aa1d72166..1a6e278539 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,9 @@ .~lock.* Archives/* Build/* +Testing/ build/* +build_*/ core cscope.out Firmware.sublime-workspace @@ -52,3 +54,4 @@ src/platforms/posix/px4_messages/ src/platforms/posix-arm/px4_messages/ src/platforms/qurt/px4_messages/ ROMFS/*/*/rc.autostart +rootfs/ 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/.travis.yml b/.travis.yml index 20b15d323d..5806f9d232 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,12 @@ language: cpp -# use travis-ci docker based infrastructure -sudo: false +matrix: + include: + - os: linux + sudo: false + - os: osx + osx_image: beta-xcode6.3 cache: directories: @@ -32,17 +36,34 @@ addons: - texinfo - zlib1g-dev +before_install: + - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then + pushd . + && cd ~ + && wget https://launchpadlibrarian.net/186124160/gcc-arm-none-eabi-4_8-2014q3-20140805-linux.tar.bz2 + && tar -jxf gcc-arm-none-eabi-4_8-2014q3-20140805-linux.tar.bz2 + && exportline="export PATH=$HOME/gcc-arm-none-eabi-4_8-2014q3/bin:\$PATH" + && if grep -Fxq "$exportline" ~/.profile; then echo nothing to do ; else echo $exportline >> ~/.profile; fi + && . ~/.profile + && popd + && mkdir -p ~/bin + && wget -O ~/bin/astyle https://github.com/PX4/astyle/releases/download/2.05.1/astyle-linux && chmod +x ~/bin/astyle + && astyle --version + && if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi + ; + elif [ "${TRAVIS_OS_NAME}" = "osx" ]; then + brew tap PX4/homebrew-px4 + && brew update + && brew install genromfs + && brew install kconfig-frontends + && brew install gcc-arm-none-eabi + && brew install astyle + && sudo easy_install pip + && sudo pip install pyserial empy + ; + fi + before_script: - - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi -# General toolchain dependencies - - pushd . - - cd ~ - - wget https://launchpadlibrarian.net/186124160/gcc-arm-none-eabi-4_8-2014q3-20140805-linux.tar.bz2 - - tar -jxf gcc-arm-none-eabi-4_8-2014q3-20140805-linux.tar.bz2 - - exportline="export PATH=$HOME/gcc-arm-none-eabi-4_8-2014q3/bin:\$PATH" - - if grep -Fxq "$exportline" ~/.profile; then echo nothing to do ; else echo $exportline >> ~/.profile; fi - - . ~/.profile - - popd # setup ccache - mkdir -p ~/bin - ln -s /usr/bin/ccache ~/bin/arm-none-eabi-g++ @@ -56,9 +77,6 @@ before_script: - ln -s /usr/bin/ccache ~/bin/g++-4.8 - ln -s /usr/bin/ccache ~/bin/gcc-4.8 - export PATH=~/bin:$PATH -# grab astyle 2.05.1 - - wget -O ~/bin/astyle https://github.com/PX4/astyle/releases/download/2.05.1/astyle-linux && chmod +x ~/bin/astyle - - astyle --version env: global: @@ -70,41 +88,54 @@ env: script: - make check_format - - ccache -z - arm-none-eabi-gcc --version - echo 'Building POSIX Firmware..' && echo -en 'travis_fold:start:script.1\\r' - - make posix -j4 - - ccache -s + - make posix_sitl_simple - echo -en 'travis_fold:end:script.1\\r' - echo 'Running Tests..' && echo -en 'travis_fold:start:script.2\\r' - - make tests - - cat src/modules/systemlib/mixer/mixer_multirotor.generated.h + - make posix_sitl_simple test + - cat build_posix_sitl_simple/src/modules/systemlib/mixer/mixer_multirotor.generated.h - echo -en 'travis_fold:end:script.2\\r' - - echo 'Building NuttX..' && echo -en 'travis_fold:start:script.3\\r' - - make archives - - ccache -s + - echo 'Building NuttX Firmware..' && echo -en 'travis_fold:start:script.3\\r' + - make px4fmu-v1_default + - make px4fmu-v2_default - echo -en 'travis_fold:end:script.3\\r' - - echo 'Building NuttX Firmware..' && echo -en 'travis_fold:start:script.4\\r' - - make -j4 - - make size - - ccache -s + - echo 'Running Tests..' && echo -en 'travis_fold:start:script.4\\r' + - make px4fmu-v2_default test - echo -en 'travis_fold:end:script.4\\r' - - zip Firmware.zip Images/*.px4 + #- make px4fmu-v2_default package + #- make posix -j4 + #- ccache -s + #- echo -en 'travis_fold:end:script.1\\r' + #- echo 'Running Tests..' && echo -en 'travis_fold:start:script.2\\r' + #- make tests + #- cat src/modules/systemlib/mixer/mixer_multirotor.generated.h + #- echo -en 'travis_fold:end:script.2\\r' + #- echo 'Building NuttX..' && echo -en 'travis_fold:start:script.3\\r' + #- make archives + #- ccache -s + #- echo -en 'travis_fold:end:script.3\\r' + #- echo 'Building NuttX Firmware..' && echo -en 'travis_fold:start:script.4\\r' + #- make -j4 + #- make size + #- ccache -s + #- echo -en 'travis_fold:end:script.4\\r' + #- zip Firmware.zip Images/*.px4 -after_script: - - git clone git://github.com/PX4/CI-Tools.git - - ./CI-Tools/s3cmd-configure -# upload newest build for this branch with s3 index - - ./CI-Tools/s3cmd-put Images/px4*.px4 CI-Tools/directory/index.html Firmware/$TRAVIS_BRANCH/ -# archive newest build by date with s3 index - - ./CI-Tools/s3cmd-put Firmware.zip archives/Firmware/$TRAVIS_BRANCH/$TRAVIS_BUILD_ID/ - - ./CI-Tools/s3cmd-put CI-Tools/directory/index.html archives/Firmware/$TRAVIS_BRANCH/ -# upload top level index.html and timestamp.html - - ./CI-Tools/s3cmd-put CI-Tools/index.html index.html - - ./CI-Tools/s3cmd-put CI-Tools/timestamp.html timestamp.html - - echo "" - - echo "Binaries have been posted to:" - - echo https://px4-travis.s3.amazonaws.com/archives/Firmware/$TRAVIS_BRANCH/$TRAVIS_BUILD_ID/Firmware.zip +#after_script: + #- git clone git://github.com/PX4/CI-Tools.git + #- ./CI-Tools/s3cmd-configure +## upload newest build for this branch with s3 index + #- ./CI-Tools/s3cmd-put Images/px4*.px4 CI-Tools/directory/index.html Firmware/$TRAVIS_BRANCH/ +## archive newest build by date with s3 index + #- ./CI-Tools/s3cmd-put Firmware.zip archives/Firmware/$TRAVIS_BRANCH/$TRAVIS_BUILD_ID/ + #- ./CI-Tools/s3cmd-put CI-Tools/directory/index.html archives/Firmware/$TRAVIS_BRANCH/ +## upload top level index.html and timestamp.html + #- ./CI-Tools/s3cmd-put CI-Tools/index.html index.html + #- ./CI-Tools/s3cmd-put CI-Tools/timestamp.html timestamp.html + #- echo "" + #- echo "Binaries have been posted to:" + #- echo https://px4-travis.s3.amazonaws.com/archives/Firmware/$TRAVIS_BRANCH/$TRAVIS_BUILD_ID/Firmware.zip deploy: provider: releases diff --git a/CMakeLists.txt b/CMakeLists.txt index bfd7b662b1..6aec7f2e0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,332 +1,328 @@ -cmake_minimum_required(VERSION 2.8.3) -project(px4) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -add_definitions(-D__PX4_ROS) -add_definitions(-D__EXPORT=) -add_definitions(-DMAVLINK_DIALECT=common) +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ -## Find catkin macros and libraries -## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) -## is used, also find other catkin packages -find_package(catkin REQUIRED COMPONENTS - roscpp - rospy - std_msgs - geometry_msgs - message_generation - cmake_modules - gazebo_msgs - sensor_msgs - mav_msgs - libmavconn - tf -) -find_package(Eigen REQUIRED) +#============================================================================= +# CMAKE CODING STANDARD FOR PX4 +# +# Structure +# --------------------------------------------------------------------------- +# +# * Common functions should be included in px_base.cmake. +# +# * OS/ board specific fucntions should be include in +# px_impl_${OS}.cmake or px4_impl_${OS}_${BOARD}.cmake. +# +# Formatting +# --------------------------------------------------------------------------- +# +# * Use hard indents to match the px4 source code. +# +# * All function and script arguments are upper case. +# +# * All local variables are lower case. +# +# * All cmake functions are lowercase. +# +# * For else, endif, endfunction, etc, never put the name of the statement +# +# Instead of the very confusing: +# if (${var} STREQUAL "1") <-- condition now becomes if name +# # do somthing +# elseif (${var} STREQUAL "2") <-- another condition +# # do somthing +# else (${var} STREQUAL "1") <-- tag is referring to name of if +# # do somthing +# endif (${var} STREQUAL "1") <-- tag is referring to name of if +# +# Do this: +# if (${var} STREQUAL "1") <-- condition now becomes if name +# # do somthing +# elseif (${var} STREQUAL "2") <-- another condition +# # do somthing +# else () <-- leave blank +# # do somthing +# endif () <-- leave blank +# +# Functions/Macros +# --------------------------------------------------------------------------- +# +# * Use px4_parse_function_args to parse functions and check for required +# arguments. Unless there is only one argument in the function and it is clear. +# +# * Never use macros. They allow overwriting global variables and this +# makes variable declarations hard to locate. +# +# * If a target from add_custom_* is set in a function, explicitly pass it +# as an output argument so that the target name is clear to the user. +# +# * Avoid use of global variables in functions. Functions in a nested +# scope may use global variables, but this makes it difficult to +# resuse functions. +# +# Included CMake Files +# --------------------------------------------------------------------------- +# +# * All variables in config files must have the prefix "config_". +# +# * Never set global variables in an included cmake file, +# you may only define functions. This excludes config and Toolchain files. +# This makes it clear to the user when variables are being set or targets +# are being created. +# +# * Setting a global variable in a CMakeLists.txt file is ok, because +# each CMakeLists.txt file has scope in the current directory and all +# subdirecties, so it is not truly global. +# +# * All toolchain files should be included in the cmake +# directory and named Toolchain-"name".cmake. +# +# Misc +# --------------------------------------------------------------------------- +# +# * If referencing a string variable, don't put it in quotes. +# Don't do "${OS}" STREQUAL "posix", +# instead type ${OS} STREQUAL "posix". This will throw an +# error when ${OS} is not defined instead of silently +# evaluating to false. +# +#============================================================================= -## System dependencies are found with CMake's conventions -# find_package(Boost REQUIRED COMPONENTS system) +cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +#============================================================================= +# parameters +# -## Uncomment this if the package has a setup.py. This macro ensures -## modules and global scripts declared therein get installed -## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html -# catkin_python_setup() +set(CMAKE_BUILD_TYPE "" CACHE STRING "build type") +set_property(CACHE CMAKE_BUILD_TYPE PROPERTY + STRINGS ";Debug;Release;RelWithDebInfo;MinSizeRel") +set(CONFIG "nuttx_px4fmu-v2_default" CACHE STRING "desired configuration") +file(GLOB_RECURSE configs RELATIVE cmake/configs "cmake/configs/*.cmake") +set_property(CACHE CONFIG PROPERTY STRINGS ${configs}) +set(THREADS "4" CACHE STRING + "number of threads to use for external build processes") +set(DEBUG_PORT "/dev/ttyACM0" CACHE STRING "debugging port") -################################################ -## Declare ROS messages, services and actions ## -################################################ +#============================================================================= +# configuration +# +# must come before project to set toolchain -## To declare and build messages, services or actions from within this -## package, follow these steps: -## * Let MSG_DEP_SET be the set of packages whose message types you use in -## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). -## * In the file package.xml: -## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET -## * If MSG_DEP_SET isn't empty the following dependencies might have been -## pulled in transitively but can be declared for certainty nonetheless: -## * add a build_depend tag for "message_generation" -## * add a run_depend tag for "message_runtime" -## * In this file (CMakeLists.txt): -## * add "message_generation" and every package in MSG_DEP_SET to -## find_package(catkin REQUIRED COMPONENTS ...) -## * add "message_runtime" and every package in MSG_DEP_SET to -## catkin_package(CATKIN_DEPENDS ...) -## * uncomment the add_*_files sections below as needed -## and list every .msg/.srv/.action file to be processed -## * uncomment the generate_messages entry below -## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) +string(REPLACE "_" ";" config_args ${CONFIG}) +list(GET config_args 0 OS) +list(GET config_args 1 BOARD) +list(GET config_args 2 LABEL) +set(target_name "${OS}-${BOARD}-${LABEL}") -## Generate messages in the 'msg' folder -add_message_files( - FILES - rc_channels.msg - vehicle_attitude.msg - vehicle_attitude_setpoint.msg - manual_control_setpoint.msg - actuator_controls.msg - actuator_controls_0.msg - actuator_controls_virtual_mc.msg - vehicle_rates_setpoint.msg - mc_virtual_rates_setpoint.msg - vehicle_attitude.msg - vehicle_control_mode.msg - actuator_armed.msg - parameter_update.msg - vehicle_status.msg - vehicle_local_position.msg - position_setpoint.msg - position_setpoint_triplet.msg - vehicle_local_position_setpoint.msg - vehicle_global_velocity_setpoint.msg - offboard_control_mode.msg - vehicle_force_setpoint.msg - distance_sensor.msg -) +message(STATUS "${target_name}") -## Generate services in the 'srv' folder -# add_service_files( -# FILES -# Service1.srv -# Service2.srv -# ) +# switch to ros CMake file if building ros +if (${OS} STREQUAL "ros") + include("cmake/ros-CMakeLists.txt") +else() # otherwise use the rest of this file -## Generate actions in the 'action' folder -# add_action_files( -# FILES -# Action1.action -# Action2.action -# ) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +set(config_module "configs/${CONFIG}") +include(${config_module}) -## Generate added messages and services with any dependencies listed here -generate_messages( - DEPENDENCIES - std_msgs - gazebo_msgs -) +# cmake modules +include(ExternalProject) -################################### -## catkin specific configuration ## -################################### -## The catkin_package macro generates cmake config files for your package -## Declare things to be passed to dependent projects -## INCLUDE_DIRS: uncomment this if you package contains header files -## LIBRARIES: libraries you create in this project that dependent projects also need -## CATKIN_DEPENDS: catkin_packages dependent projects also need -## DEPENDS: system dependencies of this project that dependent projects also need -catkin_package( - INCLUDE_DIRS src/include - LIBRARIES px4 - CATKIN_DEPENDS message_runtime roscpp rospy std_msgs libmavconn - DEPENDS system_lib -) +# require px4 module interface +set(px4_required_interface + px4_os_prebuild_targets + px4_os_add_flags + ) +foreach(cmd ${px4_required_interface}) + if(NOT COMMAND ${cmd}) + message(FATAL_ERROR "${config_module} must implement ${cmd}") + endif() +endforeach() +set(px4_required_config + config_module_list + ) +foreach(conf ${px4_required_config}) + if(NOT DEFINED ${conf}) + message(FATAL_ERROR "cmake/${config_module} must define ${conf}") + endif() +endforeach() -########### -## Build ## -########### - -## Specify additional locations of header files -## Your package locations should be listed before other locations -include_directories( - ${catkin_INCLUDE_DIRS} - src/platforms - src/platforms/ros/px4_messages - src/include - src/modules - src/ - src/lib - ${EIGEN_INCLUDE_DIRS} - integrationtests -) - -## generate multiplatform wrapper headers -## note that the message header files are generated as in any ROS project with generate_messages() -set(MULTIPLATFORM_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/platforms/ros/px4_messages) -set(MULTIPLATFORM_TEMPLATE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/msg/templates/px4/ros) -set(TOPICHEADER_TEMP_DIR ${CMAKE_BINARY_DIR}/topics_temporary) -set(MULTIPLATFORM_PREFIX px4_) -add_custom_target(multiplatform_message_headers ALL ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Tools/px_generate_uorb_topic_headers.py - -d ${CMAKE_CURRENT_SOURCE_DIR}/msg -o ${MULTIPLATFORM_HEADER_DIR} -e ${MULTIPLATFORM_TEMPLATE_DIR} - -t ${TOPICHEADER_TEMP_DIR} -p ${MULTIPLATFORM_PREFIX}) - -## Declare a cpp library -add_library(px4 - src/platforms/ros/px4_ros_impl.cpp - src/platforms/ros/perf_counter.cpp - src/platforms/ros/geo.cpp - src/lib/mathlib/math/Limits.cpp - src/modules/systemlib/circuit_breaker.cpp -) -add_dependencies(px4 ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) - -target_link_libraries(px4 - ${catkin_LIBRARIES} -) - -## Declare a test publisher -add_executable(publisher - src/examples/publisher/publisher_main.cpp - src/examples/publisher/publisher_example.cpp) -add_dependencies(publisher ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) -target_link_libraries(publisher - ${catkin_LIBRARIES} - px4 -) - -## Declare a test subscriber -add_executable(subscriber - src/examples/subscriber/subscriber_main.cpp - src/examples/subscriber/subscriber_example.cpp) -add_dependencies(subscriber ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) -target_link_libraries(subscriber - ${catkin_LIBRARIES} - px4 -) - -## MC Attitude Control -add_executable(mc_att_control - src/modules/mc_att_control_multiplatform/mc_att_control_main.cpp - src/modules/mc_att_control_multiplatform/mc_att_control.cpp - src/modules/mc_att_control_multiplatform/mc_att_control_base.cpp) -add_dependencies(mc_att_control ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(mc_att_control - ${catkin_LIBRARIES} - px4 -) - -## MC Position Control -add_executable(mc_pos_control - src/modules/mc_pos_control_multiplatform/mc_pos_control_main.cpp - src/modules/mc_pos_control_multiplatform/mc_pos_control.cpp) -add_dependencies(mc_pos_control ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(mc_pos_control - ${catkin_LIBRARIES} - px4 -) - -## Attitude Estimator dummy -add_executable(attitude_estimator - src/platforms/ros/nodes/attitude_estimator/attitude_estimator.cpp) -add_dependencies(attitude_estimator ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(attitude_estimator - ${catkin_LIBRARIES} - px4 -) - -## Position Estimator dummy -add_executable(position_estimator - src/platforms/ros/nodes/position_estimator/position_estimator.cpp) -add_dependencies(position_estimator ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(position_estimator - ${catkin_LIBRARIES} - px4 -) - -## Manual input -add_executable(manual_input - src/platforms/ros/nodes/manual_input/manual_input.cpp) -add_dependencies(manual_input ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(manual_input - ${catkin_LIBRARIES} - px4 -) - -## Multicopter Mixer dummy -add_executable(mc_mixer - src/platforms/ros/nodes/mc_mixer/mc_mixer.cpp) -add_dependencies(mc_mixer ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(mc_mixer - ${catkin_LIBRARIES} - px4 -) - -## Commander dummy -add_executable(commander - src/platforms/ros/nodes/commander/commander.cpp) -add_dependencies(commander ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(commander - ${catkin_LIBRARIES} - px4 -) - -## Mavlink dummy -add_executable(mavlink - src/platforms/ros/nodes/mavlink/mavlink.cpp) -add_dependencies(mavlink ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(mavlink - ${catkin_LIBRARIES} - px4 -) - -## Offboard Position Setpoint Demo -add_executable(demo_offboard_position_setpoints - src/platforms/ros/nodes/demo_offboard_position_setpoints/demo_offboard_position_setpoints.cpp) -add_dependencies(demo_offboard_position_setpoints ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(demo_offboard_position_setpoints - ${catkin_LIBRARIES} - px4 -) - -## Offboard Attitude Setpoint Demo -add_executable(demo_offboard_attitude_setpoints - src/platforms/ros/nodes/demo_offboard_attitude_setpoints/demo_offboard_attitude_setpoints.cpp) -add_dependencies(demo_offboard_attitude_setpoints ${PROJECT_NAME}_generate_messages_cpp_cpp) -target_link_libraries(demo_offboard_attitude_setpoints - ${catkin_LIBRARIES} - px4 -) - -############# -## Install ## -############# - -# all install targets should use catkin DESTINATION variables -# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html - -## Mark executable scripts (Python etc.) for installation -## in contrast to setup.py, you can choose the destination -# install(PROGRAMS -# scripts/my_python_script -# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} -# ) - -## Mark executables and/or libraries for installation -install(TARGETS ${PROJECT_NAME} - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} -) - -## Mark cpp header files for installation -# install(DIRECTORY include/${PROJECT_NAME}/ -# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} -# FILES_MATCHING PATTERN "*.h" -# PATTERN ".svn" EXCLUDE -# ) - -## Mark other files for installation (e.g. launch and bag files, etc.) -# install(FILES -# # myfile1 -# # myfile2 -# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} -# ) - -############# -## Testing ## -############# - -## Add gtest based cpp test target and link libraries -# catkin_add_gtest(${PROJECT_NAME}-test test/test_px4test.cpp) -# if(TARGET ${PROJECT_NAME}-test) -# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) -# endif() - -## Add folders to be run by python nosetests -# catkin_add_nosetests(test) - -if(CATKIN_ENABLE_TESTING) - find_package(rostest REQUIRED) - add_rostest(integrationtests/demo_tests/direct_tests.launch) - add_rostest(integrationtests/demo_tests/mavros_tests.launch) +#============================================================================= +# project definition +# +project(px4 CXX C ASM) +if (NOT ${CMAKE_VERSION} VERSION_LESS 3.0.0) + cmake_policy(SET CMP0045 NEW) # error on non-existent target in get prop + cmake_policy(SET CMP0046 NEW) # no non-existent targets as dependencies +endif() +if (NOT ${CMAKE_VERSION} VERSION_LESS 3.1.0) + cmake_policy(SET CMP0054 NEW) # don't dereference quoted variables endif() +set(version_major 1) +set(version_minor 0) +set(version_patch 1) +set(version "${version_major}.${version_minor}.${version_patch}") +set(package-contact "px4users@googlegroups.com") +#============================================================================= +# programs +# +find_package(PythonInterp REQUIRED) + +#============================================================================= +# cmake modules +# +enable_testing() + +#============================================================================= +# check required toolchain variables +# +set(required_variables + CMAKE_C_COMPILER_ID + ) +foreach(var ${required_variables}) + if (NOT ${var}) + message(FATAL_ERROR "Toolchain/config must define ${var}") + endif() +endforeach() + +#============================================================================= +# git +# +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/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") + +add_custom_target(submodule_clean + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND git submodule deinit -f . + COMMAND rm -rf .git/modules/* + ) + +#============================================================================= +# external libraries +# +px4_os_prebuild_targets(OUT prebuild_targets + BOARD ${BOARD} + THREADS ${THREADS}) + +#============================================================================= +# build flags +# +px4_os_add_flags( + BOARD ${BOARD} + C_FLAGS c_flags + CXX_FLAGS cxx_flags + EXE_LINKER_FLAGS exe_linker_flags + INCLUDE_DIRS include_dirs + LINK_DIRS link_dirs + DEFINITIONS definitions) + +px4_join(OUT CMAKE_EXE_LINKER_FLAGS LIST "${exe_linker_flags}" GLUE " ") +px4_join(OUT CMAKE_C_FLAGS LIST "${c_flags}" GLUE " ") +px4_join(OUT CMAKE_CXX_FLAGS LIST "${cxx_flags}" GLUE " ") + +include_directories(${include_dirs}) +link_directories(${link_dirs}) +add_definitions(${definitions}) + +#============================================================================= +# source code generation +# +file(GLOB_RECURSE msg_files msg/*.msg) +px4_generate_messages(TARGET msg_gen + MSG_FILES ${msg_files} + OS ${OS} + DEPENDS git_genmsg git_gencpp + ) +px4_generate_parameters_xml(OUT parameters.xml BOARD ${BOARD}) +px4_generate_airframes_xml(OUT airframes.xml BOARD ${BOARD}) +add_custom_target(xml_gen + DEPENDS git_eigen parameters.xml airframes.xml) + +#============================================================================= +# external projects +# + +set(ep_base ${CMAKE_BINARY_DIR}/external) +set_property(DIRECTORY PROPERTY EP_BASE ${ep_base}) + +# add external project install folders to build +link_directories(${ep_base}/Install/lib) +include_directories(${ep_base}/Install/include) +# add the directories so cmake won't warn +execute_process(COMMAND cmake -E make_directory ${ep_base}/Install/lib) +execute_process(COMMAND cmake -E make_directory ${ep_base}/Install/include) + +#============================================================================= +# subdirectories +# +set(module_libraries) +foreach(module ${config_module_list}) + add_subdirectory(src/${module}) + px4_mangle_name(${module} mangled_name) + list(APPEND module_libraries ${mangled_name}) + #message(STATUS "adding module: ${module}") +endforeach() + +add_subdirectory(src/firmware/${OS}) + +if (config_io_board) + add_subdirectory(src/modules/px4iofirmware) +endif() + +#============================================================================= +# generate git version +# +px4_create_git_hash_header(HEADER ${CMAKE_BINARY_DIR}/build_git_version.h) + +#============================================================================= +# packaging +# +# Important to having packaging at end of cmake file. +# +set(CPACK_PACKAGE_VERSION ${version}) +set(CPACK_PACKAGE_CONTACT ${package_contact}) +set(CPACK_GENERATOR "ZIP") +set(CPACK_SOURCE_GENERATOR "ZIP") +include(CPack) + +endif() # ros alternative endif + +# vim: set noet fenc=utf-8 ff=unix ft=cmake : diff --git a/Makefile b/Makefile index 3c47aad3e0..e2f1814f0c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ +############################################################################ # -# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -28,280 +29,170 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # +############################################################################ +# Enforce the presence of the GIT repository # -# Top-level Makefile for building PX4 firmware images. -# - -TARGETS := nuttx posix posix-arm qurt -EXPLICIT_TARGET := $(filter $(TARGETS),$(MAKECMDGOALS)) -ifneq ($(EXPLICIT_TARGET),) - export PX4_TARGET_OS=$(EXPLICIT_TARGET) - export GOALS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) +# We depend on our submodules, so we have to prevent attempts to +# compile without it being present. +ifeq ($(wildcard .git),) + $(error YOU HAVE TO USE GIT TO DOWNLOAD THIS REPOSITORY. ABORTING.) endif +# Help +# -------------------------------------------------------------------- +# Don't be afraid of this makefile, it is just passing +# arguments to cmake to allow us to keep the wiki pages etc. +# that describe how to build the px4 firmware +# the same even when using cmake instead of make. # -# Get path and tool configuration +# Example usage: # -export PX4_BASE := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))/ -include $(PX4_BASE)makefiles/setup.mk - +# make px4fmu-v2_default (builds) +# make px4fmu-v2_default upload (builds and uploads) +# make px4fmu-v2_default test (builds and tests) # -# Get a version string provided by git -# This assumes that git command is available and that -# the directory holding this file also contains .git directory -# -GIT_DESC := $(shell git log -1 --pretty=format:%H) -ifneq ($(words $(GIT_DESC)),1) - GIT_DESC := "unknown_git_version" -endif +# This tells cmake to build the nuttx px4fmu-v2 default config in the +# directory build_nuttx_px4fmu-v2_default and then call make +# in that directory with the target upload. -GIT_DESC_SHORT := $(shell echo $(GIT_DESC) | cut -c1-16) +# explicity set default build target +all: px4fmu-v2_default -# -# Canned firmware configurations that we (know how to) build. -# -KNOWN_CONFIGS := $(subst config_,,$(basename $(notdir $(wildcard $(PX4_MK_DIR)/$(PX4_TARGET_OS)/config_*.mk)))) -CONFIGS ?= $(KNOWN_CONFIGS) +# Parsing +# -------------------------------------------------------------------- +# assume 1st argument passed is the main target, the +# rest are arguments to pass to the makefile generated +# by cmake in the subdirectory +ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) +j ?= 4 -# -# Boards that we (know how to) build NuttX export kits for. -# -KNOWN_BOARDS := $(subst board_,,$(basename $(notdir $(wildcard $(PX4_MK_DIR)/$(PX4_TARGET_OS)/board_*.mk)))) -BOARDS ?= $(KNOWN_BOARDS) - -# -# Debugging -# -MQUIET = --no-print-directory -#MQUIET = --print-directory - -################################################################################ -# No user-serviceable parts below -################################################################################ - -# -# If the user has listed a config as a target, strip it out and override CONFIGS. -# -FIRMWARE_GOAL = firmware -EXPLICIT_CONFIGS := $(filter $(CONFIGS),$(MAKECMDGOALS)) -ifneq ($(EXPLICIT_CONFIGS),) -CONFIGS := $(EXPLICIT_CONFIGS) -.PHONY: $(EXPLICIT_CONFIGS) -$(EXPLICIT_CONFIGS): all - -# -# If the user has asked to upload, they must have also specified exactly one -# config. -# -ifneq ($(filter upload,$(MAKECMDGOALS)),) -ifneq ($(words $(EXPLICIT_CONFIGS)),1) -$(error In order to upload, exactly one board config must be specified) -endif -FIRMWARE_GOAL = upload -.PHONY: upload -upload: - @: -endif -endif - -ifeq ($(PX4_TARGET_OS),nuttx) -include $(PX4_BASE)makefiles/nuttx/firmware_nuttx.mk -endif -ifeq ($(PX4_TARGET_OS),posix) -include $(PX4_BASE)makefiles/posix/firmware_posix.mk -endif -ifeq ($(PX4_TARGET_OS),posix-arm) -include $(PX4_BASE)makefiles/posix/firmware_posix.mk -endif -ifeq ($(PX4_TARGET_OS),qurt) -include $(PX4_BASE)makefiles/qurt/firmware_qurt.mk -endif - -qurt_fixup: - makefiles/qurt/setup.sh $(PX4_BASE) - -restore: - cd src/lib/eigen && git checkout . - git submodule update - -# -# Versioning -# - -GIT_VER_FILE = $(PX4_VERSIONING_DIR).build_git_ver -GIT_HEADER_FILE = $(PX4_VERSIONING_DIR)build_git_version.h - -$(GIT_VER_FILE) : - $(Q) if [ ! -f $(GIT_VER_FILE) ]; then \ - $(MKDIR) -p $(PX4_VERSIONING_DIR); \ - $(ECHO) "" > $(GIT_VER_FILE); \ - fi - -.PHONY: checkgitversion -checkgitversion: $(GIT_VER_FILE) - $(Q) if [ "$(GIT_DESC)" != "$(shell cat $(GIT_VER_FILE))" ]; then \ - $(ECHO) "/* Auto Magically Generated file */" > $(GIT_HEADER_FILE); \ - $(ECHO) "/* Do not edit! */" >> $(GIT_HEADER_FILE); \ - $(ECHO) "#define PX4_GIT_VERSION_STR \"$(GIT_DESC)\"" >> $(GIT_HEADER_FILE); \ - $(ECHO) "#define PX4_GIT_VERSION_BINARY 0x$(GIT_DESC_SHORT)" >> $(GIT_HEADER_FILE); \ - $(ECHO) $(GIT_DESC) > $(GIT_VER_FILE); \ - fi -# -# Sizes -# - -.PHONY: size -size: - $(Q) for elfs in Build/*; do if [ -f $$elfs/firmware.elf ]; then $(SIZE) $$elfs/firmware.elf; fi done - - -# -# Submodule Checks -# - -.PHONY: checksubmodules -checksubmodules: - $(Q) ($(PX4_BASE)/Tools/check_submodules.sh $(PX4_TARGET_OS)) - -.PHONY: updatesubmodules -updatesubmodules: - $(Q) (git submodule init) - $(Q) (git submodule update) - -MSG_DIR = $(PX4_BASE)msg -UORB_TEMPLATE_DIR = $(PX4_BASE)msg/templates/uorb -MULTIPLATFORM_TEMPLATE_DIR = $(PX4_BASE)msg/templates/px4/uorb -TOPICS_DIR = $(PX4_BASE)src/modules/uORB/topics -MULTIPLATFORM_HEADER_DIR = $(PX4_BASE)src/platforms/$(PX4_TARGET_OS)/px4_messages -MULTIPLATFORM_PREFIX = px4_ -TOPICHEADER_TEMP_DIR = $(BUILD_DIR)topics_temporary -MULTI_TOPICHEADER_TEMP_DIR = $(BUILD_DIR)multi_topics_temporary -GENMSG_PYTHONPATH = $(PX4_BASE)Tools/genmsg/src -GENCPP_PYTHONPATH = $(PX4_BASE)Tools/gencpp/src - -.PHONY: generateuorbtopicheaders -generateuorbtopicheaders: checksubmodules - @$(ECHO) "Generating uORB topic headers" - $(Q) (PYTHONPATH=$(GENMSG_PYTHONPATH):$(GENCPP_PYTHONPATH):$(PYTHONPATH) $(PYTHON) \ - $(PX4_BASE)Tools/px_generate_uorb_topic_headers.py \ - -d $(MSG_DIR) -o $(TOPICS_DIR) -e $(UORB_TEMPLATE_DIR) -t $(TOPICHEADER_TEMP_DIR)) - @$(ECHO) "Generating multiplatform uORB topic wrapper headers" - $(Q) (PYTHONPATH=$(GENMSG_PYTHONPATH):$(GENCPP_PYTHONPATH):$(PYTHONPATH) $(PYTHON) \ - $(PX4_BASE)Tools/px_generate_uorb_topic_headers.py \ - -d $(MSG_DIR) -o $(MULTIPLATFORM_HEADER_DIR) -e $(MULTIPLATFORM_TEMPLATE_DIR) -t $(MULTI_TOPICHEADER_TEMP_DIR) -p $(MULTIPLATFORM_PREFIX)) - -# -# Testing targets -# -testbuild: - $(Q) (cd $(PX4_BASE) && $(MAKE) distclean && $(MAKE) archives && $(MAKE) -j8) - $(Q) (zip -r Firmware.zip $(PX4_BASE)/Images) - -nuttx posix posix-arm qurt: -ifeq ($(GOALS),) - $(MAKE) PX4_TARGET_OS=$@ $(GOALS) +# disable ninja by default for now because it hides upload progress +#NINJA_BUILD := $(shell ninja --version 2>/dev/null) +ifdef NINJA_BUILD + PX4_CMAKE_GENERATOR ?= "Ninja" + PX4_MAKE = ninja + PX4_MAKE_ARGS = else - export PX4_TARGET_OS=$@ + +ifdef SYSTEMROOT + # Windows + PX4_CMAKE_GENERATOR ?= "MSYS Makefiles" +else + PX4_CMAKE_GENERATOR ?= "Unix Makefiles" endif + PX4_MAKE = make + PX4_MAKE_ARGS = -j$(j) --no-print-directory +endif + +# Functions +# -------------------------------------------------------------------- +# describe how to build a cmake config +define cmake-build ++@if [ ! -e $(PWD)/build_$@/CMakeCache.txt ]; then git submodule update --init --recursive --force && mkdir -p $(PWD)/build_$@ && cd $(PWD)/build_$@ && cmake .. -G$(PX4_CMAKE_GENERATOR) -DCONFIG=$(1); fi ++$(PX4_MAKE) -C $(PWD)/build_$@ $(PX4_MAKE_ARGS) $(ARGS) +endef + +# create empty targets to avoid msgs for targets passed to cmake +define cmake-targ +$(1): + @# +.PHONY: $(1) +endef + +# ADD CONFIGS HERE +# -------------------------------------------------------------------- +# Do not put any spaces between function arguments. + +px4fmu-v1_default: + $(call cmake-build,nuttx_px4fmu-v1_default) + +px4fmu-v2_default: + $(call cmake-build,nuttx_px4fmu-v2_default) + +px4fmu-v2_simple: + $(call cmake-build,nuttx_px4fmu-v2_simple) + +nuttx_sim_simple: + $(call cmake-build,$@) + +posix_sitl_simple: + $(call cmake-build,$@) + +ros_sitl_simple: + $(call cmake-build,$@) + +qurt_eagle_travis: + $(call cmake-build,$@) + +posix: posix_sitl_simple + +ros: ros_sitl_simple + +run_sitl_quad: posix + Tools/sitl_run.sh posix-configs/SITL/init/rcS + +run_sitl_plane: posix + Tools/sitl_run.sh posix-configs/SITL/init/rc.fixed_wing + +run_sitl_ros: posix + Tools/sitl_run.sh posix-configs/SITL/init/rc_iris_ros + +lldb_sitl_quad: posix + Tools/sitl_run.sh posix-configs/SITL/init/rcS lldb + +lldb_sitl_plane: posix + Tools/sitl_run.sh posix-configs/SITL/init/rc.fixed_wing lldb + +lldb_sitl_ros: posix + Tools/sitl_run.sh posix-configs/SITL/init/rc_iris_ros lldb + +gdb_sitl_quad: posix + Tools/sitl_run.sh posix-configs/SITL/init/rcS gdb + +gdb_sitl_plane: posix + Tools/sitl_run.sh posix-configs/SITL/init/rc.fixed_wing lldb + +gdb_sitl_ros: posix + Tools/sitl_run.sh posix-configs/SITL/init/rc_iris_ros lldb sitl_quad: - $(Q) Tools/sitl_run.sh posix-configs/SITL/init/rcS -sitl_quad_gazebo: - $(Q) Tools/sitl_run.sh posix-configs/SITL/init/rc_iris_ros + @echo "Deprecated. Use 'run_sitl_quad' instead." + sitl_plane: - $(Q) Tools/sitl_run.sh posix-configs/SITL/init/rc.fixed_wing + @echo "Deprecated. Use 'run_sitl_plane' instead." -qurtrun: - $(MAKE) PX4_TARGET_OS=qurt sim +sitl_ros: + @echo "Deprecated. Use 'run_sitl_ros' instead." -# -# Unittest targets. Builds and runs the host-level -# unit tests. -.PHONY: tests -tests: generateuorbtopicheaders - $(Q) (mkdir -p $(PX4_BASE)/unittests/build && cd $(PX4_BASE)/unittests/build && cmake .. && $(MAKE) --no-print-directory unittests) - -.PHONY: check_format +# Other targets +# -------------------------------------------------------------------- check_format: - $(Q) (./Tools/check_code_style.sh) + @./Tools/check_code_style.sh -# -# Cleanup targets. 'clean' should remove all built products and force -# a complete re-compilation, 'distclean' should remove everything -# that's generated leaving only files that are in source control. -# -.PHONY: clean clean: - @echo > /dev/null - $(Q) $(RMDIR) $(BUILD_DIR)*.build - $(Q) $(RMDIR) $(PX4_VERSIONING_DIR) - $(Q) $(REMOVE) $(IMAGE_DIR)*.px4 - $(Q) $(RMDIR) $(TOPICHEADER_TEMP_DIR) - $(Q) $(RMDIR) $(MULTI_TOPICHEADER_TEMP_DIR) + @rm -rf build_*/ + @(cd NuttX && git clean -d -f -x) + @(cd src/modules/uavcan/libuavcan && git clean -d -f -x) -.PHONY: distclean -distclean: clean - @echo > /dev/null - $(Q) $(REMOVE) $(ARCHIVE_DIR)*.export - $(Q) $(MAKE) -C $(NUTTX_SRC) -r $(MQUIET) distclean - $(Q) (cd $(NUTTX_SRC)/configs && $(FIND) . -maxdepth 1 -type l -delete) +# 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 +$(foreach targ,$(cmake_targets),$(eval $(call cmake-targ,$(targ)))) +.PHONY: clean + +CONFIGS:=$(shell ls cmake/configs | sed -e "s~.*/~~" | sed -e "s~\..*~~") + +# Future: +#$(CONFIGS): +## @cd Build/$@ && cmake ../.. -DCONFIG=$@ +# @cd Build/$@ && make # -# Print some help text +#clean-all: +# @rm -rf Build/* # -.PHONY: help -help: - @$(ECHO) "" - @$(ECHO) " PX4 firmware builder" - @$(ECHO) " ====================" - @$(ECHO) "" - @$(ECHO) " Available targets:" - @$(ECHO) " ------------------" - @$(ECHO) "" -ifeq ($(PX4_TARGET_OS),nuttx) - @$(ECHO) " archives" - @$(ECHO) " Build the NuttX RTOS archives that are used by the firmware build." - @$(ECHO) "" -endif - @$(ECHO) " all" - @$(ECHO) " Build all firmware configs: $(CONFIGS)" - @$(ECHO) " A limited set of configs can be built with CONFIGS=" - @$(ECHO) "" - @for config in $(CONFIGS); do \ - $(ECHO) " $$config"; \ - $(ECHO) " Build just the $$config firmware configuration."; \ - $(ECHO) ""; \ - done - @$(ECHO) " clean" - @$(ECHO) " Remove all firmware build pieces." - @$(ECHO) "" -ifeq ($(PX4_TARGET_OS),nuttx) - @$(ECHO) " distclean" - @$(ECHO) " Remove all compilation products, including NuttX RTOS archives." - @$(ECHO) "" - @$(ECHO) " upload" - @$(ECHO) " When exactly one config is being built, add this target to upload the" - @$(ECHO) " firmware to the board when the build is complete. Not supported for" - @$(ECHO) " all configurations." - @$(ECHO) "" -endif - @$(ECHO) " testbuild" - @$(ECHO) " Perform a complete clean build of the entire tree." - @$(ECHO) "" - @$(ECHO) " Common options:" - @$(ECHO) " ---------------" - @$(ECHO) "" - @$(ECHO) " V=1" - @$(ECHO) " If V is set, more verbose output is printed during the build. This can" - @$(ECHO) " help when diagnosing issues with the build or toolchain." - @$(ECHO) "" -ifeq ($(PX4_TARGET_OS),nuttx) - @$(ECHO) " To see help for a specifix target use 'make help' where target is" - @$(ECHO) " one of: " - @$(ECHO) " nuttx" - @$(ECHO) " posix" - @$(ECHO) " qurt" - @$(ECHO) "" -endif - +#help: +# @echo +# @echo "Type 'make ' and hit the tab key twice to see a list of the available" +# @echo "build configurations." +# @echo diff --git a/NuttX b/NuttX index 8891d035df..3009fb230e 160000 --- a/NuttX +++ b/NuttX @@ -1 +1 @@ -Subproject commit 8891d035df45c8be570cfbd9419b438679faf7ee +Subproject commit 3009fb230ec8232c4c4fd7798fd70ea9632692ec diff --git a/README.md b/README.md index 1abab0df13..7cb07907ff 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This repository contains the PX4 Flight Core, with the main applications located * [Downloads](http://px4.io/firmware/downloads) * Releases * [Downloads](https://github.com/PX4/Firmware/releases) -* Mailing list: [Google Groups](http://groups.google.com/group/px4users) +* Forum / Mailing list: [Google Groups](http://groups.google.com/group/px4users) ### Users ### @@ -29,7 +29,7 @@ Contributing guide: * [PX4 Contribution Guide](http://px4.io/dev/contributing) Software in the Loop guide: -Use software in the loop [to get started with the codebase](https://github.com/PX4/Firmware/tree/master/posix-configs/SITL) +Use software in the loop [to get started with the codebase](https://pixhawk.org/dev/simulation/native_sitl). Developer guide: http://px4.io/dev/ @@ -38,8 +38,10 @@ Testing guide: http://px4.io/dev/unit_tests This repository contains code supporting these boards: + * [Snapdragon Flight](https://www.intrinsyc.com/qualcomm-snapdragon-flight/) * FMUv1.x - * FMUv2.x + * FMUv2.x (Pixhawk) + * FMUv3.x (Pixhawk 2) * AeroCore (v1 and v2) * STM32F4Discovery (basic support) [Tutorial](https://pixhawk.org/modules/stm32f4discovery) diff --git a/ROMFS/px4fmu_common/init.d/2101_fw_AERT b/ROMFS/px4fmu_common/init.d/2101_fw_AERT index 19a47cda8c..3631a1e36c 100644 --- a/ROMFS/px4fmu_common/init.d/2101_fw_AERT +++ b/ROMFS/px4fmu_common/init.d/2101_fw_AERT @@ -20,3 +20,7 @@ sh /etc/init.d/rc.fw_defaults set MIXER AERT + +# The ESC requires a specific pulse to arm. +set PWM_OUT 4 +set PWM_DISARMED p:PWM_DISARMED diff --git a/ROMFS/px4fmu_common/init.d/2104_fw_AETR b/ROMFS/px4fmu_common/init.d/2104_fw_AETR index 083eb42330..3113ede87a 100644 --- a/ROMFS/px4fmu_common/init.d/2104_fw_AETR +++ b/ROMFS/px4fmu_common/init.d/2104_fw_AETR @@ -20,3 +20,7 @@ sh /etc/init.d/rc.fw_defaults set MIXER AETR + +# The ESC requires a specific pulse to arm. +set PWM_OUT 3 +set PWM_DISARMED p:PWM_DISARMED diff --git a/ROMFS/px4fmu_common/init.d/rc.mc_apps b/ROMFS/px4fmu_common/init.d/rc.mc_apps index 914807889f..1dfe6c09bc 100644 --- a/ROMFS/px4fmu_common/init.d/rc.mc_apps +++ b/ROMFS/px4fmu_common/init.d/rc.mc_apps @@ -9,18 +9,7 @@ # filter by setting INAV_ENABLED = 0 if param compare INAV_ENABLED 1 then - # The system is defaulting to EKF_ATT_ENABLED = 1 - # and uses the older EKF filter. However users can - # enable the new quaternion based complimentary - # filter by setting EKF_ATT_ENABLED = 0. - # Note that on FMUv1, the EKF att estimator is not - # available and the Q estimator runs instead. - if param compare EKF_ATT_ENABLED 1 - then - attitude_estimator_ekf start - else - attitude_estimator_q start - fi + attitude_estimator_q start position_estimator_inav start else ekf_att_pos_estimator start diff --git a/ROMFS/px4fmu_common/init.d/rc.sensors b/ROMFS/px4fmu_common/init.d/rc.sensors index 517c77b872..08a044329f 100644 --- a/ROMFS/px4fmu_common/init.d/rc.sensors +++ b/ROMFS/px4fmu_common/init.d/rc.sensors @@ -112,4 +112,6 @@ fi # Wait 20 ms for sensors (because we need to wait for the HRT and work queue callbacks to fire) usleep 20000 -sensors start +if sensors start +then +fi diff --git a/ROMFS/px4fmu_common/init.d/rcS b/ROMFS/px4fmu_common/init.d/rcS index 8e7df42743..f14dd3015d 100644 --- a/ROMFS/px4fmu_common/init.d/rcS +++ b/ROMFS/px4fmu_common/init.d/rcS @@ -365,11 +365,6 @@ then then fi - # - # UAVCAN - # - sh /etc/init.d/rc.uavcan - # # Sensors System (start before Commander so Preflight checks are properly run) # @@ -576,6 +571,11 @@ then fi fi + # + # UAVCAN + # + sh /etc/init.d/rc.uavcan + # # Logging # 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/Tools/check_submodules.sh b/Tools/check_submodules.sh deleted file mode 100755 index 5fa0831438..0000000000 --- a/Tools/check_submodules.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/sh - -[ -n "$GIT_SUBMODULES_ARE_EVIL" ] && { - # GIT_SUBMODULES_ARE_EVIL is set, meaning user doesn't want submodules - echo "Skipping submodules. NUTTX_SRC is set to $NUTTX_SRC" - exit 0 -} - -if [ -d NuttX/nuttx ]; - then - STATUSRETVAL=$(git submodule summary | grep -A20 -i "NuttX" | grep "<") - if [ -z "$STATUSRETVAL" ]; then - echo "Checked NuttX submodule, correct version found" - else - echo "" - echo "" - echo "New commits required:" - echo "$(git submodule summary)" - echo "" - echo "" - echo " NuttX sub repo not at correct version. Try 'git submodule update'" - echo " or follow instructions on http://pixhawk.org/dev/git/submodules" - echo "" - echo " DO NOT FORGET TO RUN 'make distclean && make archives' AFTER EACH NUTTX UPDATE!" - exit 1 - fi -else - git submodule update --init --recursive -fi - - -if [ -d mavlink/include/mavlink/v1.0 ]; - then - STATUSRETVAL=$(git submodule summary | grep -A20 -i "mavlink/include/mavlink/v1.0" | grep "<") - if [ -z "$STATUSRETVAL" ]; then - echo "Checked mavlink submodule, correct version found" - else - echo "" - echo "" - echo "New commits required:" - echo "$(git submodule summary)" - echo "" - echo "" - echo "mavlink sub repo not at correct version. Try 'git submodule update'" - echo "or follow instructions on http://pixhawk.org/dev/git/submodules" - exit 1 - fi -else - git submodule update --init --recursive -fi - - -if [ -d uavcan ] -then - STATUSRETVAL=$(git submodule summary | grep -A20 -i uavcan | grep "<") - if [ -z "$STATUSRETVAL" ] - then - echo "Checked uavcan submodule, correct version found" - else - echo "" - echo "" - echo "New commits required:" - echo "$(git submodule summary)" - echo "" - echo "" - echo "uavcan sub repo not at correct version. Try 'git submodule update'" - echo "or follow instructions on http://pixhawk.org/dev/git/submodules" - exit 1 - fi -else - git submodule update --init --recursive -fi - -if [ -d src/lib/eigen ] -then - echo "ARG = $1" - if [ $1 = "qurt" ] - then - # QuRT needs to use Eigen 3.2 because the toolchain doews not support C++11 - STATUSRETVAL=$(true) - else - STATUSRETVAL=$(git submodule summary | grep -A20 -i eigen | grep "<") - if [ -z "$STATUSRETVAL" ] - then - echo "Checked Eigen submodule, correct version found" - else - echo "" - echo "" - echo "New commits required:" - echo "$(git submodule summary)" - echo "" - echo "" - echo "eigen sub repo not at correct version. Try 'git submodule update'" - echo "or follow instructions on http://pixhawk.org/dev/git/submodules" - exit 1 - fi - fi -else - git submodule update --init --recursive -fi - -if [ -d Tools/gencpp ] -then - STATUSRETVAL=$(git submodule summary | grep -A20 -i gencpp | grep "<") - if [ -z "$STATUSRETVAL" ] - then - echo "Checked gencpp submodule, correct version found" - else - echo "" - echo "" - echo "New commits required:" - echo "$(git submodule summary)" - echo "" - echo "" - echo "gencpp sub repo not at correct version. Try 'git submodule update'" - echo "or follow instructions on http://pixhawk.org/dev/git/submodules" - exit 1 - fi -else - git submodule update --init --recursive -fi - -if [ -d Tools/genmsg ] -then - STATUSRETVAL=$(git submodule summary | grep -A20 -i genmsg | grep "<") - if [ -z "$STATUSRETVAL" ] - then - echo "Checked genmsg submodule, correct version found" - else - echo "" - echo "" - echo "New commits required:" - echo "$(git submodule summary)" - echo "" - echo "" - echo "genmsg sub repo not at correct version. Try 'git submodule update'" - echo "or follow instructions on http://pixhawk.org/dev/git/submodules" - exit 1 - fi -else - git submodule update --init --recursive -fi - -exit 0 diff --git a/Tools/generate_listener.py b/Tools/generate_listener.py index 4e5b8ab088..1f240ddbf6 100755 --- a/Tools/generate_listener.py +++ b/Tools/generate_listener.py @@ -1,6 +1,7 @@ #!/usr/bin/python import glob +import os import sys # This script is run from Build/_default.build/$(PX4_BASE)/Firmware/src/systemcmds/topic_listener @@ -20,20 +21,42 @@ for index,m in enumerate(raw_messages): temp_list = [] f = open(m,'r') for line in f.readlines(): - if(line.split(' ')[0] == "float32"): + if ('float32[' in line.split(' ')[0]): + num_floats = int(line.split(" ")[0].split("[")[1].split("]")[0]) + temp_list.append(("float_array",line.split(' ')[1].split('\t')[0].split('\n')[0],num_floats)) + elif ('float64[' in line.split(' ')[0]): + num_floats = int(line.split(" ")[0].split("[")[1].split("]")[0]) + temp_list.append(("double_array",line.split(' ')[1].split('\t')[0].split('\n')[0],num_floats)) + elif ('uint64[' in line.split(' ')[0]): + num_floats = int(line.split(" ")[0].split("[")[1].split("]")[0]) + temp_list.append(("uint64_array",line.split(' ')[1].split('\t')[0].split('\n')[0],num_floats)) + elif(line.split(' ')[0] == "float32"): temp_list.append(("float",line.split(' ')[1].split('\t')[0].split('\n')[0])) - elif(line.split(' ')[0] == "uint64"): + elif(line.split(' ')[0] == "float64"): + temp_list.append(("double",line.split(' ')[1].split('\t')[0].split('\n')[0])) + elif(line.split(' ')[0] == "uint64") and len(line.split('=')) == 1: temp_list.append(("uint64",line.split(' ')[1].split('\t')[0].split('\n')[0])) - elif (line.split(' ')[0] == "bool"): + elif(line.split(' ')[0] == "uint32") and len(line.split('=')) == 1: + temp_list.append(("uint32",line.split(' ')[1].split('\t')[0].split('\n')[0])) + elif(line.split(' ')[0] == "uint16") and len(line.split('=')) == 1: + temp_list.append(("uint16",line.split(' ')[1].split('\t')[0].split('\n')[0])) + elif(line.split(' ')[0] == "int64") and len(line.split('=')) == 1: + temp_list.append(("int64",line.split(' ')[1].split('\t')[0].split('\n')[0])) + elif(line.split(' ')[0] == "int32") and len(line.split('=')) == 1: + temp_list.append(("int32",line.split(' ')[1].split('\t')[0].split('\n')[0])) + elif(line.split(' ')[0] == "int16") and len(line.split('=')) == 1: + temp_list.append(("int16",line.split(' ')[1].split('\t')[0].split('\n')[0])) + elif (line.split(' ')[0] == "bool") and len(line.split('=')) == 1: temp_list.append(("bool",line.split(' ')[1].split('\t')[0].split('\n')[0])) elif (line.split(' ')[0] == "uint8") and len(line.split('=')) == 1: temp_list.append(("uint8",line.split(' ')[1].split('\t')[0].split('\n')[0])) - elif ('float32[' in line.split(' ')[0]): - num_floats = int(line.split(" ")[0].split("[")[1].split("]")[0]) - temp_list.append(("float_array",line.split(' ')[1].split('\t')[0].split('\n')[0],num_floats)) + elif (line.split(' ')[0] == "int8") and len(line.split('=')) == 1: + temp_list.append(("int8",line.split(' ')[1].split('\t')[0].split('\n')[0])) f.close() - messages.append(m.split('/')[-1].split('.')[0]) + (m_head, m_tail) = os.path.split(m) + messages.append(m_tail.split('.')[0]) + #messages.append(m.split('/')[-1].split('.')[0]) message_elements.append(temp_list) num_messages = len(messages); @@ -74,24 +97,32 @@ print(""" ****************************************************************************/ /** - * @file topic_listener.cpp, autogenerated by Tools/generate_listener.py + * @file topic_listener.cpp + * + * Autogenerated by Tools/generate_listener.py * * Tool for listening to topics when running flight stack on linux. */ + #include #include #include -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include #define __STDC_FORMAT_MACROS #include + +#ifndef PRIu64 +#define PRIu64 "llu" +#endif + +#ifndef PRI64 +#define PRI64 "lld" +#endif + """) for m in messages: print("#include " % m) @@ -108,39 +139,60 @@ int listener_main(int argc, char *argv[]) { return 1; } """) -print("\tuint32_t num_msgs = (uint32_t)std::stoi(argv[2],NULL,10);") -print("\tif(strncmp(argv[1],\"%s\",50)== 0) {" % messages[0]) +print("\tunsigned num_msgs = atoi(argv[2]);") +print("\tif (strncmp(argv[1],\"%s\",50) == 0) {" % messages[0]) print("\t\tsub = orb_subscribe(ORB_ID(%s));" % messages[0]) print("\t\tID = ORB_ID(%s);" % messages[0]) print("\t\tstruct %s_s container;" % messages[0]) print("\t\tmemset(&container, 0, sizeof(container));") for index,m in enumerate(messages[1:]): - print("\t} else if(strncmp(argv[1],\"%s\",50) == 0) {" % m) + print("\t} else if (strncmp(argv[1],\"%s\",50) == 0) {" % m) print("\t\tsub = orb_subscribe(ORB_ID(%s));" % m) print("\t\tID = ORB_ID(%s);" % m) print("\t\tstruct %s_s container;" % m) print("\t\tmemset(&container, 0, sizeof(container));") print("\t\tbool updated;") - print("\t\tfor(uint32_t i = 0;i" << endl; + return 1; + } + usleep(atoi(argv[1])); + return 0; +} """) diff --git a/Tools/posix_lldbinit b/Tools/posix_lldbinit new file mode 100644 index 0000000000..a3e04d3a07 --- /dev/null +++ b/Tools/posix_lldbinit @@ -0,0 +1,3 @@ +run +pro hand -p true -s false -n false SIGCONT +continue diff --git a/Tools/px4airframes/rcout.py b/Tools/px4airframes/rcout.py index de5af0f305..48bb1774a9 100644 --- a/Tools/px4airframes/rcout.py +++ b/Tools/px4airframes/rcout.py @@ -1,5 +1,6 @@ from xml.sax.saxutils import escape import codecs +import os class RCOutput(): def __init__(self, groups, board): @@ -30,7 +31,7 @@ class RCOutput(): for group in groups: result += "# GROUP: %s\n\n" % group.GetName() for param in group.GetParams(): - path = param.GetPath().rsplit('/', 1)[1] + path = os.path.split(param.GetPath())[1] id_val = param.GetId() name = param.GetFieldValue("short_desc") long_desc = param.GetFieldValue("long_desc") diff --git a/Tools/px4airframes/srcparser.py b/Tools/px4airframes/srcparser.py index 699a2cdc3b..e1d522dcd8 100644 --- a/Tools/px4airframes/srcparser.py +++ b/Tools/px4airframes/srcparser.py @@ -1,5 +1,6 @@ import sys import re +import os class ParameterGroup(object): """ @@ -151,7 +152,7 @@ class SourceParser(object): Returns list of supported file extensions that can be parsed by this parser. The parser uses any extension. """ - return [""] + return ["", ".hil"] def Parse(self, path, contents): """ @@ -160,7 +161,7 @@ class SourceParser(object): """ airframe_id = None - airframe_id = path.rsplit('/',1)[1].split('_',1)[0] + airframe_id = os.path.split(path)[1].split('_',1)[0] # Skip if not numeric if (not self.IsNumber(airframe_id)): diff --git a/Tools/px4airframes/srcscanner.py b/Tools/px4airframes/srcscanner.py index cb31906a30..398c7ed067 100644 --- a/Tools/px4airframes/srcscanner.py +++ b/Tools/px4airframes/srcscanner.py @@ -16,9 +16,11 @@ class SourceScanner(object): extensions = tuple(parser.GetSupportedExtensions()) for dirname, dirnames, filenames in os.walk(srcdir): for filename in filenames: - path = os.path.join(dirname, filename) - if not self.ScanFile(path, parser): - return False + extension = os.path.splitext(filename)[1] + if extension in extensions: + path = os.path.join(dirname, filename) + if not self.ScanFile(path, parser): + return False return True def ScanFile(self, path, parser): diff --git a/Tools/px_generate_params.py b/Tools/px_generate_params.py new file mode 100755 index 0000000000..3df124f523 --- /dev/null +++ b/Tools/px_generate_params.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +import xml.etree.ElementTree as ET +import os + +if len(os.sys.argv) != 2: + print("Error in %s" % os.sys.argv[0]) + print("Usage: %s " % os.sys.argv[0]) + raise SystemExit + +fp_header = open("px4_parameters.h", "w") +fp_src = open("px4_parameters.c", "w") + +tree = ET.parse(os.sys.argv[1]) +root = tree.getroot() + +# Generate the header file content +header = """ +#include +#include + +// DO NOT EDIT +// This file is autogenerated from parameters.xml + +__BEGIN_DECLS + +struct px4_parameters_t { +""" +start_name = "" +end_name = "" + +for group in root: + if group.tag == "group": + header += """ + /***************************************************************** + * %s + ****************************************************************/""" % group.attrib["name"] + for param in group: + if not start_name: + start_name = param.attrib["name"] + end_name = param.attrib["name"] + header += """ + const struct param_info_s __param__%s;""" % param.attrib["name"] +header += """ + const unsigned int param_count; +}; + +extern const struct px4_parameters_t px4_parameters; +""" + +# Generate the C file content +src = """ +#include + +// DO NOT EDIT +// This file is autogenerated from paramaters.xml + +const +#ifndef __PX4_DARWIN +__attribute__((used, section("__param"))) +#endif +struct px4_parameters_t px4_parameters = { +""" +i=0 +for group in root: + if group.tag == "group": + src += """ + /***************************************************************** + * %s + ****************************************************************/""" % group.attrib["name"] + for param in group: + if not start_name: + start_name = param.attrib["name"] + end_name = param.attrib["name"] + val_str = "#error UNKNOWN PARAM TYPE, FIX px_generate_params.py" + if (param.attrib["type"] == "FLOAT"): + val_str = ".val.f = " + elif (param.attrib["type"] == "INT32"): + val_str = ".val.i = " + i+=1 + src += """ + { + "%s", + PARAM_TYPE_%s, + %s%s + }, +""" % (param.attrib["name"], param.attrib["type"], val_str, param.attrib["default"]) +src += """ + %d +}; + +//extern const struct px4_parameters_t px4_parameters; + +__END_DECLS + +""" % i + +fp_header.write(header) +fp_src.write(src) + diff --git a/Tools/px_generate_uorb_topic_headers.py b/Tools/px_generate_uorb_topic_headers.py index 449f208c25..7ed0b3af19 100755 --- a/Tools/px_generate_uorb_topic_headers.py +++ b/Tools/px_generate_uorb_topic_headers.py @@ -43,6 +43,11 @@ import shutil import filecmp import argparse +import sys +px4_tools_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(px4_tools_dir + "/genmsg/src") +sys.path.append(px4_tools_dir + "/gencpp/src") + try: import genmsg.template_tools except ImportError as e: @@ -79,7 +84,7 @@ def convert_file(filename, outputdir, templatedir, includepath): """ Converts a single .msg file to a uorb header """ - print("Generating headers from {0}".format(filename)) + #print("Generating headers from {0}".format(filename)) genmsg.template_tools.generate_from_file(filename, package, outputdir, @@ -136,7 +141,7 @@ def convert_dir(inputdir, outputdir, templatedir): return True -def copy_changed(inputdir, outputdir, prefix=''): +def copy_changed(inputdir, outputdir, prefix='', quiet=False): """ Copies files from inputdir to outputdir if they don't exist in ouputdir or if their content changed @@ -153,7 +158,8 @@ def copy_changed(inputdir, outputdir, prefix=''): fno = os.path.join(outputdir, prefix + f) if not os.path.isfile(fno): shutil.copy(fni, fno) - print("{0}: new header file".format(f)) + if not quiet: + print("{0}: new header file".format(f)) continue if os.path.getmtime(fni) > os.path.getmtime(fno): @@ -161,13 +167,15 @@ def copy_changed(inputdir, outputdir, prefix=''): # only copy if contents do not match if not filecmp.cmp(fni, fno): shutil.copy(fni, fno) - print("{0}: updated".format(f)) + if not quiet: + print("{0}: updated".format(f)) continue - #print("{0}: unchanged".format(f)) + if not quiet: + print("{0}: unchanged".format(f)) -def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix): +def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix, quiet=False): """ Converts all .msg files in inputdir to uORB header files Unchanged existing files are not overwritten. @@ -175,7 +183,7 @@ def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix): # Create new headers in temporary output directory convert_dir(inputdir, temporarydir, templatedir) # Copy changed headers from temporary dir to output dir - copy_changed(temporarydir, outputdir, prefix) + copy_changed(temporarydir, outputdir, prefix, quiet) if __name__ == "__main__": parser = argparse.ArgumentParser( @@ -193,6 +201,9 @@ if __name__ == "__main__": parser.add_argument('-p', dest='prefix', default='', help='string added as prefix to the output file ' ' name when converting directories') + parser.add_argument('-q', dest='quiet', default=False, action='store_true', + help='string added as prefix to the output file ' + ' name when converting directories') args = parser.parse_args() if args.file is not None: @@ -208,4 +219,5 @@ if __name__ == "__main__": args.outputdir, args.templatedir, args.temporarydir, - args.prefix) + args.prefix, + args.quiet) diff --git a/Tools/px_romfs_pruner.py b/Tools/px_romfs_pruner.py index aef1cc7a3b..85ff678b93 100644 --- a/Tools/px_romfs_pruner.py +++ b/Tools/px_romfs_pruner.py @@ -76,8 +76,8 @@ def main(): pruned_content += line # overwrite old scratch file - with open(file_path, "w") as f: - f.write(pruned_content) + with open(file_path, "wb") as f: + f.write(pruned_content.encode("ascii", errors='strict')) if __name__ == '__main__': diff --git a/Tools/sitl_run.sh b/Tools/sitl_run.sh index 3c65aa4eec..1a7741d6fd 100755 --- a/Tools/sitl_run.sh +++ b/Tools/sitl_run.sh @@ -1,5 +1,16 @@ #!/bin/bash - -mkdir -p Build/posix_sitl.build/rootfs/fs/microsd -mkdir -p Build/posix_sitl.build/rootfs/eeprom -cd Build/posix_sitl.build && ./mainapp ../../$1 +cp Tools/posix_lldbinit build_posix_sitl_simple/src/firmware/posix/.lldbinit +cp Tools/posix.gdbinit build_posix_sitl_simple/src/firmware/posix/.gdbinit +cd build_posix_sitl_simple/src/firmware/posix +mkdir -p rootfs/fs/microsd +mkdir -p rootfs/eeprom +touch rootfs/eeprom/parameters +if [ "$2" == "lldb" ] +then + lldb -- mainapp ../../../../$1 +elif [ "$2" == "gdb" ] +then + gdb --args mainapp ../../../../$1 +else + ./mainapp ../../../../$1 +fi diff --git a/Vagrantfile b/Vagrantfile index 25ba1ce35c..775abd461f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -73,12 +73,12 @@ Vagrant.configure(2) do |config| # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. - config.vm.provision "shell", inline: <<-SHELL + config.vm.provision "shell", privileged: false, inline: <<-SHELL # Ensure we start in the Firmware folder echo "cd /Firmware" >> ~/.bashrc # Install software sudo apt-get update - sudo apt-get install -y build-essential ccache cmake clang-3.5 lldb-3.5 g++-4.8 gcc-4.8 genromfs libc6-i386 libncurses5-dev python-argparse python-empy python-serial s3cmd texinfo zlib1g-dev git-core + sudo apt-get install -y build-essential ccache cmake clang-3.5 lldb-3.5 g++-4.8 gcc-4.8 genromfs libc6-i386 libncurses5-dev python-argparse python-empy python-serial s3cmd texinfo zlib1g-dev git-core zip gdb pushd . cd ~ wget -q https://launchpadlibrarian.net/186124160/gcc-arm-none-eabi-4_8-2014q3-20140805-linux.tar.bz2 diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake new file mode 100644 index 0000000000..5c9b8aefdf --- /dev/null +++ b/cmake/common/px4_base.cmake @@ -0,0 +1,870 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +#============================================================================= +# +# Defined functions in this file +# +# utility functions +# +# * px4_parse_function_args +# * px4_add_git_submodule +# * px4_prepend_string +# * px4_join +# * px4_add_module +# * px4_generate_messages +# * px4_add_upload +# * px4_add_common_flags +# + +include(CMakeParseArguments) + +#============================================================================= +# +# px4_parse_function_args +# +# This function simpliies usage of the cmake_parse_arguments module. +# It is inteded to be called by other functions. +# +# Usage: +# px4_parse_function_args( +# NAME +# [ OPTIONS ] +# [ ONE_VALUE ] +# [ MULTI_VALUE ] +# REQUIRED +# ARGN ) +# +# Input: +# NAME : the name of the calling function +# OPTIONS : boolean flags +# ONE_VALUE : single value variables +# MULTI_VALUE : multi value variables +# REQUIRED : required arguments +# ARGN : the function input arguments, typically ${ARGN} +# +# Output: +# The function arguments corresponding to the following are set: +# ${OPTIONS}, ${ONE_VALUE}, ${MULTI_VALUE} +# +# Example: +# function test() +# px4_parse_function_args( +# NAME TEST +# ONE_VALUE NAME +# MULTI_VALUE LIST +# REQUIRED NAME LIST +# ARGN ${ARGN}) +# message(STATUS "name: ${NAME}") +# message(STATUS "list: ${LIST}") +# endfunction() +# +# test(NAME "hello" LIST a b c) +# +# OUTPUT: +# name: hello +# list: a b c +# +function(px4_parse_function_args) + cmake_parse_arguments(IN "" "NAME" "OPTIONS;ONE_VALUE;MULTI_VALUE;REQUIRED;ARGN" "${ARGN}") + cmake_parse_arguments(OUT "${IN_OPTIONS}" "${IN_ONE_VALUE}" "${IN_MULTI_VALUE}" "${IN_ARGN}") + if (OUT_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "${IN_NAME}: unparsed ${OUT_UNPARSED_ARGUMENTS}") + endif() + foreach(arg ${IN_REQUIRED}) + if (NOT OUT_${arg}) + message(FATAL_ERROR "${IN_NAME} requires argument ${arg}\nARGN: ${IN_ARGN}") + endif() + endforeach() + foreach(arg ${IN_OPTIONS} ${IN_ONE_VALUE} ${IN_MULTI_VALUE}) + set(${arg} ${OUT_${arg}} PARENT_SCOPE) + endforeach() +endfunction() + +#============================================================================= +# +# px4_add_git_submodule +# +# This function add a git submodule target. +# +# Usage: +# px4_add_git_submodule(TARGET PATH ) +# +# Input: +# PATH : git submodule path +# +# Output: +# TARGET : git target +# +# Example: +# px4_add_git_submodule(TARGET git_nuttx PATH "NuttX") +# +function(px4_add_git_submodule) + px4_parse_function_args( + NAME px4_add_git_submodule + ONE_VALUE TARGET PATH + REQUIRED TARGET PATH + ARGN ${ARGN}) + string(REPLACE "/" "_" NAME ${PATH}) + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git_init_${NAME}.stamp + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND git submodule init ${PATH} + COMMAND touch ${CMAKE_BINARY_DIR}/git_init_${NAME}.stamp + DEPENDS ${CMAKE_SOURCE_DIR}/.gitmodules + ) + add_custom_target(${TARGET} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND git submodule update --recursive ${PATH} + DEPENDS ${CMAKE_BINARY_DIR}/git_init_${NAME}.stamp + ) +endfunction() + +#============================================================================= +# +# px4_prepend_string +# +# This function prepends a string to a list +# +# Usage: +# px4_prepend_string(OUT STR LIST ) +# +# Input: +# STR : string to prepend +# LIST : list to prepend to +# +# Output: +# ${OUT} : prepended list +# +# Example: +# px4_prepend_string(OUT test_str STR "path/to/" LIST src/file1.cpp src/file2.cpp) +# test_str would then be: +# path/to/src/file1.cpp +# path/to/src/file2.cpp +# +function(px4_prepend_string) + px4_parse_function_args( + NAME px4_prepend_string + ONE_VALUE OUT STR + MULTI_VALUE LIST + REQUIRED OUT STR LIST + ARGN ${ARGN}) + set(${OUT}) + foreach(file ${LIST}) + list(APPEND ${OUT} ${STR}${file}) + endforeach() + set(${OUT} ${${OUT}} PARENT_SCOPE) +endfunction() + +#============================================================================= +# +# px4_join +# +# This function joins a list with a given separator. If list is not +# passed, or is sent "", this will return the empty string. +# +# Usage: +# px4_join(OUT ${OUT} [ LIST ${LIST} ] GLUE ${GLUE}) +# +# Input: +# LIST : list to join +# GLUE : separator to use +# +# Output: +# OUT : joined list +# +# Example: +# px4_join(OUT test_join LIST a b c GLUE ";") +# test_join would then be: +# "a;b;c" +# +function(px4_join) + px4_parse_function_args( + NAME px4_join + ONE_VALUE OUT GLUE + MULTI_VALUE LIST + REQUIRED GLUE OUT + ARGN ${ARGN}) + string (REPLACE ";" "${GLUE}" _TMP_STR "${LIST}") + set(${OUT} ${_TMP_STR} PARENT_SCOPE) +endfunction() + +#============================================================================= +# +# px4_add_module +# +# This function builds a static library from a module description. +# +# Usage: +# px4_add_module(MODULE +# [ MAIN ] +# [ STACK ] +# [ COMPILE_FLAGS ] +# [ INCLUDES ] +# [ DEPENDS ] +# ) +# +# Input: +# MODULE : unique name of module +# MAIN : entry point, if not given, assumed to be library +# STACK : size of stack +# COMPILE_FLAGS : compile flags +# LINK_FLAGS : link flags +# SRCS : source files +# INCLUDES : include directories +# DEPENDS : targets which this module depends on +# +# Output: +# Static library with name matching MODULE. +# +# Example: +# px4_add_module(MODULE test +# SRCS +# file.cpp +# STACK 1024 +# DEPENDS +# git_nuttx +# ) +# +function(px4_add_module) + + px4_parse_function_args( + NAME px4_add_module + ONE_VALUE MODULE MAIN STACK PRIORITY + MULTI_VALUE COMPILE_FLAGS LINK_FLAGS SRCS INCLUDES DEPENDS + REQUIRED MODULE + ARGN ${ARGN}) + + add_library(${MODULE} STATIC EXCLUDE_FROM_ALL ${SRCS}) + + if(MAIN) + set_target_properties(${MODULE} PROPERTIES + COMPILE_DEFINITIONS PX4_MAIN=${MAIN}_app_main) + endif() + + if(INCLUDES) + target_include_directories(${MODULE} ${INCLUDES}) + endif() + + if(DEPENDS) + add_dependencies(${MODULE} ${DEPENDS}) + endif() + + # join list variables to get ready to send to compiler + foreach(prop LINK_FLAGS COMPILE_FLAGS) + if(${prop}) + px4_join(OUT ${prop} LIST ${${prop}} GLUE " ") + endif() + endforeach() + + # store module properties in target + # COMPILE_FLAGS and LINK_FLAGS are passed to compiler/linker by cmake + # STACK, MAIN, PRIORITY are PX4 specific + foreach (prop COMPILE_FLAGS LINK_FLAGS STACK MAIN PRIORITY) + if (${prop}) + set_target_properties(${MODULE} PROPERTIES ${prop} ${${prop}}) + endif() + endforeach() + +endfunction() + +#============================================================================= +# +# px4_generate_messages +# +# This function generates source code from ROS msg definitions. +# +# Usage: +# px4_generate_messages(TARGET MSGS ) +# +# Input: +# MSG_FILES : the ROS msgs to generate files from +# OS : the operating system selected +# DEPENDS : dependencies +# +# Output: +# TARGET : the message generation target +# +# Example: +# px4_generate_messages(TARGET +# MSG_FILES OS +# [ DEPENDS ] +# ) +# +function(px4_generate_messages) + px4_parse_function_args( + NAME px4_generate_messages + OPTIONS VERBOSE + ONE_VALUE OS TARGET + MULTI_VALUE MSG_FILES DEPENDS + REQUIRED MSG_FILES OS TARGET + ARGN ${ARGN}) + set(QUIET) + if(NOT VERBOSE) + set(QUIET "-q") + endif() + set(msg_out_path ${CMAKE_BINARY_DIR}/src/modules/uORB/topics) + set(msg_list) + foreach(msg_file ${MSG_FILES}) + get_filename_component(msg ${msg_file} NAME_WE) + list(APPEND msg_list ${msg}) + endforeach() + set(msg_files_out) + foreach(msg ${msg_list}) + list(APPEND msg_files_out ${msg_out_path}/${msg}.h) + endforeach() + add_custom_command(OUTPUT ${msg_files_out} + COMMAND ${PYTHON_EXECUTABLE} + Tools/px_generate_uorb_topic_headers.py + ${QUIET} + -d msg + -o ${msg_out_path} + -e msg/templates/uorb + -t ${CMAKE_BINARY_DIR}/topics_temporary + DEPENDS ${DEPENDS} ${MSG_FILES} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Generating uORB topic headers" + VERBATIM + ) + + # multi messages for target OS + set(msg_multi_out_path + ${CMAKE_BINARY_DIR}/src/platforms/${OS}/px4_messages) + set(msg_multi_files_out) + foreach(msg ${msg_list}) + list(APPEND msg_multi_files_out ${msg_multi_out_path}/px4_${msg}.h) + endforeach() + add_custom_command(OUTPUT ${msg_multi_files_out} + COMMAND ${PYTHON_EXECUTABLE} + Tools/px_generate_uorb_topic_headers.py + ${QUIET} + -d msg + -o ${msg_multi_out_path} + -e msg/templates/px4/uorb + -t ${CMAKE_BINARY_DIR}/multi_topics_temporary/${OS} + -p "px4_" + DEPENDS ${DEPENDS} ${MSG_FILES} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Generating uORB topic multi headers for ${OS}" + VERBATIM + ) + add_custom_target(${TARGET} + DEPENDS ${msg_multi_files_out} ${msg_files_out}) +endfunction() + +#============================================================================= +# +# px4_add_upload +# +# This function generates source code from ROS msg definitions. +# +# Usage: +# px4_add_upload(OUT BUNDLE ) +# +# Input: +# BUNDLE : the firmware.px4 file +# OS : the operating system +# BOARD : the board +# +# Output: +# OUT : the firmware target +# +# Example: +# px4_add_upload(OUT upload +# BUNDLE main.px4 +# ) +# +function(px4_add_upload) + px4_parse_function_args( + NAME px4_add_upload + ONE_VALUE OS BOARD OUT BUNDLE + REQUIRED OS BOARD OUT BUNDLE + ARGN ${ARGN}) + set(serial_ports) + if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") + list(APPEND serial_ports + /dev/serial/by-id/usb-3D_Robotics* + /dev/serial/by-id/pci-3D_Robotics* + ) + elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") + list(APPEND serial_ports + /dev/tty.usbmodemPX*,/dev/tty.usbmodem* + ) + elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") + foreach(port RANGE 32 0) + list(APPEND serial_ports + "COM${port}") + endforeach() + endif() + px4_join(OUT serial_ports LIST "${serial_ports}" GLUE ",") + add_custom_target(${OUT} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_SOURCE_DIR}/Tools/px_uploader.py --port ${serial_ports} ${BUNDLE} + DEPENDS ${BUNDLE} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "uploading ${BUNDLE}" + VERBATIM + ) +endfunction() + +#============================================================================= +# +# px4_add_common_flags +# +# Set ths default build flags. +# +# Usage: +# px4_add_common_flags( +# BOARD +# C_FLAGS +# CXX_FLAGS +# EXE_LINKER_FLAGS +# INCLUDE_DIRS +# LINK_DIRS +# DEFINITIONS ) +# +# Input: +# BOARD : board +# +# Input/Output: (appends to existing variable) +# C_FLAGS : c compile flags variable +# CXX_FLAGS : c++ compile flags variable +# EXE_LINKER_FLAGS : executable linker flags variable +# INCLUDE_DIRS : include directories +# LINK_DIRS : link directories +# DEFINITIONS : definitions +# +# Example: +# px4_add_common_flags( +# BOARD px4fmu-v2 +# C_FLAGS CMAKE_C_FLAGS +# CXX_FLAGS CMAKE_CXX_FLAGS +# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS +# INCLUDES ) +# +function(px4_add_common_flags) + + set(inout_vars + C_FLAGS CXX_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS) + + px4_parse_function_args( + NAME px4_add_common_flags + ONE_VALUE ${inout_vars} BOARD + REQUIRED ${inout_vars} BOARD + ARGN ${ARGN}) + + set(warnings + -Wall + -Werror + -Wno-sign-compare + -Wextra + #-Wshadow # very verbose due to eigen + -Wfloat-equal + -Wpointer-arith + -Wmissing-declarations + -Wno-unused-parameter + -Wno-varargs + -Werror=format-security + -Werror=array-bounds + -Wfatal-errors + -Werror=unused-variable + -Werror=reorder + -Werror=uninitialized + -Werror=init-self + #-Wcast-qual - generates spurious noreturn attribute warnings, + # try again later + #-Wconversion - would be nice, but too many "risky-but-safe" + # conversions in the code + #-Wcast-align - would help catch bad casts in some cases, + # but generates too many false positives + ) + + if (${OS} STREQUAL "nuttx") + list(APPEND warnings -Wframe-larger-than=1024) + endif() + + if (${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + # QuRT 6.4.X compiler identifies as Clang but does not support this option + if (NOT ${OS} STREQUAL "qurt") + list(APPEND warnings + -Wno-unused-const-variable + ) + endif() + else() + list(APPEND warnings + -Werror=unused-but-set-variable + -Wformat=1 + #-Wlogical-op # very verbose due to eigen + -Wdouble-promotion + -Werror=double-promotion + ) + endif() + + set(max_optimization -Os) + + set(optimization_flags + -fno-strict-aliasing + -fomit-frame-pointer + -funsafe-math-optimizations + -ffunction-sections + -fdata-sections + ) + + if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + list(APPEND optimization_flags + -fno-strength-reduce + -fno-builtin-printf + ) + endif() + + set(c_warnings + -Wbad-function-cast + -Wstrict-prototypes + -Wmissing-prototypes + -Wnested-externs + ) + + if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + list(APPEND c_warnings + -Wold-style-declaration + -Wmissing-parameter-type + ) + endif() + + set(c_compile_flags + -g + -std=gnu99 + -fno-common + ) + + set(cxx_warnings + -Wno-missing-field-initializers + ) + + set(cxx_compile_flags + -g + -fno-exceptions + -fno-rtti + -std=gnu++0x + -fno-threadsafe-statics + -DCONFIG_WCHAR_BUILTIN + -D__CUSTOM_FILE_IO__ + ) + + set(visibility_flags + -fvisibility=hidden + -include visibility.h + ) + + set(added_c_flags + ${c_compile_flags} + ${warnings} + ${c_warnings} + ${max_optimization} + ${optimization_flags} + ${visibility_flags} + ) + + set(added_cxx_flags + ${cxx_compile_flags} + ${warnings} + ${cxx_warnings} + ${max_optimization} + ${optimization_flags} + ${visibility_flags} + ) + + set(added_include_dirs + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src + ${CMAKE_SOURCE_DIR}/src/modules + ${CMAKE_SOURCE_DIR}/src/include + ${CMAKE_SOURCE_DIR}/src/lib + ${CMAKE_SOURCE_DIR}/src/platforms + # TODO Build/versioning was in Makefile, + # do we need this, how does it work with cmake + ${CMAKE_SOURCE_DIR}/src/drivers/boards/${BOARD} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src/modules/px4_messages + ${CMAKE_BINARY_DIR}/src/modules + ${CMAKE_SOURCE_DIR}/mavlink/include/mavlink + ) + + list(APPEND added_include_dirs + src/lib/eigen + ) + + set(added_link_dirs) # none used currently + + string(TOUPPER ${BOARD} board_upper) + string(REPLACE "-" "_" board_config ${board_upper}) + set(added_definitions + -DCONFIG_ARCH_BOARD_${board_config} + ) + + if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + set(added_exe_link_flags + -Wl,--warn-common + -Wl,--gc-sections + ) + else() + set(added_exe_link_flags + -Wl,--warn-common + ) + endif() + + # output + foreach(var ${inout_vars}) + string(TOLOWER ${var} lower_var) + set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE) + #message(STATUS "set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)") + endforeach() + +endfunction() + +#============================================================================= +# +# px4_mangle_name +# +# Convert a path name to a module name +# +# Usage: +# px4_mangle_name(dirname newname) +# +# Input: +# dirname : path to module dir +# +# Output: +# newname : module name +# +# Example: +# px4_mangle_name(${dirpath} mangled_name) +# message(STATUS "module name is ${mangled_name}") +# +function(px4_mangle_name dirname newname) + set(tmp) + string(REPLACE "/" "__" tmp ${dirname}) + set(${newname} ${tmp} PARENT_SCOPE) +endfunction() + +#============================================================================= +# +# px4_create_git_hash_header +# +# Create a header file containing the git hash of the current tree +# +# Usage: +# px4_create_git_hash_header(HEADER ${CMAKE_BUILD_DIR}/git_hash.h) +# +# Input: +# HEADER : path of the header file to generate +# +# Example: +# px4_create_git_hash_header(HEADER ${CMAKE_BUILD_DIR}/git_hash.h) +# +function(px4_create_git_hash_header) + px4_parse_function_args( + NAME px4_create_git_hash_header + ONE_VALUE HEADER + REQUIRED HEADER + ARGN ${ARGN}) + execute_process( + COMMAND git log -n 1 --pretty=format:"%H" + OUTPUT_VARIABLE git_desc + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + message(STATUS "GIT_DESC = ${git_desc}") + set(git_desc_short) + string(SUBSTRING ${git_desc} 1 16 git_desc_short) + configure_file(${CMAKE_SOURCE_DIR}/cmake/templates/build_git_version.h.in ${HEADER} @ONLY) +endfunction() + +#============================================================================= +# +# px4_generate_parameters_xml +# +# Generates a parameters.xml file. +# +# Usage: +# px4_generate_parameters_xml(OUT ) +# +# Input: +# BOARD : the board +# +# Output: +# OUT : the generated xml file +# +# Example: +# px4_generate_parameters_xml(OUT parameters.xml) +# +function(px4_generate_parameters_xml) + px4_parse_function_args( + NAME px4_generate_parameters_xml + ONE_VALUE OUT BOARD + REQUIRED OUT BOARD + ARGN ${ARGN}) + set(path ${CMAKE_SOURCE_DIR}/src) + file(GLOB_RECURSE param_src_files + ${CMAKE_SOURCE_DIR}/src/*params.c + ) + add_custom_command(OUTPUT ${OUT} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/px_process_params.py + -s ${path} --board CONFIG_ARCH_${BOARD} --xml + DEPENDS ${param_src_files} + ) + set(${OUT} ${${OUT}} PARENT_SCOPE) +endfunction() + +#============================================================================= +# +# px4_generate_parameters_source +# +# Generates a source file with all parameters. +# +# Usage: +# px4_generate_parameters_source(OUT XML ) +# +# Input: +# XML : the parameters.xml file +# DEPS : target dependencies +# +# Output: +# OUT : the generated source files +# +# Example: +# px4_generate_parameters_source(OUT param_files XML parameters.xml) +# +function(px4_generate_parameters_source) + px4_parse_function_args( + NAME px4_generate_parameters_source + ONE_VALUE OUT XML DEPS + REQUIRED OUT XML + ARGN ${ARGN}) + set(generated_files + ${CMAKE_CURRENT_BINARY_DIR}/px4_parameters.h + ${CMAKE_CURRENT_BINARY_DIR}/px4_parameters.c) + set_source_files_properties(${generated_files} + PROPERTIES GENERATED TRUE) + add_custom_command(OUTPUT ${generated_files} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/px_generate_params.py ${XML} + DEPENDS ${XML} ${DEPS} + ) + set(${OUT} ${generated_files} PARENT_SCOPE) +endfunction() + +#============================================================================= +# +# px4_generate_airframes_xml +# +# Generates airframes.xml +# +# Usage: +# px4_generate_airframes_xml(OUT ) +# +# Input: +# XML : the airframes.xml file +# BOARD : the board +# +# Output: +# OUT : the generated source files +# +# Example: +# px4_generate_airframes_xml(OUT airframes.xml) +# +function(px4_generate_airframes_xml) + px4_parse_function_args( + NAME px4_generate_airframes_xml + ONE_VALUE OUT BOARD + REQUIRED OUT BOARD + ARGN ${ARGN}) + set(process_airframes ${CMAKE_SOURCE_DIR}/Tools/px_process_airframes.py) + add_custom_command(OUTPUT ${OUT} + COMMAND ${PYTHON_EXECUTABLE} ${process_airframes} + -a ${CMAKE_SOURCE_DIR}/ROMFS/px4fmu_common/init.d + --board CONFIG_ARCH_BOARD_${BOARD} --xml + ) + set(${OUT} ${${OUT}} PARENT_SCOPE) +endfunction() + +#============================================================================= +# +# px4_copy_tracked +# +# Copy files to a directory and keep track of dependencies. +# +# Usage: +# px4_copy_tracked(OUT FILES DIR ) +# +# Input: +# FILES : the source files +# DEST : the directory to copy files to +# RELATIVE : relative directory for source files +# +# Output: +# OUT : the copied files +# +# Example: +# px4_copy_tracked(OUT copied_files FILES src_files DEST path RELATIVE path_rel) +# +function(px4_copy_tracked) + px4_parse_function_args( + NAME px4_copy_tracked + ONE_VALUE DEST OUT RELATIVE + MULTI_VALUE FILES + REQUIRED DEST OUT FILES + ARGN ${ARGN}) + set(files) + # before build, make sure dest directory exists + execute_process( + COMMAND cmake -E make_directory ${DEST}) + # create rule to copy each file and set dependency as source file + set(_files_out) + foreach(_file ${FILES}) + if (RELATIVE) + file(RELATIVE_PATH _file_path ${RELATIVE} ${_file}) + else() + set(_file_path ${_file}) + endif() + set(_dest_file ${DEST}/${_file_path}) + #message(STATUS "copy ${_file} -> ${_dest_file}") + add_custom_command(OUTPUT ${_dest_file} + COMMAND cmake -E copy ${_file} ${_dest_file} + DEPENDS ${_file}) + list(APPEND _files_out ${_dest_file}) + endforeach() + set(${OUT} ${_files_out} PARENT_SCOPE) +endfunction() + + +# vim: set noet fenc=utf-8 ff=unix nowrap: diff --git a/cmake/configs/nuttx_px4fmu-v1_default.cmake b/cmake/configs/nuttx_px4fmu-v1_default.cmake new file mode 100644 index 0000000000..ed48bd4f34 --- /dev/null +++ b/cmake/configs/nuttx_px4fmu-v1_default.cmake @@ -0,0 +1,177 @@ +include(nuttx/px4_impl_nuttx) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) + +set(config_module_list + # + # Board support modules + # + drivers/device + drivers/stm32 + drivers/stm32/adc + drivers/stm32/tone_alarm + drivers/led + drivers/px4fmu + drivers/px4io + drivers/boards/px4fmu-v1 + drivers/ardrone_interface + drivers/rgbled + drivers/mpu6000 + drivers/lsm303d + drivers/l3gd20 + drivers/hmc5883 + drivers/ms5611 + drivers/mb12xx + drivers/sf0x + drivers/ll40ls + drivers/trone + drivers/gps + drivers/pwm_out_sim + drivers/hott + drivers/hott/hott_telemetry + drivers/hott/hott_sensors + drivers/blinkm + drivers/airspeed + drivers/ets_airspeed + drivers/meas_airspeed + drivers/frsky_telemetry + modules/sensors + drivers/mkblctrl + drivers/px4flow + + # + # System commands + # + systemcmds/bl_update + systemcmds/mixer + systemcmds/param + systemcmds/perf + systemcmds/pwm + systemcmds/esc_calib + systemcmds/reboot + systemcmds/top + systemcmds/config + systemcmds/nshterm + systemcmds/mtd + systemcmds/dumpfile + systemcmds/ver + + # + # General system control + # + modules/commander + modules/navigator + modules/mavlink + modules/gpio_led + modules/land_detector + + # + # Estimation modules (EKF/ SO3 / other filters) + # + # Too high RAM usage due to static allocations + # modules/attitude_estimator_ekf + modules/attitude_estimator_q + modules/ekf_att_pos_estimator + modules/position_estimator_inav + + # + # Vehicle Control + # + # modules/segway # XXX Needs GCC 4.7 fix + modules/fw_pos_control_l1 + modules/fw_att_control + modules/mc_att_control + modules/mc_pos_control + modules/vtol_att_control + + # + # Logging + # + modules/sdlog2 + + # + # Library modules + # + modules/param + modules/systemlib + modules/systemlib/mixer + modules/controllib + modules/uORB + modules/dataman + + # + # Libraries + # + #lib/mathlib/CMSIS + lib/mathlib + lib/mathlib/math/filter + lib/ecl + lib/external_lgpl + lib/geo + lib/geo_lookup + lib/conversion + lib/launchdetection + platforms/nuttx + + # had to add for cmake, not sure why wasn't in original config + platforms/common + platforms/nuttx/px4_layer + + # + # OBC challenge + # + modules/bottle_drop + + # + # Rover apps + # + examples/rover_steering_control + + # + # Demo apps + # + #examples/math_demo + # Tutorial code from + # https://px4.io/dev/px4_simple_app + #examples/px4_simple_app + + # Tutorial code from + # https://px4.io/dev/daemon + #examples/px4_daemon_app + + # Tutorial code from + # https://px4.io/dev/debug_values + #examples/px4_mavlink_debug + + # Tutorial code from + # https://px4.io/dev/example_fixedwing_control + #examples/fixedwing_control + + # Hardware test + #examples/hwtest +) + +set(config_extra_builtin_cmds + serdis + sercon + ) + +set(config_io_board + px4io-v1 + ) + +set(config_extra_libs + ${CMAKE_SOURCE_DIR}/src/lib/mathlib/CMSIS/libarm_cortexM4lf_math.a + ) + +set(config_io_extra_libs + #${CMAKE_SOURCE_DIR}/src/lib/mathlib/CMSIS/libarm_cortexM3l_math.a + ) + +add_custom_target(sercon) +set_target_properties(sercon PROPERTIES + MAIN "sercon" STACK "2048") + +add_custom_target(serdis) +set_target_properties(serdis PROPERTIES + MAIN "serdis" STACK "2048") diff --git a/cmake/configs/nuttx_px4fmu-v2_default.cmake b/cmake/configs/nuttx_px4fmu-v2_default.cmake new file mode 100644 index 0000000000..a242f4f736 --- /dev/null +++ b/cmake/configs/nuttx_px4fmu-v2_default.cmake @@ -0,0 +1,185 @@ +include(nuttx/px4_impl_nuttx) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) + +set(config_module_list + # + # Board support modules + # + drivers/device + drivers/stm32 + drivers/stm32/adc + drivers/stm32/tone_alarm + drivers/led + drivers/px4fmu + drivers/px4io + drivers/boards/px4fmu-v2 + drivers/rgbled + drivers/mpu6000 + drivers/mpu9250 + drivers/lsm303d + drivers/l3gd20 + drivers/hmc5883 + drivers/ms5611 + drivers/mb12xx + drivers/sf0x + drivers/ll40ls + drivers/trone + drivers/gps + drivers/pwm_out_sim + drivers/hott + drivers/hott/hott_telemetry + drivers/hott/hott_sensors + drivers/blinkm + drivers/airspeed + drivers/ets_airspeed + drivers/meas_airspeed + drivers/frsky_telemetry + modules/sensors + drivers/mkblctrl + drivers/px4flow + drivers/oreoled + drivers/gimbal + drivers/pwm_input + drivers/camera_trigger + + # + # System commands + # + systemcmds/bl_update + systemcmds/mixer + systemcmds/param + systemcmds/perf + systemcmds/pwm + systemcmds/esc_calib + systemcmds/reboot + systemcmds/topic_listener + systemcmds/top + systemcmds/config + systemcmds/nshterm + systemcmds/mtd + systemcmds/dumpfile + systemcmds/ver + + # + # General system control + # + modules/commander + modules/navigator + modules/mavlink + modules/gpio_led + modules/uavcan + modules/land_detector + + # + # Estimation modules (EKF/ SO3 / other filters) + # + # Too high RAM usage due to static allocations + # modules/attitude_estimator_ekf + modules/attitude_estimator_q + modules/ekf_att_pos_estimator + modules/position_estimator_inav + + # + # Vehicle Control + # + # modules/segway # XXX Needs GCC 4.7 fix + modules/fw_pos_control_l1 + modules/fw_att_control + modules/mc_att_control + modules/mc_pos_control + modules/vtol_att_control + + # + # Logging + # + modules/sdlog2 + + # + # Library modules + # + modules/param + modules/systemlib + modules/systemlib/mixer + modules/controllib + modules/uORB + modules/dataman + + # + # Libraries + # + #lib/mathlib/CMSIS + lib/mathlib + lib/mathlib/math/filter + lib/ecl + lib/external_lgpl + lib/geo + lib/geo_lookup + lib/conversion + lib/launchdetection + platforms/nuttx + + # had to add for cmake, not sure why wasn't in original config + platforms/common + platforms/nuttx/px4_layer + + # + # OBC challenge + # + modules/bottle_drop + + # + # Rover apps + # + examples/rover_steering_control + + # + # Demo apps + # + #examples/math_demo + # Tutorial code from + # https://px4.io/dev/px4_simple_app + #examples/px4_simple_app + + # Tutorial code from + # https://px4.io/dev/daemon + #examples/px4_daemon_app + + # Tutorial code from + # https://px4.io/dev/debug_values + #examples/px4_mavlink_debug + + # Tutorial code from + # https://px4.io/dev/example_fixedwing_control + #examples/fixedwing_control + + # Hardware test + #examples/hwtest +) + +set(config_extra_builtin_cmds + serdis + sercon + ) + +set(config_io_board + px4io-v2 + ) + +set(config_extra_libs + ${CMAKE_SOURCE_DIR}/src/lib/mathlib/CMSIS/libarm_cortexM4lf_math.a + uavcan + uavcan_stm32_driver + ) + +set(config_io_extra_libs + #${CMAKE_SOURCE_DIR}/src/lib/mathlib/CMSIS/libarm_cortexM3l_math.a + ) + +add_custom_target(sercon) +set_target_properties(sercon PROPERTIES + MAIN "sercon" STACK "2048") + +add_custom_target(serdis) +set_target_properties(serdis PROPERTIES + MAIN "serdis" STACK "2048") diff --git a/cmake/configs/nuttx_px4fmu-v2_simple.cmake b/cmake/configs/nuttx_px4fmu-v2_simple.cmake new file mode 100644 index 0000000000..070fbd703f --- /dev/null +++ b/cmake/configs/nuttx_px4fmu-v2_simple.cmake @@ -0,0 +1,143 @@ +include(nuttx/px4_impl_nuttx) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) + +set(config_module_list + # + # Board support modules + # + drivers/device + drivers/stm32 + drivers/stm32/adc + drivers/stm32/tone_alarm + drivers/led + drivers/px4fmu + drivers/px4io + drivers/boards/px4fmu-v2 + drivers/rgbled + drivers/mpu6000 + drivers/mpu9250 + drivers/lsm303d + drivers/l3gd20 + drivers/hmc5883 + drivers/ms5611 + drivers/mb12xx + drivers/sf0x + drivers/ll40ls + drivers/trone + drivers/gps + drivers/pwm_out_sim + drivers/hott + drivers/hott/hott_telemetry + drivers/hott/hott_sensors + drivers/blinkm + drivers/airspeed + drivers/ets_airspeed + drivers/meas_airspeed + drivers/frsky_telemetry + modules/sensors + drivers/mkblctrl + drivers/px4flow + drivers/oreoled + drivers/gimbal + drivers/pwm_input + drivers/camera_trigger + + # + # System commands + # + systemcmds/bl_update + systemcmds/mixer + systemcmds/param + systemcmds/perf + systemcmds/pwm + systemcmds/esc_calib + systemcmds/reboot + systemcmds/top + systemcmds/config + systemcmds/nshterm + systemcmds/mtd + systemcmds/dumpfile + systemcmds/ver + + # + # Logging + # + modules/sdlog2 + + # + # Library modules + # + modules/param + modules/systemlib + modules/systemlib/mixer + modules/controllib + modules/uORB + modules/dataman + + # + # Libraries + # + #lib/mathlib/CMSIS + lib/mathlib + lib/mathlib/math/filter + lib/ecl + lib/external_lgpl + lib/geo + lib/geo_lookup + lib/conversion + lib/launchdetection + platforms/nuttx + + # had to add for cmake, not sure why wasn't in original config + platforms/common + platforms/nuttx/px4_layer + + # + # Demo apps + # + #examples/math_demo + # Tutorial code from + # https://px4.io/dev/px4_simple_app + examples/px4_simple_app + + # Tutorial code from + # https://px4.io/dev/daemon + examples/px4_daemon_app + + # Tutorial code from + # https://px4.io/dev/debug_values + examples/px4_mavlink_debug + + # Tutorial code from + # https://px4.io/dev/example_fixedwing_control + examples/fixedwing_control + + # Hardware test + examples/hwtest +) + +set(config_extra_builtin_cmds + serdis + sercon + ) + +set(config_io_board + px4io-v2 + ) + +set(config_extra_libs + ${CMAKE_SOURCE_DIR}/src/lib/mathlib/CMSIS/libarm_cortexM4lf_math.a + ) + +set(config_io_extra_libs + ${CMAKE_SOURCE_DIR}/src/lib/mathlib/CMSIS/libarm_cortexM3l_math.a + ) + +add_custom_target(sercon) +set_target_properties(sercon PROPERTIES + MAIN "sercon" STACK "2048") + +add_custom_target(serdis) +set_target_properties(serdis PROPERTIES + MAIN "serdis" STACK "2048") diff --git a/cmake/configs/nuttx_sim_simple.cmake b/cmake/configs/nuttx_sim_simple.cmake new file mode 100644 index 0000000000..068c6409f2 --- /dev/null +++ b/cmake/configs/nuttx_sim_simple.cmake @@ -0,0 +1,21 @@ +include(nuttx/px4_impl_nuttx) + +message(WARNING "this is a work in progress and doesn't build yet") + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) + +set(config_module_list + #platforms/nuttx + #platforms/nuttx/px4_layer + platforms/common + #drivers/led + drivers/device + #modules/systemlib + #modules/uORB + #examples/px4_simple_app + #lib/mathlib/math/filter + #lib/conversion + ) + +set(config_extra_builtin_cmds + ) diff --git a/cmake/configs/posix_eagle_default.cmake b/cmake/configs/posix_eagle_default.cmake new file mode 100644 index 0000000000..fc97e70918 --- /dev/null +++ b/cmake/configs/posix_eagle_default.cmake @@ -0,0 +1,46 @@ +include(posix/px4_impl_posix) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) + +set(config_module_list + drivers/device + drivers/blinkm + drivers/pwm_out_sim + drivers/rgbled + drivers/led + drivers/boards/sitl + + systemcmds/param + systemcmds/mixer + systemcmds/ver + + modules/mavlink + + modules/attitude_estimator_ekf + modules/ekf_att_pos_estimator + + modules/mc_pos_control + modules/mc_att_control + + modules/param + modules/systemlib + modules/systemlib/mixer + modules/uORB + modules/sensors + modules/dataman + modules/sdlog2 + modules/simulator + modules/commander + modules/controllib + + lib/mathlib + lib/mathlib/math/filter + lib/geo + lib/geo_lookup + lib/conversion + + platforms/common + platforms/posix/px4_layer + platforms/posix/work_queue + ) + diff --git a/cmake/configs/posix_eagle_hil.cmake b/cmake/configs/posix_eagle_hil.cmake new file mode 100644 index 0000000000..cae322edb9 --- /dev/null +++ b/cmake/configs/posix_eagle_hil.cmake @@ -0,0 +1,40 @@ +include(posix/px4_impl_posix) + +# Use build stubs unless explicitly set not to +if("${DSPAL_STUBS_ENABLE}" STREQUAL "") + set(DSPAL_STUBS_ENABLE "1") +endif() + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) + +set(config_module_list + drivers/device + drivers/boards/sitl + drivers/led + + systemcmds/param + systemcmds/ver + + modules/mavlink + + modules/param + modules/systemlib + modules/uORB + modules/sensors + modules/dataman + modules/sdlog2 + modules/simulator + modules/commander + + lib/mathlib + lib/mathlib/math/filter + lib/geo + lib/geo_lookup + lib/conversion + + platforms/common + platforms/posix/px4_layer + platforms/posix/work_queue + modules/muorb/krait + ) + diff --git a/cmake/configs/posix_eagle_muorb.cmake b/cmake/configs/posix_eagle_muorb.cmake new file mode 100644 index 0000000000..813fbbfecb --- /dev/null +++ b/cmake/configs/posix_eagle_muorb.cmake @@ -0,0 +1,15 @@ +include(posix/px4_impl_posix) + +set(CMAKE_TOOLCHAIN_FILE cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) + +set(config_module_list + drivers/device + + modules/uORB + + platforms/posix/px4_layer + platforms/posix/work_queue + + modules/muorb/krait + ) + diff --git a/cmake/configs/posix_eagle_release.cmake b/cmake/configs/posix_eagle_release.cmake new file mode 100644 index 0000000000..8e3bb26078 --- /dev/null +++ b/cmake/configs/posix_eagle_release.cmake @@ -0,0 +1,35 @@ +include(posix/px4_impl_posix) + +# Use build stubs unless explicitly set not to +if("${DSPAL_STUBS_ENABLE}" STREQUAL "") + set(DSPAL_STUBS_ENABLE "1") +endif() + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) + +set(config_module_list + drivers/device + + systemcmds/param + systemcmds/ver + + modules/mavlink + + modules/param + modules/systemlib + modules/uORB + modules/dataman + + lib/mathlib + lib/mathlib/math/filter + lib/geo + lib/geo_lookup + lib/conversion + + platforms/common + platforms/posix/px4_layer + platforms/posix/work_queue + + modules/muorb/krait + ) + diff --git a/cmake/configs/posix_sitl_simple.cmake b/cmake/configs/posix_sitl_simple.cmake new file mode 100644 index 0000000000..227bffeab8 --- /dev/null +++ b/cmake/configs/posix_sitl_simple.cmake @@ -0,0 +1,71 @@ +include(posix/px4_impl_posix) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cmake) + +set(config_module_list + drivers/led + drivers/device + drivers/boards/sitl + drivers/pwm_out_sim + drivers/rgbled + platforms/common + platforms/posix/px4_layer + platforms/posix/work_queue + platforms/posix/drivers/adcsim + platforms/posix/drivers/gpssim + platforms/posix/drivers/tonealrmsim + platforms/posix/drivers/accelsim + platforms/posix/drivers/airspeedsim + platforms/posix/drivers/barosim + platforms/posix/drivers/gyrosim + systemcmds/param + systemcmds/mixer + systemcmds/ver + systemcmds/esc_calib + systemcmds/reboot + systemcmds/topic_listener + modules/uORB + modules/param + modules/systemlib + modules/systemlib/mixer + modules/sensors + modules/simulator + modules/mavlink + modules/attitude_estimator_ekf + modules/attitude_estimator_q + modules/ekf_att_pos_estimator + modules/position_estimator_inav + modules/navigator + modules/mc_pos_control + modules/mc_att_control + modules/mc_pos_control_multiplatform + modules/mc_att_control_multiplatform + modules/land_detector + modules/fw_att_control + modules/fw_pos_control_l1 + modules/dataman + modules/sdlog2 + modules/commander + modules/controllib + lib/mathlib + lib/mathlib/math/filter + lib/conversion + lib/ecl + lib/external_lgpl + lib/geo + lib/geo_lookup + lib/launchdetection + ) + +set(config_extra_builtin_cmds + serdis + sercon + ) + +add_custom_target(sercon) +set_target_properties(sercon PROPERTIES + MAIN "sercon" STACK "2048") + +add_custom_target(serdis) +set_target_properties(serdis PROPERTIES + MAIN "serdis" STACK "2048") diff --git a/cmake/configs/qurt_eagle_hello.cmake b/cmake/configs/qurt_eagle_hello.cmake new file mode 100644 index 0000000000..c127216681 --- /dev/null +++ b/cmake/configs/qurt_eagle_hello.cmake @@ -0,0 +1,28 @@ +include(qurt/px4_impl_qurt) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-hexagon-7.4.cmake) + +set(config_module_list + drivers/device + + # + # System commands + # + systemcmds/param + + # + # Library modules + # + modules/param + modules/systemlib + modules/uORB + + # + # QuRT port + # + platforms/common + platforms/qurt/px4_layer + platforms/posix/work_queue + platforms/qurt/tests/hello + ) + diff --git a/cmake/configs/qurt_eagle_hil.cmake b/cmake/configs/qurt_eagle_hil.cmake new file mode 100644 index 0000000000..0b48820254 --- /dev/null +++ b/cmake/configs/qurt_eagle_hil.cmake @@ -0,0 +1,63 @@ +include(qurt/px4_impl_qurt) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-hexagon-7.4.cmake) + +set(config_module_list + drivers/device + drivers/boards/sitl + drivers/pwm_out_sim + drivers/led + drivers/rgbled + modules/sensors + + # + # System commands + # + systemcmds/param + systemcmds/mixer + + # + # Estimation modules (EKF/ SO3 / other filters) + # + #modules/attitude_estimator_ekf + modules/ekf_att_pos_estimator + modules/attitude_estimator_q + modules/position_estimator_inav + + # + # Vehicle Control + # + modules/mc_att_control + modules/mc_pos_control + + # + # Library modules + # + modules/param + modules/systemlib + modules/systemlib/mixer + modules/uORB + modules/commander + + # + # Libraries + # + lib/mathlib + lib/mathlib/math/filter + lib/geo + lib/geo_lookup + lib/conversion + modules/controllib + + # + # QuRT port + # + platforms/common + platforms/qurt/px4_layer + platforms/posix/work_queue + + # + # sources for muorb over fastrpc + # + modules/muorb/adsp + ) diff --git a/cmake/configs/qurt_eagle_muorb.cmake b/cmake/configs/qurt_eagle_muorb.cmake new file mode 100644 index 0000000000..492225aa40 --- /dev/null +++ b/cmake/configs/qurt_eagle_muorb.cmake @@ -0,0 +1,41 @@ +include(qurt/px4_impl_qurt) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-hexagon-7.4.cmake) + +set(config_module_list + drivers/device + + # + # System commands + # + systemcmds/param + + # + # Library modules + # + modules/param + modules/systemlib + modules/uORB + + # + # Libraries + # + lib/mathlib + lib/mathlib/math/filter + lib/geo + lib/geo_lookup + lib/conversion + + # + # QuRT port + # + platforms/common + platforms/qurt/px4_layer + platforms/posix/work_queue + platforms/qurt/tests/muorb + + # + # sources for muorb over fastrpc + # + modules/muorb/adsp + ) diff --git a/cmake/configs/qurt_eagle_release.cmake b/cmake/configs/qurt_eagle_release.cmake new file mode 100644 index 0000000000..494416ed4f --- /dev/null +++ b/cmake/configs/qurt_eagle_release.cmake @@ -0,0 +1,85 @@ +include(qurt/px4_impl_qurt) + +if ("${HEXAGON_DRIVERS_ROOT}" STREQUAL "") + message(FATAL_ERROR "HEXAGON_DRIVERS_ROOT is not set") +endif() + +if ("${EAGLE_DRIVERS_SRC}" STREQUAL "") + message(FATAL_ERROR "EAGLE_DRIVERS_SRC is not set") +endif() + +include_directories(${HEXAGON_DRIVERS_ROOT}/inc) + +# For Actual flight we need to link against the driver dynamic libraries +set(target_libraries + -L${HEXAGON_DRIVERS_ROOT}/libs + mpu9x50 + uart_esc + csr_gps + rc_receiver + ) + + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-hexagon-7.4.cmake) + +set(config_module_list + # + # Board support modules + # + drivers/device + modules/sensors + $(EAGLE_DRIVERS_SRC)/mpu9x50 + $(EAGLE_DRIVERS_SRC)/uart_esc + $(EAGLE_DRIVERS_SRC)/rc_receiver + $(EAGLE_DRIVERS_SRC)/csr_gps + + # + # System commands + # + systemcmds/param + + # + # Estimation modules (EKF/ SO3 / other filters) + # + #modules/attitude_estimator_ekf + modules/ekf_att_pos_estimator + modules/attitude_estimator_q + modules/position_estimator_inav + + # + # Vehicle Control + # + modules/mc_att_control + modules/mc_pos_control + + # + # Library modules + # + modules/param + modules/systemlib + modules/systemlib/mixer + modules/uORB + modules/commander + modules/controllib + + # + # Libraries + # + lib/mathlib + lib/mathlib/math/filter + lib/geo + lib/geo_lookup + lib/conversion + + # + # QuRT port + # + platforms/common + platforms/qurt/px4_layer + platforms/posix/work_queue + + # + # sources for muorb over fastrpc + # + modules/muorb/adsp + ) diff --git a/cmake/configs/qurt_eagle_test.cmake b/cmake/configs/qurt_eagle_test.cmake new file mode 100644 index 0000000000..b2935f1fda --- /dev/null +++ b/cmake/configs/qurt_eagle_test.cmake @@ -0,0 +1,39 @@ +include(qurt/px4_impl_qurt) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-hexagon-7.4.cmake) + +set(config_module_list + drivers/device + + # + # System commands + # + systemcmds/param + + # + # Library modules + # + modules/param + modules/systemlib + modules/systemlib/mixer + modules/uORB + + # + # Libraries + # + lib/mathlib + lib/mathlib/math/filter + lib/conversion + + # + # QuRT port + # + platforms/common + platforms/qurt/px4_layer + platforms/posix/work_queue + platforms/qurt/tests/hello + platforms/posix/tests/vcdev_test + platforms/posix/tests/hrt_test + platforms/posix/tests/wqueue + ) + diff --git a/cmake/configs/qurt_eagle_travis.cmake b/cmake/configs/qurt_eagle_travis.cmake new file mode 100644 index 0000000000..3b4672a115 --- /dev/null +++ b/cmake/configs/qurt_eagle_travis.cmake @@ -0,0 +1,68 @@ +include(qurt/px4_impl_qurt) + +# Run a full link with build stubs to make sure qurt target isn't broken +set(QURT_ENABLE_STUBS "1") + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-hexagon-7.4.cmake) + +set(config_module_list + drivers/device + drivers/boards/sitl + drivers/pwm_out_sim + drivers/led + drivers/rgbled + modules/sensors + + # + # System commands + # + systemcmds/param + systemcmds/mixer + + # + # Estimation modules (EKF/ SO3 / other filters) + # + #modules/attitude_estimator_ekf + modules/ekf_att_pos_estimator + modules/attitude_estimator_q + modules/position_estimator_inav + + # + # Vehicle Control + # + modules/mc_att_control + modules/mc_pos_control + + # + # Library modules + # + modules/param + modules/systemlib + modules/systemlib/mixer + modules/uORB + modules/commander + modules/controllib + + # + # Libraries + # + lib/mathlib + lib/mathlib/math/filter + lib/geo + lib/geo_lookup + lib/conversion + lib/ecl + + # + # QuRT port + # + platforms/common + platforms/qurt/px4_layer + platforms/posix/work_queue + + # + # sources for muorb over fastrpc + # + modules/muorb/adsp + ) + diff --git a/cmake/nuttx/bin_to_obj.py b/cmake/nuttx/bin_to_obj.py new file mode 100755 index 0000000000..80ce80d741 --- /dev/null +++ b/cmake/nuttx/bin_to_obj.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +""" +This converts a binary imagge to an object file +""" +from __future__ import print_function +import subprocess +import argparse +import re +from subprocess import PIPE + +#pylint: disable=invalid-name +parser = argparse.ArgumentParser(description='Convert bin to obj.') +parser.add_argument('--c_flags', required=True) +parser.add_argument('--c_compiler', required=True) +parser.add_argument('--include_path', required=True) +parser.add_argument('--nm', required=True) +parser.add_argument('--ld', required=True) +parser.add_argument('--objcopy', required=True) +parser.add_argument('--bin', required=True) +parser.add_argument('--obj', required=True) +parser.add_argument('--var', required=True) +args = parser.parse_args() + +in_bin = args.bin +c_flags = args.c_flags +c_compiler = args.c_compiler +include_path = args.include_path +nm = args.nm +ld = args.ld +obj = args.obj +var = args.var +objcopy = args.objcopy + +sym = "_binary_" + in_bin.replace('/', '_').replace('.', '_').replace('-', '_') +#print("sym: ", sym) + +# write empty file +with open('{obj:s}.c'.format(**locals()), 'w') as f: + f.write("") + +def run_cmd(cmd, d): + cmd = cmd.format(**d) + #print(cmd) + proc = subprocess.Popen(cmd.split(), stdout=PIPE, stderr=PIPE) + stdout, stderr = proc.communicate() + if stderr.decode() != "": + raise RuntimeError(stderr) + return stdout + +# do compile +run_cmd("{c_compiler:s} -I{include_path:s} {c_flags:s} -c {obj:s}.c -o {obj:s}.c.o", + locals()) + +# link +run_cmd("{ld:s} -r -o {obj:s}.bin.o {obj:s}.c.o -b binary {in_bin:s}", + locals()) + +# get size of image +stdout = run_cmd("{nm:s} -p --radix=x {obj:s}.bin.o", locals()) +re_string = r"^([0-9A-Fa-f]+) .*{sym:s}_size".format(**locals()) +re_size = re.compile(re_string, re.MULTILINE) +size_match = re.search(re_size, stdout.decode()) + +try: + size = size_match.group(1) +except AttributeError as e: + raise RuntimeError("{:s}\nre:{:s}\n{:s}".format( + e, re_string, stdout)) +except IndexError as e: + group0 = size_match.group(0) + raise RuntimeError("{:s}\ngroup 0:{:s}\n{:s}".format( + e, group0, stdout)) + +#print("romfs size: ", size) + +# write size to file +with open('{obj:s}.c'.format(**locals()), 'w') as f: + f.write("const unsigned int {var:s}_len = 0x{size:s};".format( + **locals())) + +# do compile +run_cmd("{c_compiler:s} -I{include_path:s} {c_flags:s} -c {obj:s}.c -o {obj:s}.c.o", + locals()) + +# link +run_cmd("{ld:s} -r -o {obj:s} {obj:s}.c.o {obj:s}.bin.o", + locals()) + +# obj copy +run_cmd(""" +{objcopy:s} {obj:s} + --redefine-sym {sym:s}_start={var:s} + --strip-symbol {sym:s}_size + --strip-symbol {sym:s}_end + --rename-section .data=.rodata +""", locals()) + +# vim: set et ft=python fenc= ff=unix sts=4 sw=4 ts=4 : diff --git a/cmake/nuttx/builtin_commands.c.in b/cmake/nuttx/builtin_commands.c.in new file mode 100644 index 0000000000..53c69b98ef --- /dev/null +++ b/cmake/nuttx/builtin_commands.c.in @@ -0,0 +1,10 @@ +/* builtin command list - automatically generated, do not edit */ +#include +#include +#include +${builtin_apps_decl_string} +const struct builtin_s g_builtins[] = { +${builtin_apps_string} + {NULL, 0, 0, NULL} +}; +const int g_builtin_count = ${command_count}; diff --git a/cmake/nuttx/px4_impl_nuttx.cmake b/cmake/nuttx/px4_impl_nuttx.cmake new file mode 100644 index 0000000000..af7391f45c --- /dev/null +++ b/cmake/nuttx/px4_impl_nuttx.cmake @@ -0,0 +1,529 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +#============================================================================= +# +# Defined functions in this file +# +# OS Specific Functions +# +# * px4_nuttx_add_firmware +# * px4_nuttx_generate_builtin_commands +# * px4_nuttx_add_export +# * px4_nuttx_add_romfs +# +# Required OS Inteface Functions +# +# * px4_os_add_flags +# * px4_os_prebuild_targets +# + +include(common/px4_base) + +#============================================================================= +# +# px4_nuttx_add_firmware +# +# This function adds a nuttx firmware target. +# +# Usage: +# px4_nuttx_add_firmware(OUT EXE +# PARAM_XML AIRFRAMES_XML ) +# +# Input: +# EXE : the executable to generate the firmware from +# BOARD : the board +# PARAM_XML : param xml file (optional) +# AIRFRAMES_XML : airframes xml file (optional) +# +# Output: +# OUT : the generated firmware target +# +# Example: +# px4_nuttx_add_firmware(TARGET fw_test EXE test) +# +function(px4_nuttx_add_firmware) + px4_parse_function_args( + NAME px4_nuttx_add_firmware + ONE_VALUE BOARD OUT EXE PARAM_XML AIRFRAMES_XML + REQUIRED OUT EXE BOARD + ARGN ${ARGN}) + + set(extra_args) + + if (PARAM_XML) + list(APPEND extra_args + --parameter_xml ${PARAM_XML} + ) + endif() + + if (AIRFRAMES_XML) + list(APPEND extra_args + --airframe_xml ${AIRFRAMES_XML} + ) + endif() + + add_custom_command(OUTPUT ${OUT} + COMMAND ${OBJCOPY} -O binary ${EXE} ${EXE}.bin + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/px_mkfw.py + --prototype ${CMAKE_SOURCE_DIR}/Images/${BOARD}.prototype + --git_identity ${CMAKE_SOURCE_DIR} + ${extra_args} + --image ${EXE}.bin > ${OUT} + DEPENDS ${EXE} + ) + add_custom_target(build_firmware_${BOARD} ALL DEPENDS ${OUT}) +endfunction() + +#============================================================================= +# +# px4_nuttx_generate_builtin_commands +# +# This function generates the builtin_commands.c src for nuttx +# +# Usage: +# px4_nuttx_generate_builtin_commands( +# MODULE_LIST +# OUT ) +# +# Input: +# MODULE_LIST : list of modules +# +# Output: +# OUT : generated builtin_commands.c src +# +# Example: +# px4_nuttx_generate_builtin_commands( +# OUT MODULE_LIST px4_simple_app) +# +function(px4_nuttx_generate_builtin_commands) + px4_parse_function_args( + NAME px4_nuttx_generate_builtin_commands + ONE_VALUE OUT + MULTI_VALUE MODULE_LIST + REQUIRED MODULE_LIST OUT + ARGN ${ARGN}) + set(builtin_apps_string) + set(builtin_apps_decl_string) + set(command_count 0) + foreach(module ${MODULE_LIST}) + #message("generating builtin for: ${module}") + # default + set(MAIN_DEFAULT MAIN-NOTFOUND) + set(STACK_DEFAULT 1024) + set(PRIORITY_DEFAULT SCHED_PRIORITY_DEFAULT) + foreach(property MAIN STACK PRIORITY) + get_target_property(${property} ${module} ${property}) + if(NOT ${property}) + set(${property} ${${property}_DEFAULT}) + endif() + endforeach() + if (MAIN) + set(builtin_apps_string + "${builtin_apps_string}\t{\"${MAIN}\", ${PRIORITY}, ${STACK}, ${MAIN}_main},\n") + set(builtin_apps_decl_string + "${builtin_apps_decl_string}extern int ${MAIN}_main(int argc, char *argv[]);\n") + math(EXPR command_count "${command_count}+1") + endif() + endforeach() + configure_file(${CMAKE_SOURCE_DIR}/cmake/nuttx/builtin_commands.c.in + ${OUT}) +endfunction() + +#============================================================================= +# +# px4_nuttx_add_export +# +# This function generates a nuttx export. +# +# Usage: +# px4_nuttx_add_export( +# OUT +# CONFIG +# DEPENDS ) +# +# Input: +# CONFIG : the board to generate the export for +# DEPENDS : dependencies +# +# Output: +# OUT : the export target +# +# Example: +# px4_nuttx_add_export(OUT nuttx_export CONFIG px4fmu-v2) +# +function(px4_nuttx_add_export) + + px4_parse_function_args( + NAME px4_nuttx_add_export + ONE_VALUE OUT CONFIG THREADS + MULTI_VALUE DEPENDS + REQUIRED OUT CONFIG THREADS + ARGN ${ARGN}) + + set(nuttx_src ${CMAKE_BINARY_DIR}/${CONFIG}/NuttX) + + # patch + add_custom_target(__nuttx_patch_${CONFIG}) + file(GLOB nuttx_patches RELATIVE ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/nuttx-patches/*.patch) + foreach(patch ${nuttx_patches}) + string(REPLACE "/" "_" patch_name "${patch}-${CONFIG}") + message(STATUS "nuttx-patch: ${patch}") + add_custom_command(OUTPUT nuttx_patch_${patch_name}.stamp + COMMAND ${PATCH} -p0 -N < ${CMAKE_SOURCE_DIR}/${patch} + COMMAND ${TOUCH} nuttx_patch_${patch_name}.stamp + DEPENDS ${DEPENDS} + ) + add_custom_target(nuttx_patch_${patch_name} + DEPENDS nuttx_patch_${patch_name}.stamp) + add_dependencies(nuttx_patch nuttx_patch_${patch_name}) + endforeach() + + # copy + add_custom_command(OUTPUT nuttx_copy_${CONFIG}.stamp + COMMAND ${MKDIR} -p ${CMAKE_BINARY_DIR}/${CONFIG} + COMMAND ${MKDIR} -p ${nuttx_src} + COMMAND ${CP} -a ${CMAKE_SOURCE_DIR}/NuttX/. ${nuttx_src}/ + COMMAND ${RM} -rf ${nuttx_src}/.git + COMMAND ${TOUCH} nuttx_copy_${CONFIG}.stamp + DEPENDS ${DEPENDS}) + add_custom_target(__nuttx_copy_${CONFIG} + DEPENDS nuttx_copy_${CONFIG}.stamp __nuttx_patch_${CONFIG}) + + # export + file(GLOB_RECURSE config_files ${CMAKE_SOURCE_DIR}/nuttx-configs/${CONFIG}/*) + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CONFIG}.export + COMMAND ${ECHO} Configuring NuttX for ${CONFIG} + COMMAND ${MAKE} --no-print-directory -C${nuttx_src}/nuttx -r --quiet distclean + COMMAND ${CP} -r ${CMAKE_SOURCE_DIR}/nuttx-configs/${CONFIG} ${nuttx_src}/nuttx/configs + COMMAND cd ${nuttx_src}/nuttx/tools && ./configure.sh ${CONFIG}/nsh + COMMAND ${ECHO} Exporting NuttX for ${CONFIG} + COMMAND ${MAKE} --no-print-directory --quiet -C ${nuttx_src}/nuttx -j${THREADS} -r CONFIG_ARCH_BOARD=${CONFIG} export > /dev/null + COMMAND ${CP} -r ${nuttx_src}/nuttx/nuttx-export.zip ${CMAKE_BINARY_DIR}/${CONFIG}.export + DEPENDS ${config_files} ${DEPENDS} __nuttx_copy_${CONFIG}) + + # extract + add_custom_command(OUTPUT nuttx_export_${CONFIG}.stamp + COMMAND ${RM} -rf ${nuttx_src}/nuttx-export + COMMAND ${UNZIP} -q ${CMAKE_BINARY_DIR}/${CONFIG}.export -d ${nuttx_src} + COMMAND ${TOUCH} nuttx_export_${CONFIG}.stamp + DEPENDS ${DEPENDS} ${CMAKE_BINARY_DIR}/${CONFIG}.export) + + add_custom_target(${OUT} + DEPENDS nuttx_export_${CONFIG}.stamp) + +endfunction() + +#============================================================================= +# +# px4_nuttx_create_bin +# +# The functions generates a bin image for nuttx. +# +# Usage: +# px4_nuttx_create_bin(BIN EXE ) +# +# Input: +# EXE : the exe file +# +# Output: +# OUT : the binary output file +# +# Example: +# px4_nuttx_create_bin(OUT my_exe.bin EXE my_exe) +# +function(px4_nuttx_create_bin) + + px4_parse_function_args( + NAME px4_nuttx_create_bin + ONE_VALUE EXE OUT + REQUIRED EXE OUT + ARGN ${ARGN}) + + add_custom_command(OUTPUT ${OUT} + COMMAND ${OBJCOPY} -O binary ${EXE} ${EXE}.bin + DEPENDS ${EXE}) + + set(${OUT} ${${OUT}} PARENT_SCOPE) + +endfunction() + + +#============================================================================= +# +# px4_nuttx_add_romfs +# +# The functions creates a ROMFS filesystem for nuttx. +# +# Usage: +# px4_nuttx_add_romfs( +# OUT +# ROOT +# EXTRAS ) +# +# Input: +# ROOT : the root of the ROMFS +# EXTRAS : list of extra files +# +# Output: +# OUT : the ROMFS library target +# +# Example: +# px4_nuttx_add_romfs(OUT my_romfs ROOT "ROMFS/my_board") +# +function(px4_nuttx_add_romfs) + + px4_parse_function_args( + NAME px4_nuttx_add_romfs + ONE_VALUE OUT ROOT + MULTI_VALUE EXTRAS + REQUIRED OUT ROOT + ARGN ${ARGN}) + + set(romfs_temp_dir ${CMAKE_BINARY_DIR}/tmp/${ROOT}) + set(romfs_src_dir ${CMAKE_SOURCE_DIR}/${ROOT}) + set(romfs_autostart ${CMAKE_SOURCE_DIR}/Tools/px_process_airframes.py) + set(romfs_pruner ${CMAKE_SOURCE_DIR}/Tools/px_romfs_pruner.py) + set(bin_to_obj ${CMAKE_SOURCE_DIR}/cmake/nuttx/bin_to_obj.py) + set(extras_dir ${CMAKE_CURRENT_BINARY_DIR}/extras) + + file(GLOB_RECURSE romfs_src_files ${romfs_src_dir} ${romfs_src_dir}/*) + + set(cmake_test ${CMAKE_SOURCE_DIR}/cmake/test/cmake_tester.py) + + + set(extras) + foreach(extra ${EXTRAS}) + get_filename_component(file_name ${extra} NAME) + set(file_dest ${extras_dir}/${file_name}) + add_custom_command(OUTPUT ${file_dest} + COMMAND cmake -E copy ${extra} ${file_dest} + DEPENDS ${extra} + ) + list(APPEND extras ${file_dest}) + endforeach() + add_custom_target(collect_extras DEPENDS ${extras}) + + add_custom_command(OUTPUT romfs.o + COMMAND cmake -E remove_directory ${romfs_temp_dir} + COMMAND cmake -E copy_directory ${romfs_src_dir} ${romfs_temp_dir} + COMMAND cmake -E copy_directory ${extras_dir} ${romfs_temp_dir}/extras + COMMAND ${PYTHON_EXECUTABLE} ${romfs_autostart} + -a ${romfs_temp_dir}/init.d + -s ${romfs_temp_dir}/init.d/rc.autostart + COMMAND ${PYTHON_EXECUTABLE} ${romfs_pruner} + --folder ${romfs_temp_dir} + COMMAND ${GENROMFS} -f ${CMAKE_CURRENT_BINARY_DIR}/romfs.bin + -d ${romfs_temp_dir} -V "NSHInitVol" + #COMMAND cmake -E remove_directory ${romfs_temp_dir} + COMMAND ${PYTHON_EXECUTABLE} ${bin_to_obj} + --ld ${LD} --c_flags ${CMAKE_C_FLAGS} + --include_path "${CMAKE_SOURCE_DIR}/src/include" + --c_compiler ${CMAKE_C_COMPILER} + --nm ${NM} --objcopy ${OBJCOPY} + --obj romfs.o + --var romfs_img + --bin romfs.bin + DEPENDS ${romfs_src_files} ${extras} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + add_library(${OUT} STATIC romfs.o) + set_target_properties(${OUT} PROPERTIES LINKER_LANGUAGE C) + set(${OUT} ${${OUT}} PARENT_SCOPE) + +endfunction() + +#============================================================================= +# +# px4_os_add_flags +# +# Set ths nuttx build flags. +# +# Usage: +# px4_os_add_flags( +# C_FLAGS +# CXX_FLAGS +# EXE_LINKER_FLAGS +# INCLUDE_DIRS +# LINK_DIRS +# DEFINITIONS ) +# +# Input: +# BOARD : flags depend on board/nuttx config +# +# Input/Output: (appends to existing variable) +# C_FLAGS : c compile flags variable +# CXX_FLAGS : c++ compile flags variable +# EXE_LINKER_FLAGS : executable linker flags variable +# INCLUDE_DIRS : include directories +# LINK_DIRS : link directories +# DEFINITIONS : definitions +# +# Example: +# px4_os_add_flags( +# C_FLAGS CMAKE_C_FLAGS +# CXX_FLAGS CMAKE_CXX_FLAGS +# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS +# INCLUDES ) +# +function(px4_os_add_flags) + + set(inout_vars + C_FLAGS CXX_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS) + + px4_parse_function_args( + NAME px4_add_flags + ONE_VALUE ${inout_vars} BOARD + REQUIRED ${inout_vars} BOARD + ARGN ${ARGN}) + + px4_add_common_flags( + BOARD ${BOARD} + C_FLAGS ${C_FLAGS} + CXX_FLAGS ${CXX_FLAGS} + EXE_LINKER_FLAGS ${EXE_LINKER_FLAGS} + INCLUDE_DIRS ${INCLUDE_DIRS} + LINK_DIRS ${LINK_DIRS} + DEFINITIONS ${DEFINITIONS}) + + set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) + set(added_include_dirs + ${nuttx_export_dir}/include + ${nuttx_export_dir}/include/cxx + ${nuttx_export_dir}/arch/chip + ${nuttx_export_dir}/arch/common + ) + set(added_link_dirs + ${nuttx_export_dir}/libs + ) + set(added_definitions + -D__PX4_NUTTX + ) + set(added_c_flags + -nodefaultlibs + -nostdlib + ) + set(added_cxx_flags + -nodefaultlibs + -nostdlib + ) + + set(added_exe_linker_flags) # none currently + + set(cpu_flags) + if (${BOARD} STREQUAL "px4fmu-v1") + set(cpu_flags + -mcpu=cortex-m4 + -mthumb + -march=armv7e-m + -mfpu=fpv4-sp-d16 + -mfloat-abi=hard + ) + elseif (${BOARD} STREQUAL "px4fmu-v2") + set(cpu_flags + -mcpu=cortex-m4 + -mthumb + -march=armv7e-m + -mfpu=fpv4-sp-d16 + -mfloat-abi=hard + ) + elseif (${BOARD} STREQUAL "aerocore") + set(cpu_flags + -mcpu=cortex-m4 + -mthumb + -march=armv7e-m + -mfpu=fpv4-sp-d16 + -mfloat-abi=hard + ) + elseif (${BOARD} STREQUAL "px4io-v1") + set(cpu_flags + -mcpu=cortex-m3 + -mthumb + -march=armv7-m + ) + elseif (${BOARD} STREQUAL "px4io-v2") + set(cpu_flags + -mcpu=cortex-m3 + -mthumb + -march=armv7-m + ) + endif() + list(APPEND c_flags ${cpu_flags}) + list(APPEND cxx_flags ${cpu_flags}) + + # output + foreach(var ${inout_vars}) + string(TOLOWER ${var} lower_var) + set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE) + #message(STATUS "nuttx: set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)") + endforeach() + +endfunction() + +#============================================================================= +# +# px4_os_prebuild_targets +# +# This function generates os dependent targets + +# Usage: +# px4_os_prebuild_targets( +# OUT +# BOARD +# ) +# +# Input: +# BOARD : board +# THREADS : number of threads for building +# +# Output: +# OUT : the target list +# +# Example: +# px4_os_prebuild_targets(OUT target_list BOARD px4fmu-v2) +# +function(px4_os_prebuild_targets) + px4_parse_function_args( + NAME px4_os_prebuild_targets + ONE_VALUE OUT BOARD THREADS + REQUIRED OUT BOARD + ARGN ${ARGN}) + px4_nuttx_add_export(OUT nuttx_export_${BOARD} + CONFIG ${BOARD} + THREADS ${THREADS} + DEPENDS git_nuttx) + add_custom_target(${OUT} DEPENDS nuttx_export_${BOARD}) +endfunction() + +# vim: set noet fenc=utf-8 ff=unix nowrap: diff --git a/cmake/posix/apps.h_in b/cmake/posix/apps.h_in new file mode 100644 index 0000000000..7b29304b3f --- /dev/null +++ b/cmake/posix/apps.h_in @@ -0,0 +1,88 @@ +/* builtin command list - automatically generated, do not edit */ +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; + +extern void px4_show_devices(void); + +extern "C" { +${builtin_apps_decl_string} +static int shutdown_main(int argc, char *argv[]); +static int list_tasks_main(int argc, char *argv[]); +static int list_files_main(int argc, char *argv[]); +static int list_devices_main(int argc, char *argv[]); +static int list_topics_main(int argc, char *argv[]); +static int sleep_main(int argc, char *argv[]); +} + +static map app_map(void) +{ + static map apps; + +${builtin_apps_string} + apps["shutdown"] = shutdown_main; + apps["list_tasks"] = list_tasks_main; + apps["list_files"] = list_files_main; + apps["list_devices"] = list_devices_main; + apps["list_topics"] = list_topics_main; + apps["sleep"] = sleep_main; + + return apps; +} + +map apps = app_map(); + +static void list_builtins(void) +{ + cout << "Builtin Commands:" << endl; + for (map::iterator it=apps.begin(); it!=apps.end(); ++it) + cout << '\t' << it->first << endl; +} + +static int shutdown_main(int argc, char *argv[]) +{ + printf("Shutting down\\n"); + exit(0); +} + +static int list_tasks_main(int argc, char *argv[]) +{ + px4_show_tasks(); + return 0; +} + +static int list_devices_main(int argc, char *argv[]) +{ + px4_show_devices(); + return 0; +} + +static int list_topics_main(int argc, char *argv[]) +{ + px4_show_topics(); + return 0; +} + +static int list_files_main(int argc, char *argv[]) +{ + px4_show_files(); + return 0; +} + +static int sleep_main(int argc, char *argv[]) +{ + if (argc != 2) { + cout << "Usage: sleep " << endl; + return 1; + } + sleep(atoi(argv[1])); + return 0; +} + diff --git a/makefiles/posix/ld.script b/cmake/posix/ld.script similarity index 98% rename from makefiles/posix/ld.script rename to cmake/posix/ld.script index 32478e1e14..7069271193 100644 --- a/makefiles/posix/ld.script +++ b/cmake/posix/ld.script @@ -44,3 +44,4 @@ SECTIONS __param_end = .; } } +INSERT AFTER .rodata; diff --git a/cmake/posix/px4_impl_posix.cmake b/cmake/posix/px4_impl_posix.cmake new file mode 100644 index 0000000000..d51b5527d5 --- /dev/null +++ b/cmake/posix/px4_impl_posix.cmake @@ -0,0 +1,236 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +#============================================================================= +# +# Defined functions in this file +# +# OS Specific Functions +# +# * px4_posix_add_firmware +# * px4_posix_generate_builtin_commands +# * px4_posix_add_export +# * px4_posix_generate_romfs +# +# Required OS Inteface Functions +# +# * px4_os_add_flags +# * px4_os_prebuild_targets +# + +include(common/px4_base) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/posix) + +#============================================================================= +# +# px4_posix_generate_builtin_commands +# +# This function generates the builtin_commands.c src for posix +# +# Usage: +# px4_posix_generate_builtin_commands( +# MODULE_LIST +# OUT ) +# +# Input: +# MODULE_LIST : list of modules +# +# Output: +# OUT : generated builtin_commands.c src +# +# Example: +# px4_posix_generate_builtin_commands( +# OUT MODULE_LIST px4_simple_app) +# +function(px4_posix_generate_builtin_commands) + px4_parse_function_args( + NAME px4_posix_generate_builtin_commands + ONE_VALUE OUT + MULTI_VALUE MODULE_LIST + REQUIRED MODULE_LIST OUT + ARGN ${ARGN}) + set(builtin_apps_string) + set(builtin_apps_decl_string) + set(command_count 0) + foreach(module ${MODULE_LIST}) + # default + set(MAIN_DEFAULT MAIN-NOTFOUND) + set(STACK_DEFAULT 1024) + set(PRIORITY_DEFAULT SCHED_PRIORITY_DEFAULT) + foreach(property MAIN STACK PRIORITY) + get_target_property(${property} ${module} ${property}) + if(NOT ${property}) + set(${property} ${${property}_DEFAULT}) + endif() + endforeach() + if (MAIN) + set(builtin_apps_string + "${builtin_apps_string}\tapps[\"${MAIN}\"] = ${MAIN}_main;\n") + set(builtin_apps_decl_string + "${builtin_apps_decl_string}extern int ${MAIN}_main(int argc, char *argv[]);\n") + math(EXPR command_count "${command_count}+1") + endif() + endforeach() + configure_file(${CMAKE_SOURCE_DIR}/cmake/posix/apps.h_in + ${OUT}) +endfunction() + +#============================================================================= +# +# px4_os_add_flags +# +# Set ths posix build flags. +# +# Usage: +# px4_os_add_flags( +# C_FLAGS +# CXX_FLAGS +# EXE_LINKER_FLAGS +# INCLUDE_DIRS +# LINK_DIRS +# DEFINITIONS ) +# +# Input: +# BOARD : flags depend on board/posix config +# +# Input/Output: (appends to existing variable) +# C_FLAGS : c compile flags variable +# CXX_FLAGS : c++ compile flags variable +# EXE_LINKER_FLAGS : executable linker flags variable +# INCLUDE_DIRS : include directories +# LINK_DIRS : link directories +# DEFINITIONS : definitions +# +# Example: +# px4_os_add_flags( +# C_FLAGS CMAKE_C_FLAGS +# CXX_FLAGS CMAKE_CXX_FLAGS +# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS +# INCLUDES ) +# +function(px4_os_add_flags) + + set(inout_vars + C_FLAGS CXX_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS) + + px4_parse_function_args( + NAME px4_add_flags + ONE_VALUE ${inout_vars} BOARD + REQUIRED ${inout_vars} BOARD + ARGN ${ARGN}) + + px4_add_common_flags( + BOARD ${BOARD} + C_FLAGS ${C_FLAGS} + CXX_FLAGS ${CXX_FLAGS} + EXE_LINKER_FLAGS ${EXE_LINKER_FLAGS} + INCLUDE_DIRS ${INCLUDE_DIRS} + LINK_DIRS ${LINK_DIRS} + DEFINITIONS ${DEFINITIONS}) + + set(PX4_BASE ) + set(added_include_dirs + src/modules/systemlib + src/lib/eigen + src/platforms/posix/include + mavlink/include/mavlink + ) + +if(UNIX AND APPLE) + set(added_definitions + -D__PX4_POSIX + -D__PX4_DARWIN + -DCLOCK_MONOTONIC=1 + -Dnoreturn_function=__attribute__\(\(noreturn\)\) + -include ${PX4_INCLUDE_DIR}visibility.h + ) + +else() + + set(added_definitions + -D__PX4_POSIX + -D__PX4_LINUX + -DCLOCK_MONOTONIC=1 + -Dnoreturn_function=__attribute__\(\(noreturn\)\) + -include ${PX4_INCLUDE_DIR}visibility.h + ) +endif() + + set(added_exe_linker_flags + -lpthread + ) + + + # Add the toolchain specific flags + set(added_cflags ${POSIX_CMAKE_C_FLAGS}) + set(added_cxx_flags ${POSIX_CMAKE_CXX_FLAGS}) + + # output + foreach(var ${inout_vars}) + string(TOLOWER ${var} lower_var) + set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE) + #message(STATUS "posix: set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)") + endforeach() + +endfunction() + +#============================================================================= +# +# px4_os_prebuild_targets +# +# This function generates os dependent targets +# +# Usage: +# px4_os_prebuild_targets( +# OUT +# BOARD +# ) +# +# Input: +# BOARD : board +# THREADS : number of threads for building +# +# Output: +# OUT : the target list +# +# Example: +# px4_os_prebuild_targets(OUT target_list BOARD px4fmu-v2) +# +function(px4_os_prebuild_targets) + px4_parse_function_args( + NAME px4_os_prebuild_targets + ONE_VALUE OUT BOARD THREADS + REQUIRED OUT BOARD + ARGN ${ARGN}) + add_custom_target(${OUT}) +endfunction() diff --git a/cmake/qurt/apps.h_in b/cmake/qurt/apps.h_in new file mode 100644 index 0000000000..f4d240d529 --- /dev/null +++ b/cmake/qurt/apps.h_in @@ -0,0 +1,84 @@ +/* builtin command list - automatically generated, do not edit */ +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; + +extern void px4_show_devices(void); + +extern "C" { +${builtin_apps_decl_string} +static int shutdown_main(int argc, char *argv[]); +static int list_tasks_main(int argc, char *argv[]); +static int list_files_main(int argc, char *argv[]); +static int list_devices_main(int argc, char *argv[]); +static int list_topics_main(int argc, char *argv[]); +static int sleep_main(int argc, char *argv[]); +} + + +void init_app_map(map &apps) +{ +${builtin_apps_string} + apps["shutdown"] = shutdown_main; + apps["list_tasks"] = list_tasks_main; + apps["list_files"] = list_files_main; + apps["list_devices"] = list_devices_main; + apps["list_topics"] = list_topics_main; + apps["sleep"] = sleep_main; +} + +void list_builtins(map &apps) +{ + printf("Builtin Commands:\\n"); + for (map::iterator it=apps.begin(); it!=apps.end(); ++it) + printf("\\t%s\\n", (it->first).c_str()); +} + +static int shutdown_main(int argc, char *argv[]) +{ + printf("Shutting down\\n"); + exit(0); +} + +static int list_tasks_main(int argc, char *argv[]) +{ + px4_show_tasks(); + return 0; +} + +static int list_devices_main(int argc, char *argv[]) +{ + px4_show_devices(); + return 0; +} + +static int list_topics_main(int argc, char *argv[]) +{ + px4_show_topics(); + return 0; +} +static int list_files_main(int argc, char *argv[]) +{ + px4_show_files(); + return 0; +} +static int sleep_main(int argc, char *argv[]) +{ + if (argc != 2) { + PX4_WARN( "Usage: sleep " ); + return 1; + } + + unsigned long usecs = ( (unsigned long) atol( argv[1] ) ) * 1000 * 1000; + PX4_WARN("Sleeping for %s, %ld",argv[1],usecs); + usleep( usecs ); + return 0; +} + diff --git a/cmake/qurt/px4_impl_qurt.cmake b/cmake/qurt/px4_impl_qurt.cmake new file mode 100644 index 0000000000..49bd83f53b --- /dev/null +++ b/cmake/qurt/px4_impl_qurt.cmake @@ -0,0 +1,236 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + + +#============================================================================= +# +# Defined functions in this file +# +# OS Specific Functions +# +# * px4_qurt_add_firmware +# * px4_qurt_generate_builtin_commands +# * px4_qurt_add_export +# * px4_qurt_generate_romfs +# +# Required OS Inteface Functions +# +# * px4_os_add_flags +# * px4_os_prebuild_targets +# + +include(common/px4_base) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/qurt) + +#============================================================================= +# +# px4_qurt_generate_builtin_commands +# +# This function generates the builtin_commands.c src for qurt +# +# Usage: +# px4_qurt_generate_builtin_commands( +# MODULE_LIST +# OUT ) +# +# Input: +# MODULE_LIST : list of modules +# +# Output: +# OUT : generated builtin_commands.c src +# +# Example: +# px4_qurt_generate_builtin_commands( +# OUT MODULE_LIST px4_simple_app) +# +function(px4_qurt_generate_builtin_commands) + px4_parse_function_args( + NAME px4_qurt_generate_builtin_commands + ONE_VALUE OUT + MULTI_VALUE MODULE_LIST + REQUIRED MODULE_LIST OUT + ARGN ${ARGN}) + set(builtin_apps_string) + set(builtin_apps_decl_string) + set(command_count 0) + foreach(module ${MODULE_LIST}) + # default + set(MAIN_DEFAULT MAIN-NOTFOUND) + set(STACK_DEFAULT 1024) + set(PRIORITY_DEFAULT SCHED_PRIORITY_DEFAULT) + foreach(property MAIN STACK PRIORITY) + get_target_property(${property} ${module} ${property}) + if(NOT ${property}) + set(${property} ${${property}_DEFAULT}) + endif() + endforeach() + if (MAIN) + set(builtin_apps_string + "${builtin_apps_string}\tapps[\"${MAIN}\"] = ${MAIN}_main;\n") + set(builtin_apps_decl_string + "${builtin_apps_decl_string}extern int ${MAIN}_main(int argc, char *argv[]);\n") + math(EXPR command_count "${command_count}+1") + endif() + endforeach() + configure_file(${CMAKE_SOURCE_DIR}/cmake/qurt/apps.h_in ${OUT}) +endfunction() + +#============================================================================= +# +# px4_os_add_flags +# +# Set ths qurt build flags. +# +# Usage: +# px4_os_add_flags( +# C_FLAGS +# CXX_FLAGS +# EXE_LINKER_FLAGS +# INCLUDE_DIRS +# LINK_DIRS +# DEFINITIONS ) +# +# Input: +# BOARD : flags depend on board/qurt config +# +# Input/Output: (appends to existing variable) +# C_FLAGS : c compile flags variable +# CXX_FLAGS : c++ compile flags variable +# EXE_LINKER_FLAGS : executable linker flags variable +# INCLUDE_DIRS : include directories +# LINK_DIRS : link directories +# DEFINITIONS : definitions +# +# Example: +# px4_os_add_flags( +# C_FLAGS CMAKE_C_FLAGS +# CXX_FLAGS CMAKE_CXX_FLAGS +# EXE_LINKER_FLAG CMAKE_EXE_LINKER_FLAGS +# INCLUDES ) +# +function(px4_os_add_flags) + + set(inout_vars + C_FLAGS CXX_FLAGS EXE_LINKER_FLAGS INCLUDE_DIRS LINK_DIRS DEFINITIONS) + + px4_parse_function_args( + NAME px4_add_flags + ONE_VALUE ${inout_vars} BOARD + REQUIRED ${inout_vars} BOARD + ARGN ${ARGN}) + + px4_add_common_flags( + BOARD ${BOARD} + C_FLAGS ${C_FLAGS} + CXX_FLAGS ${CXX_FLAGS} + EXE_LINKER_FLAGS ${EXE_LINKER_FLAGS} + INCLUDE_DIRS ${INCLUDE_DIRS} + LINK_DIRS ${LINK_DIRS} + DEFINITIONS ${DEFINITIONS}) + + set(DSPAL_ROOT src/lib/dspal) + set(added_include_dirs + ${DSPAL_ROOT}/include + ${DSPAL_ROOT}/sys + ${DSPAL_ROOT}/sys/sys + ${DSPAL_ROOT}/mpu_spi/inc + ${DSPAL_ROOT}/uart_esc/inc + src/platforms/qurt/include + src/platforms/posix/include + ) + + set(added_definitions + -D__PX4_QURT + -D__PX4_POSIX + -include ${PX4_INCLUDE_DIR}visibility.h + ) + + # Add the toolchain specific flags + set(added_cflags ${QURT_CMAKE_C_FLAGS}) + set(added_cxx_flags ${QURT_CMAKE_CXX_FLAGS}) + + # FIXME @jgoppert - how to work around issues like this? + # Without changing global variables? + # Clear -rdynamic flag which fails for hexagon + set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") + set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + + # output + foreach(var ${inout_vars}) + string(TOLOWER ${var} lower_var) + set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE) + #message(STATUS "qurt: set(${${var}} ${${${var}}} ${added_${lower_var}} PARENT_SCOPE)") + endforeach() + +endfunction() + +#============================================================================= +# +# px4_os_prebuild_targets +# +# This function generates os dependent targets +# +# Usage: +# px4_os_prebuild_targets( +# OUT +# BOARD +# ) +# +# Input: +# BOARD : board +# THREADS : number of threads for building +# +# Output: +# OUT : the target list +# +# Example: +# px4_os_prebuild_targets(OUT target_list BOARD px4fmu-v2) +# +function(px4_os_prebuild_targets) + px4_parse_function_args( + NAME px4_os_prebuild_targets + ONE_VALUE OUT BOARD THREADS + REQUIRED OUT BOARD + ARGN ${ARGN}) + add_custom_target(git_eigen_patched + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src/lib/eigen + COMMAND git checkout . + COMMAND git checkout master + COMMAND patch -p1 -i ${CMAKE_SOURCE_DIR}/cmake/qurt/qurt_eigen.patch + DEPENDS git_eigen) + add_custom_target(${OUT} DEPENDS git_dspal git_eigen_patched) + add_custom_target(ALL DEPENDS git_eigen_patched) + +endfunction() + +# vim: set noet fenc=utf-8 ff=unix nowrap: diff --git a/cmake/qurt/qurt_eigen.patch b/cmake/qurt/qurt_eigen.patch new file mode 100644 index 0000000000..3b3e76d6ad --- /dev/null +++ b/cmake/qurt/qurt_eigen.patch @@ -0,0 +1,37 @@ +diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h +index 1ca1d66..9bc928b 100644 +--- a/Eigen/src/Core/util/Macros.h ++++ b/Eigen/src/Core/util/Macros.h +@@ -194,6 +194,12 @@ + #define EIGEN_ARCH_PPC 0 + #endif + ++/// \internal EIGEN_ARCH_HEXAGON set to 1 if the architecture is Hexagon ++#ifdef __HEXAGON_ARCH__ ++ #define EIGEN_ARCH_HEXAGON 1 ++#else ++ #define EIGEN_ARCH_HEXAGON 0 ++#endif + + + // Operating system identification, EIGEN_OS_* +@@ -334,15 +340,16 @@ + #endif + + // Do we support r-value references? +-#if (__has_feature(cxx_rvalue_references) || \ ++#if ((__has_feature(cxx_rvalue_references) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) || \ + defined(__GXX_EXPERIMENTAL_CXX0X__) || \ +- (EIGEN_COMP_MSVC >= 1600)) ++ (EIGEN_COMP_MSVC >= 1600)) && (!defined(EIGEN_ARCH_HEXAGON))) + #define EIGEN_HAVE_RVALUE_REFERENCES + #endif + + // Does the compiler support result_of? +-#if (__has_feature(cxx_lambdas) || (defined(__cplusplus) && __cplusplus >= 201103L)) ++#if ((__has_feature(cxx_lambdas) || (defined(__cplusplus) && __cplusplus >= 201103L)) && \ ++ (!defined(EIGEN_ARCH_HEXAGON))) + #define EIGEN_HAS_STD_RESULT_OF 1 + #endif + diff --git a/src/lib/mathlib/module.mk b/cmake/qurt/qurt_funcs.cmake similarity index 74% rename from src/lib/mathlib/module.mk rename to cmake/qurt/qurt_funcs.cmake index 191e2da739..4690799b2b 100644 --- a/src/lib/mathlib/module.mk +++ b/cmake/qurt/qurt_funcs.cmake @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,14 +31,18 @@ # ############################################################################ +#============================================================================= +# FILE: posix/px4_target_impl.cmake # -# Math library +# Each PX4 target OS must implement the cmake/${OS}/px4_target_impl.cmake +# rules for their target that implement the following macros: # -SRCS = math/test/test.cpp \ - math/Limits.cpp - +# px4_target_set_flags +# px4_target_validate_config +# px4_target_firmware +# px4_target_rules +# px4_target_testing # -# In order to include .config we first have to save off the -# current makefile name, since app.mk needs it. +# The macros are called from the top level CMakeLists.txt # -APP_MAKEFILE := $(lastword $(MAKEFILE_LIST)) +px4_add_git_submodule(TARGET git_dspal PATH "src/lib/dspal") diff --git a/cmake/ros-CMakeLists.txt b/cmake/ros-CMakeLists.txt new file mode 100644 index 0000000000..aa42fb6ff4 --- /dev/null +++ b/cmake/ros-CMakeLists.txt @@ -0,0 +1,333 @@ +cmake_minimum_required(VERSION 2.8.3) +project(px4) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +add_definitions(-D__PX4_ROS) +add_definitions(-D__EXPORT=) +add_definitions(-DMAVLINK_DIALECT=common) + +## Find catkin macros and libraries +## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) +## is used, also find other catkin packages +find_package(catkin REQUIRED COMPONENTS + roscpp + rospy + std_msgs + geometry_msgs + message_generation + cmake_modules + gazebo_msgs + sensor_msgs + mav_msgs + libmavconn + tf +) +find_package(Eigen REQUIRED) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependencies might have been +## pulled in transitively but can be declared for certainty nonetheless: +## * add a build_depend tag for "message_generation" +## * add a run_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +add_message_files( + FILES + rc_channels.msg + vehicle_attitude.msg + vehicle_attitude_setpoint.msg + manual_control_setpoint.msg + actuator_controls.msg + actuator_controls_0.msg + actuator_controls_virtual_mc.msg + vehicle_rates_setpoint.msg + mc_virtual_rates_setpoint.msg + vehicle_attitude.msg + vehicle_control_mode.msg + actuator_armed.msg + parameter_update.msg + vehicle_status.msg + vehicle_local_position.msg + position_setpoint.msg + position_setpoint_triplet.msg + vehicle_local_position_setpoint.msg + vehicle_global_velocity_setpoint.msg + offboard_control_mode.msg + vehicle_force_setpoint.msg + distance_sensor.msg +) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +generate_messages( + DEPENDENCIES + std_msgs + gazebo_msgs +) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if you package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( + INCLUDE_DIRS src/include + LIBRARIES px4 + CATKIN_DEPENDS message_runtime roscpp rospy std_msgs libmavconn + DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +include_directories( + ${catkin_INCLUDE_DIRS} + src/platforms + src/platforms/ros/px4_messages + src/include + src/modules + ${CMAKE_BINARY_DIR}/src/modules + src/ + src/lib + ${EIGEN_INCLUDE_DIRS} + integrationtests +) + +## generate multiplatform wrapper headers +## note that the message header files are generated as in any ROS project with generate_messages() +set(MULTIPLATFORM_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/platforms/ros/px4_messages) +set(MULTIPLATFORM_TEMPLATE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/msg/templates/px4/ros) +set(TOPICHEADER_TEMP_DIR ${CMAKE_BINARY_DIR}/topics_temporary) +set(MULTIPLATFORM_PREFIX px4_) +add_custom_target(multiplatform_message_headers ALL ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Tools/px_generate_uorb_topic_headers.py + -d ${CMAKE_CURRENT_SOURCE_DIR}/msg -o ${MULTIPLATFORM_HEADER_DIR} -e ${MULTIPLATFORM_TEMPLATE_DIR} + -t ${TOPICHEADER_TEMP_DIR} -p ${MULTIPLATFORM_PREFIX}) + +## Declare a cpp library +add_library(px4 + src/platforms/ros/px4_ros_impl.cpp + src/platforms/ros/perf_counter.cpp + src/platforms/ros/geo.cpp + src/lib/mathlib/math/Limits.cpp + src/modules/systemlib/circuit_breaker.cpp +) +add_dependencies(px4 ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) + +target_link_libraries(px4 + ${catkin_LIBRARIES} +) + +## Declare a test publisher +add_executable(publisher + src/examples/publisher/publisher_main.cpp + src/examples/publisher/publisher_example.cpp) +add_dependencies(publisher ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) +target_link_libraries(publisher + ${catkin_LIBRARIES} + px4 +) + +## Declare a test subscriber +add_executable(subscriber + src/examples/subscriber/subscriber_main.cpp + src/examples/subscriber/subscriber_example.cpp) +add_dependencies(subscriber ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) +target_link_libraries(subscriber + ${catkin_LIBRARIES} + px4 +) + +## MC Attitude Control +add_executable(mc_att_control + src/modules/mc_att_control_multiplatform/mc_att_control_main.cpp + src/modules/mc_att_control_multiplatform/mc_att_control.cpp + src/modules/mc_att_control_multiplatform/mc_att_control_base.cpp) +add_dependencies(mc_att_control ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(mc_att_control + ${catkin_LIBRARIES} + px4 +) + +## MC Position Control +add_executable(mc_pos_control + src/modules/mc_pos_control_multiplatform/mc_pos_control_main.cpp + src/modules/mc_pos_control_multiplatform/mc_pos_control.cpp) +add_dependencies(mc_pos_control ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(mc_pos_control + ${catkin_LIBRARIES} + px4 +) + +## Attitude Estimator dummy +add_executable(attitude_estimator + src/platforms/ros/nodes/attitude_estimator/attitude_estimator.cpp) +add_dependencies(attitude_estimator ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(attitude_estimator + ${catkin_LIBRARIES} + px4 +) + +## Position Estimator dummy +add_executable(position_estimator + src/platforms/ros/nodes/position_estimator/position_estimator.cpp) +add_dependencies(position_estimator ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(position_estimator + ${catkin_LIBRARIES} + px4 +) + +## Manual input +add_executable(manual_input + src/platforms/ros/nodes/manual_input/manual_input.cpp) +add_dependencies(manual_input ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(manual_input + ${catkin_LIBRARIES} + px4 +) + +## Multicopter Mixer dummy +add_executable(mc_mixer + src/platforms/ros/nodes/mc_mixer/mc_mixer.cpp) +add_dependencies(mc_mixer ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(mc_mixer + ${catkin_LIBRARIES} + px4 +) + +## Commander dummy +add_executable(commander + src/platforms/ros/nodes/commander/commander.cpp) +add_dependencies(commander ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(commander + ${catkin_LIBRARIES} + px4 +) + +## Mavlink dummy +add_executable(mavlink + src/platforms/ros/nodes/mavlink/mavlink.cpp) +add_dependencies(mavlink ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(mavlink + ${catkin_LIBRARIES} + px4 +) + +## Offboard Position Setpoint Demo +add_executable(demo_offboard_position_setpoints + src/platforms/ros/nodes/demo_offboard_position_setpoints/demo_offboard_position_setpoints.cpp) +add_dependencies(demo_offboard_position_setpoints ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(demo_offboard_position_setpoints + ${catkin_LIBRARIES} + px4 +) + +## Offboard Attitude Setpoint Demo +add_executable(demo_offboard_attitude_setpoints + src/platforms/ros/nodes/demo_offboard_attitude_setpoints/demo_offboard_attitude_setpoints.cpp) +add_dependencies(demo_offboard_attitude_setpoints ${PROJECT_NAME}_generate_messages_cpp_cpp) +target_link_libraries(demo_offboard_attitude_setpoints + ${catkin_LIBRARIES} + px4 +) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +# install(PROGRAMS +# scripts/my_python_script +# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark executables and/or libraries for installation +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +# install(FILES +# # myfile1 +# # myfile2 +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +# ) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_px4test.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) + +if(CATKIN_ENABLE_TESTING) + find_package(rostest REQUIRED) + add_rostest(integrationtests/demo_tests/direct_tests.launch) + add_rostest(integrationtests/demo_tests/mavros_tests.launch) +endif() + + diff --git a/cmake/scripts/convert_modules_to_cmake.py b/cmake/scripts/convert_modules_to_cmake.py new file mode 100755 index 0000000000..7cd8768c65 --- /dev/null +++ b/cmake/scripts/convert_modules_to_cmake.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import argparse +import os +import sys +import fnmatch +import re +import shutil +import jinja2 + +src_path = os.path.join(os.path.curdir, 'src') + +parser = argparse.ArgumentParser('converts module.mk to CMakeList.txt, run in root of repo') +parser.add_argument('path', help='directory of modules to convert') +parser.add_argument('--overwrite', help='overwrite existing files', dest='overwrite', action='store_true') +parser.add_argument('--backup', help='create backup of existing files if overwriting', dest='backup', action='store_true') +parser.set_defaults(overwrite=False, backup=False) +args = parser.parse_args() + +cmake_template = jinja2.Template(open('cmake/scripts/cmake_lists.jinja', 'r').read()) + +module_files = [] +for root, dirnames, filenames in os.walk(args.path): + for filename in fnmatch.filter(filenames, 'module.mk'): + module_files.append(os.path.join(root, filename)) + + +search_data = [ + # name # re string + ('command', r'.*MODULE_COMMAND\s*[\+]?=\s*([^\n]+)'), + ('stacksize', r'.*MODULE_STACKSIZE\s*[\+]?=([^\n]+)'), + ('extracxxflags', r'.*EXTRACXXFLAGS\s*[\+]?=([^\n]+)'), + ('extracflags', r'.*EXTRACFLAGS\s*[\+]?=\s*([^\s]+)\s*'), + ('priority', r'.*MODULE_PRIORITY\s*[\+]?=\s*([^\s]+)\s*'), + ('maxoptimization', r'.*MAXOPTIMIZATION\s*[\+]?=\s*([^\s]+)\s*'), + ('srcs', '.*SRCS\s*[\+]?=([^\n\\\]*([\\\]\s*\n[^\n\\\]*)*)'), + ('include_dirs', '.*INCLUDE_DIRS\s*[\+]?=([^\n\\\]*([\\\]\s*\n[^\n\\\]*)*)'), + ] + +progs = {} +for name, re_str in search_data: + progs[name] = re.compile(re_str) + +for module_file in module_files: + + data = {} + with open(module_file, 'r') as f: + module_text = f.read() + data['text'] = module_text + module_dir = os.path.dirname(module_file) + data['module'] = os.path.relpath(module_dir, src_path).replace( + os.sep, '__').split('.')[0] + #print(module_text) + for name, re_str in search_data: + result = progs[name].search(module_text) + if result is not None: + d = result.group(1).strip() + if name in ['srcs', 'extracxxflags', 'extracflags']: + d_store = d.replace('\\', '').split() + elif name == 'include_dirs': + d_store = d.replace('(', '{').replace(')', '}').split() + else: + d_store = d + data[name] = d_store + else: + data[name] = '' + + cmake_file = os.path.join(os.path.dirname(module_file), 'CMakeLists.txt') + cmake_file_backup = cmake_file + '.backup' + + if os.path.exists(cmake_file): + if args.backup: + if os.path.exists(cmake_file_backup): + print('error: file already exists:', cmake_file_backup) + continue + else: + shutil.copyfile(cmake_file, cmake_file_backup) + if args.overwrite: + print('overwriting', cmake_file) + else: + print('error: file already exists:', cmake_file) + continue + + with open(cmake_file, 'w') as f: + data_rendered = cmake_template.render(data=data) + f.write(data_rendered) + + +# vim: set et fenc= ff=unix sts=4 sw=4 ts=4 : diff --git a/cmake/scripts/test_compare.py b/cmake/scripts/test_compare.py new file mode 100755 index 0000000000..fb2b4745a4 --- /dev/null +++ b/cmake/scripts/test_compare.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +""" +This runs a command and compares output to a known file over +a given line range. +""" +from __future__ import print_function +import subprocess +import argparse +import os + + +#pylint: disable=invalid-name +parser = argparse.ArgumentParser(description='Process some integers.') +parser.add_argument('--command', required=True) +parser.add_argument('--stdin', required=True) +parser.add_argument('--stdout', required=True) +parser.add_argument('--check', required=True) +parser.add_argument('--start', default=0) +parser.add_argument('--stop', default=-1) +args = parser.parse_args() + +d = os.path.dirname(args.stdout) +if not os.path.exists(d): + os.makedirs(d) + +with open(args.stdout, 'w') as outfile: + with open(args.stdin, 'r') as infile: + proc = subprocess.Popen( + args.command, stdout=outfile, stdin=infile) +proc.communicate() + +i_start = int(args.start) +i_stop = int(args.stop) + +with open(args.stdout, 'r') as outfile: + out_contents = file.readlines(outfile) +out_contents = "".join(out_contents[i_start:i_stop]) + +with open(args.check, 'r') as checkfile: + check_contents = file.readlines(checkfile) +check_contents = "".join(check_contents[i_start:i_stop]) + +if (out_contents != check_contents): + print("output:\n", out_contents) + print("check:\n", check_contents) + exit(1) + +exit(0) + +# vim: set et ft=python fenc= ff=unix sts=4 sw=4 ts=4 : diff --git a/cmake/templates/build_git_version.h.in b/cmake/templates/build_git_version.h.in new file mode 100644 index 0000000000..1d1adb9ba3 --- /dev/null +++ b/cmake/templates/build_git_version.h.in @@ -0,0 +1,4 @@ +/* Auto Magically Generated file */ +/* Do not edit! */ +#define PX4_GIT_VERSION_STR @git_desc@ +#define PX4_GIT_VERSION_BINARY 0x@git_desc_short@ diff --git a/cmake/templates/cmake_lists.jinja b/cmake/templates/cmake_lists.jinja new file mode 100644 index 0000000000..f24bc0bcbd --- /dev/null +++ b/cmake/templates/cmake_lists.jinja @@ -0,0 +1,73 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE {{data.module}} +{%- if data.command != '' %} + MAIN {{data.command}} +{%- endif %} +{%- if data.priority != '' %} + PRIORITY {{data.priority}} +{%- endif %} +{%- if data.stacksize != '' %} + STACK {{data.stacksize}} +{%- endif %} +{%- if (data.extracxxflags|length > 0) or (data.extracflags|length > 0) or (data.maxoptimization != '') %} + COMPILE_FLAGS +{%- for flag in data.extracxxflags %} + {{flag}} +{%- endfor %} +{%- for flag in data.extracflags %} + {{flag}} +{%- endfor %} + {{data.maxoptimization}} +{%- endif %} +{%- if data.srcs|length > 0 %} + SRCS +{%- for src in data.srcs %} + {{src}} +{%- endfor %} +{%- endif %} + DEPENDS +{%- if data.module != 'platforms__common' %} + platforms__common +{%- else %} + msg_gen +{%- endif %} +{%- if data.includes|length > 0 %} + INCLUDES {%- for include in data.includes %} + {{include}} +{%- endfor %} +{%- endif %} + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : +{# vim: set noet list ft=jinja fenc=utf-8 ff=unix : #} diff --git a/cmake/test/cmake_tester.py b/cmake/test/cmake_tester.py new file mode 100755 index 0000000000..34bebacb9d --- /dev/null +++ b/cmake/test/cmake_tester.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +""" +The module facilitates testing in cmake. +It takes a command and a regex for failure ok passing. +It passes if: + * No stderr output. + * Stdout doesn't match failure regex. + * Stdout matches ok regex if given. +""" +from __future__ import print_function +import argparse +import subprocess +import re +import sys + +#pylint: disable=invalid-name + +parser = argparse.ArgumentParser() + +parser.add_argument('cmd') +parser.add_argument('--re-fail') +parser.add_argument('--re-ok') +parser.add_argument('--verbose', '-v', dest='verbose', action='store_true') + +parser.set_defaults(verbose=False) +args = parser.parse_args() + +proc = subprocess.Popen(args.cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) +stdout, stderr = proc.communicate() + +if stderr != "": + print(stderr) + sys.exit(1) + +if args.re_fail is not None: + fail_match = re.search(args.re_fail, stdout) + if fail_match is not None: + print(stdout) + sys.exit(1) + +if args.re_ok is not None: + ok_match = re.search(args.re_ok, stdout) + if re.match(args.re_ok, stdout) is None: + print(stdout) + sys.exit(1) + +if args.verbose: + print(stdout) + +sys.exit(0) + +# vim: set et ft=python fenc=utf-8 ff=unix sts=4 sw=4 ts=4 : diff --git a/cmake/test/px4_simple_app_correct.txt b/cmake/test/px4_simple_app_correct.txt new file mode 100644 index 0000000000..317d4f5982 --- /dev/null +++ b/cmake/test/px4_simple_app_correct.txt @@ -0,0 +1,27 @@ +INFO Shell id is 47996278451456 +WARN 1 starting task wkr_high (file /home/jgoppert/git/px4/cmake-Firmware/src/platforms/posix/px4_layer/px4_posix_tasks.cpp line 146) +WARN 54 starting task wkr_low (file /home/jgoppert/git/px4/cmake-Firmware/src/platforms/posix/px4_layer/px4_posix_tasks.cpp line 146) +WARN 100 starting task wkr_hrt (file /home/jgoppert/git/px4/cmake-Firmware/src/platforms/posix/px4_layer/px4_posix_tasks.cpp line 146) +App name: mainapp +Enter a command and its args: +---------------------------------- +Running: uorb +Returning: uorb +Enter a command and its args: +---------------------------------- +Running: accelsim +Returning: accelsim +Enter a command and its args: +---------------------------------- +Running: px4_simple_app +Hello Sky! +[px4_simple_app] Got no data within a second +[px4_simple_app] Got no data within a second +[px4_simple_app] Got no data within a second +[px4_simple_app] Got no data within a second +[px4_simple_app] Got no data within a second +Returning: px4_simple_app +Enter a command and its args: +---------------------------------- +Running: shutdown +Shutting down diff --git a/cmake/test/px4_simple_app_input.txt b/cmake/test/px4_simple_app_input.txt new file mode 100644 index 0000000000..29360b9624 --- /dev/null +++ b/cmake/test/px4_simple_app_input.txt @@ -0,0 +1,4 @@ +uorb start +accelsim start +px4_simple_app +shutdown diff --git a/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake new file mode 100644 index 0000000000..61d63f8677 --- /dev/null +++ b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake @@ -0,0 +1,67 @@ +# defines: +# +# NM +# OBJCOPY +# LD +# CXX_COMPILER +# C_COMPILER +# CMAKE_SYSTEM_NAME +# CMAKE_SYSTEM_VERSION +# GENROMFS +# LINKER_FLAGS +# CMAKE_EXE_LINKER_FLAGS +# CMAKE_FIND_ROOT_PATH +# CMAKE_FIND_ROOT_PATH_MODE_PROGRAM +# CMAKE_FIND_ROOT_PATH_MODE_LIBRARY +# CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + +include(CMakeForceCompiler) + +# this one is important +set(CMAKE_SYSTEM_NAME Generic) + +#this one not so much +set(CMAKE_SYSTEM_VERSION 1) + +# specify the cross compiler +find_program(C_COMPILER arm-linux-gnueabihf-gcc) +if(NOT C_COMPILER) + message(FATAL_ERROR "could not find arm-none-eabi-gcc compiler") +endif() +cmake_force_c_compiler(${C_COMPILER} GNU) + +find_program(CXX_COMPILER arm-linux-gnueabihf-g++) +if(NOT CXX_COMPILER) + message(FATAL_ERROR "could not find arm-none-eabi-g++ compiler") +endif() +cmake_force_cxx_compiler(${CXX_COMPILER} GNU) + +# compiler tools +foreach(tool objcopy nm ld) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} arm-linux-gnueabihf-${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${tool}") + endif() +endforeach() + +# os tools +foreach(tool echo patch grep rm mkdir nm genromfs cp touch make unzip) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} ${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${TOOL}") + endif() +endforeach() + +set(LINKER_FLAGS "-Wl,-gc-sections") +set(CMAKE_EXE_LINKER_FLAGS ${LINKER_FLAGS}) + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchains/Toolchain-arm-none-eabi.cmake b/cmake/toolchains/Toolchain-arm-none-eabi.cmake new file mode 100644 index 0000000000..ac13b9f517 --- /dev/null +++ b/cmake/toolchains/Toolchain-arm-none-eabi.cmake @@ -0,0 +1,85 @@ +# defines: +# +# NM +# OBJCOPY +# LD +# CXX_COMPILER +# C_COMPILER +# CMAKE_SYSTEM_NAME +# CMAKE_SYSTEM_VERSION +# GENROMFS +# LINKER_FLAGS +# CMAKE_EXE_LINKER_FLAGS +# CMAKE_FIND_ROOT_PATH +# CMAKE_FIND_ROOT_PATH_MODE_PROGRAM +# CMAKE_FIND_ROOT_PATH_MODE_LIBRARY +# CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + +include(CMakeForceCompiler) + +# this one is important +set(CMAKE_SYSTEM_NAME Generic) + +#this one not so much +set(CMAKE_SYSTEM_VERSION 1) + +# specify the cross compiler +find_program(C_COMPILER arm-none-eabi-gcc) +if(NOT C_COMPILER) + message(FATAL_ERROR "could not find arm-none-eabi-gcc compiler") +endif() +cmake_force_c_compiler(${C_COMPILER} GNU) + +find_program(CXX_COMPILER arm-none-eabi-g++) +if(NOT CXX_COMPILER) + message(FATAL_ERROR "could not find arm-none-eabi-g++ compiler") +endif() +cmake_force_cxx_compiler(${CXX_COMPILER} GNU) + +# compiler tools +foreach(tool objcopy nm ld) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} arm-none-eabi-${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${tool}") + endif() +endforeach() + +# optional compiler tools +foreach(tool gdb gdbtui) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} arm-none-eabi-${tool}) + if(NOT ${TOOL}) + message(STATUS "could not find ${tool}") + endif() +endforeach() + +# os tools +foreach(tool echo patch grep rm mkdir nm genromfs cp touch make unzip) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} ${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${tool}") + endif() +endforeach() + +# optional os tools +foreach(tool ddd) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} ${tool}) + if(NOT ${TOOL}) + message(STATUS "could not find ${tool}") + endif() +endforeach() + +set(LINKER_FLAGS "-Wl,-gc-sections") +set(CMAKE_EXE_LINKER_FLAGS ${LINKER_FLAGS}) + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchains/Toolchain-hexagon-7.4.cmake b/cmake/toolchains/Toolchain-hexagon-7.4.cmake new file mode 100644 index 0000000000..9c4286044d --- /dev/null +++ b/cmake/toolchains/Toolchain-hexagon-7.4.cmake @@ -0,0 +1,240 @@ +# +# Copyright (C) 2015 Mark Charlebois. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(CMakeForceCompiler) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +include(common/px4_base) + +if(NOT HEXAGON_TOOLS_ROOT) + set(HEXAGON_TOOLS_ROOT /opt/7.4/Tools) +endif() + +macro (list2string out in) + set(list ${ARGV}) + list(REMOVE_ITEM list ${out}) + foreach(item ${list}) + set(${out} "${${out}} ${item}") + endforeach() +endmacro(list2string) + +set(V_ARCH "v5") +set(CROSSDEV "hexagon-") +set(HEXAGON_BIN ${HEXAGON_TOOLS_ROOT}/bin) +set(HEXAGON_LIB_DIR ${HEXAGON_TOOLS_ROOT}/gnu/hexagon/lib) +set(HEXAGON_ISS_DIR ${HEXAGON_TOOLS_ROOT}/lib/iss) +set(TOOLSLIB ${HEXAGON_TOOLS_ROOT}/target/hexagon/lib/${V_ARCH}/G0) + +# Use the HexagonTools compiler (6.4.05) +set(CMAKE_C_COMPILER ${HEXAGON_BIN}/${CROSSDEV}clang) +set(CMAKE_CXX_COMPILER ${HEXAGON_BIN}/${CROSSDEV}clang++) + +set(CMAKE_AR ${HEXAGON_BIN}/${CROSSDEV}ar CACHE FILEPATH "Archiver") +set(CMAKE_RANLIB ${HEXAGON_BIN}/${CROSSDEV}ranlib) +set(CMAKE_LINKER ${HEXAGON_BIN}/${CROSSDEV}ld.qcld) +set(CMAKE_NM ${HEXAGON_BIN}/${CROSSDEV}nm) +set(CMAKE_OBJDUMP ${HEXAGON_BIN}/${CROSSDEV}objdump) +set(CMAKE_OBJCOPY ${HEXAGON_BIN}/${CROSSDEV}objcopy) + +list2string(HEXAGON_INCLUDE_DIRS + -I${HEXAGON_TOOLS_ROOT}/target/hexagon/include + ) + +#set(DYNAMIC_LIBS -Wl,${TOOLSLIB}/pic/libstdc++.a) + +#set(MAXOPTIMIZATION -O0) + +# Base CPU flags for each of the supported architectures. +# +set(ARCHCPUFLAGS + -m${V_ARCH} + -G0 + ) + +add_definitions( + -D_PID_T -D_UID_T -D_TIMER_T + -Dnoreturn_function= + -D__EXPORT= + -Drestrict= + -D_DEBUG + -Wno-error=shadow + ) + +# optimisation flags +# +set(ARCHOPTIMIZATION + -O0 + -g + -fno-strict-aliasing + -fdata-sections + -fno-zero-initialized-in-bss + ) + +# Language-specific flags +# +set(ARCHCFLAGS + -std=gnu99 + -D__CUSTOM_FILE_IO__ + ) +set(ARCHCXXFLAGS + -fno-exceptions + -fno-rtti + -std=c++11 + -fno-threadsafe-statics + -DCONFIG_WCHAR_BUILTIN + -D__CUSTOM_FILE_IO__ + ) + +set(ARCHWARNINGS + -Wall + -Wextra + -Werror + -Wno-unused-parameter + -Wno-unused-function + -Wno-unused-variable + -Wno-gnu-array-member-paren-init + -Wno-cast-align + -Wno-missing-braces + -Wno-strict-aliasing +# -Werror=float-conversion - works, just needs to be phased in with some effort and needs GCC 4.9+ +# -Wcast-qual - generates spurious noreturn attribute warnings, try again later +# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code +# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives + ) + +# C-specific warnings +# +set(ARCHCWARNINGS + ${ARCHWARNINGS} + -Wstrict-prototypes + -Wnested-externs + ) + +# C++-specific warnings +# +set(ARCHWARNINGSXX + ${ARCHWARNINGS} + -Wno-missing-field-initializers + ) +exec_program(${CMAKE_CXX_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR} ARGS -print-libgcc-file-name OUTPUT_VARIABLE LIBGCC) +exec_program(${CMAKE_CXX_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR} ARGS -print-file-name=libm.a OUTPUT_VARIABLE LIBM) +set(EXTRA_LIBS ${EXTRA_LIBS} ${LIBM}) + +# Flags we pass to the C compiler +# +list2string(CFLAGS + ${ARCHCFLAGS} + ${ARCHCWARNINGS} + ${ARCHOPTIMIZATION} + ${ARCHCPUFLAGS} + ${ARCHINCLUDES} + ${INSTRUMENTATIONDEFINES} + ${ARCHDEFINES} + ${EXTRADEFINES} + ${EXTRACFLAGS} + ${HEXAGON_INCLUDE_DIRS} + ) + +# Flags we pass to the C++ compiler +# +list2string(CXXFLAGS + ${ARCHCXXFLAGS} + ${ARCHWARNINGSXX} + ${ARCHOPTIMIZATION} + ${ARCHCPUFLAGS} + ${ARCHXXINCLUDES} + ${INSTRUMENTATIONDEFINES} + ${ARCHDEFINES} + ${EXTRADEFINES} + ${EXTRACXXFLAGS} + ${HEXAGON_INCLUDE_DIRS} + ) + +# Flags we pass to the assembler +# +list2string(AFLAGS + ${CFLAGS} + -D__ASSEMBLY__ + ${EXTRADEFINES} + ${EXTRAAFLAGS} + ) + +# Set cmake flags +# +list2string(CMAKE_C_FLAGS + ${CMAKE_C_FLAGS} + ${CFLAGS} + ) + +set(QURT_CMAKE_C_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "cflags") + +message(STATUS "CMAKE_C_FLAGS: -${CMAKE_C_FLAGS}-") + +list2string(CMAKE_CXX_FLAGS + ${CMAKE_CXX_FLAGS} + ${CXXFLAGS} + ) + +set(QURT_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "cxxflags") + +message(STATUS "CMAKE_CXX_FLAGS: -${CMAKE_CXX_FLAGS}-") + +# Flags we pass to the linker +# +list2string(CMAKE_EXE_LINKER_FLAGS + -g + -mv5 + -mG0lib + -G0 + -fpic + -shared + -Wl,-Bsymbolic + -Wl,--wrap=malloc + -Wl,--wrap=calloc + -Wl,--wrap=free + -Wl,--wrap=realloc + -Wl,--wrap=memalign + -Wl,--wrap=__stack_chk_fail + -lc + ${EXTRALDFLAGS} + ) + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) + +set(CMAKE_C_COMPILER_ID, "Clang") +set(CMAKE_CXX_COMPILER_ID, "Clang") + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchains/Toolchain-hexagon.cmake b/cmake/toolchains/Toolchain-hexagon.cmake new file mode 100644 index 0000000000..4de37f553c --- /dev/null +++ b/cmake/toolchains/Toolchain-hexagon.cmake @@ -0,0 +1,249 @@ +# +# Copyright (C) 2015 Mark Charlebois. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(CMakeForceCompiler) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +include(common/px4_base) + +if(NOT HEXAGON_TOOLS_ROOT) + set(HEXAGON_TOOLS_ROOT /opt/6.4.05) +endif() + +if(NOT HEXAGON_SDK_ROOT) + set(HEXAGON_SDK_ROOT /opt/Hexagon_SDK) +endif() + +macro (list2string out in) + set(list ${ARGV}) + list(REMOVE_ITEM list ${out}) + foreach(item ${list}) + set(${out} "${${out}} ${item}") + endforeach() +endmacro(list2string) + +set(V_ARCH "v5") +set(CROSSDEV "hexagon-") +set(HEXAGON_BIN ${HEXAGON_TOOLS_ROOT}/gnu/bin) +set(HEXAGON_CLANG_BIN ${HEXAGON_TOOLS_ROOT}/qc/bin) +set(HEXAGON_LIB_DIR ${HEXAGON_TOOLS_ROOT}/gnu/hexagon/lib) +set(HEXAGON_ISS_DIR ${HEXAGON_TOOLS_ROOT}/qc/lib/iss) +set(TOOLSLIB ${HEXAGON_TOOLS_ROOT}/dinkumware/lib/$(V_ARCH)/G0) +set(QCTOOLSLIB ${HEXAGON_TOOLS_ROOT}/qc/lib/$(V_ARCH)/G0) + +# Use the HexagonTools compiler (6.4.05) +set(CMAKE_C_COMPILER ${HEXAGON_CLANG_BIN}/${CROSSDEV}clang) +set(CMAKE_CXX_COMPILER ${HEXAGON_CLANG_BIN}/${CROSSDEV}clang++) + +set(CMAKE_AR ${HEXAGON_BIN}/${CROSSDEV}ar CACHE FILEPATH "Archiver") +set(CMAKE_RANLIB ${HEXAGON_BIN}/${CROSSDEV}ranlib) +set(CMAKE_LINKER ${HEXAGON_BIN}/${CROSSDEV}ld) +set(CMAKE_NM ${HEXAGON_BIN}/${CROSSDEV}nm) +set(CMAKE_OBJDUMP ${HEXAGON_BIN}/${CROSSDEV}objdump) +set(CMAKE_OBJCOPY ${HEXAGON_BIN}/${CROSSDEV}objcopy) + +list2string(HEXAGON_INCLUDE_DIRS + -I${HEXAGON_TOOLS_ROOT}/gnu/hexagon/include + -I${HEXAGON_SDK_ROOT}/inc + -I${HEXAGON_SDK_ROOT}/inc/stddef + ) + +#set(DYNAMIC_LIBS -Wl,${TOOLSLIB}/pic/libstdc++.a) + +#set(MAXOPTIMIZATION -O0) + +# Base CPU flags for each of the supported architectures. +# +set(ARCHCPUFLAGS + -m${V_ARCH} + -G0 + ) + +add_definitions( + -D_PID_T -D_UID_T -D_TIMER_T + -Dnoreturn_function= + -D__EXPORT= + -Drestrict= + -D_DEBUG + -Wno-error=shadow + ) + +# optimisation flags +# +set(ARCHOPTIMIZATION + -O0 + -g + -fno-strict-aliasing + -fdata-sections + -fpic + -fno-zero-initialized-in-bss + ) + +# Language-specific flags +# +set(ARCHCFLAGS + -std=gnu99 + -D__CUSTOM_FILE_IO__ + ) +set(ARCHCXXFLAGS + -fno-exceptions + -fno-rtti + -std=c++11 + -fno-threadsafe-statics + -DCONFIG_WCHAR_BUILTIN + -D__CUSTOM_FILE_IO__ + ) + +set(ARCHWARNINGS + -Wall + -Wextra + -Werror + -Wno-unused-parameter + -Wno-unused-function + -Wno-unused-variable + -Wno-gnu-array-member-paren-init + -Wno-cast-align + -Wno-missing-braces + -Wno-strict-aliasing +# -Werror=float-conversion - works, just needs to be phased in with some effort and needs GCC 4.9+ +# -Wcast-qual - generates spurious noreturn attribute warnings, try again later +# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code +# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives + ) + +# C-specific warnings +# +set(ARCHCWARNINGS + ${ARCHWARNINGS} + -Wstrict-prototypes + -Wnested-externs + ) + +# C++-specific warnings +# +set(ARCHWARNINGSXX + ${ARCHWARNINGS} + -Wno-missing-field-initializers + ) +exec_program(${CMAKE_CXX_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR} ARGS -print-libgcc-file-name OUTPUT_VARIABLE LIBGCC) +exec_program(${CMAKE_CXX_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR} ARGS -print-file-name=libm.a OUTPUT_VARIABLE LIBM) +set(EXTRA_LIBS ${EXTRA_LIBS} ${LIBM}) + +# Flags we pass to the C compiler +# +list2string(CFLAGS + ${ARCHCFLAGS} + ${ARCHCWARNINGS} + ${ARCHOPTIMIZATION} + ${ARCHCPUFLAGS} + ${ARCHINCLUDES} + ${INSTRUMENTATIONDEFINES} + ${ARCHDEFINES} + ${EXTRADEFINES} + ${EXTRACFLAGS} + ${HEXAGON_INCLUDE_DIRS} + ) + +# Flags we pass to the C++ compiler +# +list2string(CXXFLAGS + ${ARCHCXXFLAGS} + ${ARCHWARNINGSXX} + ${ARCHOPTIMIZATION} + ${ARCHCPUFLAGS} + ${ARCHXXINCLUDES} + ${INSTRUMENTATIONDEFINES} + ${ARCHDEFINES} + ${EXTRADEFINES} + ${EXTRACXXFLAGS} + ${HEXAGON_INCLUDE_DIRS} + ) + +# Flags we pass to the assembler +# +list2string(AFLAGS + ${CFLAGS} + -D__ASSEMBLY__ + ${EXTRADEFINES} + ${EXTRAAFLAGS} + ) + +# Set cmake flags +# +list2string(CMAKE_C_FLAGS + ${CMAKE_C_FLAGS} + ${CFLAGS} + ) + +set(QURT_CMAKE_C_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "cflags") + +message(STATUS "CMAKE_C_FLAGS: -${CMAKE_C_FLAGS}-") + +list2string(CMAKE_CXX_FLAGS + ${CMAKE_CXX_FLAGS} + ${CXXFLAGS} + ) + +set(QURT_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "cxxflags") + +message(STATUS "CMAKE_CXX_FLAGS: -${CMAKE_CXX_FLAGS}-") + +# Flags we pass to the linker +# +list2string(CMAKE_EXE_LINKER_FLAGS + -g + -mv5 + -mG0lib + -G0 + -fpic + -shared + -Wl,-Bsymbolic + -Wl,--wrap=malloc + -Wl,--wrap=calloc + -Wl,--wrap=free + -Wl,--wrap=realloc + -Wl,--wrap=memalign + -Wl,--wrap=__stack_chk_fail + -lc + ${EXTRALDFLAGS} + ) + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) + +set(CMAKE_C_COMPILER_ID, "Clang") +set(CMAKE_CXX_COMPILER_ID, "Clang") + +# search for programs in the build host directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchains/Toolchain-native.cmake b/cmake/toolchains/Toolchain-native.cmake new file mode 100644 index 0000000000..888c73a6d8 --- /dev/null +++ b/cmake/toolchains/Toolchain-native.cmake @@ -0,0 +1,17 @@ +# compiler tools +foreach(tool nm ld) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} ${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${tool}") + endif() +endforeach() + +# os tools +foreach(tool echo patch grep rm mkdir nm genromfs cp touch make unzip) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} ${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${TOOL}") + endif() +endforeach() diff --git a/cmake/toolchains/Toolchain-posix-clang-native.cmake b/cmake/toolchains/Toolchain-posix-clang-native.cmake new file mode 100644 index 0000000000..0945b2b1f5 --- /dev/null +++ b/cmake/toolchains/Toolchain-posix-clang-native.cmake @@ -0,0 +1,90 @@ + +set(WARNINGS + -Wall + -Werror + -Wextra + -Wdouble-promotion + -Wshadow + -Wfloat-equal + -Wframe-larger-than=1024 + -Wpointer-arith + -Wlogical-op + -Wmissing-declarations + -Wno-unused-parameter + -Werror=format-security + -Werror=array-bounds + -Wfatal-errors + -Wformat=1 + -Werror=unused-but-set-variable + -Werror=unused-variable + -Werror=double-promotion + -Werror=reorder + -Werror=uninitialized + -Werror=init-self + -Werror=return-type + -Werror=deprecated + -Werror=unused-private-field + -Wno-packed + -Wno-frame-larger-than= + -Wno-varargs + #-Wcast-qual - generates spurious noreturn attribute warnings, + # try again later + #-Wconversion - would be nice, but too many "risky-but-safe" + # conversions in the code + #-Wcast-align - would help catch bad casts in some cases, + # but generates too many false positives + ) + +set(OPT_FLAGS + -Os -g3 + ) + +#============================================================================= +# c flags +# +set(C_WARNINGS + -Wbad-function-cast + -Wstrict-prototypes + -Wold-style-declaration + -Wmissing-parameter-type + -Wmissing-prototypes + -Wnested-externs + ) +set(C_FLAGS + -std=gnu99 + -fno-common + ) + +#============================================================================= +# cxx flags +# +set(CXX_WARNINGS + -Wno-missing-field-initializers + -Wno-varargs + ) +set(CXX_FLAGS + -fno-exceptions + -fno-rtti + -std=gnu++0x + -fno-threadsafe-statics + -DCONFIG_WCHAR_BUILTIN + -D__CUSTOM_FILE_IO__ + ) + +#============================================================================= +# ld flags +# +set(LD_FLAGS + -Wl,--warn-common + -Wl,--gc-sections + ) + +#============================================================================= +# misc flags +# +set(VISIBILITY_FLAGS + -fvisibility=hidden + "-include ${CMAKE_SOURCE_DIR}/src/include/visibility.h" + ) +set(EXE_LINK_FLAGS) + diff --git a/makefiles/README.txt b/makefiles/README.txt deleted file mode 100644 index 9578793957..0000000000 --- a/makefiles/README.txt +++ /dev/null @@ -1,86 +0,0 @@ -PX4 Build System -================ - -The files in this directory implement the PX4 runtime firmware build system -and configuration for the standard PX4 boards and software, in conjunction -with Makefile in the parent directory. - -../Makefile - - Top-level makefile for the PX4 build system. - This makefile supports building NuttX archives for the NuttX based - configurations, as well as supervising the building of all - of the defined PX4 firmware configurations. - - Try 'make help' in the parent directory for documentation. - -firmware.mk - - Manages the build for one specific firmware configuration. - See the comments at the top of this file for detailed documentation. - - Builds modules, builtin command lists and the ROMFS (if configured). - - This is the makefile directly used by external build systems; it can - be configured to compile modules both inside and outside the PX4 - source tree. When used in this mode, at least BOARD, MODULES and - CONFIG_FILE must be set. - -firmware_nuttx.mk - - Called by firmware.mk to build NuttX based firmware. - -firmware_posix.mk - - Called by firmware.mk to build POSIX (non-ROS) based firmware. - -module.mk - - Called by firmware.mk to build individual modules. - See the comments at the top of this file for detailed documentation. - - Not normally used other than by firmware.mk. - -nuttx.mk - - Called by ../Makefile to build or download the NuttX archives if - PX4_TARGET_OS is set to "nuttx". - -posix.mk - - Called by ../Makefile to set POSIX specific parameters if - PX4_TARGET_OS is set to "posix". - -upload.mk - - Called by ../Makefile to upload files to a target board. Can be used - by external build systems as well. (NuttX targets only) - -setup.mk - - Provides common path and tool definitions. Implements host - system-specific compatibility hacks. Sets PX4_TARGET_OS. - -board_.mk - - Board-specific configuration for . Typically sets - CONFIG_ARCH and then includes the toolchain definition for the board. - -config__.mk - - Parameters for a specific configuration on a specific board. - The board name is derived from the filename. Sets MODULES to select - source modules to be included in the configuration, may also set - ROMFS_ROOT to build a ROMFS and BUILTIN_COMMANDS to include non-module - commands (e.g. from NuttX) - -toolchain_.mk - - Provides macros used to compile and link source files. - Accepts EXTRADEFINES to add additional pre-processor symbol definitions, - EXTRACFLAGS, EXTRACXXFLAGS, EXTRAAFLAGS and EXTRALDFLAGS to pass - additional flags to the C compiler, C++ compiler, assembler and linker - respectively. - - Defines the COMPILE, COMPILEXX, ASSEMBLE, PRELINK, ARCHIVE and LINK - macros that are used elsewhere in the build system. diff --git a/makefiles/firmware.mk b/makefiles/firmware.mk deleted file mode 100644 index b8c8d4a85b..0000000000 --- a/makefiles/firmware.mk +++ /dev/null @@ -1,381 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Generic Makefile for PX4 firmware images. -# -# Requires: -# -# BOARD -# Must be set to a board name known to the PX4 distribution (as -# we need a corresponding NuttX export archive to link with). -# -# Optional: -# -# MODULES -# Contains a list of module paths or path fragments used -# to find modules. The names listed here are searched in -# the following directories: -# -# $(MODULE_SEARCH_DIRS) -# WORK_DIR -# MODULE_SRC -# PX4_MODULE_SRC -# -# Application directories are expected to contain a module.mk -# file which provides build configuration for the module. See -# makefiles/module.mk for more details. -# -# BUILTIN_COMMANDS -# Contains a list of built-in commands not explicitly provided -# by modules / libraries. Each entry in this list is formatted -# as ... -# -# PX4_BASE: -# Points to a PX4 distribution. Normally determined based on the -# path to this file. -# -# CONFIG: -# Used when searching for the configuration file, and available -# to module Makefiles to select optional features. -# If not set, CONFIG_FILE must be set and CONFIG will be derived -# automatically from it. -# -# CONFIG_FILE: -# If set, overrides the configuration file search logic. Sets -# CONFIG to the name of the configuration file, strips any -# leading config_ prefix and any suffix. e.g. config_board_foo.mk -# results in CONFIG being set to 'board_foo'. -# -# WORK_DIR: -# Sets the directory in which the firmware will be built. Defaults -# to the directory 'build' under the directory containing the -# parent Makefile. -# -# -# MODULE_SEARCH_DIRS: -# Extra directories to search first for MODULES before looking in the -# usual places. -# - -################################################################################ -# Paths and configuration -################################################################################ - -# -# Work out where this file is, so we can find other makefiles in the -# same directory. -# -# If PX4_BASE wasn't set previously, work out what it should be -# and set it here now. -# -MK_DIR ?= $(dir $(firstword $(MAKEFILE_LIST))) -ifeq ($(PX4_BASE),) -export PX4_BASE := $(abspath $(MK_DIR)/..) -endif -$(info % PX4_BASE = $(PX4_BASE)) -ifneq ($(words $(PX4_BASE)),1) -$(error Cannot build when the PX4_BASE path contains one or more space characters.) -endif - -# -# Set a default target so that included makefiles or errors here don't -# cause confusion. -# -# XXX We could do something cute here with $(DEFAULT_GOAL) if it's not one -# of the maintenance targets and set CONFIG based on it. -# -all: firmware - -# -# Get path and tool config -# -include $(MK_DIR)/setup.mk - -# -# Locate the configuration file -# -ifneq ($(CONFIG_FILE),) -CONFIG := $(subst config_,,$(basename $(notdir $(CONFIG_FILE)))) -else -CONFIG_FILE := $(wildcard $(PX4_MK_DIR)/$(PX4_TARGET_OS)/config_$(CONFIG).mk) -endif -ifeq ($(CONFIG),) -$(error Missing configuration name or file (specify with CONFIG=)) -endif -export CONFIG -include $(CONFIG_FILE) -$(info % CONFIG = $(CONFIG)) - -# -# Sanity-check the BOARD variable and then get the board config. -# If BOARD was not set by the configuration, extract it automatically. -# -# The board config in turn will fetch the toolchain configuration. -# -ifeq ($(BOARD),) -BOARD := $(firstword $(subst _, ,$(CONFIG))) -endif -BOARD_FILE := $(wildcard $(PX4_MK_DIR)/$(PX4_TARGET_OS)/board_$(BOARD).mk) -ifeq ($(BOARD_FILE),) -$(error Config $(CONFIG) references board $(BOARD), but no board definition file found) -endif -export BOARD -export BOARD_FILE -include $(BOARD_FILE) -$(info % BOARD = $(BOARD)) - -# -# If WORK_DIR is not set, create a 'build' directory next to the -# parent Makefile. -# -PARENT_MAKEFILE := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) -ifeq ($(WORK_DIR),) -export WORK_DIR := $(dir $(PARENT_MAKEFILE))build/ -endif -$(info % WORK_DIR = $(WORK_DIR)) - -# -# Things that, if they change, might affect everything -# -GLOBAL_DEPS += $(MAKEFILE_LIST) - -# -# Extra things we should clean -# -EXTRA_CLEANS = - - -# -# Append the per-board driver directory to the header search path. -# -INCLUDE_DIRS += $(PX4_MODULE_SRC)drivers/boards/$(BOARD) - -################################################################################ -# External library includes -################################################################################ - -INCLUDE_DIRS += $(PX4_BASE)src/lib/eigen/ - -################################################################################ -# OS specific libraries and paths -################################################################################ - -include $(PX4_MK_DIR)/$(PX4_TARGET_OS)/$(PX4_TARGET_OS).mk - -################################################################################ -# Modules -################################################################################ - -# where to look for modules -MODULE_SEARCH_DIRS += $(WORK_DIR) $(MODULE_SRC) $(PX4_MODULE_SRC) - -# sort and unique the modules list -MODULES := $(sort $(MODULES)) - -# locate the first instance of a module by full path or by looking on the -# module search path -define MODULE_SEARCH - $(firstword $(abspath $(wildcard $(1)/module.mk)) \ - $(abspath $(foreach search_dir,$(MODULE_SEARCH_DIRS),$(wildcard $(search_dir)/$(1)/module.mk))) \ - MISSING_$1) -endef - -# make a list of module makefiles and check that we found them all -MODULE_MKFILES := $(foreach module,$(MODULES),$(call MODULE_SEARCH,$(module))) -MISSING_MODULES := $(subst MISSING_,,$(filter MISSING_%,$(MODULE_MKFILES))) -ifneq ($(MISSING_MODULES),) -$(error Cant find module(s): $(MISSING_MODULES)) -endif - -# Make a list of the object files we expect to build from modules -# Note that this path will typically contain a double-slash at the WORK_DIR boundary; this must be -# preserved as it is used below to get the absolute path for the module.mk file correct. -# -MODULE_OBJS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)module.pre.o) - -# rules to build module objects -.PHONY: $(MODULE_OBJS) -$(MODULE_OBJS): relpath = $(patsubst $(WORK_DIR)%,%,$@) -$(MODULE_OBJS): mkfile = $(patsubst %module.pre.o,%module.mk,$(relpath)) -$(MODULE_OBJS): workdir = $(@D) -$(MODULE_OBJS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER) - $(Q) $(MKDIR) -p $(workdir) - $(Q) $(MAKE) -r -f $(PX4_MK_DIR)module.mk \ - --no-print-directory -C $(workdir) \ - MODULE_WORK_DIR=$(workdir) \ - MODULE_OBJ=$@ \ - MODULE_MK=$(mkfile) \ - MODULE_NAME=$(lastword $(subst /, ,$(workdir))) \ - module - -# make a list of phony clean targets for modules -MODULE_CLEANS := $(foreach path,$(dir $(MODULE_MKFILES)),$(WORK_DIR)$(path)/clean) - -# rules to clean modules -.PHONY: $(MODULE_CLEANS) -$(MODULE_CLEANS): relpath = $(patsubst $(WORK_DIR)%,%,$@) -$(MODULE_CLEANS): mkfile = $(patsubst %clean,%module.mk,$(relpath)) -$(MODULE_CLEANS): - @$(ECHO) %% cleaning using $(mkfile) - $(Q) $(MAKE) -r -f $(PX4_MK_DIR)module.mk \ - MODULE_WORK_DIR=$(dir $@) \ - MODULE_MK=$(mkfile) \ - clean - -################################################################################ -# Libraries -################################################################################ - -# where to look for libraries -LIBRARY_SEARCH_DIRS += $(WORK_DIR) $(MODULE_SRC) $(PX4_MODULE_SRC) - -# sort and unique the library list -LIBRARIES := $(sort $(LIBRARIES)) - -# locate the first instance of a library by full path or by looking on the -# library search path -define LIBRARY_SEARCH - $(firstword $(abspath $(wildcard $(1)/library.mk)) \ - $(abspath $(foreach search_dir,$(LIBRARY_SEARCH_DIRS),$(wildcard $(search_dir)/$(1)/library.mk))) \ - MISSING_$1) -endef - -# make a list of library makefiles and check that we found them all -LIBRARY_MKFILES := $(foreach library,$(LIBRARIES),$(call LIBRARY_SEARCH,$(library))) -MISSING_LIBRARIES := $(subst MISSING_,,$(filter MISSING_%,$(LIBRARY_MKFILES))) -ifneq ($(MISSING_LIBRARIES),) -$(error Cant find library(s): $(MISSING_LIBRARIES)) -endif - -# Make a list of the archive files we expect to build from libraries -# Note that this path will typically contain a double-slash at the WORK_DIR boundary; this must be -# preserved as it is used below to get the absolute path for the library.mk file correct. -# -LIBRARY_LIBS := $(foreach path,$(dir $(LIBRARY_MKFILES)),$(WORK_DIR)$(path)library.a) - -# rules to build module objects -.PHONY: $(LIBRARY_LIBS) -$(LIBRARY_LIBS): relpath = $(patsubst $(WORK_DIR)%,%,$@) -$(LIBRARY_LIBS): mkfile = $(patsubst %library.a,%library.mk,$(relpath)) -$(LIBRARY_LIBS): workdir = $(@D) -$(LIBRARY_LIBS): $(GLOBAL_DEPS) $(NUTTX_CONFIG_HEADER) - $(Q) $(MKDIR) -p $(workdir) - $(Q) $(MAKE) -r -f $(PX4_MK_DIR)library.mk \ - --no-print-directory -C $(workdir) \ - LIBRARY_WORK_DIR=$(workdir) \ - LIBRARY_LIB=$@ \ - LIBRARY_MK=$(mkfile) \ - LIBRARY_NAME=$(lastword $(subst /, ,$(workdir))) \ - library - -# make a list of phony clean targets for modules -LIBRARY_CLEANS := $(foreach path,$(dir $(LIBRARY_MKFILES)),$(WORK_DIR)$(path)/clean) - -# rules to clean modules -.PHONY: $(LIBRARY_CLEANS) -$(LIBRARY_CLEANS): relpath = $(patsubst $(WORK_DIR)%,%,$@) -$(LIBRARY_CLEANS): mkfile = $(patsubst %clean,%library.mk,$(relpath)) -$(LIBRARY_CLEANS): - @$(ECHO) %% cleaning using $(mkfile) - $(Q) $(MAKE) -r -f $(PX4_MK_DIR)library.mk \ - LIBRARY_WORK_DIR=$(dir $@) \ - LIBRARY_MK=$(mkfile) \ - clean - -################################################################################ -# ROMFS generation -################################################################################ -ifeq ($(PX4_TARGET_OS),nuttx) -include $(MK_DIR)/nuttx/nuttx_romfs.mk -endif - -################################################################################ -# Default SRCS generation -################################################################################ - -# -# If there are no SRCS, the build will fail; in that case, generate an empty -# source file. -# -ifeq ($(SRCS),) -EMPTY_SRC = $(WORK_DIR)empty.c -$(EMPTY_SRC): - $(Q) $(ECHO) '/* this is an empty file */' > $@ - -SRCS += $(EMPTY_SRC) -endif - -################################################################################ -# Build rules -################################################################################ - -# -# Object files we will generate from sources -# -OBJS := $(foreach src,$(SRCS),$(WORK_DIR)$(src).o) - -# -# SRCS -> OBJS rules -# - -$(OBJS): $(GLOBAL_DEPS) - -$(filter %.c.o,$(OBJS)): $(WORK_DIR)%.c.o: %.c $(GLOBAL_DEPS) - $(call COMPILE,$<,$@) - -$(filter %.cpp.o,$(OBJS)): $(WORK_DIR)%.cpp.o: %.cpp $(GLOBAL_DEPS) - $(call COMPILEXX,$<,$@) - -$(filter %.S.o,$(OBJS)): $(WORK_DIR)%.S.o: %.S $(GLOBAL_DEPS) - $(call ASSEMBLE,$<,$@) - -# Include the OS specific build rules -# The rules must define the "firmware" make target -# - -ifeq ($(PX4_TARGET_OS),nuttx) -include $(MK_DIR)/nuttx/nuttx_px4.mk -endif -ifeq ($(PX4_TARGET_OS),posix) -include $(MK_DIR)/posix/posix_elf.mk -endif -ifeq ($(PX4_TARGET_OS),posix-arm) -include $(MK_DIR)/posix/posix_elf.mk -endif -ifeq ($(PX4_TARGET_OS),qurt) -include $(MK_DIR)/qurt/qurt_elf.mk -endif - -# -# DEP_INCLUDES is defined by the toolchain include in terms of $(OBJS) -# --include $(DEP_INCLUDES) diff --git a/makefiles/library.mk b/makefiles/library.mk deleted file mode 100644 index e20fcce941..0000000000 --- a/makefiles/library.mk +++ /dev/null @@ -1,169 +0,0 @@ -# -# Copyright (c) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Framework makefile for PX4 libraries -# -# This makefile is invoked by firmware.mk to build each of the linraries -# that will subsequently be linked into the firmware image. -# -# Applications are built as standard ar archives. Unlike modules, -# all public symbols in library objects are visible across the entire -# firmware stack. -# -# In general, modules should be preferred to libraries when possible. -# Libraries may also be pre-built. -# -# IMPORTANT NOTE: -# -# This makefile assumes it is being invoked in the library's output directory. -# - -# -# Variables that can be set by the library's library.mk: -# -# -# SRCS (optional) -# -# Lists the .c, cpp and .S files that should be compiled/assembled to -# produce the library. -# -# PREBUILT_LIB (optional) -# -# Names the prebuilt library in the source directory that should be -# linked into the firmware. -# -# INCLUDE_DIRS (optional, must be appended, ignored if SRCS not set) -# -# The list of directories searched for include files. If non-standard -# includes (e.g. those from another module) are required, paths to search -# can be added here. -# -# - -# -# Variables visible to the library's library.mk: -# -# CONFIG -# BOARD -# LIBRARY_WORK_DIR -# LIBRARY_LIB -# LIBRARY_MK -# Anything set in setup.mk, board_$(BOARD).mk and the toolchain file. -# Anything exported from config_$(CONFIG).mk -# - -################################################################################ -# No user-serviceable parts below. -################################################################################ - -ifeq ($(LIBRARY_MK),) -$(error No library makefile specified) -endif -$(info %% LIBRARY_MK = $(LIBRARY_MK)) - -# -# Get the board/toolchain config -# -include $(PX4_MK_DIR)/$(PX4_TARGET_OS)/board_$(BOARD).mk - -# -# Get the library's config -# -include $(LIBRARY_MK) -LIBRARY_SRC := $(dir $(LIBRARY_MK)) -$(info % LIBRARY_NAME = $(LIBRARY_NAME)) -$(info % LIBRARY_SRC = $(LIBRARY_SRC)) -$(info % LIBRARY_LIB = $(LIBRARY_LIB)) -$(info % LIBRARY_WORK_DIR = $(LIBRARY_WORK_DIR)) - -# -# Things that, if they change, might affect everything -# -GLOBAL_DEPS += $(MAKEFILE_LIST) - -################################################################################ -# Build rules -################################################################################ - -# -# What we're going to build -# -library: $(LIBRARY_LIB) - -ifneq ($(PREBUILT_LIB),) - -VPATH = $(LIBRARY_SRC) -$(LIBRARY_LIB): $(PREBUILT_LIB) $(GLOBAL_DEPS) - @$(ECHO) "PREBUILT: $(PREBUILT_LIB)" - $(Q) $(COPY) $< $@ - -else - -## -## Object files we will generate from sources -## - -OBJS = $(addsuffix .o,$(SRCS)) - -# -# SRCS -> OBJS rules -# - -$(OBJS): $(GLOBAL_DEPS) - -vpath %.c $(LIBRARY_SRC) -$(filter %.c.o,$(OBJS)): %.c.o: %.c $(GLOBAL_DEPS) - $(call COMPILE,$<,$@) - -vpath %.cpp $(LIBRARY_SRC) -$(filter %.cpp.o,$(OBJS)): %.cpp.o: %.cpp $(GLOBAL_DEPS) - $(call COMPILEXX,$<,$@) - -vpath %.S $(LIBRARY_SRC) -$(filter %.S.o,$(OBJS)): %.S.o: %.S $(GLOBAL_DEPS) - $(call ASSEMBLE,$<,$@) - -# -# Built product rules -# - -$(LIBRARY_LIB): $(OBJS) $(GLOBAL_DEPS) - $(call ARCHIVE,$@,$(OBJS)) - -endif - -# -# Utility rules -# - -clean: - $(Q) $(REMOVE) $(LIBRARY_LIB) $(OBJS) diff --git a/makefiles/module.mk b/makefiles/module.mk deleted file mode 100644 index c92abaec3f..0000000000 --- a/makefiles/module.mk +++ /dev/null @@ -1,234 +0,0 @@ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Framework makefile for PX4 modules -# -# This makefile is invoked by firmware.mk to build each of the modules -# that will subsequently be linked into the firmware image. -# -# Modules are built as prelinked objects with a limited set of exported -# symbols, as the global namespace is shared between all modules. Normally an -# module will just export one or more _main functions. -# -# IMPORTANT NOTE: -# -# This makefile assumes it is being invoked in the module's output directory. -# - -# -# Variables that can be set by the module's module.mk: -# -# -# SRCS (required) -# -# Lists the .c, cpp and .S files that should be compiled/assembled to -# produce the module. -# -# MODULE_COMMAND (optional) -# MODULE_ENTRYPOINT (optional if MODULE_COMMAND is set) -# MODULE_STACKSIZE (optional if MODULE_COMMAND is set) -# MODULE_PRIORITY (optional if MODULE_COMMAND is set) -# -# Defines a single builtin command exported by the module. -# MODULE_COMMAND must be unique for any configuration, but need not be the -# same as the module directory name. -# -# If MODULE_ENTRYPOINT is set, it names the function (which must be exported) -# that will be the entrypoint for the builtin command. It defaults to -# $(MODULE_COMMAND)_main. -# -# If MODULE_STACKSIZE is set, it is the size in bytes of the stack to be -# allocated for the builtin command. If it is not set, it defaults -# to CONFIG_PTHREAD_STACK_DEFAULT. -# -# If MODULE_PRIORITY is set, it is the thread priority for the builtin -# command. If it is not set, it defaults to SCHED_PRIORITY_DEFAULT. -# -# MODULE_COMMANDS (optional if MODULE_COMMAND is not set) -# -# Defines builtin commands exported by the module. Each word in -# the list should be formatted as: -# ... -# -# INCLUDE_DIRS (optional, must be appended) -# -# The list of directories searched for include files. If non-standard -# includes (e.g. those from another module) are required, paths to search -# can be added here. -# -# DEFAULT_VISIBILITY (optional) -# -# If not set, global symbols defined in a module will not be visible -# outside the module. Symbols that should be globally visible must be -# marked __EXPORT. -# If set, global symbols defined in a module will be globally visible. -# - -# -# Variables visible to the module's module.mk: -# -# CONFIG -# BOARD -# BOARD_FILE -# MODULE_WORK_DIR -# MODULE_OBJ -# MODULE_MK -# Anything set in setup.mk, board_$(BOARD).mk and the toolchain file. -# Anything exported from config_$(CONFIG).mk -# - -################################################################################ -# No user-serviceable parts below. -################################################################################ - -ifeq ($(MODULE_MK),) -$(error No module makefile specified) -endif -ifeq ($(V),1) -$(info %% MODULE_MK = $(MODULE_MK)) -endif - -# -# Get the board/toolchain config -# -include $(BOARD_FILE) - -# -# Get the module's config -# -include $(MODULE_MK) -MODULE_SRC := $(dir $(MODULE_MK)) -ifeq ($(V),1) -$(info % MODULE_NAME = $(MODULE_NAME)) -$(info % MODULE_SRC = $(MODULE_SRC)) -$(info % MODULE_OBJ = $(MODULE_OBJ)) -$(info % MODULE_WORK_DIR = $(MODULE_WORK_DIR)) -endif - -# -# Things that, if they change, might affect everything -# -GLOBAL_DEPS += $(MAKEFILE_LIST) - -################################################################################ -# Builtin command definitions -################################################################################ - -ifneq ($(MODULE_COMMAND),) -MODULE_ENTRYPOINT ?= $(MODULE_COMMAND)_main -MODULE_STACKSIZE ?= CONFIG_PTHREAD_STACK_DEFAULT -MODULE_PRIORITY ?= SCHED_PRIORITY_DEFAULT -MODULE_COMMANDS += $(MODULE_COMMAND).$(MODULE_PRIORITY).$(MODULE_STACKSIZE).$(MODULE_ENTRYPOINT) -CXXFLAGS += -DPX4_MAIN=$(MODULE_COMMAND)_app_main -endif - -ifneq ($(MODULE_COMMANDS),) -MODULE_COMMAND_FILES := $(addprefix $(WORK_DIR)/builtin_commands/COMMAND.,$(MODULE_COMMANDS)) - -# Create the command files -# Ensure that there is only one entry for each command -# -.PHONY: $(MODULE_COMMAND_FILES) -$(MODULE_COMMAND_FILES): command = $(word 2,$(subst ., ,$(notdir $(@)))) -$(MODULE_COMMAND_FILES): exclude = $(dir $@)COMMAND.$(command).* -$(MODULE_COMMAND_FILES): $(GLOBAL_DEPS) - @$(REMOVE) -f $(exclude) - @$(MKDIR) -p $(dir $@) - @$(ECHO) "CMD: $(command)" - $(Q) $(TOUCH) $@ -endif - -################################################################################ -# Adjust compilation flags to implement EXPORT -################################################################################ - -ifeq ($(DEFAULT_VISIBILITY),) -DEFAULT_VISIBILITY = hidden -else -DEFAULT_VISIBILITY = default -endif - -CFLAGS += -fvisibility=$(DEFAULT_VISIBILITY) -include $(PX4_INCLUDE_DIR)visibility.h -CXXFLAGS += -fvisibility=$(DEFAULT_VISIBILITY) -include $(PX4_INCLUDE_DIR)visibility.h - -################################################################################ -# Build rules -################################################################################ - -# -# What we're going to build -# -module: $(MODULE_OBJ) $(MODULE_COMMAND_FILES) - -# -# Object files we will generate from sources -# -OBJS = $(addsuffix .o,$(SRCS)) - -# -# Dependency files that will be auto-generated -# -DEPS = $(addsuffix .d,$(SRCS)) - -# -# SRCS -> OBJS rules -# - -$(OBJS): $(GLOBAL_DEPS) - -vpath %.c $(MODULE_SRC) -$(filter %.c.o,$(OBJS)): %.c.o: %.c $(GLOBAL_DEPS) - $(call COMPILE,$<,$@) - -vpath %.cpp $(MODULE_SRC) -$(filter %.cpp.o,$(OBJS)): %.cpp.o: %.cpp $(GLOBAL_DEPS) - $(call COMPILEXX,$<,$@) - -vpath %.S $(MODULE_SRC) -$(filter %.S.o,$(OBJS)): %.S.o: %.S $(GLOBAL_DEPS) - $(call ASSEMBLE,$<,$@) - -# -# Built product rules -# - -$(MODULE_OBJ): $(OBJS) $(GLOBAL_DEPS) - $(call PRELINK,$@,$(OBJS)) - -# -# Utility rules -# - -clean: - $(Q) $(REMOVE) $(MODULE_PRELINK) $(OBJS) - --include $(DEPS) diff --git a/makefiles/nuttx/board_aerocore.mk b/makefiles/nuttx/board_aerocore.mk deleted file mode 100644 index 71a0f264d0..0000000000 --- a/makefiles/nuttx/board_aerocore.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Board-specific definitions for the Gumstix AeroCore -# - -# -# Configure the toolchain -# -CONFIG_ARCH = CORTEXM4F -CONFIG_BOARD = AEROCORE - -include $(PX4_MK_DIR)/nuttx/toolchain_gnu-arm-eabi.mk diff --git a/makefiles/nuttx/board_px4-stm32f4discovery.mk b/makefiles/nuttx/board_px4-stm32f4discovery.mk deleted file mode 100644 index 2477f55858..0000000000 --- a/makefiles/nuttx/board_px4-stm32f4discovery.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Board-specific definitions for the PX4_STM32F4DISCOVERY -# - -# -# Configure the toolchain -# -CONFIG_ARCH = CORTEXM4F -CONFIG_BOARD = PX4_STM32F4DISCOVERY - -include $(PX4_MK_DIR)/nuttx/toolchain_gnu-arm-eabi.mk diff --git a/makefiles/nuttx/board_px4fmu-v1.mk b/makefiles/nuttx/board_px4fmu-v1.mk deleted file mode 100644 index 45156efcdc..0000000000 --- a/makefiles/nuttx/board_px4fmu-v1.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Board-specific definitions for the PX4FMU -# - -# -# Configure the toolchain -# -CONFIG_ARCH = CORTEXM4F -CONFIG_BOARD = PX4FMU_V1 - -include $(PX4_MK_DIR)/nuttx/toolchain_gnu-arm-eabi.mk diff --git a/makefiles/nuttx/board_px4fmu-v2.mk b/makefiles/nuttx/board_px4fmu-v2.mk deleted file mode 100644 index 7c3e00c5d0..0000000000 --- a/makefiles/nuttx/board_px4fmu-v2.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Board-specific definitions for the PX4FMUv2 -# - -# -# Configure the toolchain -# -CONFIG_ARCH = CORTEXM4F -CONFIG_BOARD = PX4FMU_V2 - -include $(PX4_MK_DIR)/nuttx/toolchain_gnu-arm-eabi.mk diff --git a/makefiles/nuttx/board_px4io-v1.mk b/makefiles/nuttx/board_px4io-v1.mk deleted file mode 100644 index 66731a5694..0000000000 --- a/makefiles/nuttx/board_px4io-v1.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Board-specific definitions for the PX4IO -# - -# -# Configure the toolchain -# -CONFIG_ARCH = CORTEXM3 -CONFIG_BOARD = PX4IO_V1 - -include $(PX4_MK_DIR)/nuttx/toolchain_gnu-arm-eabi.mk diff --git a/makefiles/nuttx/board_px4io-v2.mk b/makefiles/nuttx/board_px4io-v2.mk deleted file mode 100644 index 94c3318199..0000000000 --- a/makefiles/nuttx/board_px4io-v2.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Board-specific definitions for the PX4IOv2 -# - -# -# Configure the toolchain -# -CONFIG_ARCH = CORTEXM3 -CONFIG_BOARD = PX4IO_V2 - -include $(PX4_MK_DIR)/nuttx/toolchain_gnu-arm-eabi.mk diff --git a/makefiles/nuttx/config_aerocore_default.mk b/makefiles/nuttx/config_aerocore_default.mk deleted file mode 100644 index ba6bcdccde..0000000000 --- a/makefiles/nuttx/config_aerocore_default.mk +++ /dev/null @@ -1,126 +0,0 @@ -# -# Makefile for the AeroCore *default* configuration -# - -# -# Use the configuration's ROMFS. -# -ROMFS_ROOT = $(PX4_BASE)/ROMFS/px4fmu_common - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/stm32 -MODULES += drivers/stm32/adc -MODULES += drivers/stm32/tone_alarm -MODULES += drivers/led -MODULES += drivers/px4fmu -MODULES += drivers/boards/aerocore -MODULES += drivers/lsm303d -MODULES += drivers/l3gd20 -MODULES += drivers/ms5611 -MODULES += drivers/gps -MODULES += drivers/pwm_out_sim -MODULES += modules/sensors - -# -# System commands -# -MODULES += systemcmds/ver -MODULES += systemcmds/mixer -MODULES += systemcmds/param -MODULES += systemcmds/perf -MODULES += systemcmds/pwm -MODULES += systemcmds/esc_calib -MODULES += systemcmds/reboot -MODULES += systemcmds/top -MODULES += systemcmds/config -MODULES += systemcmds/nshterm -MODULES += systemcmds/mtd -MODULES += systemcmds/dumpfile - -# -# General system control -# -MODULES += modules/commander -MODULES += modules/navigator -MODULES += modules/mavlink - -# -# Estimation modules (EKF / other filters) -# -# Too high RAM usage due to static allocations -#MODULES += modules/attitude_estimator_ekf -MODULES += modules/ekf_att_pos_estimator -MODULES += modules/attitude_estimator_q -MODULES += modules/position_estimator_inav - -# -# Vehicle Control -# -MODULES += modules/fw_pos_control_l1 -MODULES += modules/fw_att_control -MODULES += modules/mc_att_control -MODULES += modules/mc_pos_control - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/controllib -MODULES += modules/uORB -MODULES += modules/dataman - -# -# Libraries -# -LIBRARIES += lib/mathlib/CMSIS -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/ecl -MODULES += lib/external_lgpl -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion -MODULES += lib/launchdetection - -# -# Demo apps -# -#MODULES += examples/math_demo -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/hello_sky -MODULES += examples/px4_simple_app - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/daemon -#MODULES += examples/px4_daemon_app - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/debug_values -#MODULES += examples/px4_mavlink_debug - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/example_fixedwing_control -#MODULES += examples/fixedwing_control - -# Hardware test -#MODULES += examples/hwtest - -# -# Transitional support - add commands from the NuttX export archive. -# -# In general, these should move to modules over time. -# -# Each entry here is ... but we use a helper macro -# to make the table a bit more readable. -# -define _B - $(strip $1).$(or $(strip $2),SCHED_PRIORITY_DEFAULT).$(or $(strip $3),CONFIG_PTHREAD_STACK_DEFAULT).$(strip $4) -endef - -BUILTIN_COMMANDS := \ - $(call _B, hello, , 2048, hello_main) \ - $(call _B, i2c, , 2048, i2c_main) diff --git a/makefiles/nuttx/config_px4-stm32f4discovery_default.mk b/makefiles/nuttx/config_px4-stm32f4discovery_default.mk deleted file mode 100644 index 8f73a7f047..0000000000 --- a/makefiles/nuttx/config_px4-stm32f4discovery_default.mk +++ /dev/null @@ -1,92 +0,0 @@ -# -# Makefile for the px4fmu_default configuration -# - -# -# Use the configuration's ROMFS, copy the PX4_STM32F4DISCOVERY firmware into -# the ROMFS if it's available -# -ROMFS_ROOT = $(PX4_BASE)/ROMFS/px4fmu_common -ROMFS_OPTIONAL_FILES = - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/stm32 -MODULES += drivers/led -MODULES += drivers/boards/px4-stm32f4discovery - -# -# System commands -# -MODULES += systemcmds/bl_update -MODULES += systemcmds/mixer -MODULES += systemcmds/param -MODULES += systemcmds/perf -MODULES += systemcmds/reboot -MODULES += systemcmds/top -MODULES += systemcmds/tests -MODULES += systemcmds/config -MODULES += systemcmds/nshterm -MODULES += systemcmds/ver - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/controllib -MODULES += modules/uORB - -# -# Libraries -# -LIBRARIES += lib/mathlib/CMSIS -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/ecl -MODULES += lib/external_lgpl -MODULES += lib/geo -MODULES += lib/conversion -MODULES += platforms/nuttx - -# -# Demo apps -# -#MODULES += examples/math_demo -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/hello_sky -MODULES += examples/px4_simple_app - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/daemon -#MODULES += examples/px4_daemon_app - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/debug_values -#MODULES += examples/px4_mavlink_debug - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/example_fixedwing_control -#MODULES += examples/fixedwing_control - -# Hardware test -#MODULES += examples/hwtest - -# -# Transitional support - add commands from the NuttX export archive. -# -# In general, these should move to modules over time. -# -# Each entry here is ... but we use a helper macro -# to make the table a bit more readable. -# -define _B - $(strip $1).$(or $(strip $2),SCHED_PRIORITY_DEFAULT).$(or $(strip $3),CONFIG_PTHREAD_STACK_DEFAULT).$(strip $4) -endef - -# command priority stack entrypoint -BUILTIN_COMMANDS := \ - $(call _B, sercon, , 2048, sercon_main ) \ - $(call _B, serdis, , 2048, serdis_main ) diff --git a/makefiles/nuttx/config_px4fmu-v1_default.mk b/makefiles/nuttx/config_px4fmu-v1_default.mk deleted file mode 100644 index d7915ee8d0..0000000000 --- a/makefiles/nuttx/config_px4fmu-v1_default.mk +++ /dev/null @@ -1,159 +0,0 @@ -# -# Makefile for the px4fmu_default configuration -# - -# -# Use the configuration's ROMFS. -# -ROMFS_ROOT = $(PX4_BASE)/ROMFS/px4fmu_common -ROMFS_OPTIONAL_FILES = $(PX4_BASE)/Images/px4io-v1_default.bin - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/stm32 -MODULES += drivers/stm32/adc -MODULES += drivers/stm32/tone_alarm -MODULES += drivers/led -MODULES += drivers/px4io -MODULES += drivers/px4fmu -MODULES += drivers/boards/px4fmu-v1 -MODULES += drivers/ardrone_interface -MODULES += drivers/l3gd20 -MODULES += drivers/mpu6000 -MODULES += drivers/hmc5883 -MODULES += drivers/ms5611 -MODULES += drivers/ll40ls -MODULES += drivers/trone -MODULES += drivers/mb12xx -MODULES += drivers/gps -MODULES += drivers/pwm_out_sim -MODULES += drivers/blinkm -MODULES += drivers/rgbled -MODULES += drivers/mkblctrl -MODULES += drivers/airspeed -MODULES += drivers/ets_airspeed -MODULES += drivers/meas_airspeed -MODULES += drivers/frsky_telemetry -MODULES += modules/sensors -MODULES += drivers/px4flow - -# -# System commands -# -MODULES += systemcmds/mtd -MODULES += systemcmds/mixer -MODULES += systemcmds/param -MODULES += systemcmds/perf -MODULES += systemcmds/pwm -MODULES += systemcmds/esc_calib -MODULES += systemcmds/reboot -MODULES += systemcmds/top -MODULES += systemcmds/config -MODULES += systemcmds/nshterm -MODULES += systemcmds/dumpfile -MODULES += systemcmds/ver - -# -# General system control -# -MODULES += modules/commander -MODULES += modules/navigator -MODULES += modules/mavlink -MODULES += modules/gpio_led -MODULES += modules/land_detector - -# -# Estimation modules (EKF / other filters) -# -# Too high RAM usage due to static allocations -#MODULES += modules/attitude_estimator_ekf -MODULES += modules/ekf_att_pos_estimator -MODULES += modules/attitude_estimator_q -MODULES += modules/position_estimator_inav - -# -# Vehicle Control -# -MODULES += modules/fw_pos_control_l1 -MODULES += modules/fw_att_control -MODULES += modules/mc_att_control -MODULES += modules/mc_pos_control - -# -# Logging -# -MODULES += modules/sdlog2 - -# -# Unit tests -# -#MODULES += modules/unit_test -#MODULES += modules/commander/commander_tests - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/controllib -MODULES += modules/uORB -MODULES += modules/dataman - -# -# Libraries -# -LIBRARIES += lib/mathlib/CMSIS -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/ecl -MODULES += lib/external_lgpl -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion -MODULES += lib/launchdetection -MODULES += platforms/nuttx - -# -# Demo apps -# -#MODULES += examples/math_demo -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/hello_sky -#MODULES += examples/px4_simple_app - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/daemon -#MODULES += examples/px4_daemon_app - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/debug_values -#MODULES += examples/px4_mavlink_debug - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/example_fixedwing_control -#MODULES += examples/fixedwing_control - -# Hardware test -#MODULES += examples/hwtest - -# Generate parameter XML file -GEN_PARAM_XML = 1 - -# -# Transitional support - add commands from the NuttX export archive. -# -# In general, these should move to modules over time. -# -# Each entry here is ... but we use a helper macro -# to make the table a bit more readable. -# -define _B - $(strip $1).$(or $(strip $2),SCHED_PRIORITY_DEFAULT).$(or $(strip $3),CONFIG_PTHREAD_STACK_DEFAULT).$(strip $4) -endef - -# command priority stack entrypoint -BUILTIN_COMMANDS := \ - $(call _B, sercon, , 2048, sercon_main ) \ - $(call _B, serdis, , 2048, serdis_main ) diff --git a/makefiles/nuttx/config_px4fmu-v2_default.mk b/makefiles/nuttx/config_px4fmu-v2_default.mk deleted file mode 100644 index 8d16e538a0..0000000000 --- a/makefiles/nuttx/config_px4fmu-v2_default.mk +++ /dev/null @@ -1,182 +0,0 @@ -# -# Makefile for the px4fmu_default configuration -# - -# -# Use the configuration's ROMFS, copy the px4iov2 firmware into -# the ROMFS if it's available -# -ROMFS_ROOT = $(PX4_BASE)/ROMFS/px4fmu_common -ROMFS_OPTIONAL_FILES = $(PX4_BASE)/Images/px4io-v2_default.bin - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/stm32 -MODULES += drivers/stm32/adc -MODULES += drivers/stm32/tone_alarm -MODULES += drivers/led -MODULES += drivers/px4fmu -MODULES += drivers/px4io -MODULES += drivers/boards/px4fmu-v2 -MODULES += drivers/rgbled -MODULES += drivers/mpu6000 -MODULES += drivers/mpu9250 -MODULES += drivers/lsm303d -MODULES += drivers/l3gd20 -MODULES += drivers/hmc5883 -MODULES += drivers/ms5611 -MODULES += drivers/mb12xx -MODULES += drivers/sf0x -MODULES += drivers/ll40ls -MODULES += drivers/trone -MODULES += drivers/gps -MODULES += drivers/pwm_out_sim -MODULES += drivers/hott -MODULES += drivers/hott/hott_telemetry -MODULES += drivers/hott/hott_sensors -MODULES += drivers/blinkm -MODULES += drivers/airspeed -MODULES += drivers/ets_airspeed -MODULES += drivers/meas_airspeed -MODULES += drivers/frsky_telemetry -MODULES += modules/sensors -MODULES += drivers/mkblctrl -MODULES += drivers/px4flow -MODULES += drivers/oreoled -MODULES += drivers/gimbal -MODULES += drivers/pwm_input -MODULES += drivers/camera_trigger - -# -# System commands -# -MODULES += systemcmds/bl_update -MODULES += systemcmds/mixer -MODULES += systemcmds/param -MODULES += systemcmds/perf -MODULES += systemcmds/pwm -MODULES += systemcmds/esc_calib -MODULES += systemcmds/reboot -MODULES += systemcmds/top -MODULES += systemcmds/config -MODULES += systemcmds/nshterm -MODULES += systemcmds/mtd -MODULES += systemcmds/dumpfile -MODULES += systemcmds/ver - -# -# General system control -# -MODULES += modules/commander -MODULES += modules/navigator -MODULES += modules/mavlink -MODULES += modules/gpio_led -MODULES += modules/uavcan -MODULES += modules/land_detector - -# -# Estimation modules (EKF/ SO3 / other filters) -# -# Removed from build due to large static allocations -#MODULES += modules/attitude_estimator_ekf -MODULES += modules/attitude_estimator_q -MODULES += modules/ekf_att_pos_estimator -MODULES += modules/position_estimator_inav - -# -# Vehicle Control -# -#MODULES += modules/segway # XXX Needs GCC 4.7 fix -MODULES += modules/fw_pos_control_l1 -MODULES += modules/fw_att_control -MODULES += modules/mc_att_control -MODULES += modules/mc_pos_control -MODULES += modules/vtol_att_control - -# -# Logging -# -MODULES += modules/sdlog2 - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/controllib -MODULES += modules/uORB -MODULES += modules/dataman - -# -# Libraries -# -LIBRARIES += lib/mathlib/CMSIS -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/ecl -MODULES += lib/external_lgpl -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion -MODULES += lib/launchdetection -MODULES += platforms/nuttx - -# -# OBC challenge -# -MODULES += modules/bottle_drop - -# -# PX4 flow estimator, good for indoors -# -MODULES += examples/flow_position_estimator - -# -# Rover apps -# -MODULES += examples/rover_steering_control - -# -# Demo apps -# -#MODULES += examples/math_demo -# Tutorial code from -# https://px4.io/dev/px4_simple_app -#MODULES += examples/px4_simple_app - -# Tutorial code from -# https://px4.io/dev/daemon -#MODULES += examples/px4_daemon_app - -# Tutorial code from -# https://px4.io/dev/debug_values -#MODULES += examples/px4_mavlink_debug - -# Tutorial code from -# https://px4.io/dev/example_fixedwing_control -#MODULES += examples/fixedwing_control - -# Hardware test -#MODULES += examples/hwtest - -# Generate parameter XML file -GEN_PARAM_XML = 1 - -# -# Transitional support - add commands from the NuttX export archive. -# -# In general, these should move to modules over time. -# -# Each entry here is ... but we use a helper macro -# to make the table a bit more readable. -# -define _B - $(strip $1).$(or $(strip $2),SCHED_PRIORITY_DEFAULT).$(or $(strip $3),CONFIG_PTHREAD_STACK_DEFAULT).$(strip $4) -endef - -# command priority stack entrypoint -BUILTIN_COMMANDS := \ - $(call _B, sercon, , 2048, sercon_main ) \ - $(call _B, serdis, , 2048, serdis_main ) diff --git a/makefiles/nuttx/config_px4fmu-v2_multiplatform.mk b/makefiles/nuttx/config_px4fmu-v2_multiplatform.mk deleted file mode 100644 index 41fc34023f..0000000000 --- a/makefiles/nuttx/config_px4fmu-v2_multiplatform.mk +++ /dev/null @@ -1,168 +0,0 @@ -# -# Makefile for the px4fmu_default configuration -# - -# -# Use the configuration's ROMFS, copy the px4iov2 firmware into -# the ROMFS if it's available -# -ROMFS_ROOT = $(PX4_BASE)/ROMFS/px4fmu_common -ROMFS_OPTIONAL_FILES = $(PX4_BASE)/Images/px4io-v2_default.bin - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/stm32 -MODULES += drivers/stm32/adc -MODULES += drivers/stm32/tone_alarm -MODULES += drivers/led -MODULES += drivers/px4fmu -MODULES += drivers/px4io -MODULES += drivers/boards/px4fmu-v2 -MODULES += drivers/rgbled -MODULES += drivers/mpu6000 -MODULES += drivers/lsm303d -MODULES += drivers/l3gd20 -MODULES += drivers/hmc5883 -MODULES += drivers/ms5611 -MODULES += drivers/mb12xx -# MODULES += drivers/sf0x -MODULES += drivers/ll40ls -# MODULES += drivers/trone -MODULES += drivers/gps -MODULES += drivers/pwm_out_sim -MODULES += drivers/hott -MODULES += drivers/hott/hott_telemetry -MODULES += drivers/hott/hott_sensors -# MODULES += drivers/blinkm -MODULES += drivers/airspeed -MODULES += drivers/ets_airspeed -MODULES += drivers/meas_airspeed -MODULES += drivers/frsky_telemetry -MODULES += modules/sensors -MODULES += drivers/mkblctrl -MODULES += drivers/px4flow - -# -# System commands -# -MODULES += systemcmds/bl_update -MODULES += systemcmds/mixer -MODULES += systemcmds/param -MODULES += systemcmds/perf -MODULES += systemcmds/pwm -MODULES += systemcmds/esc_calib -MODULES += systemcmds/reboot -MODULES += systemcmds/top -MODULES += systemcmds/config -MODULES += systemcmds/nshterm -MODULES += systemcmds/mtd -MODULES += systemcmds/dumpfile -MODULES += systemcmds/ver - -# -# General system control -# -MODULES += modules/commander -MODULES += modules/navigator -MODULES += modules/mavlink -MODULES += modules/gpio_led -# MODULES += modules/uavcan - -# -# Estimation modules (EKF/ SO3 / other filters) -# -MODULES += modules/attitude_estimator_ekf -MODULES += modules/ekf_att_pos_estimator -MODULES += modules/position_estimator_inav - -# -# Vehicle Control -# -#MODULES += modules/segway # XXX Needs GCC 4.7 fix -#MODULES += modules/fw_pos_control_l1 -#MODULES += modules/fw_att_control -# MODULES += modules/mc_att_control -MODULES += modules/mc_att_control_multiplatform -MODULES += examples/subscriber -MODULES += examples/publisher -# MODULES += modules/mc_pos_control -MODULES += modules/mc_pos_control_multiplatform -MODULES += modules/vtol_att_control - -# -# Logging -# -MODULES += modules/sdlog2 - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/controllib -MODULES += modules/uORB -MODULES += modules/dataman - -# -# Libraries -# -LIBRARIES += lib/mathlib/CMSIS -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/ecl -MODULES += lib/external_lgpl -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion -MODULES += lib/launchdetection -MODULES += platforms/nuttx - -# -# OBC challenge -# -MODULES += modules/bottle_drop - -# -# Demo apps -# -#MODULES += examples/math_demo -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/hello_sky -#MODULES += examples/px4_simple_app - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/daemon -#MODULES += examples/px4_daemon_app - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/debug_values -#MODULES += examples/px4_mavlink_debug - -# Tutorial code from -# https://pixhawk.ethz.ch/px4/dev/example_fixedwing_control -#MODULES += examples/fixedwing_control - -# Hardware test -#MODULES += examples/hwtest - -# Generate parameter XML file -GEN_PARAM_XML = 1 - -# -# Transitional support - add commands from the NuttX export archive. -# -# In general, these should move to modules over time. -# -# Each entry here is ... but we use a helper macro -# to make the table a bit more readable. -# -define _B - $(strip $1).$(or $(strip $2),SCHED_PRIORITY_DEFAULT).$(or $(strip $3),CONFIG_PTHREAD_STACK_DEFAULT).$(strip $4) -endef - -# command priority stack entrypoint -BUILTIN_COMMANDS := \ - $(call _B, sercon, , 2048, sercon_main ) \ - $(call _B, serdis, , 2048, serdis_main ) diff --git a/makefiles/nuttx/config_px4fmu-v2_test.mk b/makefiles/nuttx/config_px4fmu-v2_test.mk deleted file mode 100644 index 9c8510e06d..0000000000 --- a/makefiles/nuttx/config_px4fmu-v2_test.mk +++ /dev/null @@ -1,116 +0,0 @@ -# -# Makefile for the px4fmu_default configuration -# - -# -# Use the configuration's ROMFS. -# -ROMFS_ROOT = $(PX4_BASE)/ROMFS/px4fmu_test -ROMFS_OPTIONAL_FILES = $(PX4_BASE)/Images/px4io-v2_default.bin - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/stm32 -MODULES += drivers/stm32/adc -MODULES += drivers/stm32/tone_alarm -MODULES += drivers/led -MODULES += drivers/boards/px4fmu-v2 -MODULES += drivers/px4io -MODULES += drivers/rgbled -MODULES += drivers/mpu6000 -MODULES += drivers/lsm303d -MODULES += drivers/l3gd20 -MODULES += drivers/hmc5883 -MODULES += drivers/ms5611 -MODULES += drivers/pca8574 -MODULES += drivers/roboclaw -MODULES += drivers/airspeed -MODULES += drivers/ets_airspeed -MODULES += drivers/meas_airspeed -MODULES += systemcmds/perf -MODULES += systemcmds/reboot -MODULES += systemcmds/tests -MODULES += systemcmds/nshterm -MODULES += systemcmds/mtd -MODULES += systemcmds/ver -MODULES += systemcmds/top -MODULES += modules/sensors - -# -# System commands -# -MODULES += systemcmds/bl_update -MODULES += systemcmds/mixer -MODULES += systemcmds/param -MODULES += systemcmds/perf -MODULES += systemcmds/pwm -MODULES += systemcmds/esc_calib -MODULES += systemcmds/reboot -MODULES += systemcmds/top -MODULES += systemcmds/config -MODULES += systemcmds/nshterm -MODULES += systemcmds/mtd -MODULES += systemcmds/dumpfile -MODULES += systemcmds/ver - -# -# Example modules -# -MODULES += examples/matlab_csv_serial -MODULES += examples/subscriber -MODULES += examples/publisher - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/uORB -LIBRARIES += lib/mathlib/CMSIS -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/conversion -MODULES += platforms/nuttx - -# -# Example modules to test-build -# -MODULES += examples/flow_position_estimator -MODULES += examples/fixedwing_control -MODULES += examples/hwtest -MODULES += examples/matlab_csv_serial -MODULES += examples/px4_daemon_app -MODULES += examples/px4_mavlink_debug -MODULES += examples/px4_simple_app - -# -# Drivers / modules to test build, but not useful for test environment -# -MODULES += drivers/pca8574 - -# -# Tests -# - -MODULES += modules/unit_test -MODULES += modules/mavlink/mavlink_tests -MODULES += modules/commander/commander_tests - -# -# Transitional support - add commands from the NuttX export archive. -# -# In general, these should move to modules over time. -# -# Each entry here is ... but we use a helper macro -# to make the table a bit more readable. -# -define _B - $(strip $1).$(or $(strip $2),SCHED_PRIORITY_DEFAULT).$(or $(strip $3),CONFIG_PTHREAD_STACK_DEFAULT).$(strip $4) -endef - -# command priority stack entrypoint -BUILTIN_COMMANDS := \ - $(call _B, sercon, , 2048, sercon_main ) \ - $(call _B, serdis, , 2048, serdis_main ) diff --git a/makefiles/nuttx/config_px4io-v1_default.mk b/makefiles/nuttx/config_px4io-v1_default.mk deleted file mode 100644 index 73f8adf202..0000000000 --- a/makefiles/nuttx/config_px4io-v1_default.mk +++ /dev/null @@ -1,10 +0,0 @@ -# -# Makefile for the px4io_default configuration -# - -# -# Board support modules -# -MODULES += drivers/stm32 -MODULES += drivers/boards/px4io-v1 -MODULES += modules/px4iofirmware \ No newline at end of file diff --git a/makefiles/nuttx/config_px4io-v2_default.mk b/makefiles/nuttx/config_px4io-v2_default.mk deleted file mode 100644 index dbeaba3d37..0000000000 --- a/makefiles/nuttx/config_px4io-v2_default.mk +++ /dev/null @@ -1,10 +0,0 @@ -# -# Makefile for the px4iov2_default configuration -# - -# -# Board support modules -# -MODULES += drivers/stm32 -MODULES += drivers/boards/px4io-v2 -MODULES += modules/px4iofirmware \ No newline at end of file diff --git a/makefiles/nuttx/firmware_nuttx.mk b/makefiles/nuttx/firmware_nuttx.mk deleted file mode 100644 index ca4831b8bd..0000000000 --- a/makefiles/nuttx/firmware_nuttx.mk +++ /dev/null @@ -1,121 +0,0 @@ -# -# Built products -# -DESIRED_FIRMWARES = $(foreach config,$(CONFIGS),$(IMAGE_DIR)$(config).px4) -STAGED_FIRMWARES = $(foreach config,$(KNOWN_CONFIGS),$(IMAGE_DIR)$(config).px4) -FIRMWARES = $(foreach config,$(KNOWN_CONFIGS),$(BUILD_DIR)$(config).build/firmware.px4) - -all: $(DESIRED_FIRMWARES) - -# -# Copy FIRMWARES into the image directory. -# -# XXX copying the .bin files is a hack to work around the PX4IO uploader -# not supporting .px4 files, and it should be deprecated onced that -# is taken care of. -# -$(STAGED_FIRMWARES): $(IMAGE_DIR)%.px4: $(BUILD_DIR)%.build/firmware.px4 - @$(ECHO) %% Copying $@ - $(Q) $(COPY) $< $@ - $(Q) $(COPY) $(patsubst %.px4,%.bin,$<) $(patsubst %.px4,%.bin,$@) - -# -# Generate FIRMWARES. -# -.PHONY: $(FIRMWARES) -$(BUILD_DIR)%.build/firmware.px4: config = $(patsubst $(BUILD_DIR)%.build/firmware.px4,%,$@) -$(BUILD_DIR)%.build/firmware.px4: work_dir = $(BUILD_DIR)$(config).build/ -$(FIRMWARES): $(BUILD_DIR)%.build/firmware.px4: checkgitversion generateuorbtopicheaders checksubmodules - @$(ECHO) %%%% - @$(ECHO) %%%% Building $(config) in $(work_dir) - @$(ECHO) %%%% - $(Q) $(MKDIR) -p $(work_dir) - $(Q) $(MAKE) -r --no-print-directory -C $(work_dir) \ - -f $(PX4_MK_DIR)firmware.mk \ - CONFIG=$(config) \ - WORK_DIR=$(work_dir) \ - $(FIRMWARE_GOAL) - -# -# Make FMU firmwares depend on the corresponding IO firmware. -# -# This is a pretty vile hack, since it hard-codes knowledge of the FMU->IO dependency -# and forces the _default config in all cases. There has to be a better way to do this... -# -FMU_VERSION = $(patsubst px4fmu-%,%,$(word 1, $(subst _, ,$(1)))) -define FMU_DEP -$(BUILD_DIR)$(1).build/firmware.px4: $(IMAGE_DIR)px4io-$(call FMU_VERSION,$(1))_default.px4 -endef -FMU_CONFIGS := $(filter px4fmu%,$(CONFIGS)) -$(foreach config,$(FMU_CONFIGS),$(eval $(call FMU_DEP,$(config)))) - -# -# Build the NuttX export archives. -# -# Note that there are no explicit dependencies extended from these -# archives. If NuttX is updated, the user is expected to rebuild the -# archives/build area manually. Likewise, when the 'archives' target is -# invoked, all archives are always rebuilt. -# -# XXX Should support fetching/unpacking from a separate directory to permit -# downloads of the prebuilt archives as well... -# -NUTTX_ARCHIVES = $(foreach board,$(BOARDS),$(ARCHIVE_DIR)$(board).export) -.PHONY: archives -archives: checksubmodules $(NUTTX_ARCHIVES) - -# We cannot build these parallel; note that we also force -j1 for the -# sub-make invocations. -ifneq ($(filter archives,$(MAKECMDGOALS)),) -.NOTPARALLEL: -endif - -J?=1 - -$(ARCHIVE_DIR)%.export: board = $(notdir $(basename $@)) -$(ARCHIVE_DIR)%.export: configuration = nsh -$(NUTTX_ARCHIVES): $(ARCHIVE_DIR)%.export: $(NUTTX_SRC) - @$(ECHO) %% Configuring NuttX for $(board) - $(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export) - $(Q) $(MAKE) -r -j$(J) --no-print-directory -C $(NUTTX_SRC) -r $(MQUIET) distclean - $(Q) (cd $(NUTTX_SRC)/configs && $(COPYDIR) $(PX4_BASE)nuttx-configs/$(board) .) - $(Q) (cd $(NUTTX_SRC)tools && ./configure.sh $(board)/$(configuration)) - @$(ECHO) %% Exporting NuttX for $(board) - $(Q) $(MAKE) -r -j$(J) --no-print-directory -C $(NUTTX_SRC) -r $(MQUIET) CONFIG_ARCH_BOARD=$(board) export - $(Q) $(MKDIR) -p $(dir $@) - $(Q) $(COPY) $(NUTTX_SRC)nuttx-export.zip $@ - $(Q) (cd $(NUTTX_SRC)/configs && $(RMDIR) $(board)) - -# -# The user can run the NuttX 'menuconfig' tool for a single board configuration with -# make BOARDS= menuconfig -# -ifeq ($(MAKECMDGOALS),menuconfig) -ifneq ($(words $(BOARDS)),1) -$(error BOARDS must specify exactly one board for the menuconfig goal) -endif -BOARD = $(BOARDS) -menuconfig: $(NUTTX_SRC) - @$(ECHO) %% Configuring NuttX for $(BOARD) - $(Q) (cd $(NUTTX_SRC) && $(RMDIR) nuttx-export) - $(Q) $(MAKE) -r -j$(J) --no-print-directory -C $(NUTTX_SRC) -r $(MQUIET) distclean - $(Q) (cd $(NUTTX_SRC)/configs && $(COPYDIR) $(PX4_BASE)nuttx-configs/$(BOARD) .) - $(Q) (cd $(NUTTX_SRC)tools && ./configure.sh $(BOARD)/nsh) - @$(ECHO) %% Running menuconfig for $(BOARD) - $(Q) $(MAKE) -r -j$(J) --no-print-directory -C $(NUTTX_SRC) -r $(MQUIET) oldconfig - $(Q) $(MAKE) -r -j$(J) --no-print-directory -C $(NUTTX_SRC) -r $(MQUIET) menuconfig - @$(ECHO) %% Saving configuration file - $(Q)$(COPY) $(NUTTX_SRC).config $(PX4_BASE)nuttx-configs/$(BOARD)/nsh/defconfig -else -menuconfig: - @$(ECHO) "" - @$(ECHO) "The menuconfig goal must be invoked without any other goal being specified" - @$(ECHO) "" - -endif - -$(NUTTX_SRC): checkgitversion checksubmodules - -$(UAVCAN_DIR): - $(Q) (./Tools/check_submodules.sh) - diff --git a/makefiles/nuttx/gumstix-aerocore.cfg b/makefiles/nuttx/gumstix-aerocore.cfg deleted file mode 100644 index ba217c0431..0000000000 --- a/makefiles/nuttx/gumstix-aerocore.cfg +++ /dev/null @@ -1,10 +0,0 @@ -# JTAG for the STM32F4x chip used on the Gumstix AeroCore is available on -# the first interface of a Quad FTDI chip. nTRST is bit 4. -interface ftdi -ftdi_vid_pid 0x0403 0x6011 - -ftdi_layout_init 0x0000 0x001b -ftdi_layout_signal nTRST -data 0x0010 - -source [find target/stm32f4x.cfg] -reset_config trst_only diff --git a/makefiles/nuttx/nuttx.mk b/makefiles/nuttx/nuttx.mk deleted file mode 100644 index 4ca1dc2ac6..0000000000 --- a/makefiles/nuttx/nuttx.mk +++ /dev/null @@ -1,85 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Rules and definitions related to handling the NuttX export archives when -# building firmware. -# - -MODULES += platforms/nuttx/px4_layer platforms/common - -# -# Check that the NuttX archive for the selected board is available. -# -NUTTX_ARCHIVE := $(wildcard $(ARCHIVE_DIR)$(BOARD).export) -ifeq ($(NUTTX_ARCHIVE),) -$(error The NuttX export archive for $(BOARD) is missing from $(ARCHIVE_DIR) - try 'make archives' in $(PX4_BASE)) -endif - -# -# The NuttX config header should always be present in the NuttX archive, and -# if it changes, everything should be rebuilt. So, use it as the trigger to -# unpack the NuttX archive. -# -NUTTX_EXPORT_DIR = $(WORK_DIR)nuttx-export/ -NUTTX_CONFIG_HEADER = $(NUTTX_EXPORT_DIR)include/nuttx/config.h -$(info % NUTTX_EXPORT_DIR = $(NUTTX_EXPORT_DIR)) -$(info % NUTTX_CONFIG_HEADER = $(NUTTX_CONFIG_HEADER)) - - -GLOBAL_DEPS += $(NUTTX_CONFIG_HEADER) - -# -# Use the linker script from the NuttX export -# -LDSCRIPT += $(NUTTX_EXPORT_DIR)build/ld.script - -# -# Add directories from the NuttX export to the relevant search paths -# -INCLUDE_DIRS += $(NUTTX_EXPORT_DIR)include \ - $(NUTTX_EXPORT_DIR)include/cxx \ - $(NUTTX_EXPORT_DIR)arch/chip \ - $(NUTTX_EXPORT_DIR)arch/common - -LIB_DIRS += $(NUTTX_EXPORT_DIR)libs -LIBS += -lapps -lnuttx -NUTTX_LIBS = $(NUTTX_EXPORT_DIR)libs/libapps.a \ - $(NUTTX_EXPORT_DIR)libs/libnuttx.a -LINK_DEPS += $(NUTTX_LIBS) - -$(NUTTX_CONFIG_HEADER): $(NUTTX_ARCHIVE) - @$(ECHO) %% Unpacking $(NUTTX_ARCHIVE) - $(Q) $(UNZIP_CMD) -q -o -d $(WORK_DIR) $(NUTTX_ARCHIVE) - $(Q) $(TOUCH) $@ - - $(LDSCRIPT): $(NUTTX_CONFIG_HEADER) - $(NUTTX_LIBS): $(NUTTX_CONFIG_HEADER) diff --git a/makefiles/nuttx/nuttx_px4.mk b/makefiles/nuttx/nuttx_px4.mk deleted file mode 100644 index 11e50e03ae..0000000000 --- a/makefiles/nuttx/nuttx_px4.mk +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# What we're going to build. -# -PRODUCT_BUNDLE = $(WORK_DIR)firmware.px4 -PRODUCT_BIN = $(WORK_DIR)firmware.bin -PRODUCT_ELF = $(WORK_DIR)firmware.elf -PRODUCT_PARAMXML = $(WORK_DIR)/parameters.xml -PRODUCT_AIRFRAMEXML = $(WORK_DIR)/airframes.xml - -.PHONY: firmware -firmware: $(PRODUCT_BUNDLE) - -# -# Built product rules -# - -$(PRODUCT_BUNDLE): $(PRODUCT_BIN) - @$(ECHO) %% Generating $@ -ifdef GEN_PARAM_XML - $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_params.py --src-path $(PX4_BASE)/src --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml - $(Q) $(PYTHON) $(PX4_BASE)/Tools/px_process_airframes.py -a $(PX4_BASE)/ROMFS/px4fmu_common/init.d/ --board CONFIG_ARCH_BOARD_$(CONFIG_BOARD) --xml - $(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \ - --git_identity $(PX4_BASE) \ - --parameter_xml $(PRODUCT_PARAMXML) \ - --airframe_xml $(PRODUCT_AIRFRAMEXML) \ - --image $< > $@ -else - $(Q) $(MKFW) --prototype $(IMAGE_DIR)/$(BOARD).prototype \ - --git_identity $(PX4_BASE) \ - --image $< > $@ -endif - -$(PRODUCT_BIN): $(PRODUCT_ELF) - $(call SYM_TO_BIN,$<,$@) - -$(PRODUCT_ELF): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES) - $(call LINK,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS)) - -# -# Utility rules -# - -.PHONY: upload -upload: $(PRODUCT_BUNDLE) $(PRODUCT_BIN) - $(Q) $(MAKE) -f $(PX4_MK_DIR)/nuttx/upload.mk \ - METHOD=serial \ - CONFIG=$(CONFIG) \ - BOARD=$(BOARD) \ - BUNDLE=$(PRODUCT_BUNDLE) \ - BIN=$(PRODUCT_BIN) - -.PHONY: clean -clean: $(MODULE_CLEANS) - @$(ECHO) %% cleaning - $(Q) $(REMOVE) $(PRODUCT_BUNDLE) $(PRODUCT_BIN) $(PRODUCT_ELF) - $(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS) - $(Q) $(RMDIR) $(NUTTX_EXPORT_DIR) - diff --git a/makefiles/nuttx/nuttx_romfs.mk b/makefiles/nuttx/nuttx_romfs.mk deleted file mode 100644 index 9554151360..0000000000 --- a/makefiles/nuttx/nuttx_romfs.mk +++ /dev/null @@ -1,163 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -################################################################################ -# ROMFS generation -################################################################################ - -ifneq ($(ROMFS_ROOT),) -ifeq ($(wildcard $(ROMFS_ROOT)),) -$(error ROMFS_ROOT specifies a directory that does not exist) -endif - -# -# Note that there is no support for more than one root directory or constructing -# a root from several templates. That would be a nice feature. -# - -# Add dependencies on anything in the ROMFS root directory -ROMFS_FILES += $(wildcard \ - $(ROMFS_ROOT)/* \ - $(ROMFS_ROOT)/*/* \ - $(ROMFS_ROOT)/*/*/* \ - $(ROMFS_ROOT)/*/*/*/* \ - $(ROMFS_ROOT)/*/*/*/*/* \ - $(ROMFS_ROOT)/*/*/*/*/*/*) -ifeq ($(ROMFS_FILES),) -$(error ROMFS_ROOT $(ROMFS_ROOT) specifies a directory containing no files) -endif -ROMFS_DEPS += $(ROMFS_FILES) - -# Extra files that may be copied into the ROMFS /extras directory -# ROMFS_EXTRA_FILES are required, ROMFS_OPTIONAL_FILES are optional -ROMFS_EXTRA_FILES += $(wildcard $(ROMFS_OPTIONAL_FILES)) -ROMFS_DEPS += $(ROMFS_EXTRA_FILES) - -ROMFS_IMG = romfs.img -ROMFS_SCRATCH = romfs_scratch -ROMFS_CSRC = $(ROMFS_IMG:.img=.c) -ROMFS_OBJ = $(ROMFS_CSRC:.c=.o) -LIBS += $(ROMFS_OBJ) -LINK_DEPS += $(ROMFS_OBJ) - -# Add autostart script -ROMFS_AUTOSTART = $(PX4_BASE)/Tools/px_process_airframes.py - -# Remove all comments from startup and mixer files -ROMFS_PRUNER = $(PX4_BASE)/Tools/px_romfs_pruner.py - -# Turn the ROMFS image into an object file -$(ROMFS_OBJ): $(ROMFS_IMG) $(GLOBAL_DEPS) - $(call BIN_TO_OBJ,$<,$@,romfs_img) - -# Generate the ROMFS image from the root -$(ROMFS_IMG): $(ROMFS_SCRATCH) $(ROMFS_DEPS) $(GLOBAL_DEPS) - @$(ECHO) "ROMFS: $@" - $(Q) $(GENROMFS) -f $@ -d $(ROMFS_SCRATCH) -V "NSHInitVol" - -# Construct the ROMFS scratch root from the canonical root -$(ROMFS_SCRATCH): $(ROMFS_DEPS) $(GLOBAL_DEPS) - $(Q) $(MKDIR) -p $(ROMFS_SCRATCH) - $(Q) $(COPYDIR) $(ROMFS_ROOT)/* $(ROMFS_SCRATCH) -# delete all files in ROMFS_SCRATCH which start with a . or end with a ~ - $(Q) $(RM) $(ROMFS_SCRATCH)/*/.[!.]* $(ROMFS_SCRATCH)/*/*~ -ifneq ($(ROMFS_EXTRA_FILES),) - $(Q) $(MKDIR) -p $(ROMFS_SCRATCH)/extras - $(Q) $(COPY) $(ROMFS_EXTRA_FILES) $(ROMFS_SCRATCH)/extras -endif - $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d/ -s $(ROMFS_SCRATCH)/init.d/rc.autostart - # Execute in standard dir as well - # so developers notice the generated file - $(Q) $(PYTHON) -u $(ROMFS_AUTOSTART) -a $(ROMFS_ROOT)/init.d/ -s $(ROMFS_ROOT)/init.d/rc.autostart - $(Q) $(PYTHON) -u $(ROMFS_PRUNER) --folder $(ROMFS_SCRATCH) - -EXTRA_CLEANS += $(ROMGS_OBJ) $(ROMFS_IMG) - -endif - -################################################################################ -# Builtin command list generation -################################################################################ - -# -# Builtin commands can be generated by the configuration, in which case they -# must refer to commands that already exist, or indirectly generated by modules -# when they are built. -# -# The configuration supplies builtin command information in the BUILTIN_COMMANDS -# variable. Applications make empty files in $(WORK_DIR)/builtin_commands whose -# filename contains the same information. -# -# In each case, the command information consists of four fields separated with a -# period. These fields are the command's name, its thread priority, its stack size -# and the name of the function to call when starting the thread. -# -BUILTIN_CSRC = $(WORK_DIR)builtin_commands.c - -# command definitions from modules (may be empty at Makefile parsing time...) -MODULE_COMMANDS = $(subst COMMAND.,,$(notdir $(wildcard $(WORK_DIR)builtin_commands/COMMAND.*))) - -# We must have at least one pre-defined builtin command in order to generate -# any of this. -# -ifneq ($(BUILTIN_COMMANDS),) - -# (BUILTIN_PROTO,,) -define BUILTIN_PROTO - $(ECHO) 'extern int $(word 4,$1)(int argc, char *argv[]);' >> $2; -endef - -# (BUILTIN_DEF,,) -define BUILTIN_DEF - $(ECHO) ' {"$(word 1,$1)", $(word 2,$1), $(word 3,$1), $(word 4,$1)},' >> $2; -endef - -# Don't generate until modules have updated their command files -$(BUILTIN_CSRC): $(GLOBAL_DEPS) $(MODULE_OBJS) $(MODULE_MKFILES) $(BUILTIN_COMMAND_FILES) - @$(ECHO) "CMDS: $@" - $(Q) $(ECHO) '/* builtin command list - automatically generated, do not edit */' > $@ - $(Q) $(ECHO) '#include ' >> $@ - $(Q) $(ECHO) '#include ' >> $@ - $(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@)) - $(Q) $(foreach spec,$(MODULE_COMMANDS),$(call BUILTIN_PROTO,$(subst ., ,$(spec)),$@)) - $(Q) $(ECHO) 'const struct builtin_s g_builtins[] = {' >> $@ - $(Q) $(foreach spec,$(BUILTIN_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@)) - $(Q) $(foreach spec,$(MODULE_COMMANDS),$(call BUILTIN_DEF,$(subst ., ,$(spec)),$@)) - $(Q) $(ECHO) ' {NULL, 0, 0, NULL}' >> $@ - $(Q) $(ECHO) '};' >> $@ - $(Q) $(ECHO) 'const int g_builtin_count = $(words $(BUILTIN_COMMANDS) $(MODULE_COMMANDS));' >> $@ - -SRCS += $(BUILTIN_CSRC) - -EXTRA_CLEANS += $(BUILTIN_CSRC) - -endif - diff --git a/makefiles/nuttx/toolchain_gnu-arm-eabi.mk b/makefiles/nuttx/toolchain_gnu-arm-eabi.mk deleted file mode 100644 index 868c3d161e..0000000000 --- a/makefiles/nuttx/toolchain_gnu-arm-eabi.mk +++ /dev/null @@ -1,342 +0,0 @@ -# -# Copyright (C) 2012-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Definitions for a generic GNU ARM-EABI toolchain -# - -#$(info TOOLCHAIN gnu-arm-eabi) - -# Toolchain commands. Normally only used inside this file. -# -CROSSDEV = arm-none-eabi- - -CC = $(CROSSDEV)gcc -CXX = $(CROSSDEV)g++ -CPP = $(CROSSDEV)gcc -E -LD = $(CROSSDEV)ld -AR = $(CROSSDEV)ar rcs -NM = $(CROSSDEV)nm -OBJCOPY = $(CROSSDEV)objcopy -OBJDUMP = $(CROSSDEV)objdump - -# Check if the right version of the toolchain is available -# -CROSSDEV_VER_SUPPORTED = 4.7.4 4.7.5 4.7.6 4.8.4 4.9.3 -CROSSDEV_VER_FOUND = $(shell $(CC) -dumpversion) - -ifeq (,$(findstring $(CROSSDEV_VER_FOUND), $(CROSSDEV_VER_SUPPORTED))) -$(error Unsupported version of $(CC), found: $(CROSSDEV_VER_FOUND) instead of one in: $(CROSSDEV_VER_SUPPORTED)) -endif - - -# XXX this is pulled pretty directly from the fmu Make.defs - needs cleanup - -MAXOPTIMIZATION ?= -O3 - -# Base CPU flags for each of the supported architectures. -# -ARCHCPUFLAGS_CORTEXM4F = -mcpu=cortex-m4 \ - -mthumb \ - -march=armv7e-m \ - -mfpu=fpv4-sp-d16 \ - -mfloat-abi=hard - -ARCHCPUFLAGS_CORTEXM4 = -mcpu=cortex-m4 \ - -mthumb \ - -march=armv7e-m \ - -mfloat-abi=soft - -ARCHCPUFLAGS_CORTEXM3 = -mcpu=cortex-m3 \ - -mthumb \ - -march=armv7-m \ - -mfloat-abi=soft - -# Enabling stack checks if OS was build with them -# -TEST_FILE_STACKCHECK=$(WORK_DIR)nuttx-export/include/nuttx/config.h -TEST_VALUE_STACKCHECK=CONFIG_ARMV7M_STACKCHECK\ 1 -ENABLE_STACK_CHECKS=$(shell $(GREP) -q "$(TEST_VALUE_STACKCHECK)" $(TEST_FILE_STACKCHECK); echo $$?;) -ifeq ("$(ENABLE_STACK_CHECKS)","0") -ARCHINSTRUMENTATIONDEFINES_CORTEXM4F = -finstrument-functions -ffixed-r10 -ARCHINSTRUMENTATIONDEFINES_CORTEXM4 = -finstrument-functions -ffixed-r10 -ARCHINSTRUMENTATIONDEFINES_CORTEXM3 = -else -ARCHINSTRUMENTATIONDEFINES_CORTEXM4F = -ARCHINSTRUMENTATIONDEFINES_CORTEXM4 = -ARCHINSTRUMENTATIONDEFINES_CORTEXM3 = -endif - -# Pick the right set of flags for the architecture. -# -ARCHCPUFLAGS = $(ARCHCPUFLAGS_$(CONFIG_ARCH)) -ifeq ($(ARCHCPUFLAGS),) -$(error Must set CONFIG_ARCH to one of CORTEXM4F, CORTEXM4 or CORTEXM3) -endif - -# Set the board flags -# -ifeq ($(CONFIG_BOARD),) -$(error Board config does not define CONFIG_BOARD) -endif -ARCHDEFINES += -DCONFIG_ARCH_BOARD_$(CONFIG_BOARD) -D__PX4_NUTTX - -# optimisation flags -# -ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \ - -g3 \ - -fno-strict-aliasing \ - -fno-strength-reduce \ - -fomit-frame-pointer \ - -funsafe-math-optimizations \ - -fno-builtin-printf \ - -ffunction-sections \ - -fdata-sections - -# enable precise stack overflow tracking -# note - requires corresponding support in NuttX -INSTRUMENTATIONDEFINES = $(ARCHINSTRUMENTATIONDEFINES_$(CONFIG_ARCH)) - -LIBC := $(shell ${CC} ${ARCHCPUFLAGS} -print-file-name=libc.a) - -# Language-specific flags -# -ARCHCFLAGS = -std=gnu99 -ARCHCXXFLAGS = -fno-exceptions -fno-rtti -std=gnu++0x -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ - -# -# Provide defaults, but allow for module override -WFRAME_LARGER_THAN ?= 1024 - - - -# Generic warnings -# -ARCHWARNINGS = -Wall \ - -Wextra \ - -Werror \ - -Wdouble-promotion \ - -Wshadow \ - -Wfloat-equal \ - -Wpointer-arith \ - -Wmissing-declarations \ - -Wpacked \ - -Wno-unused-parameter \ - -Werror=format-security \ - -Werror=array-bounds \ - -Wfatal-errors \ - -Wformat=1 \ - -Werror=unused-but-set-variable \ - -Werror=unused-variable \ - -Werror=double-promotion \ - -Werror=reorder \ - -Werror=uninitialized \ - -Werror=init-self -# -Werror=float-conversion - works, just needs to be phased in with some effort and needs GCC 4.9+ -# -Wcast-qual - generates spurious noreturn attribute warnings, try again later -# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code -# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives - -# C-specific warnings -# -ARCHCWARNINGS = $(ARCHWARNINGS) \ - -Wbad-function-cast \ - -Wstrict-prototypes \ - -Wold-style-declaration \ - -Wmissing-parameter-type \ - -Wmissing-prototypes \ - -Wnested-externs - -# C++-specific warnings -# -ARCHWARNINGSXX = $(ARCHWARNINGS) \ - -Wno-missing-field-initializers - -# pull in *just* libm from the toolchain ... this is grody -LIBM := $(shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a) -EXTRA_LIBS += $(LIBM) - -# Flags we pass to the C compiler -# -CFLAGS = $(ARCHCFLAGS) \ - $(ARCHCWARNINGS) \ - $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) \ - $(ARCHINCLUDES) \ - $(INSTRUMENTATIONDEFINES) \ - $(ARCHDEFINES) \ - $(EXTRADEFINES) \ - $(EXTRACFLAGS) \ - -fno-common \ - $(addprefix -I,$(INCLUDE_DIRS)) - -# Flags we pass to the C++ compiler -# -CXXFLAGS = $(ARCHCXXFLAGS) \ - $(ARCHWARNINGSXX) \ - $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) \ - $(ARCHXXINCLUDES) \ - $(INSTRUMENTATIONDEFINES) \ - $(ARCHDEFINES) \ - -DCONFIG_WCHAR_BUILTIN \ - $(EXTRADEFINES) \ - $(EXTRACXXFLAGS) \ - $(addprefix -I,$(INCLUDE_DIRS)) - -# Flags we pass to the assembler -# -AFLAGS = $(CFLAGS) -D__ASSEMBLY__ \ - $(EXTRADEFINES) \ - $(EXTRAAFLAGS) - -# Flags we pass to the linker -# -LDFLAGS += --warn-common \ - --gc-sections \ - $(EXTRALDFLAGS) \ - $(addprefix -T,$(LDSCRIPT)) \ - $(addprefix -L,$(LIB_DIRS)) - -# Compiler support library -# -LIBGCC := $(shell $(CC) $(ARCHCPUFLAGS) -print-libgcc-file-name) - -# Files that the final link depends on -# -LINK_DEPS += $(LDSCRIPT) - -# Files to include to get automated dependencies -# -DEP_INCLUDES = $(subst .o,.d,$(OBJS)) - -# Compile C source $1 to object $2 -# as a side-effect, generate a dependency file -# -define COMPILE - @$(ECHO) "CC: $1" - @$(MKDIR) -p $(dir $2) - $(Q) $(CCACHE) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2 -endef - -# Compile C++ source $1 to $2 -# as a side-effect, generate a dependency file -# -define COMPILEXX - @$(ECHO) "CXX: $1" - @$(MKDIR) -p $(dir $2) - $(Q) $(CCACHE) $(CXX) -MD -c $(CXXFLAGS) $(abspath $1) -o $2 -endef - -# Assemble $1 into $2 -# -define ASSEMBLE - @$(ECHO) "AS: $1" - @$(MKDIR) -p $(dir $2) - $(Q) $(CC) -c $(AFLAGS) $(abspath $1) -o $2 -endef - -# Produce partially-linked $1 from files in $2 -# -define PRELINK - @$(ECHO) "PRELINK: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(LD) -Ur -Map $1.map -o $1 $2 && $(OBJCOPY) --localize-hidden $1 -endef - -# Update the archive $1 with the files in $2 -# -define ARCHIVE - @$(ECHO) "AR: $2" - @$(MKDIR) -p $(dir $1) - $(Q) $(AR) $1 $2 -endef - -# Link the objects in $2 into the binary $1 -# -define LINK - @$(ECHO) "LINK: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(LD) $(LDFLAGS) -Map $1.map -o $1 --start-group $2 $(LIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group -endef - -# Convert $1 from a linked object to a raw binary in $2 -# -define SYM_TO_BIN - @$(ECHO) "BIN: $2" - @$(MKDIR) -p $(dir $2) - $(Q) $(OBJCOPY) -O binary $1 $2 -endef - -# Take the raw binary $1 and make it into an object file $2. -# The symbol $3 points to the beginning of the file, and $3_len -# gives its length. -# -# - compile an empty file to generate a suitable object file -# - relink the object and insert the binary file -# - extract the length -# - create const unsigned $3_len with the extracted length as its value and compile it to an object file -# - link the two generated object files together -# - edit symbol names to suit -# -# NOTE: exercise caution using this with absolute pathnames; it looks -# like the MinGW tools insert an extra _ in the binary symbol name; e.g. -# the path: -# -# /d/px4/firmware/Build/px4fmu_default.build/romfs.img -# -# is assigned symbols like: -# -# _binary_d__px4_firmware_Build_px4fmu_default_build_romfs_img_size -# -# when we would expect -# -# _binary__d_px4_firmware_Build_px4fmu_default_build_romfs_img_size -# -define BIN_SYM_PREFIX - _binary_$(subst /,_,$(subst .,_,$1)) -endef -define BIN_TO_OBJ - @$(ECHO) "OBJ: $2" - @$(MKDIR) -p $(dir $2) - $(Q) $(ECHO) > $2.c - $(call COMPILE,$2.c,$2.c.o) - $(Q) $(LD) -r -o $2.bin.o $2.c.o -b binary $1 - $(Q) $(ECHO) "const unsigned int $3_len = 0x`$(NM) -p --radix=x $2.bin.o | $(GREP) $(call BIN_SYM_PREFIX,$1)_size$$ | $(GREP) -o ^[0-9a-fA-F]*`;" > $2.c - $(call COMPILE,$2.c,$2.c.o) - $(Q) $(LD) -r -o $2 $2.c.o $2.bin.o - $(Q) $(OBJCOPY) $2 \ - --redefine-sym $(call BIN_SYM_PREFIX,$1)_start=$3 \ - --strip-symbol $(call BIN_SYM_PREFIX,$1)_size \ - --strip-symbol $(call BIN_SYM_PREFIX,$1)_end \ - --rename-section .data=.rodata - $(Q) $(REMOVE) $2.c $2.c.o $2.bin.o -endef diff --git a/makefiles/nuttx/upload.mk b/makefiles/nuttx/upload.mk deleted file mode 100644 index e73c31dc31..0000000000 --- a/makefiles/nuttx/upload.mk +++ /dev/null @@ -1,50 +0,0 @@ -# -# Rules and tools for uploading firmware to various PX4 boards. -# - -UPLOADER = $(PX4_BASE)/Tools/px_uploader.py - -SYSTYPE := $(shell uname -s) - -# -# Serial port defaults. -# -# XXX The uploader should be smarter than this. -# -ifeq ($(SYSTYPE),Darwin) -SERIAL_PORTS ?= "/dev/tty.usbmodemPX*,/dev/tty.usbmodem*" -endif -ifeq ($(SYSTYPE),Linux) -SERIAL_PORTS ?= "/dev/serial/by-id/usb-3D_Robotics*,/dev/serial/by-id/pci-3D_Robotics*" -endif -ifeq ($(SERIAL_PORTS),) -SERIAL_PORTS = "COM32,COM31,COM30,COM29,COM28,COM27,COM26,COM25,COM24,COM23,COM22,COM21,COM20,COM19,COM18,COM17,COM16,COM15,COM14,COM13,COM12,COM11,COM10,COM9,COM8,COM7,COM6,COM5,COM4,COM3,COM2,COM1,COM0" -endif - -.PHONY: all upload-$(METHOD)-$(BOARD) -all: upload-$(METHOD)-$(BOARD) - -upload-serial-px4fmu-v1: $(BUNDLE) $(UPLOADER) - $(Q) $(PYTHON) -u $(UPLOADER) --port $(SERIAL_PORTS) $(BUNDLE) - -upload-serial-px4fmu-v2: $(BUNDLE) $(UPLOADER) - $(Q) $(PYTHON) -u $(UPLOADER) --port $(SERIAL_PORTS) $(BUNDLE) - -upload-serial-aerocore: - openocd -f $(PX4_BASE)/makefiles/nuttx/gumstix-aerocore.cfg -c 'init; reset halt; flash write_image erase $(PX4_BASE)/../Bootloader/px4aerocore_bl.bin 0x08000000; flash write_image erase $(PX4_BASE)/Build/aerocore_default.build/firmware.bin 0x08004000; reset run; exit' - -upload-serial-px4-stm32f4discovery: $(BUNDLE) $(UPLOADER) - $(Q) $(PYTHON) -u $(UPLOADER) --port $(SERIAL_PORTS) $(BUNDLE) - -# -# JTAG firmware uploading with OpenOCD -# -JTAGCONFIG ?= interface/olimex-jtag-tiny.cfg - -upload-jtag-px4fmu: all - @$(ECHO) Attempting to flash PX4FMU board via JTAG - $(Q) $(OPENOCD) -f $(JTAGCONFIG) -f ../Bootloader/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx/nuttx" -c "flash write_image erase ../Bootloader/px4fmu_bl.elf" -c "reset run" -c shutdown - -upload-jtag-px4io: all - @$(ECHO) Attempting to flash PX4IO board via JTAG - $(Q) $(OPENOCD) -f $(JTAGCONFIG) -f ../Bootloader/stm32f1x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx/nuttx" -c "flash write_image erase ../Bootloader/px4io_bl.elf" -c "reset run" -c shutdown diff --git a/makefiles/posix-arm/board_eagle.mk b/makefiles/posix-arm/board_eagle.mk deleted file mode 100644 index 94dd049367..0000000000 --- a/makefiles/posix-arm/board_eagle.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Board-specific definitions for the POSIX port of PX4 -# - -# -# Configure the toolchain -# -CONFIG_ARCH = CORTEXA8 -CONFIG_BOARD = EAGLE - -include $(PX4_MK_DIR)/posix-arm/toolchain_gnu-arm-linux-gnueabihf.mk diff --git a/makefiles/posix-arm/config_eagle_adsp.mk b/makefiles/posix-arm/config_eagle_adsp.mk deleted file mode 100644 index e7e0d8cf6f..0000000000 --- a/makefiles/posix-arm/config_eagle_adsp.mk +++ /dev/null @@ -1,57 +0,0 @@ -# -# Makefile for the EAGLE *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device - -# -# System commands -# -MODULES += systemcmds/param -MODULES += systemcmds/ver - -# -# General system control -# -MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# - -# -# Vehicle Control -# - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/uORB -MODULES += modules/dataman - -# -# Libraries -# -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion -# -# Linux port -# -MODULES += platforms/posix/px4_layer -MODULES += platforms/posix/work_queue - -# -# Unit tests -# - -# -# muorb fastrpc changes. -# -MODULES += modules/muorb/krait diff --git a/makefiles/posix-arm/config_eagle_default.mk b/makefiles/posix-arm/config_eagle_default.mk deleted file mode 100644 index 1f335522cd..0000000000 --- a/makefiles/posix-arm/config_eagle_default.mk +++ /dev/null @@ -1,79 +0,0 @@ -# -# Makefile for the EAGLE *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/blinkm -MODULES += drivers/pwm_out_sim -MODULES += drivers/rgbled -MODULES += drivers/led -MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -MODULES += systemcmds/param -MODULES += systemcmds/mixer -MODULES += systemcmds/ver -#MODULES += systemcmds/topic_listener - -# -# General system control -# -MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -MODULES += modules/attitude_estimator_ekf -MODULES += modules/ekf_att_pos_estimator - -# -# Vehicle Control -# -#MODULES += modules/navigator -MODULES += modules/mc_pos_control -MODULES += modules/mc_att_control - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/uORB -MODULES += modules/dataman -MODULES += modules/sdlog2 -MODULES += modules/simulator -MODULES += modules/commander -MODULES += modules/controllib - -# -# Libraries -# -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion -# -# Linux port -# -MODULES += platforms/posix/px4_layer -MODULES += platforms/posix/work_queue - -# -# Unit tests -# -#MODULES += platforms/posix/tests/hello -#MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue - -# -# muorb fastrpc changes. -# -#MODULES += $(PX4_BASE)../muorb_krait diff --git a/makefiles/posix-arm/config_eagle_hil.mk b/makefiles/posix-arm/config_eagle_hil.mk deleted file mode 100644 index 522549d05b..0000000000 --- a/makefiles/posix-arm/config_eagle_hil.mk +++ /dev/null @@ -1,88 +0,0 @@ -# -# Makefile for the POSIXTEST *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/boards/sitl -#MODULES += drivers/blinkm -#MODULES += drivers/pwm_out_sim -#MODULES += drivers/rgbled -MODULES += drivers/led -#MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -MODULES += systemcmds/param -#MODULES += systemcmds/mixer -#MODULES += systemcmds/topic_listener -MODULES += systemcmds/ver - -# -# General system control -# -MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -#MODULES += modules/attitude_estimator_ekf -#MODULES += modules/ekf_att_pos_estimator - -# -# Vehicle Control -# -#MODULES += modules/navigator -#MODULES += modules/mc_pos_control -#MODULES += modules/mc_att_control - -# -# Library modules -# -MODULES += modules/systemlib -#MODULES += modules/systemlib/mixer -MODULES += modules/uORB -MODULES += modules/dataman -MODULES += modules/sdlog2 -MODULES += modules/simulator -MODULES += modules/commander -#MODULES += modules/controllib - -# -# Libraries -# -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion - -# -# Linux port -# -MODULES += platforms/posix/px4_layer -MODULES += platforms/posix/work_queue -#MODULES += platforms/posix/drivers/accelsim -#MODULES += platforms/posix/drivers/gyrosim -#MODULES += platforms/posix/drivers/adcsim -#MODULES += platforms/posix/drivers/barosim -#MODULES += platforms/posix/drivers/tonealrmsim -#MODULES += platforms/posix/drivers/airspeedsim -#MODULES += platforms/posix/drivers/gpssim - -# -# Unit tests -# -#MODULES += platforms/posix/tests/hello -#MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue - -# -# muorb fastrpc changes. -# -MODULES += modules/muorb/krait diff --git a/makefiles/posix-arm/config_eagle_muorb_test.mk b/makefiles/posix-arm/config_eagle_muorb_test.mk deleted file mode 100644 index bb87cd35fb..0000000000 --- a/makefiles/posix-arm/config_eagle_muorb_test.mk +++ /dev/null @@ -1,90 +0,0 @@ -# -# Makefile for the POSIXTEST *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -#MODULES += drivers/blinkm -#MODULES += drivers/pwm_out_sim -#MODULES += drivers/rgbled -#MODULES += drivers/led -#MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -#MODULES += systemcmds/param -#MODULES += systemcmds/mixer -#MODULES += systemcmds/topic_listener - -# -# General system control -# -#MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -#MODULES += modules/attitude_estimator_ekf -#MODULES += modules/ekf_att_pos_estimator - -# -# Vehicle Control -# -#MODULES += modules/navigator -#MODULES += modules/mc_pos_control -#MODULES += modules/mc_att_control - -# -# Library modules -# -#MODULES += modules/systemlib -#MODULES += modules/systemlib/mixer -MODULES += modules/uORB -#MODULES += modules/dataman -#MODULES += modules/sdlog2 -#MODULES += modules/simulator -#MODULES += modules/commander -#MODULES += modules/controllib - -# -# Libraries -# -#MODULES += lib/mathlib -#MODULES += lib/mathlib/math/filter -#MODULES += lib/geo -#MODULES += lib/geo_lookup -#MODULES += lib/conversion - -# -# Linux port -# -MODULES += platforms/posix/px4_layer -MODULES += platforms/posix/work_queue -#MODULES += platforms/posix/drivers/accelsim -#MODULES += platforms/posix/drivers/gyrosim -#MODULES += platforms/posix/drivers/adcsim -#MODULES += platforms/posix/drivers/barosim -#MODULES += platforms/posix/drivers/tonealrmsim -#MODULES += platforms/posix/drivers/airspeedsim -#MODULES += platforms/posix/drivers/gpssim - -# -# muorb fastrpc changes. -# -MODULES += modules/muorb/krait - - -# -# -# Unit tests -# -#MODULES += platforms/posix/tests/hello -#MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue -MODULES += platforms/posix/tests/muorb - diff --git a/makefiles/posix-arm/posix-arm.mk b/makefiles/posix-arm/posix-arm.mk deleted file mode 100644 index 13cb97f0db..0000000000 --- a/makefiles/posix-arm/posix-arm.mk +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Rules and definitions related to handling the Linux specific impl when -# building firmware. -# - -MODULES += \ - platforms/common \ - platforms/posix/px4_layer - diff --git a/makefiles/posix-arm/toolchain_gnu-arm-linux-gnueabihf.mk b/makefiles/posix-arm/toolchain_gnu-arm-linux-gnueabihf.mk deleted file mode 100644 index 4eb3b0fd19..0000000000 --- a/makefiles/posix-arm/toolchain_gnu-arm-linux-gnueabihf.mk +++ /dev/null @@ -1,305 +0,0 @@ -# -# Copyright (C) 2012-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Definitions for a generic GNU ARM-EABI toolchain -# - -#$(info TOOLCHAIN arm-linux-gnueabihf) - -# Toolchain commands. Normally only used inside this file. -# -CROSSDEV = arm-linux-gnueabihf- - -CC ?= $(CROSSDEV)gcc -CXX ?= $(CROSSDEV)g++ -CPP ?= $(CROSSDEV)gcc -E -LD ?= $(CROSSDEV)ld -AR ?= $(CROSSDEV)ar rcs -NM ?= $(CROSSDEV)nm -OBJCOPY ?= $(CROSSDEV)objcopy -OBJDUMP ?= $(CROSSDEV)objdump -ifdef OECORE_NATIVE_SYSROOT -AR := $(AR) rcs -endif - -# Check if the right version of the toolchain is available -# -CROSSDEV_VER_SUPPORTED = 4.7.4 4.7.5 4.7.6 4.8.2 4.8.4 4.9.3 -CROSSDEV_VER_FOUND = $(shell $(CC) -dumpversion) - -ifeq (,$(findstring $(CROSSDEV_VER_FOUND), $(CROSSDEV_VER_SUPPORTED))) -$(error Unsupported version of $(CC), found: $(CROSSDEV_VER_FOUND) instead of one in: $(CROSSDEV_VER_SUPPORTED)) -endif - -ifndef POSIX_EXT_LIB_ROOT -$(error POSIX_EXT_LIB_ROOT is not set) -endif - -# XXX this is pulled pretty directly from the fmu Make.defs - needs cleanup - -MAXOPTIMIZATION ?= -O3 - -# Base CPU flags for each of the supported architectures. -# -ARCHCPUFLAGS_CORTEXA8 = -mtune=cortex-a8 \ - -mthumb-interwork \ - -march=armv7-a \ - -mfloat-abi=hard \ - -mfpu=neon - -# Pick the right set of flags for the architecture. -# -ARCHCPUFLAGS = $(ARCHCPUFLAGS_$(CONFIG_ARCH)) -ifeq ($(ARCHCPUFLAGS),) -$(error Must set CONFIG_ARCH to one of CORTEXA8 CORTEXM4F, CORTEXM4 or CORTEXM3) -endif - -# Set the board flags -# -ifeq ($(CONFIG_BOARD),) -$(error Board config does not define CONFIG_BOARD) -endif -ARCHDEFINES += -DCONFIG_ARCH_BOARD_$(CONFIG_BOARD) \ - -D__PX4_LINUX -D__PX4_POSIX \ - -Dnoreturn_function= \ - -I$(PX4_BASE)/src/modules/systemlib \ - -I$(PX4_BASE)/src/lib/eigen \ - -I$(PX4_BASE)/src/platforms/posix/include \ - -I$(PX4_BASE)/mavlink/include/mavlink \ - -Wno-error=shadow - -# optimisation flags -# -ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \ - -g3 \ - -fno-strict-aliasing \ - -fomit-frame-pointer \ - -funsafe-math-optimizations \ - -fno-builtin-printf \ - -ffunction-sections \ - -fdata-sections - -# Language-specific flags -# -ARCHCFLAGS = -std=gnu99 -ARCHCXXFLAGS = -fno-exceptions -fno-rtti -std=c++0x -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ - -# Generic warnings -# -ARCHWARNINGS = -Wall \ - -Wextra \ - -Werror \ - -Wfloat-equal \ - -Wpointer-arith \ - -Wmissing-declarations \ - -Wpacked \ - -Wno-unused-parameter \ - -Wno-packed \ - -Werror=format-security \ - -Werror=array-bounds \ - -Wfatal-errors \ - -Werror=unused-variable \ - -Werror=reorder \ - -Werror=uninitialized \ - -Werror=init-self \ - -Wformat=1 \ - -Werror=unused-but-set-variable \ - -Wno-error=double-promotion \ - -fno-strength-reduce \ - -Wno-error=unused-value - -ARCHOPTIMIZATION += -fno-strength-reduce - -# -Werror=float-conversion - works, just needs to be phased in with some effort and needs GCC 4.9+ -# -Wcast-qual - generates spurious noreturn attribute warnings, try again later -# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code -# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives - -# C-specific warnings -# -ARCHCWARNINGS = $(ARCHWARNINGS) \ - -Wbad-function-cast \ - -Wstrict-prototypes \ - -Wmissing-prototypes \ - -Wnested-externs - -# C++-specific warnings -# -ARCHWARNINGSXX = $(ARCHWARNINGS) \ - -Wno-missing-field-initializers - -# pull in *just* libm from the toolchain ... this is grody -LIBM := $(shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a) -#EXTRA_LIBS += $(LIBM) -EXTRA_LIBS += -lpx4muorb -ladsprpc -EXTRA_LIBS += -pthread -lm -lrt - -LIB_DIRS += $(POSIX_EXT_LIB_ROOT)/libs -INCLUDE_DIRS += $(POSIX_EXT_LIB_ROOT)/inc - -# Flags we pass to the C compiler -# -CFLAGS = $(ARCHCFLAGS) \ - $(ARCHCWARNINGS) \ - $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) \ - $(ARCHINCLUDES) \ - $(INSTRUMENTATIONDEFINES) \ - $(ARCHDEFINES) \ - $(EXTRADEFINES) \ - $(EXTRACFLAGS) \ - -fno-common \ - $(addprefix -I,$(INCLUDE_DIRS)) - -# Flags we pass to the C++ compiler -# -CXXFLAGS = $(ARCHCXXFLAGS) \ - $(ARCHWARNINGSXX) \ - $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) \ - $(ARCHXXINCLUDES) \ - $(INSTRUMENTATIONDEFINES) \ - $(ARCHDEFINES) \ - -DCONFIG_WCHAR_BUILTIN \ - $(EXTRADEFINES) \ - $(EXTRACXXFLAGS) \ - -Wno-effc++ \ - $(addprefix -I,$(INCLUDE_DIRS)) - -# Flags we pass to the assembler -# -AFLAGS = $(CFLAGS) -D__ASSEMBLY__ \ - $(EXTRADEFINES) \ - $(EXTRAAFLAGS) - -LDSCRIPT = $(PX4_BASE)/makefiles/posix-arm/ld.script -# Flags we pass to the linker -# -LDFLAGS += $(EXTRALDFLAGS) \ - $(addprefix -L,$(LIB_DIRS)) - -# Compiler support library -# -LIBGCC := $(shell $(CC) $(ARCHCPUFLAGS) -print-libgcc-file-name) - -# Files that the final link depends on -# -#LINK_DEPS += $(LDSCRIPT) -LINK_DEPS += - -# Files to include to get automated dependencies -# -DEP_INCLUDES = $(subst .o,.d,$(OBJS)) - -# Compile C source $1 to object $2 -# as a side-effect, generate a dependency file -# -define COMPILE - @$(ECHO) "CC: $1" - @$(MKDIR) -p $(dir $2) - $(Q) $(CCACHE) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2 -endef - -# Compile C++ source $1 to $2 -# as a side-effect, generate a dependency file -# -define COMPILEXX - @$(ECHO) "CXX: $1" - @$(MKDIR) -p $(dir $2) - @echo $(Q) $(CCACHE) $(CXX) -MD -c $(CXXFLAGS) $(abspath $1) -o $2 - $(Q) $(CCACHE) $(CXX) -MD -c $(CXXFLAGS) $(abspath $1) -o $2 -endef - -# Assemble $1 into $2 -# -define ASSEMBLE - @$(ECHO) "AS: $1" - @$(MKDIR) -p $(dir $2) - $(Q) $(CC) -c $(AFLAGS) $(abspath $1) -o $2 -endef - -# Produce partially-linked $1 from files in $2 -# -#$(Q) $(LD) -Ur -o $1 $2 # -Ur not supported in ld.gold -define PRELINK - @$(ECHO) "PRELINK: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(LD) -Ur -o $1 $2 - -endef -# Produce partially-linked $1 from files in $2 -# -#$(Q) $(LD) -Ur -o $1 $2 # -Ur not supported in ld.gold -define PRELINKF - @$(ECHO) "PRELINK: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(LD) -Ur -T$(LDSCRIPT) -o $1 $2 - -endef -# $(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1 - -# Update the archive $1 with the files in $2 -# -define ARCHIVE - @$(ECHO) "AR: $2" - @$(MKDIR) -p $(dir $1) - $(Q) $(AR) $1 $2 -endef - -# Link the objects in $2 into the shared library $1 -# -define LINK_A - @$(ECHO) "LINK_A: $1" - @$(MKDIR) -p $(dir $1) - echo "$(Q) $(AR) $1 $2" - $(Q) $(AR) $1 $2 -endef - -# Link the objects in $2 into the shared library $1 -# -define LINK_SO - @$(ECHO) "LINK_SO: $1" - @$(MKDIR) -p $(dir $1) - echo "$(Q) $(CXX) $(LDFLAGS) -shared -Wl,-soname,`basename $1`.1 -o $1 $2 $(LIBS) $(EXTRA_LIBS)" - $(Q) $(CXX) $(LDFLAGS) -shared -Wl,-soname,`basename $1`.1 -o $1 $2 $(LIBS) -pthread -lc -endef - -# Link the objects in $2 into the application $1 -# -define LINK - @$(ECHO) "LINK: $1" - @$(MKDIR) -p $(dir $1) - echo "$(Q) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $1 $2 $(LIBS) $(EXTRA_LIBS) $(LIBGCC)" - $(Q) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $1 $2 $(LIBS) $(EXTRA_LIBS) $(LIBGCC) - -endef - diff --git a/makefiles/posix/DISABLE_config_posix_muorb_test.mk b/makefiles/posix/DISABLE_config_posix_muorb_test.mk deleted file mode 100644 index 5f0074e2ba..0000000000 --- a/makefiles/posix/DISABLE_config_posix_muorb_test.mk +++ /dev/null @@ -1,78 +0,0 @@ -# -# Makefile for the Foo *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -#MODULES += drivers/blinkm -#MODULES += drivers/pwm_out_sim -#MODULES += drivers/led -#MODULES += drivers/rgbled -#MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -MODULES += systemcmds/param - -# -# General system control -# -#MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -#MODULES += modules/attitude_estimator_ekf -#MODULES += modules/ekf_att_pos_estimator - -# -# Vehicle Control -# -#MODULES += modules/mc_att_control - -# -# Library modules -# -MODULES += modules/systemlib -#MODULES += modules/systemlib/mixer -MODULES += modules/uORB -#MODULES += modules/dataman -#MODULES += modules/sdlog2 -#MODULES += modules/simulator -#MODULES += modules/commander - -# -# Libraries -# -#MODULES += lib/mathlib -#MODULES += lib/mathlib/math/filter -#MODULES += lib/geo -#MODULES += lib/geo_lookup -#MODULES += lib/conversion - -# -# posix port -# -MODULES += platforms/posix/px4_layer -#MODULES += platforms/posix/drivers/accelsim -#MODULES += platforms/posix/drivers/gyrosim -#MODULES += platforms/posix/drivers/adcsim -#MODULES += platforms/posix/drivers/barosim - -# -# muorb fastrpc changes. -# -#MODULES += $(PX4_BASE)../muorb_krait - -# -# Unit tests -# -MODULES += platforms/posix/tests/muorb -#MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue - diff --git a/makefiles/posix/board_posix.mk b/makefiles/posix/board_posix.mk deleted file mode 100644 index 4e8c9e9f58..0000000000 --- a/makefiles/posix/board_posix.mk +++ /dev/null @@ -1,12 +0,0 @@ -# -# Board-specific definitions for the POSIX port of PX4 -# for use in SITL testing -# - -# -# Configure the toolchain -# -CONFIG_ARCH = NATIVE -CONFIG_BOARD = SITL - -include $(PX4_MK_DIR)/posix/toolchain_native.mk diff --git a/makefiles/posix/config_posix_sitl.mk b/makefiles/posix/config_posix_sitl.mk deleted file mode 100644 index b745d0e263..0000000000 --- a/makefiles/posix/config_posix_sitl.mk +++ /dev/null @@ -1,107 +0,0 @@ -# -# Makefile for the SITL configuration -# - -# -# Board support modules -# -MODULES += drivers/boards/sitl -MODULES += drivers/device -MODULES += drivers/blinkm -MODULES += drivers/pwm_out_sim -MODULES += drivers/rgbled -MODULES += drivers/led -MODULES += modules/sensors -MODULES += drivers/ms5611 - -# -# System commands -# -MODULES += systemcmds/param -MODULES += systemcmds/mixer -#MODULES += systemcmds/esc_calib -MODULES += systemcmds/tests -#MODULES += systemcmds/reboot -MODULES += systemcmds/topic_listener -MODULES += systemcmds/ver -MODULES += systemcmds/esc_calib -MODULES += systemcmds/reboot - -# -# General system control -# -MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -MODULES += modules/attitude_estimator_ekf -MODULES += modules/attitude_estimator_q -MODULES += modules/ekf_att_pos_estimator -MODULES += modules/attitude_estimator_q -MODULES += modules/position_estimator_inav - -# -# Vehicle Control -# -MODULES += modules/navigator -MODULES += modules/mc_pos_control -MODULES += modules/mc_att_control -MODULES += modules/mc_pos_control_multiplatform -MODULES += modules/mc_att_control_multiplatform -MODULES += modules/land_detector -MODULES += modules/fw_att_control -MODULES += modules/fw_pos_control_l1 - - - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/uORB -MODULES += modules/dataman -MODULES += modules/sdlog2 -MODULES += modules/simulator -MODULES += modules/commander -MODULES += modules/controllib - -# -# Libraries -# -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/ecl -MODULES += lib/external_lgpl -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion -MODULES += lib/launchdetection - - -# -# POSIX port -# -MODULES += platforms/posix/px4_layer -MODULES += platforms/posix/work_queue -MODULES += platforms/posix/drivers/accelsim -MODULES += platforms/posix/drivers/gyrosim -MODULES += platforms/posix/drivers/adcsim -MODULES += platforms/posix/drivers/barosim -MODULES += platforms/posix/drivers/tonealrmsim -MODULES += platforms/posix/drivers/airspeedsim -MODULES += platforms/posix/drivers/gpssim - -# -# Unit tests -# -#MODULES += platforms/posix/tests/hello -MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue - -# -# muorb fastrpc changes. -# -#MODULES += $(PX4_BASE)../muorb_krait diff --git a/makefiles/posix/firmware_posix.mk b/makefiles/posix/firmware_posix.mk deleted file mode 100644 index f6f087d449..0000000000 --- a/makefiles/posix/firmware_posix.mk +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Built products -# -FIRMWARES = $(foreach config,$(CONFIGS),$(BUILD_DIR)$(config).build/firmware.a) - -all: $(FIRMWARES) - -# -# Generate FIRMWARES. -# -.PHONY: $(FIRMWARES) -$(BUILD_DIR)%.build/firmware.a: config = $(patsubst $(BUILD_DIR)%.build/firmware.a,%,$@) -$(BUILD_DIR)%.build/firmware.a: work_dir = $(BUILD_DIR)$(config).build/ -$(FIRMWARES): $(BUILD_DIR)%.build/firmware.a: checkgitversion generateuorbtopicheaders - @$(ECHO) %%%% - @$(ECHO) %%%% Building $(config) in $(work_dir) - @$(ECHO) %%%% - $(Q) $(MKDIR) -p $(work_dir) - $(Q) $(MAKE) -r --no-print-directory -C $(work_dir) \ - -f $(PX4_MK_DIR)firmware.mk \ - CONFIG=$(config) \ - WORK_DIR=$(work_dir) \ - $(FIRMWARE_GOAL) - - diff --git a/makefiles/posix/posix.mk b/makefiles/posix/posix.mk deleted file mode 100644 index 13cb97f0db..0000000000 --- a/makefiles/posix/posix.mk +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Rules and definitions related to handling the Linux specific impl when -# building firmware. -# - -MODULES += \ - platforms/common \ - platforms/posix/px4_layer - diff --git a/makefiles/posix/posix_elf.mk b/makefiles/posix/posix_elf.mk deleted file mode 100644 index bbc7545a5e..0000000000 --- a/makefiles/posix/posix_elf.mk +++ /dev/null @@ -1,75 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Makefile for PX4 POSIX based firmware images. -# - -################################################################################ -# Build rules -################################################################################ - -# -# What we're going to build. -# -PRODUCT_SHARED_LIB = $(WORK_DIR)firmware.a -PRODUCT_SHARED_PRELINK = $(WORK_DIR)firmware.o - -.PHONY: firmware -firmware: $(PRODUCT_SHARED_LIB) $(WORK_DIR)mainapp - -# -# Built product rules -# - -$(PRODUCT_SHARED_PRELINK): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES) - $(call PRELINKF,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS)) - -$(PRODUCT_SHARED_LIB): $(PRODUCT_SHARED_PRELINK) - $(call LINK_A,$@,$(PRODUCT_SHARED_PRELINK)) - -$(WORK_DIR)apps.h: $(WORK_DIR)builtin_commands - $(PX4_BASE)/Tools/posix_apps.py > $(WORK_DIR)apps.h - -MAIN = $(PX4_BASE)/src/platforms/posix/main.cpp -$(WORK_DIR)mainapp: $(PRODUCT_SHARED_LIB) $(WORK_DIR)apps.h - $(call LINK,$@, -I. $(MAIN) $(PRODUCT_SHARED_LIB)) - -# -# Utility rules -# - -.PHONY: clean -clean: $(MODULE_CLEANS) - @$(ECHO) %% cleaning - $(Q) $(REMOVE) $(PRODUCT_ELF) - $(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS) - diff --git a/makefiles/posix/toolchain_native.mk b/makefiles/posix/toolchain_native.mk deleted file mode 100644 index c3a766d5ef..0000000000 --- a/makefiles/posix/toolchain_native.mk +++ /dev/null @@ -1,369 +0,0 @@ -# -# Copyright (C) 2012-2014 PX4 Development Team. All rights reuint32_tserved. -# -# 2005 Modified for clang and GCC on POSIX: -# Author: Mark Charlebois -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Definitions for a native GCC toolchain -# - -#$(info TOOLCHAIN native) - -# Toolchain commands. Normally only used inside this file. -# - -# Set to 1 for GCC-4.8.2 and to 0 for Clang-3.5 (Ubuntu 14.04) -USE_GCC?=0 - -ifeq ($(PX4_DEBUG_LEVEL),) -VERBOSITY_LEVEL= -else -VERBOSITY_LEVEL=-D$(PX4_DEBUG_LEVEL) -endif - -ifneq ($(USE_GCC),1) - -HAVE_CLANG35:=$(shell clang-3.5 -dumpversion 2>/dev/null) - -# Clang will report 4.2.1 as GCC version -HAVE_CLANG:=$(shell clang -dumpversion 2> /dev/null) - -#If using ubuntu 14.04 and packaged clang 3.5 -ifeq ($(HAVE_CLANG35),4.2.1) -USE_GCC=0 -CLANGVER=-3.5 -else - -#If using ubuntu 12.04 and downloaded clang 3.4.2 -ifeq ($(HAVE_CLANG),4.2.1) -USE_GCC=0 -CLANGVER= -endif -endif - -# If no version of clang was found -ifeq ($(HAVE_CLANG35),) -ifeq ($(HAVE_CLANG),) -$(error Clang not found. Try make USE_GCC=1) -endif -endif -endif # USE_GCC is not 1 - -ifeq ($(USE_GCC),1) -# GCC Options: -CC = gcc -CXX = g++ -CPP = gcc -E - -# GCC Version -DEV_VER_SUPPORTED = 4.8.1 4.8.2 4.9.1 - -else -# Clang options -CC = clang$(CLANGVER) -CXX = clang++$(CLANGVER) -CPP = clang$(CLANGVER) -E - -# Clang GCC reported version -DEV_VER_SUPPORTED = 4.2.1 -endif - -#LD = ld.gold -LD = ld.bfd -AR = ar rcs -NM = nm -OBJCOPY = objcopy -OBJDUMP = objdump - -# Check if the right version of the toolchain is available -# -DEV_VER_FOUND = $(shell $(CC) -dumpversion) - -ifeq (,$(findstring $(DEV_VER_FOUND), $(DEV_VER_SUPPORTED))) -$(error Unsupported version of $(CC), found: $(DEV_VER_FOUND) instead of one in: $(DEV_VER_SUPPORTED)) -endif - - -# XXX this is pulled pretty directly from the fmu Make.defs - needs cleanup - -MAXOPTIMIZATION ?= -O3 - -# Enabling stack checks if OS was build with them -# - -# Set the board flags -# -ifeq ($(CONFIG_BOARD),) -$(error Board config does not define CONFIG_BOARD) -endif -ARCHDEFINES += -DCONFIG_ARCH_BOARD_$(CONFIG_BOARD) \ - -Dnoreturn_function=__attribute__\(\(noreturn\)\) \ - $(VERBOSITY_LEVEL)\ - -I$(PX4_BASE)/src/modules/systemlib \ - -I$(PX4_BASE)/src/lib/eigen \ - -I$(PX4_BASE)/src/platforms/posix/include \ - -I$(PX4_BASE)/mavlink/include/mavlink \ - -Wno-error=shadow - -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Linux) - ARCHDEFINES += -D__PX4_POSIX -D__PX4_LINUX -endif -ifeq ($(UNAME_S),Darwin) - ARCHDEFINES += -D__PX4_POSIX -D__PX4_DARWIN -endif - -# optimisation flags -# -ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \ - -g3 \ - -fno-strict-aliasing \ - -fomit-frame-pointer \ - -funsafe-math-optimizations \ - -fno-builtin-printf \ - -ffunction-sections \ - -fdata-sections - -# Language-specific flags -# -ARCHCFLAGS = -std=gnu99 -g -ARCHCXXFLAGS = -fno-exceptions -fno-rtti -std=c++11 -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ -g - -# Generic warnings -# -# Disabled -# -Wshadow - Breaks for the libeigen package headers -# -Wframe-larger-than=1024 - Only needed for embedded - -ARCHWARNINGS = -Wall \ - -Wextra \ - -Werror \ - -Wfloat-equal \ - -Wpointer-arith \ - -Wmissing-declarations \ - -Wpacked \ - -Wno-unused-parameter \ - -Wno-packed \ - -Werror=format-security \ - -Werror=array-bounds \ - -Wfatal-errors \ - -Werror=unused-variable \ - -Werror=reorder \ - -Werror=uninitialized \ - -Werror=init-self - -# Add compiler specific options -ifeq ($(USE_GCC),1) -ARCHDEFINES += -ARCHWARNINGS += -Wdouble-promotion \ - -Wformat=1 \ - -Werror=unused-but-set-variable \ - -Werror=double-promotion -ARCHOPTIMIZATION += -fno-strength-reduce -else -ARCHWARNINGS += -Wno-gnu-array-member-paren-init -endif - -# -Werror=float-conversion - works, just needs to be phased in with some effort and needs GCC 4.9+ -# -Wcast-qual - generates spurious noreturn attribute warnings, try again later -# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code -# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives - -# C-specific warnings -# -ARCHCWARNINGS = $(ARCHWARNINGS) \ - -Wbad-function-cast \ - -Wstrict-prototypes \ - -Wmissing-prototypes \ - -Wnested-externs - -# Add compiler specific options -ifeq ($(USE_GCC),1) -ARCHCWARNINGS += -Wold-style-declaration \ - -Wmissing-parameter-type \ - -Wno-error=unused-local-typedefs \ - -Wno-error=enum-compare \ - -Wno-error=float-equal -endif - -# C++-specific warnings -# -ARCHWARNINGSXX = $(ARCHWARNINGS) \ - -Wno-missing-field-initializers - -# pull in *just* libm from the toolchain ... this is grody -LIBM := $(shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a) -#EXTRA_LIBS += $(LIBM) -#EXTRA_LIBS += ${PX4_BASE}../muorb_krait/lib/libmuorb.so -EXTRA_LIBS += -pthread -lm -lrt - -# Flags we pass to the C compiler -# -CFLAGS = $(ARCHCFLAGS) \ - $(ARCHCWARNINGS) \ - $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) \ - $(ARCHINCLUDES) \ - $(INSTRUMENTATIONDEFINES) \ - $(ARCHDEFINES) \ - $(EXTRADEFINES) \ - $(EXTRACFLAGS) \ - -fno-common \ - $(addprefix -I,$(INCLUDE_DIRS)) - -# Flags we pass to the C++ compiler -# -CXXFLAGS = $(ARCHCXXFLAGS) \ - $(ARCHWARNINGSXX) \ - $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) \ - $(ARCHXXINCLUDES) \ - $(INSTRUMENTATIONDEFINES) \ - $(ARCHDEFINES) \ - -DCONFIG_WCHAR_BUILTIN \ - $(EXTRADEFINES) \ - $(EXTRACXXFLAGS) \ - -Wno-effc++ \ - $(addprefix -I,$(INCLUDE_DIRS)) - -ifeq ($(USE_GCC),0) -CXXFLAGS += -Wno-deprecated-register \ - -Wno-tautological-constant-out-of-range-compare \ - -Wno-unused-private-field \ - -Wno-unused-const-variable -endif - -# Flags we pass to the assembler -# -AFLAGS = $(CFLAGS) -D__ASSEMBLY__ \ - $(EXTRADEFINES) \ - $(EXTRAAFLAGS) - -LDSCRIPT = $(PX4_BASE)/makefiles/posix/ld.script -# Flags we pass to the linker -# -LDFLAGS += $(EXTRALDFLAGS) \ - $(addprefix -L,$(LIB_DIRS)) - -# Compiler support library -# -LIBGCC := $(shell $(CC) $(ARCHCPUFLAGS) -print-libgcc-file-name) - -# Files that the final link depends on -# -#LINK_DEPS += $(LDSCRIPT) -LINK_DEPS += - -# Files to include to get automated dependencies -# -DEP_INCLUDES = $(subst .o,.d,$(OBJS)) - -# Compile C source $1 to object $2 -# as a side-effect, generate a dependency file -# -define COMPILE - @$(ECHO) "CC: $1" - @$(MKDIR) -p $(dir $2) - $(Q) $(CCACHE) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2 -endef - -# Compile C++ source $1 to $2 -# as a side-effect, generate a dependency file -# -define COMPILEXX - @$(ECHO) "CXX: $1" - @$(MKDIR) -p $(dir $2) - @$(Q) $(CCACHE) $(CXX) -MD -c $(CXXFLAGS) $(abspath $1) -o $2 - $(Q) $(CCACHE) $(CXX) -MD -c $(CXXFLAGS) $(abspath $1) -o $2 -endef - -# Assemble $1 into $2 -# -define ASSEMBLE - @$(ECHO) "AS: $1" - @$(MKDIR) -p $(dir $2) - $(Q) $(CC) -c $(AFLAGS) $(abspath $1) -o $2 -endef - -# Produce partially-linked $1 from files in $2 -# -#$(Q) $(LD) -Ur -o $1 $2 # -Ur not supported in ld.gold -define PRELINK - @$(ECHO) "PRELINK: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(LD) -Ur -o $1 $2 - -endef -# Produce partially-linked $1 from files in $2 -# -#$(Q) $(LD) -Ur -o $1 $2 # -Ur not supported in ld.gold -define PRELINKF - @$(ECHO) "PRELINK: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(LD) -Ur -T$(LDSCRIPT) -o $1 $2 - -endef -# $(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1 - -# Update the archive $1 with the files in $2 -# -define ARCHIVE - @$(ECHO) "AR: $2" - @$(MKDIR) -p $(dir $1) - $(Q) $(AR) $1 $2 -endef - -# Link the objects in $2 into the shared library $1 -# -define LINK_A - @$(ECHO) "LINK_A: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(AR) $1 $2 -endef - -# Link the objects in $2 into the shared library $1 -# -define LINK_SO - @$(ECHO) "LINK_SO: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(CXX) $(LDFLAGS) -shared -Wl,-soname,`basename $1`.1 -o $1 $2 $(LIBS) -pthread -lc -endef - -# Link the objects in $2 into the application $1 -# -define LINK - @$(ECHO) "LINK: $1" - @$(MKDIR) -p $(dir $1) - $(Q) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $1 $2 $(LIBS) $(EXTRA_LIBS) $(LIBGCC) - -endef - diff --git a/makefiles/qurt/DISABLE_config_qurt_muorb_test.mk b/makefiles/qurt/DISABLE_config_qurt_muorb_test.mk deleted file mode 100644 index 07f4355073..0000000000 --- a/makefiles/qurt/DISABLE_config_qurt_muorb_test.mk +++ /dev/null @@ -1,77 +0,0 @@ -# -# Makefile for the Foo *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -#MODULES += drivers/blinkm -#MODULES += drivers/pwm_out_sim -#MODULES += drivers/led -#MODULES += drivers/rgbled -#MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -#MODULES += systemcmds/param - -# -# General system control -# -#MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -#MODULES += modules/attitude_estimator_ekf -#MODULES += modules/ekf_att_pos_estimator - -# -# Vehicle Control -# -#MODULES += modules/mc_att_control - -# -# Library modules -# -#MODULES += modules/systemlib -#MODULES += modules/systemlib/mixer -MODULES += modules/uORB -#MODULES += modules/dataman -#MODULES += modules/sdlog2 -#MODULES += modules/simulator -#MODULES += modules/commander - -# -# Libraries -# -#MODULES += lib/mathlib -#MODULES += lib/mathlib/math/filter -#MODULES += lib/geo -#MODULES += lib/geo_lookup -#MODULES += lib/conversion - -# -# QuRT port -# -MODULES += platforms/qurt/px4_layer -#MODULES += platforms/posix/drivers/accelsim -#MODULES += platforms/posix/drivers/gyrosim -#MODULES += platforms/posix/drivers/adcsim -#MODULES += platforms/posix/drivers/barosim - -# -# Unit tests -# -MODULES += platforms/qurt/tests/muorb -#MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue - -# -# sources for muorb over fastrpc -# -MODULES += $(PX4_BASE)/../muorb_qurt/ diff --git a/makefiles/qurt/board_qurt.mk b/makefiles/qurt/board_qurt.mk deleted file mode 100644 index 1038a90b76..0000000000 --- a/makefiles/qurt/board_qurt.mk +++ /dev/null @@ -1,11 +0,0 @@ -# -# Board-specific definitions for the Linux port of PX4 -# - -# -# Configure the toolchain -# -CONFIG_ARCH = HEXAGON -CONFIG_BOARD = QURTTEST - -include $(PX4_MK_DIR)/qurt/toolchain_hexagon.mk diff --git a/makefiles/qurt/config_qurt_adsp.mk b/makefiles/qurt/config_qurt_adsp.mk deleted file mode 100644 index fcd63eef57..0000000000 --- a/makefiles/qurt/config_qurt_adsp.mk +++ /dev/null @@ -1,87 +0,0 @@ -#Added configuration specific flags here. - -ifndef HEXAGON_DRIVERS_ROOT -$(error HEXAGON_DRIVERS_ROOT is not set) -endif -ifndef EAGLE_DRIVERS_SRC -$(error EAGLE_DRIVERS_SRC is not set) -endif - -INCLUDE_DIRS += $(HEXAGON_DRIVERS_ROOT)/inc - -# For Actual flight we need to link against the driver dynamic libraries -LDFLAGS += -L${HEXAGON_DRIVERS_ROOT}/libs -lmpu9x50 -LDFLAGS += -luart_esc -LDFLAGS += -lcsr_gps -LDFLAGS += -lrc_receiver - -# -# Makefile for the EAGLE QuRT *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -MODULES += modules/sensors -MODULES += $(EAGLE_DRIVERS_SRC)/mpu9x50 -MODULES += $(EAGLE_DRIVERS_SRC)/uart_esc -MODULES += $(EAGLE_DRIVERS_SRC)/rc_receiver -MODULES += $(EAGLE_DRIVERS_SRC)/csr_gps - -# -# System commands -# -MODULES += systemcmds/param - - -# -# General system control -# - -# -# Estimation modules (EKF/ SO3 / other filters) -# -MODULES += modules/ekf_att_pos_estimator -MODULES += modules/attitude_estimator_q -MODULES += modules/position_estimator_inav - -# -# Vehicle Control -# -MODULES += modules/mc_att_control -MODULES += modules/mc_pos_control - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/uORB -#MODULES += modules/dataman -MODULES += modules/commander -MODULES += modules/controllib - -# -# Libraries -# -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion - -# -# QuRT port -# -MODULES += platforms/qurt/px4_layer -MODULES += platforms/posix/work_queue - -# -# Unit tests -# - -# -# sources for muorb over fastrpc -# -MODULES += modules/muorb/adsp/ diff --git a/makefiles/qurt/config_qurt_default.mk b/makefiles/qurt/config_qurt_default.mk deleted file mode 100644 index e09754ab7b..0000000000 --- a/makefiles/qurt/config_qurt_default.mk +++ /dev/null @@ -1,83 +0,0 @@ -# -# Makefile for the Foo *default* configuration -# - -# -# Use the configuration's ROMFS. -# -#ROMFS_ROOT = $(PX4_BASE)/ROMFS/px4fmu_common - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/blinkm -MODULES += drivers/pwm_out_sim -MODULES += drivers/led -MODULES += drivers/rgbled -MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -MODULES += systemcmds/param - -# -# General system control -# -#MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -#MODULES += modules/attitude_estimator_ekf -#MODULES += modules/ekf_att_pos_estimator - -# -# Vehicle Control -# -#MODULES += modules/mc_att_control - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/uORB -#MODULES += modules/dataman -#MODULES += modules/sdlog2 -#MODULES += modules/simulator -#MODULES += modules/commander - -# -# Libraries -# -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -#MODULES += lib/geo -#MODULES += lib/geo_lookup -MODULES += lib/conversion - -# -# QuRT port -# -MODULES += platforms/qurt/px4_layer -MODULES += platforms/posix/work_queue -MODULES += platforms/posix/drivers/accelsim -MODULES += platforms/posix/drivers/gyrosim -MODULES += platforms/posix/drivers/adcsim -MODULES += platforms/posix/drivers/barosim - -# -# Unit tests -# -MODULES += platforms/qurt/tests/hello -MODULES += platforms/posix/tests/vcdev_test -MODULES += platforms/posix/tests/hrt_test -MODULES += platforms/posix/tests/wqueue - -# -# sources for muorb over fastrpc -# -#MODULES += $(PX4_BASE)/../muorb_qurt/ diff --git a/makefiles/qurt/config_qurt_hello.mk b/makefiles/qurt/config_qurt_hello.mk deleted file mode 100644 index 2ec18b7fce..0000000000 --- a/makefiles/qurt/config_qurt_hello.mk +++ /dev/null @@ -1,74 +0,0 @@ -# -# Makefile for the Foo *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -#MODULES += drivers/blinkm -#MODULES += drivers/pwm_out_sim -#MODULES += drivers/led -#MODULES += drivers/rgbled -#MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -MODULES += systemcmds/param - -# -# General system control -# -#MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -#MODULES += modules/attitude_estimator_ekf -#MODULES += modules/ekf_att_pos_estimator - -# -# Vehicle Control -# -#MODULES += modules/mc_att_control - -# -# Library modules -# -MODULES += modules/systemlib -#MODULES += modules/systemlib/mixer -MODULES += modules/uORB -#MODULES += modules/dataman -#MODULES += modules/sdlog2 -#MODULES += modules/simulator -#MODULES += modules/commander - -# -# Libraries -# -#MODULES += lib/mathlib -#MODULES += lib/mathlib/math/filter -#MODULES += lib/geo -#MODULES += lib/geo_lookup -#MODULES += lib/conversion - -# -# QuRT port -# -MODULES += platforms/qurt/px4_layer -MODULES += platforms/posix/work_queue -#MODULES += platforms/posix/drivers/accelsim -#MODULES += platforms/posix/drivers/gyrosim -#MODULES += platforms/posix/drivers/adcsim -#MODULES += platforms/posix/drivers/barosim - -# -# Unit tests -# -MODULES += platforms/qurt/tests/hello -#MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue - diff --git a/makefiles/qurt/config_qurt_hil.mk b/makefiles/qurt/config_qurt_hil.mk deleted file mode 100644 index 6f14dd6a00..0000000000 --- a/makefiles/qurt/config_qurt_hil.mk +++ /dev/null @@ -1,84 +0,0 @@ -# -# Makefile for the Foo *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -MODULES += drivers/boards/sitl -#MODULES += drivers/blinkm -MODULES += drivers/pwm_out_sim -MODULES += drivers/led -MODULES += drivers/rgbled -MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -MODULES += systemcmds/param -MODULES += systemcmds/mixer - -# -# General system control -# -#MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -#MODULES += modules/attitude_estimator_ekf -MODULES += modules/ekf_att_pos_estimator -MODULES += modules/attitude_estimator_q -MODULES += modules/position_estimator_inav - -# -# Vehicle Control -# -MODULES += modules/mc_att_control -MODULES += modules/mc_pos_control - -# -# Library modules -# -MODULES += modules/systemlib -MODULES += modules/systemlib/mixer -MODULES += modules/uORB -#MODULES += modules/dataman -#MODULES += modules/sdlog2 -#MODULES += modules/simulator -MODULES += modules/commander - -# -# Libraries -# -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion -MODULES += modules/controllib - -# -# QuRT port -# -MODULES += platforms/qurt/px4_layer -MODULES += platforms/posix/work_queue -#MODULES += platforms/posix/drivers/accelsim -#MODULES += platforms/posix/drivers/gyrosim -#MODULES += platforms/posix/drivers/adcsim -#MODULES += platforms/posix/drivers/barosim - -# -# Unit tests -# -#MODULES += platforms/qurt/tests/muorb -#MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue - -# -# sources for muorb over fastrpc -# -MODULES += modules/muorb/adsp/ diff --git a/makefiles/qurt/config_qurt_muorb_test.mk b/makefiles/qurt/config_qurt_muorb_test.mk deleted file mode 100644 index 57a961734f..0000000000 --- a/makefiles/qurt/config_qurt_muorb_test.mk +++ /dev/null @@ -1,80 +0,0 @@ -# -# Makefile for the Foo *default* configuration -# - -# -# Board support modules -# -MODULES += drivers/device -#MODULES += drivers/blinkm -#MODULES += drivers/pwm_out_sim -#MODULES += drivers/led -#MODULES += drivers/rgbled -#MODULES += modules/sensors -#MODULES += drivers/ms5611 - -# -# System commands -# -#MODULES += systemcmds/param -#MODULES += systemcmds/mixer - -# -# General system control -# -#MODULES += modules/mavlink - -# -# Estimation modules (EKF/ SO3 / other filters) -# -#MODULES += modules/attitude_estimator_ekf -#MODULES += modules/ekf_att_pos_estimator - -# -# Vehicle Control -# -#MODULES += modules/mc_att_control -#MODULES += modules/mc_pos_control - -# -# Library modules -# -MODULES += modules/systemlib -#MODULES += modules/systemlib/mixer -MODULES += modules/uORB -#MODULES += modules/dataman -#MODULES += modules/sdlog2 -#MODULES += modules/simulator -#MODULES += modules/commander - -# -# Libraries -# -MODULES += lib/mathlib -MODULES += lib/mathlib/math/filter -MODULES += lib/geo -MODULES += lib/geo_lookup -MODULES += lib/conversion - -# -# QuRT port -# -MODULES += platforms/qurt/px4_layer -MODULES += platforms/posix/work_queue -#MODULES += platforms/posix/drivers/accelsim -#MODULES += platforms/posix/drivers/gyrosim -#MODULES += platforms/posix/drivers/adcsim -#MODULES += platforms/posix/drivers/barosim - -# -# Unit tests -# -MODULES += platforms/qurt/tests/muorb -#MODULES += platforms/posix/tests/vcdev_test -#MODULES += platforms/posix/tests/hrt_test -#MODULES += platforms/posix/tests/wqueue - -# -# sources for muorb over fastrpc -# -MODULES += modules/muorb/adsp/ diff --git a/makefiles/qurt/firmware_qurt.mk b/makefiles/qurt/firmware_qurt.mk deleted file mode 100644 index ac87683487..0000000000 --- a/makefiles/qurt/firmware_qurt.mk +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Built products -# -FIRMWARES = $(foreach config,$(CONFIGS),$(BUILD_DIR)$(config).build/firmware.a) - -all: $(FIRMWARES) - -# -# Generate FIRMWARES. -# -.PHONY: $(FIRMWARES) -$(BUILD_DIR)%.build/firmware.a: config = $(patsubst $(BUILD_DIR)%.build/firmware.a,%,$@) -$(BUILD_DIR)%.build/firmware.a: work_dir = $(BUILD_DIR)$(config).build/ -$(FIRMWARES): $(BUILD_DIR)%.build/firmware.a: generateuorbtopicheaders - @$(ECHO) %%%% - @$(ECHO) %%%% Building $(config) in $(work_dir) - @$(ECHO) %%%% - $(Q) $(MKDIR) -p $(work_dir) - $(Q) $(MAKE) -r --no-print-directory -C $(work_dir) \ - -f $(PX4_MK_DIR)firmware.mk \ - CONFIG=$(config) \ - WORK_DIR=$(work_dir) \ - $(FIRMWARE_GOAL) - -HEXAGON_TOOLS_ROOT ?= /opt/6.4.03 -V_ARCH = v5 -HEXAGON_CLANG_BIN = $(addsuffix /qc/bin,$(HEXAGON_TOOLS_ROOT)) -SIM = $(HEXAGON_CLANG_BIN)/hexagon-sim -SIMFLAGS+= -m$(V_ARCH) -sim: - $(SIM) $(SIMFLAGS) Build/qurt_default.build/mainapp diff --git a/makefiles/qurt/qurt.mk b/makefiles/qurt/qurt.mk deleted file mode 100644 index 00bbe8dc8f..0000000000 --- a/makefiles/qurt/qurt.mk +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (C) 2015 Mark Charlebois. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Rules and definitions related to handling the Linux specific impl when -# building firmware. -# - -MODULES += \ - platforms/common - diff --git a/makefiles/qurt/qurt_eigen.patch b/makefiles/qurt/qurt_eigen.patch deleted file mode 100644 index 9ea57403ba..0000000000 --- a/makefiles/qurt/qurt_eigen.patch +++ /dev/null @@ -1,17 +0,0 @@ -This patch is required for QuRT. complex.h defines "I" and it replaces "I" in the -enum definition without this patch creating an error. - -diff --git a/Eigen/src/Core/SolveTriangular.h b/Eigen/src/Core/SolveTriangular.h -index ef17f28..1116270 100644 ---- a/Eigen/src/Core/SolveTriangular.h -+++ b/Eigen/src/Core/SolveTriangular.h -@@ -112,6 +112,9 @@ template - struct triangular_solver_unroller; - -+#ifdef __PX4_QURT -+#undef I -+#endif - template - struct triangular_solver_unroller { - enum { diff --git a/makefiles/qurt/qurt_elf.mk b/makefiles/qurt/qurt_elf.mk deleted file mode 100644 index 73f1cd4ece..0000000000 --- a/makefiles/qurt/qurt_elf.mk +++ /dev/null @@ -1,85 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Makefile for PX4 Linux based firmware images. -# - -################################################################################ -# Build rules -################################################################################ - -# -# What we're going to build. -# - -EXTRALDFLAGS = -Wl,-soname=libpx4.so -PRODUCT_SHARED_LIB = $(WORK_DIR)firmware.a -PRODUCT_SHARED_PRELINK = $(WORK_DIR)firmware.o - -.PHONY: firmware -firmware: $(PRODUCT_SHARED_LIB) $(WORK_DIR)libpx4.so $(WORK_DIR)mainapp - -# -# Built product rules -# - -$(PRODUCT_SHARED_PRELINK): $(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS) $(GLOBAL_DEPS) $(LINK_DEPS) $(MODULE_MKFILES) - $(call PRELINKF,$@,$(OBJS) $(MODULE_OBJS) $(LIBRARY_LIBS)) - -$(PRODUCT_SHARED_LIB): $(PRODUCT_SHARED_PRELINK) - $(call LINK_A,$@,$(PRODUCT_SHARED_PRELINK)) - -$(WORK_DIR)apps.cpp: $(PX4_BASE)/Tools/qurt_apps.py - $(PX4_BASE)/Tools/qurt_apps.py > $@ - -$(WORK_DIR)apps.o: $(WORK_DIR)apps.cpp - $(call COMPILEXX,$<, $@) - mv $(WORK_DIR)apps.cpp $(WORK_DIR)apps.cpp_sav - -$(WORK_DIR)libpx4.so: $(WORK_DIR)apps.o $(PRODUCT_SHARED_LIB) - $(call LINK_SO,$@, $^) - -$(WORK_DIR)dspal_stub.o: $(PX4_BASE)/src/platforms/qurt/dspal/dspal_stub.c - $(call COMPILENOSHARED,$^, $@) - -$(WORK_DIR)mainapp: $(WORK_DIR)dspal_stub.o - $(call LINK,$@, $^) - -# -# Utility rules -# - -.PHONY: clean -clean: $(MODULE_CLEANS) - @$(ECHO) %% cleaning - $(Q) $(REMOVE) $(PRODUCT_ELF) - $(Q) $(REMOVE) $(OBJS) $(DEP_INCLUDES) $(EXTRA_CLEANS) diff --git a/makefiles/qurt/setup.sh b/makefiles/qurt/setup.sh deleted file mode 100755 index 8ffb13cc4b..0000000000 --- a/makefiles/qurt/setup.sh +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################ -# -# Copyright (c) 2015 Mark Charlebois. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# ########################################################################### - -# -# This file is required to modify the PX4 project so it can be build with -# the Hexagon toolchain. -# -# 1. Downgrade Eigen to 3.2 because the C++11 features of latest version -# are not supported -# 2. Patch Eigen because the Hexagon toolchain complex.h defines "I" -# - -cd $1 -cd src/lib/eigen/ -git checkout . -git checkout e7850ed81f9c469e02df496ef09ae32ec0379b71 -patch -p1 < ../../../makefiles/qurt/qurt_eigen.patch - diff --git a/makefiles/qurt/toolchain_hexagon.mk b/makefiles/qurt/toolchain_hexagon.mk deleted file mode 100644 index 77a9d4e838..0000000000 --- a/makefiles/qurt/toolchain_hexagon.mk +++ /dev/null @@ -1,345 +0,0 @@ -# -# Copyright (C) 2015 Mark Charlebois. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Definitions for a generic GNU ARM-EABI toolchain -# - -#$(info TOOLCHAIN gnu-arm-eabi) - -# Toolchain commands. Normally only used inside this file. -# -HEXAGON_TOOLS_ROOT ?= /opt/6.4.03 -#HEXAGON_TOOLS_ROOT = /opt/6.4.05 -HEXAGON_SDK_ROOT ?= /opt/Hexagon_SDK/2.0 -V_ARCH = v5 -CROSSDEV = hexagon- -HEXAGON_BIN = $(addsuffix /gnu/bin,$(HEXAGON_TOOLS_ROOT)) -HEXAGON_CLANG_BIN = $(addsuffix /qc/bin,$(HEXAGON_TOOLS_ROOT)) -HEXAGON_LIB_DIR = $(HEXAGON_TOOLS_ROOT)/gnu/hexagon/lib -HEXAGON_ISS_DIR = $(HEXAGON_TOOLS_ROOT)/qc/lib/iss -TOOLSLIB = $(HEXAGON_TOOLS_ROOT)/dinkumware/lib/$(V_ARCH)/G0 -QCTOOLSLIB = $(HEXAGON_TOOLS_ROOT)/qc/lib/$(V_ARCH)/G0 -QURTLIB = $(HEXAGON_SDK_ROOT)/lib/common/qurt/ADSP$(V_ARCH)MP/lib -DSPAL_INCS ?= $(PX4_BASE)/src/lib/dspal - - -CC = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang -CXX = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang++ -CPP = $(HEXAGON_CLANG_BIN)/$(CROSSDEV)clang -E -LD = $(HEXAGON_BIN)/$(CROSSDEV)ld -AR = $(HEXAGON_BIN)/$(CROSSDEV)ar rcs -NM = $(HEXAGON_BIN)/$(CROSSDEV)nm -OBJCOPY = $(HEXAGON_BIN)/$(CROSSDEV)objcopy -OBJDUMP = $(HEXAGON_BIN)/$(CROSSDEV)objdump -HEXAGON_GCC = $(HEXAGON_BIN)/$(CROSSDEV)gcc - -QURTLIBS = \ - $(QCTOOLSLIB)/libdl.a \ - $(TOOLSLIB)/init.o \ - $(TOOLSLIB)/libc.a \ - $(TOOLSLIB)/libqcc.a \ - $(TOOLSLIB)/libstdc++.a \ - $(QURTLIB)/crt0.o \ - $(QURTLIB)/libqurt.a \ - $(QURTLIB)/libqurtkernel.a \ - $(QURTLIB)/libqurtcfs.a \ - $(QURTLIB)/libqube_compat.a \ - $(QURTLIB)/libtimer.a \ - $(QURTLIB)/libposix.a \ - $(QURTLIB)/../examples/cust_config.o \ - $(QCTOOLSLIB)/libhexagon.a \ - $(TOOLSLIB)/fini.o - -DYNAMIC_LIBS = \ - -Wl,$(TOOLSLIB)/pic/libstdc++.a - - -# Check if the right version of the toolchain is available -# -CROSSDEV_VER_SUPPORTED = 6.4.03 6.4.05 -CROSSDEV_VER_FOUND = $(shell $(CC) --version | sed -n 's/^.*version \([\. 0-9]*\),.*$$/\1/p') - -ifeq (,$(findstring $(CROSSDEV_VER_FOUND), $(CROSSDEV_VER_SUPPORTED))) -$(error Unsupported version of $(CC), found: $(CROSSDEV_VER_FOUND) instead of one in: $(CROSSDEV_VER_SUPPORTED)) -endif - - -# XXX this is pulled pretty directly from the fmu Make.defs - needs cleanup - -MAXOPTIMIZATION := -O0 - -# Base CPU flags for each of the supported architectures. -# -ARCHCPUFLAGS = -m$(V_ARCH) -G0 - - -# Set the board flags -# -ifeq ($(CONFIG_BOARD),) -$(error Board config does not define CONFIG_BOARD) -endif -ARCHDEFINES += -DCONFIG_ARCH_BOARD_$(CONFIG_BOARD) \ - -D__PX4_QURT -D__PX4_POSIX \ - -D_PID_T -D_UID_T -D_TIMER_T\ - -Dnoreturn_function= \ - -D__EXPORT= \ - -Drestrict= \ - -D_DEBUG \ - -I$(DSPAL_INCS)/include \ - -I$(DSPAL_INCS)/sys \ - -I$(HEXAGON_TOOLS_ROOT)/gnu/hexagon/include \ - -I$(PX4_BASE)/src/lib/eigen \ - -I$(PX4_BASE)/src/platforms/qurt/include \ - -I$(PX4_BASE)/src/platforms/posix/include \ - -I$(PX4_BASE)/mavlink/include/mavlink \ - -I$(PX4_BASE)/../inc \ - -I$(QURTLIB)/..//include \ - -I$(HEXAGON_SDK_ROOT)/inc \ - -I$(HEXAGON_SDK_ROOT)/inc/stddef \ - -Wno-error=shadow - - - -# optimisation flags -# -ARCHOPTIMIZATION = \ - -O0 \ - -g \ - -fno-strict-aliasing \ - -fdata-sections \ - -fpic \ - -fno-zero-initialized-in-bss - -#-fomit-frame-pointer \ -#-funsafe-math-optimizations \ -#-ffunction-sections -#$(MAXOPTIMIZATION) - -# enable precise stack overflow tracking -# note - requires corresponding support in NuttX -INSTRUMENTATIONDEFINES = $(ARCHINSTRUMENTATIONDEFINES_$(CONFIG_ARCH)) - -# Language-specific flags -# -ARCHCFLAGS = -std=gnu99 -D__CUSTOM_FILE_IO__ -ARCHCXXFLAGS = -fno-exceptions -fno-rtti -std=gnu++0x -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ - -# Generic warnings -# -ARCHWARNINGS = -Wall \ - -Wextra \ - -Werror \ - -Wno-unused-parameter \ - -Wno-unused-function \ - -Wno-unused-variable \ - -Wno-gnu-array-member-paren-init \ - -Wno-cast-align \ - -Wno-missing-braces \ - -Wno-strict-aliasing -# -Werror=float-conversion - works, just needs to be phased in with some effort and needs GCC 4.9+ -# -Wcast-qual - generates spurious noreturn attribute warnings, try again later -# -Wconversion - would be nice, but too many "risky-but-safe" conversions in the code -# -Wcast-align - would help catch bad casts in some cases, but generates too many false positives - -# C-specific warnings -# -ARCHCWARNINGS = $(ARCHWARNINGS) \ - -Wstrict-prototypes \ - -Wnested-externs - -# C++-specific warnings -# -ARCHWARNINGSXX = $(ARCHWARNINGS) \ - -Wno-missing-field-initializers - -# pull in *just* libm from the toolchain ... this is grody -LIBM := $(shell $(CC) $(ARCHCPUFLAGS) -print-file-name=libm.a) -EXTRA_LIBS += $(LIBM) - -# Flags we pass to the C compiler -# -CFLAGS = $(ARCHCFLAGS) \ - $(ARCHCWARNINGS) \ - $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) \ - $(ARCHINCLUDES) \ - $(INSTRUMENTATIONDEFINES) \ - $(ARCHDEFINES) \ - $(EXTRADEFINES) \ - $(EXTRACFLAGS) \ - $(addprefix -I,$(INCLUDE_DIRS)) - - #-fno-common -# Flags we pass to the C++ compiler -# -CXXFLAGS = $(ARCHCXXFLAGS) \ - $(ARCHWARNINGSXX) \ - $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) \ - $(ARCHXXINCLUDES) \ - $(INSTRUMENTATIONDEFINES) \ - $(ARCHDEFINES) \ - -DCONFIG_WCHAR_BUILTIN \ - $(EXTRADEFINES) \ - $(EXTRACXXFLAGS) \ - $(addprefix -I,$(INCLUDE_DIRS)) - -# Flags we pass to the assembler -# -AFLAGS = $(CFLAGS) -D__ASSEMBLY__ \ - $(EXTRADEFINES) \ - $(EXTRAAFLAGS) - -LDSCRIPT = $(PX4_BASE)/makefiles/posix/ld.script -# Flags we pass to the linker -# -LDFLAGS += -g -mv5 -mG0lib -G0 -fpic -shared \ - -Wl,-Bsymbolic \ - -Wl,--wrap=malloc \ - -Wl,--wrap=calloc \ - -Wl,--wrap=free \ - -Wl,--wrap=realloc \ - -Wl,--wrap=memalign \ - -Wl,--wrap=__stack_chk_fail \ - -lc \ - $(EXTRALDFLAGS) \ - $(addprefix -L,$(LIB_DIRS)) - -# Compiler support library -# -LIBGCC := $(shell $(CC) $(ARCHCPUFLAGS) -print-libgcc-file-name) - -# Files that the final link depends on -# -LINK_DEPS += $(LDSCRIPT) - -# Files to include to get automated dependencies -# -DEP_INCLUDES = $(subst .o,.d,$(OBJS)) - -# Compile C source $1 to object $2 -# as a side-effect, generate a dependency file -# -define COMPILENOSHARED - @$(ECHO) "CC: $1" - @$(MKDIR) -p $(dir $2) - @echo $(Q) $(CCACHE) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2 - $(Q) $(CCACHE) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2 -endef - -# Compile C source $1 to object $2 for use in shared library -# as a side-effect, generate a dependency file -# -define COMPILE - @$(ECHO) "CC: $1" - @$(MKDIR) -p $(dir $2) - @echo $(Q) $(CCACHE) $(CC) -MD -c $(CFLAGS) $(abspath $1) -o $2 - #$(Q) $(CCACHE) $(CC) -MD -c $(CFLAGS) -D__V_DYNAMIC__ -fPIC $(abspath $1) -o $2 - #$(CCACHE) $(CC) -MD -c $(CFLAGS) -D__V_DYNAMIC__ -D__FILENAME__=\"$(notdir $1)\" -fPIC $(abspath $1) -o $2 - $(CCACHE) $(CC) -c $(CFLAGS) -D__V_DYNAMIC__ -D__FILENAME__=\"$(notdir $1)\" $(abspath $1) -o $2 -endef - -# Compile C++ source $1 to $2 for use in shared library -# as a side-effect, generate a dependency file -# -define COMPILEXX - @$(ECHO) "CXX: $1" - @$(MKDIR) -p $(dir $2) - @echo $(Q) $(CCACHE) $(CXX) -MD -c $(CXXFLAGS) $(abspath $1) -o $2 - #$(Q) $(CCACHE) $(CXX) -MD -c $(CXXFLAGS) -D__V_DYNAMIC__ -fPIC $(abspath $1) -o $2 - #$(CCACHE) $(CXX) -MD -c $(CXXFLAGS) -D__V_DYNAMIC__ -D__FILENAME__=\"$(notdir $1)\" -fPIC $(abspath $1) -o $2 - $(CCACHE) $(CXX) -c $(CXXFLAGS) -D__V_DYNAMIC__ -D__FILENAME__=\"$(notdir $1)\" $(abspath $1) -o $2 -endef - -# Assemble $1 into $2 -# -define ASSEMBLE - @$(ECHO) "AS: $1" - @$(MKDIR) -p $(dir $2) - $(Q) $(CC) -c $(AFLAGS) $(abspath $1) -o $2 -endef - -# Produce partially-linked $1 from files in $2 -# -#$(Q) $(LD) -Ur -o $1 $2 # -Ur not supported in ld.gold -define PRELINK - @$(ECHO) "PRELINK: $1" - @$(MKDIR) -p $(dir $1) - @echo $(Q) $(LD) -Ur -o $1 $2 - $(Q) $(LD) -Ur -o $1 $2 - -endef -# Produce partially-linked $1 from files in $2 -# -#$(Q) $(LD) -Ur -o $1 $2 # -Ur not supported in ld.gold -define PRELINKF - @$(ECHO) "PRELINKF: $1" - @$(MKDIR) -p $(dir $1) - @echo $(Q) $(LD) -Ur -T$(LDSCRIPT) -o $1 $2 - $(Q) $(LD) -Ur -T$(LDSCRIPT) -o $1 $2 - -endef -# $(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1 - -# Update the archive $1 with the files in $2 -# -define ARCHIVE - @$(ECHO) "AR: $2" - @$(MKDIR) -p $(dir $1) - $(Q) $(AR) $1 $2 -endef - -# Link the objects in $2 into the shared library $1 -# -define LINK_A - @$(ECHO) "LINK_A: $1" - @$(MKDIR) -p $(dir $1) - echo "$(Q) $(AR) $1 $2" - $(Q) $(AR) $1 $2 -endef - -# Link the objects in $2 into the shared library $1 -# -define LINK_SO - @$(ECHO) "LINK_SO: $1" - @$(MKDIR) -p $(dir $1) - $(HEXAGON_GCC) $(LDFLAGS) -o $1 -Wl,--whole-archive $2 -Wl,--no-whole-archive $(LIBS) $(DYNAMIC_LIBS) -endef - -# Link the objects in $2 into the application $1 -# -define LINK - @$(ECHO) "LINK: $1" - @$(MKDIR) -p $(dir $1) - $(LD) --section-start .start=0x1d000000 -o $1 --start-group $2 $(EXTRA_LIBS) $(QURTLIBS) --end-group --dynamic-linker= -E --force-dynamic -endef - diff --git a/makefiles/setup.mk b/makefiles/setup.mk deleted file mode 100644 index dd5637bcd9..0000000000 --- a/makefiles/setup.mk +++ /dev/null @@ -1,110 +0,0 @@ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# -# Path and tool setup -# - -export PX4_TARGET_OS ?= nuttx - -# PX4_TARGET_OS can be nuttx, posix, or qurt -ifeq ($(PX4_TARGET_OS),) -$(error Use: make PX4_TARGET_OS= where is nuttx, posix, or qurt) -endif - -# -# Some useful paths. -# -# Note that in general we always keep directory paths with the separator -# at the end, and join paths without explicit separators. This reduces -# the number of duplicate slashes we have lying around in paths, -# and is consistent with joining the results of $(dir) and $(notdir). -# -export PX4_INCLUDE_DIR = $(abspath $(PX4_BASE)/src/include)/ -export PX4_MODULE_SRC = $(abspath $(PX4_BASE)/src)/ -export PX4_LIB_DIR = $(abspath $(PX4_BASE)/src/lib)/ -export PX4_PLATFORMS_DIR = $(abspath $(PX4_BASE)/src/platforms)/ -export PX4_MK_DIR = $(abspath $(PX4_BASE)/makefiles)/ -export NUTTX_SRC = $(abspath $(PX4_BASE)/NuttX/nuttx)/ -export NUTTX_APP_SRC = $(abspath $(PX4_BASE)/NuttX/apps)/ -#export MAVLINK_SRC = $(abspath $(PX4_BASE)/mavlink/include/mavlink/v1.0)/ -export MAVLINK_SRC = $(abspath $(PX4_BASE)/mavlink)/ -export UAVCAN_DIR = $(abspath $(PX4_BASE)/uavcan)/ -export ROMFS_SRC = $(abspath $(PX4_BASE)/ROMFS)/ -export IMAGE_DIR = $(abspath $(PX4_BASE)/Images)/ -export BUILD_DIR = $(abspath $(PX4_BASE)/Build)/ -export ARCHIVE_DIR = $(abspath $(PX4_BASE)/Archives)/ -export PX4_VERSIONING_DIR = $(BUILD_DIR)versioning/ - -# -# Default include paths -# -export INCLUDE_DIRS := $(PX4_MODULE_SRC) \ - $(PX4_MODULE_SRC)/modules/ \ - $(PX4_INCLUDE_DIR) \ - $(PX4_LIB_DIR) \ - $(PX4_PLATFORMS_DIR) \ - $(PX4_VERSIONING_DIR) - -# -# Tools -# -export MKFW = $(PX4_BASE)/Tools/px_mkfw.py -export UPLOADER = $(PX4_BASE)/Tools/px_uploader.py -export COPY = cp -export COPYDIR = cp -Rf -export REMOVE = rm -f -export RMDIR = rm -rf -export GENROMFS = genromfs -export TOUCH = touch -export MKDIR = mkdir -export FIND = find -export ECHO = echo -export UNZIP_CMD = unzip -export PYTHON = python -export OPENOCD = openocd -export GREP = grep -export SIZE = size - -# -# Host-specific paths, hacks and fixups -# -export SYSTYPE := $(shell uname -s) - -ifeq ($(SYSTYPE),Darwin) -# Eclipse may not have the toolchain on its path. -export PATH := $(PATH):/usr/local/bin -endif - -# -# Makefile debugging. -# -export Q := $(if $(V),,@) diff --git a/mavlink/include/mavlink/v1.0 b/mavlink/include/mavlink/v1.0 index c390a63abf..86a2b147e4 160000 --- a/mavlink/include/mavlink/v1.0 +++ b/mavlink/include/mavlink/v1.0 @@ -1 +1 @@ -Subproject commit c390a63abfce15af0629bdf207c4b6a183fed118 +Subproject commit 86a2b147e4cec5066efdc6d030d69d902929e66f diff --git a/msg/uavcan_parameter_request.msg b/msg/uavcan_parameter_request.msg new file mode 100644 index 0000000000..9ced52bbae --- /dev/null +++ b/msg/uavcan_parameter_request.msg @@ -0,0 +1,8 @@ +# UAVCAN-MAVLink parameter bridge request type +uint8 message_type # MAVLink message type: PARAM_REQUEST_READ, PARAM_REQUEST_LIST, PARAM_SET +uint8 node_id # UAVCAN node ID mapped from MAVLink component ID +char[17] param_id # MAVLink/UAVCAN parameter name +int16 param_index # -1 if the param_id field should be used as identifier +uint8 param_type # MAVLink parameter type +int64 int_value # current value if param_type is int-like +float32 real_value # current value if param_type is float-like diff --git a/msg/uavcan_parameter_value.msg b/msg/uavcan_parameter_value.msg new file mode 100644 index 0000000000..091c5fd278 --- /dev/null +++ b/msg/uavcan_parameter_value.msg @@ -0,0 +1,8 @@ +# UAVCAN-MAVLink parameter bridge response type +uint8 node_id # UAVCAN node ID mapped from MAVLink component ID +char[17] param_id # MAVLink/UAVCAN parameter name +int16 param_index # parameter index, if known +uint16 param_count # number of parameters exposed by the node +uint8 param_type # MAVLink parameter type +int64 int_value # current value if param_type is int-like +float32 real_value # current value if param_type is float-like diff --git a/msg/vehicle_command.msg b/msg/vehicle_command.msg index 6ac66d22c7..3a4fb3a596 100644 --- a/msg/vehicle_command.msg +++ b/msg/vehicle_command.msg @@ -53,6 +53,7 @@ uint32 VEHICLE_CMD_DO_TRIGGER_CONTROL = 2003 # Enable or disable on-b uint32 VEHICLE_CMD_DO_VTOL_TRANSITION = 3000 # Command VTOL transition uint32 VEHICLE_CMD_PAYLOAD_PREPARE_DEPLOY = 30001 # Prepare a payload deployment in the flight plan uint32 VEHICLE_CMD_PAYLOAD_CONTROL_DEPLOY = 30002 # Control a pre-programmed payload deployment +uint32 VEHICLE_CMD_PREFLIGHT_UAVCAN = 243 # UAVCAN configuration. If param 1 == 1 actuator mapping and direction assignment should be started uint32 VEHICLE_CMD_RESULT_ACCEPTED = 0 # Command ACCEPTED and EXECUTED | uint32 VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED = 1 # Command TEMPORARY REJECTED/DENIED | diff --git a/msg/vehicle_status.msg b/msg/vehicle_status.msg index 1cf771ba3c..c0c6dc7f0f 100644 --- a/msg/vehicle_status.msg +++ b/msg/vehicle_status.msg @@ -121,7 +121,6 @@ bool condition_system_sensors_initialized bool condition_system_returned_to_home bool condition_auto_mission_available bool condition_global_position_valid # set to true by the commander app if the quality of the position estimate is good enough to use it for navigation -bool condition_launch_position_valid # indicates a valid launch position bool condition_home_position_valid # indicates a valid home position (a valid home position is not always a valid launch) bool condition_local_position_valid bool condition_local_altitude_valid diff --git a/nuttx-configs/px4fmu-v1/nsh/defconfig b/nuttx-configs/px4fmu-v1/nsh/defconfig index 874615d3b2..b89b4039d8 100644 --- a/nuttx-configs/px4fmu-v1/nsh/defconfig +++ b/nuttx-configs/px4fmu-v1/nsh/defconfig @@ -420,7 +420,7 @@ CONFIG_PREALLOC_TIMERS=50 # Stack and heap information # CONFIG_IDLETHREAD_STACKSIZE=1000 -CONFIG_USERMAIN_STACKSIZE=3000 +CONFIG_USERMAIN_STACKSIZE=2500 CONFIG_PTHREAD_STACK_MIN=512 CONFIG_PTHREAD_STACK_DEFAULT=2048 @@ -506,8 +506,8 @@ CONFIG_MTD_BYTE_WRITE=y # # USART1 Configuration # -CONFIG_USART1_RXBUFSIZE=300 -CONFIG_USART1_TXBUFSIZE=300 +CONFIG_USART1_RXBUFSIZE=128 +CONFIG_USART1_TXBUFSIZE=128 CONFIG_USART1_BAUD=57600 CONFIG_USART1_BITS=8 CONFIG_USART1_PARITY=0 @@ -518,8 +518,8 @@ CONFIG_USART1_2STOP=0 # # USART2 Configuration # -CONFIG_USART2_RXBUFSIZE=512 -CONFIG_USART2_TXBUFSIZE=512 +CONFIG_USART2_RXBUFSIZE=300 +CONFIG_USART2_TXBUFSIZE=300 CONFIG_USART2_BAUD=57600 CONFIG_USART2_BITS=8 CONFIG_USART2_PARITY=0 @@ -586,8 +586,8 @@ CONFIG_CDCACM_EPBULKIN_HSSIZE=512 CONFIG_CDCACM_NWRREQS=4 CONFIG_CDCACM_NRDREQS=4 CONFIG_CDCACM_BULKIN_REQLEN=96 -CONFIG_CDCACM_RXBUFSIZE=512 -CONFIG_CDCACM_TXBUFSIZE=2048 +CONFIG_CDCACM_RXBUFSIZE=300 +CONFIG_CDCACM_TXBUFSIZE=1000 CONFIG_CDCACM_VENDORID=0x26ac CONFIG_CDCACM_PRODUCTID=0x0010 CONFIG_CDCACM_VENDORSTR="3D Robotics" @@ -722,11 +722,11 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_HPWORK=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=5000 -CONFIG_SCHED_WORKSTACKSIZE=1800 +CONFIG_SCHED_WORKSTACKSIZE=1600 CONFIG_SCHED_LPWORK=y CONFIG_SCHED_LPWORKPRIORITY=50 CONFIG_SCHED_LPWORKPERIOD=50000 -CONFIG_SCHED_LPWORKSTACKSIZE=1800 +CONFIG_SCHED_LPWORKSTACKSIZE=1600 # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set diff --git a/nuttx-configs/px4fmu-v2/nsh/defconfig b/nuttx-configs/px4fmu-v2/nsh/defconfig index 8f6af5d6b4..3340fdd0c9 100644 --- a/nuttx-configs/px4fmu-v2/nsh/defconfig +++ b/nuttx-configs/px4fmu-v2/nsh/defconfig @@ -455,7 +455,7 @@ CONFIG_PREALLOC_TIMERS=50 # Stack and heap information # CONFIG_IDLETHREAD_STACKSIZE=1000 -CONFIG_USERMAIN_STACKSIZE=3000 +CONFIG_USERMAIN_STACKSIZE=2500 CONFIG_PTHREAD_STACK_MIN=512 CONFIG_PTHREAD_STACK_DEFAULT=2048 @@ -801,11 +801,11 @@ CONFIG_SCHED_WORKQUEUE=y CONFIG_SCHED_HPWORK=y CONFIG_SCHED_WORKPRIORITY=192 CONFIG_SCHED_WORKPERIOD=5000 -CONFIG_SCHED_WORKSTACKSIZE=1800 +CONFIG_SCHED_WORKSTACKSIZE=1600 CONFIG_SCHED_LPWORK=y CONFIG_SCHED_LPWORKPRIORITY=50 CONFIG_SCHED_LPWORKPERIOD=50000 -CONFIG_SCHED_LPWORKSTACKSIZE=1800 +CONFIG_SCHED_LPWORKSTACKSIZE=1600 # CONFIG_LIB_KBDCODEC is not set # CONFIG_LIB_SLCDCODEC is not set @@ -1064,3 +1064,5 @@ CONFIG_SYSTEM_SYSINFO=y # # USB Monitor # + +CONFIG_NSOCKET_DESCRIPTORS=0 diff --git a/nuttx-configs/px4io-v1/scripts/ld.script b/nuttx-configs/px4io-v1/scripts/ld.script index 69c2f9cb2e..6cc77e9623 100755 --- a/nuttx-configs/px4io-v1/scripts/ld.script +++ b/nuttx-configs/px4io-v1/scripts/ld.script @@ -72,6 +72,11 @@ SECTIONS *(.gcc_except_table) *(.gnu.linkonce.r.*) _etext = ABSOLUTE(.); + /* + * This is a hack to make the newlib libm __errno() call + * use the NuttX get_errno_ptr() function. + */ + __errno = get_errno_ptr; } > flash /* @@ -103,6 +108,7 @@ SECTIONS *(.gnu.linkonce.d.*) CONSTRUCTORS _edata = ABSOLUTE(.); + . = ALIGN(4); } > sram AT > flash .bss : { diff --git a/nuttx-configs/px4io-v2/scripts/ld.script b/nuttx-configs/px4io-v2/scripts/ld.script index 69c2f9cb2e..6cc77e9623 100755 --- a/nuttx-configs/px4io-v2/scripts/ld.script +++ b/nuttx-configs/px4io-v2/scripts/ld.script @@ -72,6 +72,11 @@ SECTIONS *(.gcc_except_table) *(.gnu.linkonce.r.*) _etext = ABSOLUTE(.); + /* + * This is a hack to make the newlib libm __errno() call + * use the NuttX get_errno_ptr() function. + */ + __errno = get_errno_ptr; } > flash /* @@ -103,6 +108,7 @@ SECTIONS *(.gnu.linkonce.d.*) CONSTRUCTORS _edata = ABSOLUTE(.); + . = ALIGN(4); } > sram AT > flash .bss : { diff --git a/nuttx-configs/sim/include/README.txt b/nuttx-configs/sim/include/README.txt new file mode 100644 index 0000000000..f807449043 --- /dev/null +++ b/nuttx-configs/sim/include/README.txt @@ -0,0 +1 @@ +This directory contains header files unique to the Linux user-mode platform. diff --git a/nuttx-configs/sim/include/board.h b/nuttx-configs/sim/include/board.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/nuttx-configs/sim/nsh/Make.defs b/nuttx-configs/sim/nsh/Make.defs new file mode 100644 index 0000000000..83402a2397 --- /dev/null +++ b/nuttx-configs/sim/nsh/Make.defs @@ -0,0 +1,111 @@ +############################################################################ +# configs/sim/nsh/Make.defs +# +# Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk + +HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +else + ARCHOPTIMIZATION = -O2 +endif + +ARCHCPUFLAGS = -std=gnu99 -fno-builtin +ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions -fno-rtti +ARCHPICFLAGS = -fpic +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow +ARCHWARNINGSXX = -Wall -Wshadow +ARCHDEFINES = +ARCHINCLUDES = -I. -isystem $(TOPDIR)/include +ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx +ARCHSCRIPT = + +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + +CROSSDEV = +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGSXX) $(ARCHINCLUDESXX) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +OBJEXT = .o +LIBEXT = .a + +ifeq ($(HOSTOS),Cygwin) + EXEEXT = .exe +else + EXEEXT = +endif + +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 +endif + + +MKDEP = $(TOPDIR)/tools/mkdeps.sh + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \ + $(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +HOSTLDFLAGS = diff --git a/nuttx-configs/sim/nsh/defconfig b/nuttx-configs/sim/nsh/defconfig new file mode 100644 index 0000000000..391b3f03a6 --- /dev/null +++ b/nuttx-configs/sim/nsh/defconfig @@ -0,0 +1,531 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# +CONFIG_NUTTX_NEWCONFIG=y + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +CONFIG_HOST_LINUX=y +# CONFIG_HOST_OSX is not set +# CONFIG_HOST_WINDOWS is not set +# CONFIG_HOST_OTHER is not set + +# +# Build Configuration +# +# CONFIG_APPS_DIR="../apps" +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +# CONFIG_INTELHEX_BINARY is not set +# CONFIG_MOTOROLA_SREC is not set +# CONFIG_RAW_BINARY is not set + +# +# Customize Header Files +# +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_FLOAT_H is not set +# CONFIG_ARCH_STDARG_H is not set + +# +# Debug Options +# +# CONFIG_DEBUG is not set +CONFIG_DEBUG_SYMBOLS=y + +# +# System Type +# +# CONFIG_ARCH_8051 is not set +# CONFIG_ARCH_ARM is not set +# CONFIG_ARCH_AVR is not set +# CONFIG_ARCH_HC is not set +# CONFIG_ARCH_MIPS is not set +# CONFIG_ARCH_RGMP is not set +# CONFIG_ARCH_SH is not set +CONFIG_ARCH_SIM=y +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="sim" +CONFIG_BOARD_LOOPSPERMSEC=0 + +# +# Simulation Configuration Options +# +# CONFIG_SIM_M32 is not set +# CONFIG_SIM_WALLTIME is not set + +# +# External Memory Configuration +# + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +# CONFIG_ARCH_DMA is not set +# CONFIG_ARCH_IRQPRIO is not set +# CONFIG_CUSTOM_STACK is not set +# CONFIG_ADDRENV is not set +# CONFIG_ARCH_HAVE_VFORK is not set +# CONFIG_ARCH_STACKDUMP is not set +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_HAVE_RAMFUNCS is not set + +# +# Board Settings +# +CONFIG_DRAM_START=0x0 +CONFIG_DRAM_SIZE=0 + +# +# Boot options +# +CONFIG_BOOT_RUNFROMEXTSRAM=y +# CONFIG_BOOT_RUNFROMFLASH is not set +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_SIM=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="sim" + +# +# Common Board Options +# +CONFIG_NSH_MMCSDMINOR=0 + +# +# Board-Specific Options +# + +# +# RTOS Features +# +CONFIG_MSEC_PER_TICK=10 +CONFIG_RR_INTERVAL=0 +CONFIG_SCHED_INSTRUMENTATION=y +CONFIG_TASK_NAME_SIZE=32 +CONFIG_SCHED_HAVE_PARENT=y +# CONFIG_SCHED_CHILD_STATUS is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2008 +CONFIG_START_MONTH=6 +CONFIG_START_DAY=1 +CONFIG_DEV_CONSOLE=y +# CONFIG_MUTEX_TYPES is not set +# CONFIG_PRIORITY_INHERITANCE is not set +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +# CONFIG_SCHED_WORKQUEUE is not set +CONFIG_SCHED_WAITPID=y +# CONFIG_SCHED_STARTHOOK is not set +# CONFIG_SCHED_ATEXIT is not set +CONFIG_SCHED_ONEXIT=y +CONFIG_SCHED_ONEXIT_MAX=1 +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_CLOCK is not set +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_ENVIRON is not set + +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCHLD=4 +CONFIG_SIG_SIGCONDTIMEDOUT=16 + +# +# Sizes of configurable things (0 disables) +# +CONFIG_MAX_TASKS=64 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NFILE_DESCRIPTORS=32 +CONFIG_NFILE_STREAMS=16 +CONFIG_NAME_MAX=32 +CONFIG_PREALLOC_MQ_MSGS=32 +CONFIG_MQ_MAXMSGSIZE=32 +CONFIG_MAX_WDOGPARMS=4 +CONFIG_PREALLOC_WDOGS=32 +CONFIG_PREALLOC_TIMERS=8 + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_USERMAIN_STACKSIZE=4096 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=8192 + +# +# Device Drivers +# +#CONFIG_DISABLE_POLL is not set +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_LOOP is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_PWM is not set +# CONFIG_I2C is not set +# CONFIG_SPI is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set +# CONFIG_LCD is not set +# CONFIG_MMCSD is not set +# CONFIG_MTD is not set +# CONFIG_PIPES is not set +# CONFIG_PM is not set +# CONFIG_POWER is not set +# CONFIG_SENSORS is not set +# CONFIG_SERCOMM_CONSOLE is not set +CONFIG_SERIAL=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_16550_UART is not set +# CONFIG_STANDARD_SERIAL is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_WIRELESS is not set + +# +# System Logging Device Options +# + +# +# System Logging +# +# CONFIG_RAMLOG is not set + +# +# Networking Support +# +# CONFIG_NET is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_FS_RAMMAP is not set +CONFIG_FS_FAT=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FAT_MAXFNAME=32 +# CONFIG_FS_FATTIME is not set +# CONFIG_FAT_DMAMEMORY is not set +# CONFIG_FS_NXFFS is not set +CONFIG_FS_ROMFS=y +CONFIG_FS_BINFS=y + +# +# System Logging +# +# CONFIG_SYSLOG is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=1 +# CONFIG_GRAN is not set + +# +# Binary Formats +# +# CONFIG_BINFMT_DISABLE is not set +CONFIG_BINFMT_EXEPATH=y +CONFIG_PATH_INITIAL="/bin" +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +CONFIG_BUILTIN=y +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +CONFIG_LIB_HOMEDIR="/" +# CONFIG_LIBM is not set +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_EXECFUNCS_SYMTAB="g_symtab" +CONFIG_EXECFUNCS_NSYMBOLS=0 +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set + +# +# Non-standard Helper Functions +# +# CONFIG_LIB_KBDCODEC is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +# CONFIG_HAVE_CXX is not set + +# +# Application Configuration +# + +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + +# +# Examples +# +# CONFIG_EXAMPLES_BUTTONS is not set +# CONFIG_EXAMPLES_CAN is not set +# CONFIG_EXAMPLES_CDCACM is not set +# CONFIG_EXAMPLES_COMPOSITE is not set +# CONFIG_EXAMPLES_DHCPD is not set +# CONFIG_EXAMPLES_ELF is not set +# CONFIG_EXAMPLES_FTPC is not set +# CONFIG_EXAMPLES_FTPD is not set +CONFIG_EXAMPLES_HELLO=y +# CONFIG_EXAMPLES_HELLOXX is not set +# CONFIG_EXAMPLES_JSON is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_KEYPADTEST is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_LCDRW is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MOUNT is not set +# CONFIG_EXAMPLES_MODBUS is not set +CONFIG_EXAMPLES_NSH=y +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXCONSOLE is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXFLAT is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PASHELLO is not set +# CONFIG_EXAMPLES_PIPE is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set +# CONFIG_EXAMPLES_QENCODER is not set +# CONFIG_EXAMPLES_RGMP is not set +# CONFIG_EXAMPLES_ROMFS is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_TELNETD is not set +# CONFIG_EXAMPLES_THTTPD is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_UDP is not set +# CONFIG_EXAMPLES_UIP is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_USBMSC is not set +# CONFIG_EXAMPLES_USBTERM is not set +# CONFIG_EXAMPLES_WATCHDOG is not set + +# +# Interpreters +# + +# +# Interpreters +# +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# Network Utilities +# + +# +# Networking Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_DHCPC is not set +# CONFIG_NETUTILS_DHCPD is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_FTPD is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_RESOLV is not set +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_TFTPC is not set +# CONFIG_NETUTILS_THTTPD is not set +# CONFIG_NETUTILS_UIPLIB is not set +# CONFIG_NETUTILS_WEBCLIENT is not set + +# +# ModBus +# + +# +# FreeModbus +# +# CONFIG_MODBUS is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILE_APPS=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_DD is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_FREE is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MKFATFS is not set +# CONFIG_NSH_DISABLE_MKFIFO is not set +# CONFIG_NSH_DISABLE_MKRD is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MW is not set +# CONFIG_NSH_DISABLE_NSFMOUNT is not set +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PING is not set +# CONFIG_NSH_DISABLE_PUT is not set +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SH is not set +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +# CONFIG_NSH_DISABLE_WGET is not set +# CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_CODECS_BUFSIZE=128 +CONFIG_NSH_FILEIOSIZE=1024 +CONFIG_NSH_LINELEN=80 +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_ROMFSETC=y +CONFIG_NSH_ROMFSMOUNTPT="/etc" +CONFIG_NSH_INITSCRIPT="init.d/rcS" +CONFIG_NSH_ROMFSDEVNO=1 +CONFIG_NSH_ROMFSSECTSIZE=64 +CONFIG_NSH_FATDEVNO=2 +CONFIG_NSH_FATSECTSIZE=512 +CONFIG_NSH_FATNSECTORS=1024 +CONFIG_NSH_FATMOUNTPT="/tmp" +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_CONDEV is not set +# CONFIG_NSH_ARCHINIT is not set + +# +# NxWidgets/NxWM +# + +# +# System NSH Add-Ons +# + +# +# Custom Free Memory Command +# +# CONFIG_SYSTEM_FREE is not set + +# +# I2C tool +# + +# +# FLASH Program Installation +# +# CONFIG_SYSTEM_INSTALL is not set + +# +# readline() +# +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y + +# +# Power Off +# +# CONFIG_SYSTEM_POWEROFF is not set + +# +# RAMTRON +# +# CONFIG_SYSTEM_RAMTRON is not set + +# +# SD Card +# +# CONFIG_SYSTEM_SDCARD is not set + +# +# Sysinfo +# +# CONFIG_SYSTEM_SYSINFO is not set diff --git a/src/drivers/blinkm/module.mk b/nuttx-configs/sim/nsh/setenv.sh old mode 100644 new mode 100755 similarity index 75% rename from src/drivers/blinkm/module.mk rename to nuttx-configs/sim/nsh/setenv.sh index c906733175..c629c5a1ec --- a/src/drivers/blinkm/module.mk +++ b/nuttx-configs/sim/nsh/setenv.sh @@ -1,6 +1,8 @@ -############################################################################ +#!/bin/bash +# sim/nsh/setenv.sh # -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. +# Copyright (C) 2008 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -12,7 +14,7 @@ # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. -# 3. Neither the name PX4 nor the names of its contributors may be +# 3. Neither the name NuttX nor the names of its contributors may be # used to endorse or promote products derived from this software # without specific prior written permission. # @@ -29,14 +31,15 @@ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # -############################################################################ -# -# BlinkM I2C LED driver -# +if [ "$(basename $0)" = "setenv.sh" ] ; then + echo "You must source this script, not run it!" 1>&2 + exit 1 +fi -MODULE_COMMAND = blinkm +if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi -SRCS = blinkm.cpp +#export NUTTX_BIN= +#export PATH=${NUTTX_BIN}:/sbin:/usr/sbin:${PATH_ORIG} -MAXOPTIMIZATION = -Os +echo "PATH : ${PATH}" diff --git a/posix-configs/SITL/init/rc.fixed_wing b/posix-configs/SITL/init/rc.fixed_wing index 7cdad2f9dc..bdb2fb8e9d 100644 --- a/posix-configs/SITL/init/rc.fixed_wing +++ b/posix-configs/SITL/init/rc.fixed_wing @@ -39,7 +39,7 @@ navigator start ekf_att_pos_estimator start fw_att_control start fw_pos_control_l1 start -mixer load /dev/pwm_output0 ../../ROMFS/px4fmu_common/mixers/IO_pass.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/IO_pass.main.mix mavlink start -u 14556 -r 60000 mavlink stream -r 50 -s POSITION_TARGET_LOCAL_NED -u 14556 mavlink stream -r 50 -s LOCAL_POSITION_NED -u 14556 diff --git a/posix-configs/SITL/init/rcS b/posix-configs/SITL/init/rcS index b340096721..878eda3a6e 100644 --- a/posix-configs/SITL/init/rcS +++ b/posix-configs/SITL/init/rcS @@ -44,7 +44,7 @@ attitude_estimator_q start position_estimator_inav start mc_pos_control start mc_att_control start -mixer load /dev/pwm_output0 ../../ROMFS/px4fmu_common/mixers/quad_x.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/quad_x.main.mix mavlink start -u 14556 -r 2000000 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 mavlink stream -r 80 -s LOCAL_POSITION_NED -u 14556 @@ -53,5 +53,6 @@ mavlink stream -r 80 -s ATTITUDE -u 14556 mavlink stream -r 80 -s ATTITUDE_TARGET -u 14556 mavlink stream -r 20 -s RC_CHANNELS -u 14556 mavlink stream -r 250 -s HIGHRES_IMU -u 14556 +mavlink stream -r 10 -s OPTICAL_FLOW_RAD -u 14556 mavlink boot_complete sdlog2 start -r 100 -e -t -a diff --git a/posix-configs/SITL/init/rc_iris_ros b/posix-configs/SITL/init/rc_iris_ros index ffef510989..096f659d65 100644 --- a/posix-configs/SITL/init/rc_iris_ros +++ b/posix-configs/SITL/init/rc_iris_ros @@ -58,7 +58,7 @@ attitude_estimator_q start position_estimator_inav start mc_pos_control_m start mc_att_control_m start -mixer load /dev/pwm_output0 ../../ROMFS/px4fmu_common/mixers/quad_x.main.mix +mixer load /dev/pwm_output0 ../../../../ROMFS/px4fmu_common/mixers/quad_x.main.mix mavlink start -u 14556 -r 2000000 mavlink stream -r 80 -s POSITION_TARGET_LOCAL_NED -u 14556 mavlink stream -r 80 -s LOCAL_POSITION_NED -u 14556 diff --git a/src/modules/attitude_estimator_q/module.mk b/src/drivers/airspeed/CMakeLists.txt similarity index 90% rename from src/modules/attitude_estimator_q/module.mk rename to src/drivers/airspeed/CMakeLists.txt index b3688e4a9a..81a8f61113 100644 --- a/src/modules/attitude_estimator_q/module.mk +++ b/src/drivers/airspeed/CMakeLists.txt @@ -30,14 +30,13 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - -# -# Attitude estimator (quaternion based) -# - -MODULE_COMMAND = attitude_estimator_q - -SRCS = attitude_estimator_q_main.cpp \ - attitude_estimator_q_params.c - -MODULE_STACKSIZE = 1200 +px4_add_module( + MODULE drivers__airspeed + COMPILE_FLAGS + -Os + SRCS + airspeed.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/ardrone_interface/CMakeLists.txt b/src/drivers/ardrone_interface/CMakeLists.txt new file mode 100644 index 0000000000..70f50865ae --- /dev/null +++ b/src/drivers/ardrone_interface/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__ardrone_interface + MAIN ardrone_interface + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + ardrone_interface.c + ardrone_motor_control.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/ardrone_interface/module.mk b/src/drivers/ardrone_interface/module.mk deleted file mode 100644 index 285db1351c..0000000000 --- a/src/drivers/ardrone_interface/module.mk +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################ -# -# Copyright (C) 2012-2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# AR.Drone motor driver -# - -MODULE_COMMAND = ardrone_interface -SRCS = ardrone_interface.c \ - ardrone_motor_control.c -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/batt_smbus/CMakeLists.txt b/src/drivers/batt_smbus/CMakeLists.txt new file mode 100644 index 0000000000..d1ee69d45d --- /dev/null +++ b/src/drivers/batt_smbus/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__batt_smbus + MAIN batt_smbus + COMPILE_FLAGS + -Os + SRCS + batt_smbus.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/batt_smbus/module.mk b/src/drivers/batt_smbus/module.mk deleted file mode 100644 index b32ea6e55f..0000000000 --- a/src/drivers/batt_smbus/module.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -# driver for SMBus smart batteries -# - -MODULE_COMMAND = batt_smbus -SRCS = batt_smbus.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/blinkm/CMakeLists.txt b/src/drivers/blinkm/CMakeLists.txt new file mode 100644 index 0000000000..599913acaf --- /dev/null +++ b/src/drivers/blinkm/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__blinkm + MAIN blinkm + COMPILE_FLAGS + -Os + SRCS + blinkm.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/bma180/CMakeLists.txt b/src/drivers/bma180/CMakeLists.txt new file mode 100644 index 0000000000..7df83173fd --- /dev/null +++ b/src/drivers/bma180/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__bma180 + MAIN bma180 + COMPILE_FLAGS + -Os + SRCS + bma180.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/bma180/module.mk b/src/drivers/bma180/module.mk deleted file mode 100644 index 33433307a6..0000000000 --- a/src/drivers/bma180/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build the BMA180 driver. -# - -MODULE_COMMAND = bma180 - -SRCS = bma180.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/aerocore/CMakeLists.txt b/src/drivers/boards/aerocore/CMakeLists.txt new file mode 100644 index 0000000000..f1fb63a255 --- /dev/null +++ b/src/drivers/boards/aerocore/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__boards__aerocore + COMPILE_FLAGS + -Os + SRCS + aerocore_init.c + aerocore_pwm_servo.c + aerocore_spi.c + aerocore_led.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/aerocore/aerocore_spi.c b/src/drivers/boards/aerocore/aerocore_spi.c index 5a4dd15b26..1ce3f35f88 100644 --- a/src/drivers/boards/aerocore/aerocore_spi.c +++ b/src/drivers/boards/aerocore/aerocore_spi.c @@ -67,7 +67,7 @@ * ************************************************************************************/ -__EXPORT void weak_function stm32_spiinitialize(void) +__EXPORT void stm32_spiinitialize(void) { #ifdef CONFIG_STM32_SPI1 stm32_configgpio(GPIO_SPI1_NSS); diff --git a/src/drivers/boards/aerocore/module.mk b/src/drivers/boards/aerocore/module.mk deleted file mode 100644 index 0a2d910091..0000000000 --- a/src/drivers/boards/aerocore/module.mk +++ /dev/null @@ -1,10 +0,0 @@ -# -# Board-specific startup code for the AeroCore -# - -SRCS = aerocore_init.c \ - aerocore_pwm_servo.c \ - aerocore_spi.c \ - aerocore_led.c - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt b/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt new file mode 100644 index 0000000000..e4af694e5d --- /dev/null +++ b/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__boards__px4-stm32f4discovery + SRCS + px4discovery_init.c + px4discovery_usb.c + px4discovery_led.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/px4-stm32f4discovery/module.mk b/src/drivers/boards/px4-stm32f4discovery/module.mk deleted file mode 100644 index 6b75c08e92..0000000000 --- a/src/drivers/boards/px4-stm32f4discovery/module.mk +++ /dev/null @@ -1,7 +0,0 @@ -# -# Board-specific startup code for the PX4-STM32F4Discovery -# - -SRCS = px4discovery_init.c \ - px4discovery_usb.c \ - px4discovery_led.c diff --git a/src/drivers/boards/px4fmu-v1/CMakeLists.txt b/src/drivers/boards/px4fmu-v1/CMakeLists.txt new file mode 100644 index 0000000000..8807ed6730 --- /dev/null +++ b/src/drivers/boards/px4fmu-v1/CMakeLists.txt @@ -0,0 +1,47 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__boards__px4fmu-v1 + COMPILE_FLAGS + -Os + SRCS + px4fmu_can.c + px4fmu_init.c + px4fmu_pwm_servo.c + px4fmu_spi.c + px4fmu_usb.c + px4fmu_led.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/px4fmu-v1/module.mk b/src/drivers/boards/px4fmu-v1/module.mk deleted file mode 100644 index 5e1a27d5a1..0000000000 --- a/src/drivers/boards/px4fmu-v1/module.mk +++ /dev/null @@ -1,12 +0,0 @@ -# -# Board-specific startup code for the PX4FMU -# - -SRCS = px4fmu_can.c \ - px4fmu_init.c \ - px4fmu_pwm_servo.c \ - px4fmu_spi.c \ - px4fmu_usb.c \ - px4fmu_led.c - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/px4fmu-v1/px4fmu_init.c b/src/drivers/boards/px4fmu-v1/px4fmu_init.c index 2b2b5ccd7a..b0e741017e 100644 --- a/src/drivers/boards/px4fmu-v1/px4fmu_init.c +++ b/src/drivers/boards/px4fmu-v1/px4fmu_init.c @@ -145,6 +145,7 @@ static struct spi_dev_s *spi3; #include +#if 0 #ifdef __cplusplus __EXPORT int matherr(struct __exception *e) { @@ -156,6 +157,7 @@ __EXPORT int matherr(struct exception *e) return 1; } #endif +#endif __EXPORT int nsh_archinitialize(void) { diff --git a/src/drivers/boards/px4fmu-v1/px4fmu_spi.c b/src/drivers/boards/px4fmu-v1/px4fmu_spi.c index 8ef17c36ed..2a444796ff 100644 --- a/src/drivers/boards/px4fmu-v1/px4fmu_spi.c +++ b/src/drivers/boards/px4fmu-v1/px4fmu_spi.c @@ -67,7 +67,7 @@ * ************************************************************************************/ -__EXPORT void weak_function stm32_spiinitialize(void) +__EXPORT void stm32_spiinitialize(void) { stm32_configgpio(GPIO_SPI_CS_GYRO); stm32_configgpio(GPIO_SPI_CS_ACCEL); diff --git a/src/drivers/boards/px4fmu-v2/CMakeLists.txt b/src/drivers/boards/px4fmu-v2/CMakeLists.txt new file mode 100644 index 0000000000..27cb595c34 --- /dev/null +++ b/src/drivers/boards/px4fmu-v2/CMakeLists.txt @@ -0,0 +1,47 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__boards__px4fmu-v2 + COMPILE_FLAGS + -Os + SRCS + px4fmu_can.c + px4fmu2_init.c + px4fmu_pwm_servo.c + px4fmu_spi.c + px4fmu_usb.c + px4fmu2_led.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/px4fmu-v2/module.mk b/src/drivers/boards/px4fmu-v2/module.mk deleted file mode 100644 index 103232b0ca..0000000000 --- a/src/drivers/boards/px4fmu-v2/module.mk +++ /dev/null @@ -1,12 +0,0 @@ -# -# Board-specific startup code for the PX4FMUv2 -# - -SRCS = px4fmu_can.c \ - px4fmu2_init.c \ - px4fmu_pwm_servo.c \ - px4fmu_spi.c \ - px4fmu_usb.c \ - px4fmu2_led.c - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/px4fmu-v2/px4fmu2_init.c b/src/drivers/boards/px4fmu-v2/px4fmu2_init.c index 698258fa45..e4f32b34c6 100644 --- a/src/drivers/boards/px4fmu-v2/px4fmu2_init.c +++ b/src/drivers/boards/px4fmu-v2/px4fmu2_init.c @@ -210,17 +210,18 @@ static struct sdio_dev_s *sdio; #include -#ifdef __cplusplus -__EXPORT int matherr(struct __exception *e) -{ - return 1; -} -#else -__EXPORT int matherr(struct exception *e) -{ - return 1; -} -#endif +/* TODO XXX commented this out to get cmake build working */ +/*#ifdef __cplusplus*/ +/*__EXPORT int matherr(struct __exception *e)*/ +/*{*/ + /*return 1;*/ +/*}*/ +/*#else*/ +/*__EXPORT int matherr(struct exception *e)*/ +/*{*/ + /*return 1;*/ +/*}*/ +/*#endif*/ __EXPORT int nsh_archinitialize(void) { diff --git a/src/drivers/boards/px4fmu-v2/px4fmu_spi.c b/src/drivers/boards/px4fmu-v2/px4fmu_spi.c index 64b9926b8d..a380e05bd5 100644 --- a/src/drivers/boards/px4fmu-v2/px4fmu_spi.c +++ b/src/drivers/boards/px4fmu-v2/px4fmu_spi.c @@ -67,7 +67,7 @@ * ************************************************************************************/ -__EXPORT void weak_function stm32_spiinitialize(void) +__EXPORT void stm32_spiinitialize(void) { #ifdef CONFIG_STM32_SPI1 stm32_configgpio(GPIO_SPI_CS_GYRO); diff --git a/src/drivers/boards/px4io-v1/CMakeLists.txt b/src/drivers/boards/px4io-v1/CMakeLists.txt new file mode 100644 index 0000000000..0806a1e049 --- /dev/null +++ b/src/drivers/boards/px4io-v1/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__boards__px4io-v1 + COMPILE_FLAGS + -Os + SRCS + px4io_init.c + px4io_pwm_servo.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/px4io-v1/module.mk b/src/drivers/boards/px4io-v1/module.mk deleted file mode 100644 index a7a14dd072..0000000000 --- a/src/drivers/boards/px4io-v1/module.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -# Board-specific startup code for the PX4IO -# - -SRCS = px4io_init.c \ - px4io_pwm_servo.c - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/px4io-v2/CMakeLists.txt b/src/drivers/boards/px4io-v2/CMakeLists.txt new file mode 100644 index 0000000000..8969b90a29 --- /dev/null +++ b/src/drivers/boards/px4io-v2/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__boards__px4io-v2 + COMPILE_FLAGS + -Os + SRCS + px4iov2_init.c + px4iov2_pwm_servo.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/px4io-v2/module.mk b/src/drivers/boards/px4io-v2/module.mk deleted file mode 100644 index 3f0e9a0b3a..0000000000 --- a/src/drivers/boards/px4io-v2/module.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -# Board-specific startup code for the PX4IOv2 -# - -SRCS = px4iov2_init.c \ - px4iov2_pwm_servo.c - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/boards/px4io-v2/px4iov2_init.c b/src/drivers/boards/px4io-v2/px4io_init.c similarity index 100% rename from src/drivers/boards/px4io-v2/px4iov2_init.c rename to src/drivers/boards/px4io-v2/px4io_init.c diff --git a/src/drivers/boards/px4io-v2/px4iov2_pwm_servo.c b/src/drivers/boards/px4io-v2/px4io_pwm_servo.c similarity index 100% rename from src/drivers/boards/px4io-v2/px4iov2_pwm_servo.c rename to src/drivers/boards/px4io-v2/px4io_pwm_servo.c diff --git a/src/drivers/boards/sim/board_config.h b/src/drivers/boards/sim/board_config.h new file mode 100644 index 0000000000..6413bb780b --- /dev/null +++ b/src/drivers/boards/sim/board_config.h @@ -0,0 +1,13 @@ +#define UDID_START 0x1FFF7A10 + +/* + * I2C busses + */ +#define PX4_I2C_BUS_ESC 1 +#define PX4_SIM_BUS_TEST 2 +#define PX4_I2C_BUS_EXPANSION 3 +#define PX4_I2C_BUS_LED 3 + +#define PX4_I2C_OBDEV_LED 0x55 + +#define STM32_SYSMEM_UID "SIMULATIONID" diff --git a/src/drivers/boards/sitl/CMakeLists.txt b/src/drivers/boards/sitl/CMakeLists.txt new file mode 100644 index 0000000000..8d7d7bee34 --- /dev/null +++ b/src/drivers/boards/sitl/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__boards__sitl + COMPILE_FLAGS + -Os + SRCS + sitl_led.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/boards/sitl/module.mk b/src/drivers/boards/sitl/module.mk deleted file mode 100644 index c67272fc53..0000000000 --- a/src/drivers/boards/sitl/module.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -# Board-specific startup code for SITL -# - -SRCS = \ - sitl_led.c - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/camera_trigger/CMakeLists.txt b/src/drivers/camera_trigger/CMakeLists.txt new file mode 100644 index 0000000000..4f3669876e --- /dev/null +++ b/src/drivers/camera_trigger/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__camera_trigger + MAIN camera_trigger + COMPILE_FLAGS + -Os + SRCS + camera_trigger.cpp + camera_trigger_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/meas_airspeed/module.mk b/src/drivers/device/CMakeLists.txt similarity index 75% rename from src/drivers/meas_airspeed/module.mk rename to src/drivers/device/CMakeLists.txt index 6f5909978b..95df2d1855 100644 --- a/src/drivers/meas_airspeed/module.mk +++ b/src/drivers/device/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,16 +31,38 @@ # ############################################################################ -# -# Makefile to build the MEAS Spec airspeed sensor driver. -# +set(SRCS) -MODULE_COMMAND = meas_airspeed +list(APPEND SRCS + ringbuffer.cpp + integrator.cpp +) -SRCS = meas_airspeed.cpp +if(${OS} STREQUAL "nuttx") + if (NOT ${BOARD} STREQUAL "sim") + list(APPEND SRCS + device_nuttx.cpp + cdev.cpp + i2c_nuttx.cpp + pio.cpp + spi.cpp + ) + endif() +else() + list(APPEND SRCS + device_posix.cpp + vdev.cpp + vfile.cpp + vdev_posix.cpp + i2c_posix.cpp + sim.cpp + ) +endif() -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ - -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE drivers__device + SRCS ${SRCS} + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/device/cdev.cpp b/src/drivers/device/cdev.cpp index 3bc05b0c73..048357ebc8 100644 --- a/src/drivers/device/cdev.cpp +++ b/src/drivers/device/cdev.cpp @@ -306,7 +306,7 @@ CDev::poll(file_t *filp, struct pollfd *fds, bool setup) /* yes? post the notification */ if (fds->revents != 0) - sem_post(fds->sem); + px4_sem_post(fds->sem); } } else { @@ -343,7 +343,7 @@ CDev::poll_notify_one(struct pollfd *fds, pollevent_t events) /* if the state is now interesting, wake the waiter if it's still asleep */ /* XXX semcount check here is a vile hack; counting semphores should not be abused as cvars */ if ((fds->revents != 0) && (fds->sem->semcount <= 0)) - sem_post(fds->sem); + px4_sem_post(fds->sem); } pollevent_t diff --git a/src/drivers/device/device_posix.cpp b/src/drivers/device/device_posix.cpp index 5fc6a595ad..bed97ff56d 100644 --- a/src/drivers/device/device_posix.cpp +++ b/src/drivers/device/device_posix.cpp @@ -44,6 +44,7 @@ #include #include #include +#include namespace device { @@ -54,7 +55,11 @@ Device::Device(const char *name) : _name(name), _debug_enabled(false) { - sem_init(&_lock, 0, 1); + int ret = px4_sem_init(&_lock, 0, 1); + + if (ret != 0) { + PX4_WARN("SEM INIT FAIL: ret %d, %s", ret, strerror(errno)); + } /* setup a default device ID. When bus_type is UNKNOWN the other fields are invalid */ @@ -67,7 +72,7 @@ Device::Device(const char *name) : Device::~Device() { - sem_destroy(&_lock); + px4_sem_destroy(&_lock); } int diff --git a/src/drivers/device/integrator.cpp b/src/drivers/device/integrator.cpp new file mode 100644 index 0000000000..bc2baacc85 --- /dev/null +++ b/src/drivers/device/integrator.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** + * + * Copyright (c) 2015 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/** + * @file integrator.cpp + * + * A resettable integrator + * + * @author Lorenz Meier + */ + +#include "integrator.h" + +Integrator::Integrator(uint64_t auto_reset_interval, bool coning_compensation) : + _auto_reset_interval(auto_reset_interval), + _last_integration(0), + _last_auto(0), + _integral_auto(0.0f, 0.0f, 0.0f), + _integral_read(0.0f, 0.0f, 0.0f), + _last_val(0.0f, 0.0f, 0.0f), + _last_delta(0.0f, 0.0f, 0.0f), + _auto_callback(nullptr), + _coning_comp_on(coning_compensation) +{ + +} + +Integrator::~Integrator() +{ + +} + +bool +Integrator::put(uint64_t timestamp, math::Vector<3> &val, math::Vector<3> &integral, uint64_t &integral_dt) +{ + bool auto_reset = false; + + if (_last_integration == 0) { + /* this is the first item in the integrator */ + _last_integration = timestamp; + _last_auto = timestamp; + _last_val = val; + return false; + } + + // Integrate + double dt = (double)(timestamp - _last_integration) / 1000000.0; + math::Vector<3> i = (val + _last_val) * dt * 0.5f; + + // Apply coning compensation if required + if (_coning_comp_on) { + // Coning compensation derived by Paul Riseborough and Jonathan Challinger, + // following: + // Tian et al (2010) Three-loop Integration of GPS and Strapdown INS with Coning and Sculling Compensation + // Available: http://www.sage.unsw.edu.au/snap/publications/tian_etal2010b.pdf + + i += ((_integral_auto + _last_delta * (1.0f / 6.0f)) % i) * 0.5f; + } + + _integral_auto += i; + _integral_read += i; + + _last_integration = timestamp; + _last_val = val; + _last_delta = i; + + if ((timestamp - _last_auto) > _auto_reset_interval) { + if (_auto_callback) { + /* call the callback */ + _auto_callback(timestamp, _integral_auto); + } + + integral = _integral_auto; + integral_dt = (timestamp - _last_auto); + + auto_reset = true; + _last_auto = timestamp; + _integral_auto(0) = 0.0f; + _integral_auto(1) = 0.0f; + _integral_auto(2) = 0.0f; + } + + return auto_reset; +} + +math::Vector<3> +Integrator::read(bool auto_reset) +{ + math::Vector<3> val = _integral_read; + if (auto_reset) { + _integral_read(0) = 0.0f; + _integral_read(1) = 0.0f; + _integral_read(2) = 0.0f; + } + + return val; +} diff --git a/src/drivers/device/integrator.h b/src/drivers/device/integrator.h index 6dc886de96..6de5c942d9 100644 --- a/src/drivers/device/integrator.h +++ b/src/drivers/device/integrator.h @@ -43,8 +43,6 @@ #include -#include - class Integrator { public: Integrator(uint64_t auto_reset_interval = 4000 /* 250 Hz */, bool coning_compensation = false); @@ -59,7 +57,7 @@ public: * @return true if putting the item triggered an integral reset * and the integral should be published */ - bool put(hrt_abstime timestamp, math::Vector<3> &val, math::Vector<3> &integral, uint64_t &integral_dt); + bool put(uint64_t timestamp, math::Vector<3> &val, math::Vector<3> &integral, uint64_t &integral_dt); /** * Get the current integral value @@ -79,105 +77,20 @@ public: /** * Get current integral start time */ - hrt_abstime current_integral_start() { return _last_auto; } + uint64_t current_integral_start() { return _last_auto; } private: - hrt_abstime _auto_reset_interval; /**< the interval after which the content will be published and the integrator reset */ - hrt_abstime _last_integration; /**< timestamp of the last integration step */ - hrt_abstime _last_auto; /**< last auto-announcement of integral value */ + uint64_t _auto_reset_interval; /**< the interval after which the content will be published and the integrator reset */ + uint64_t _last_integration; /**< timestamp of the last integration step */ + uint64_t _last_auto; /**< last auto-announcement of integral value */ math::Vector<3> _integral_auto; /**< the integrated value which auto-resets after _auto_reset_interval */ math::Vector<3> _integral_read; /**< the integrated value since the last read */ math::Vector<3> _last_val; /**< previously integrated last value */ math::Vector<3> _last_delta; /**< last local delta */ - void (*_auto_callback)(hrt_abstime, math::Vector<3>); /**< the function callback for auto-reset */ + void (*_auto_callback)(uint64_t, math::Vector<3>); /**< the function callback for auto-reset */ bool _coning_comp_on; /**< coning compensation */ /* we don't want this class to be copied */ Integrator(const Integrator&); Integrator operator=(const Integrator&); }; - -Integrator::Integrator(hrt_abstime auto_reset_interval, bool coning_compensation) : - _auto_reset_interval(auto_reset_interval), - _last_integration(0), - _last_auto(0), - _integral_auto(0.0f, 0.0f, 0.0f), - _integral_read(0.0f, 0.0f, 0.0f), - _last_val(0.0f, 0.0f, 0.0f), - _last_delta(0.0f, 0.0f, 0.0f), - _auto_callback(nullptr), - _coning_comp_on(coning_compensation) -{ - -} - -Integrator::~Integrator() -{ - -} - -bool -Integrator::put(uint64_t timestamp, math::Vector<3> &val, math::Vector<3> &integral, uint64_t &integral_dt) -{ - bool auto_reset = false; - - if (_last_integration == 0) { - /* this is the first item in the integrator */ - _last_integration = timestamp; - _last_auto = timestamp; - _last_val = val; - return false; - } - - // Integrate - double dt = (double)(timestamp - _last_integration) / 1000000.0; - math::Vector<3> i = (val + _last_val) * dt * 0.5f; - - // Apply coning compensation if required - if (_coning_comp_on) { - // Coning compensation derived by Paul Riseborough and Jonathan Challinger, - // following: - // Tian et al (2010) Three-loop Integration of GPS and Strapdown INS with Coning and Sculling Compensation - // Available: http://www.sage.unsw.edu.au/snap/publications/tian_etal2010b.pdf - - i += ((_integral_auto + _last_delta * (1.0f / 6.0f)) % i) * 0.5f; - } - - _integral_auto += i; - _integral_read += i; - - _last_integration = timestamp; - _last_val = val; - _last_delta = i; - - if ((timestamp - _last_auto) > _auto_reset_interval) { - if (_auto_callback) { - /* call the callback */ - _auto_callback(timestamp, _integral_auto); - } - - integral = _integral_auto; - integral_dt = (timestamp - _last_auto); - - auto_reset = true; - _last_auto = timestamp; - _integral_auto(0) = 0.0f; - _integral_auto(1) = 0.0f; - _integral_auto(2) = 0.0f; - } - - return auto_reset; -} - -math::Vector<3> -Integrator::read(bool auto_reset) -{ - math::Vector<3> val = _integral_read; - if (auto_reset) { - _integral_read(0) = 0.0f; - _integral_read(1) = 0.0f; - _integral_read(2) = 0.0f; - } - - return val; -} diff --git a/src/drivers/device/module.mk b/src/drivers/device/module.mk deleted file mode 100644 index c206a5037c..0000000000 --- a/src/drivers/device/module.mk +++ /dev/null @@ -1,55 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Build the device driver framework. -# - -ifeq ($(PX4_TARGET_OS),nuttx) -SRCS = \ - device_nuttx.cpp \ - cdev.cpp \ - i2c_nuttx.cpp \ - pio.cpp \ - spi.cpp \ - ringbuffer.cpp -else -SRCS = \ - device_posix.cpp \ - vdev.cpp \ - vfile.cpp \ - vdev_posix.cpp \ - i2c_posix.cpp \ - sim.cpp \ - ringbuffer.cpp -endif diff --git a/src/drivers/device/vdev.cpp b/src/drivers/device/vdev.cpp index 507cebbf83..1900f19fbe 100644 --- a/src/drivers/device/vdev.cpp +++ b/src/drivers/device/vdev.cpp @@ -64,7 +64,7 @@ private: px4_dev_t() {} }; -#define PX4_MAX_DEV 200 +#define PX4_MAX_DEV 500 static px4_dev_t *devmap[PX4_MAX_DEV]; /* @@ -366,7 +366,7 @@ VDev::poll(file_t *filep, px4_pollfd_struct_t *fds, bool setup) /* yes? post the notification */ if (fds->revents != 0) - sem_post(fds->sem); + px4_sem_post(fds->sem); } else { PX4_WARN("Store Poll Waiter error."); } @@ -403,7 +403,7 @@ VDev::poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events) { PX4_DEBUG("VDev::poll_notify_one"); int value; - sem_getvalue(fds->sem, &value); + px4_sem_getvalue(fds->sem, &value); /* update the reported event set */ fds->revents |= fds->events & events; @@ -412,8 +412,9 @@ VDev::poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events) /* if the state is now interesting, wake the waiter if it's still asleep */ /* XXX semcount check here is a vile hack; counting semphores should not be abused as cvars */ - if ((fds->revents != 0) && (value <= 0)) - sem_post(fds->sem); + if ((fds->revents != 0) && (value <= 0)) { + px4_sem_post(fds->sem); + } } pollevent_t diff --git a/src/drivers/device/vdev.h b/src/drivers/device/vdev.h index c39857bbf0..89e06358f5 100644 --- a/src/drivers/device/vdev.h +++ b/src/drivers/device/vdev.h @@ -161,6 +161,7 @@ public: protected: const char *_name; /**< driver name */ + char *_lock_name; /**< name of the semaphore */ bool _debug_enabled; /**< if true, debug messages are printed */ union DeviceId _device_id; /**< device identifier information */ @@ -180,7 +181,7 @@ protected: */ void lock() { DEVICE_DEBUG("lock"); - do {} while (sem_wait(&_lock) != 0); + do {} while (px4_sem_wait(&_lock) != 0); } /** @@ -188,11 +189,11 @@ protected: */ void unlock() { DEVICE_DEBUG("unlock"); - sem_post(&_lock); + px4_sem_post(&_lock); } private: - sem_t _lock; + px4_sem_t _lock; /** disable copy construction for this and all subclasses */ Device(const Device &); diff --git a/src/drivers/device/vdev_posix.cpp b/src/drivers/device/vdev_posix.cpp index 10e136ed8e..5647bad892 100644 --- a/src/drivers/device/vdev_posix.cpp +++ b/src/drivers/device/vdev_posix.cpp @@ -56,8 +56,8 @@ extern "C" { static void timer_cb(void *data) { - sem_t *p_sem = (sem_t *)data; - sem_post(p_sem); + px4_sem_t *p_sem = (px4_sem_t *)data; + px4_sem_post(p_sem); PX4_DEBUG("timer_handler: Timer expired"); } @@ -193,13 +193,13 @@ int px4_ioctl(int fd, int cmd, unsigned long arg) int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout) { - sem_t sem; + px4_sem_t sem; int count = 0; int ret = -1; unsigned int i; PX4_DEBUG("Called px4_poll timeout = %d", timeout); - sem_init(&sem, 0, 0); + px4_sem_init(&sem, 0, 0); // For each fd for (i=0; i #include #include +#define __STDC_FORMAT_MACROS #include -#include +#include #include __BEGIN_DECLS diff --git a/src/drivers/drv_sensor.h b/src/drivers/drv_sensor.h index a402f327b7..0c1ab48267 100644 --- a/src/drivers/drv_sensor.h +++ b/src/drivers/drv_sensor.h @@ -121,5 +121,10 @@ */ #define SENSORIOCGROTATION _SENSORIOC(6) +/** + * Test the sensor calibration + */ +#define SENSORIOCCALTEST _SENSORIOC(7) + #endif /* _DRV_SENSOR_H */ diff --git a/src/drivers/ets_airspeed/CMakeLists.txt b/src/drivers/ets_airspeed/CMakeLists.txt new file mode 100644 index 0000000000..f989419311 --- /dev/null +++ b/src/drivers/ets_airspeed/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__ets_airspeed + MAIN ets_airspeed + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + ets_airspeed.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/frsky_telemetry/CMakeLists.txt b/src/drivers/frsky_telemetry/CMakeLists.txt new file mode 100644 index 0000000000..7d6c17f463 --- /dev/null +++ b/src/drivers/frsky_telemetry/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__frsky_telemetry + MAIN frsky_telemetry + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + frsky_data.c + frsky_telemetry.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/frsky_telemetry/module.mk b/src/drivers/frsky_telemetry/module.mk deleted file mode 100644 index 78ad6f67ec..0000000000 --- a/src/drivers/frsky_telemetry/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# FrSky telemetry application. -# - -MODULE_COMMAND = frsky_telemetry - -SRCS = frsky_data.c \ - frsky_telemetry.c - -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/gimbal/CMakeLists.txt b/src/drivers/gimbal/CMakeLists.txt new file mode 100644 index 0000000000..ac26a1876e --- /dev/null +++ b/src/drivers/gimbal/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__gimbal + MAIN gimbal + COMPILE_FLAGS + -Os + SRCS + gimbal.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/gimbal/module.mk b/src/drivers/gimbal/module.mk deleted file mode 100644 index cc0a10c6e3..0000000000 --- a/src/drivers/gimbal/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2014, 2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build the gimbal high-level controller -# - -MODULE_COMMAND = gimbal - -SRCS = gimbal.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/gps/CMakeLists.txt b/src/drivers/gps/CMakeLists.txt new file mode 100644 index 0000000000..2441ba9ff7 --- /dev/null +++ b/src/drivers/gps/CMakeLists.txt @@ -0,0 +1,48 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__gps + MAIN gps + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + gps.cpp + gps_helper.cpp + mtk.cpp + ashtech.cpp + ubx.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/gps/gps.cpp b/src/drivers/gps/gps.cpp index 41947f27e7..35ee8658a0 100644 --- a/src/drivers/gps/gps.cpp +++ b/src/drivers/gps/gps.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -230,7 +229,7 @@ GPS::init() /* start the GPS driver worker task */ _task = px4_task_spawn_cmd("gps", SCHED_DEFAULT, - SCHED_PRIORITY_SLOW_DRIVER, 1500, (main_t)&GPS::task_main_trampoline, nullptr); + SCHED_PRIORITY_SLOW_DRIVER, 1200, (main_t)&GPS::task_main_trampoline, nullptr); if (_task < 0) { warnx("task start failed: %d", errno); diff --git a/src/drivers/gps/module.mk b/src/drivers/gps/module.mk deleted file mode 100644 index 4f99b0d3b5..0000000000 --- a/src/drivers/gps/module.mk +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# GPS driver -# - -MODULE_COMMAND = gps - -SRCS = gps.cpp \ - gps_helper.cpp \ - mtk.cpp \ - ashtech.cpp \ - ubx.cpp - -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/hmc5883/CMakeLists.txt b/src/drivers/hmc5883/CMakeLists.txt new file mode 100644 index 0000000000..6f2f98a822 --- /dev/null +++ b/src/drivers/hmc5883/CMakeLists.txt @@ -0,0 +1,47 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__hmc5883 + MAIN hmc5883 + STACK 1200 + COMPILE_FLAGS + -Weffc++ + -Os + SRCS + hmc5883_i2c.cpp + hmc5883_spi.cpp + hmc5883.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/hmc5883/hmc5883.h b/src/drivers/hmc5883/hmc5883.h index 9607fe6149..4cef0aa8cf 100644 --- a/src/drivers/hmc5883/hmc5883.h +++ b/src/drivers/hmc5883/hmc5883.h @@ -48,6 +48,6 @@ #define ID_C_WHO_AM_I '3' /* interface factories */ -extern device::Device *HMC5883_SPI_interface(int bus) weak_function; -extern device::Device *HMC5883_I2C_interface(int bus) weak_function; +extern device::Device *HMC5883_SPI_interface(int bus); +extern device::Device *HMC5883_I2C_interface(int bus); typedef device::Device *(*HMC5883_constructor)(int); diff --git a/src/drivers/hmc5883/module.mk b/src/drivers/hmc5883/module.mk deleted file mode 100644 index d4028b511d..0000000000 --- a/src/drivers/hmc5883/module.mk +++ /dev/null @@ -1,46 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# HMC5883 driver -# - -MODULE_COMMAND = hmc5883 - -SRCS = hmc5883_i2c.cpp hmc5883_spi.cpp hmc5883.cpp - -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/hott/CMakeLists.txt b/src/drivers/hott/CMakeLists.txt new file mode 100644 index 0000000000..827c720317 --- /dev/null +++ b/src/drivers/hott/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__hott + COMPILE_FLAGS + -Os + SRCS + messages.cpp + comms.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/hott/hott_sensors/CMakeLists.txt b/src/drivers/hott/hott_sensors/CMakeLists.txt new file mode 100644 index 0000000000..6d9b9b6c47 --- /dev/null +++ b/src/drivers/hott/hott_sensors/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__hott__hott_sensors + MAIN hott_sensors + COMPILE_FLAGS + -Os + SRCS + hott_sensors.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/hott/hott_telemetry/CMakeLists.txt b/src/drivers/hott/hott_telemetry/CMakeLists.txt new file mode 100644 index 0000000000..b86ef91cb3 --- /dev/null +++ b/src/drivers/hott/hott_telemetry/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__hott__hott_telemetry + MAIN hott_telemetry + COMPILE_FLAGS + -Os + SRCS + hott_telemetry.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/hott/module.mk b/src/drivers/hott/module.mk deleted file mode 100644 index 31a66d491d..0000000000 --- a/src/drivers/hott/module.mk +++ /dev/null @@ -1,41 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Graupner HoTT Sensors messages. -# - -SRCS = messages.cpp \ - comms.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/irlock/CMakeLists.txt b/src/drivers/irlock/CMakeLists.txt new file mode 100644 index 0000000000..d821afb3b6 --- /dev/null +++ b/src/drivers/irlock/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__irlock + MAIN irlock + COMPILE_FLAGS + -Os + SRCS + irlock.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/irlock/module.mk b/src/drivers/irlock/module.mk deleted file mode 100644 index 5d9fbf4539..0000000000 --- a/src/drivers/irlock/module.mk +++ /dev/null @@ -1,9 +0,0 @@ -# -# Makefile to build the IRLock driver. -# - -MODULE_COMMAND = irlock - -SRCS = irlock.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/l3gd20/CMakeLists.txt b/src/drivers/l3gd20/CMakeLists.txt new file mode 100644 index 0000000000..4534295694 --- /dev/null +++ b/src/drivers/l3gd20/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__l3gd20 + MAIN l3gd20 + STACK 1200 + COMPILE_FLAGS + -Weffc++ + -Os + SRCS + l3gd20.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/l3gd20/module.mk b/src/drivers/l3gd20/module.mk deleted file mode 100644 index 3d64d62be0..0000000000 --- a/src/drivers/l3gd20/module.mk +++ /dev/null @@ -1,12 +0,0 @@ -# -# LSM303D accel/mag driver -# - -MODULE_COMMAND = l3gd20 -SRCS = l3gd20.cpp - -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/roboclaw/module.mk b/src/drivers/led/CMakeLists.txt similarity index 88% rename from src/drivers/roboclaw/module.mk rename to src/drivers/led/CMakeLists.txt index c5e55bdc30..2279751d8c 100644 --- a/src/drivers/roboclaw/module.mk +++ b/src/drivers/led/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -30,14 +30,13 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - -# -# RoboClaw Motor Controller -# - -MODULE_COMMAND = roboclaw - -SRCS = roboclaw_main.cpp \ - RoboClaw.cpp - -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE drivers__led + COMPILE_FLAGS + -Os + SRCS + led.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/led/led.cpp b/src/drivers/led/led.cpp index 7ff53fc423..831e8f4634 100644 --- a/src/drivers/led/led.cpp +++ b/src/drivers/led/led.cpp @@ -38,7 +38,6 @@ */ #include -#include #include #include #include diff --git a/src/drivers/led/module.mk b/src/drivers/led/module.mk deleted file mode 100644 index 5b7b4491b7..0000000000 --- a/src/drivers/led/module.mk +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Build the LED driver. -# - -SRCS = led.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/ll40ls/CMakeLists.txt b/src/drivers/ll40ls/CMakeLists.txt new file mode 100644 index 0000000000..e8f6a9af96 --- /dev/null +++ b/src/drivers/ll40ls/CMakeLists.txt @@ -0,0 +1,46 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__ll40ls + MAIN ll40ls + COMPILE_FLAGS + -Os + SRCS + ll40ls.cpp + LidarLite.cpp + LidarLiteI2C.cpp + LidarLitePWM.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/ll40ls/module.mk b/src/drivers/ll40ls/module.mk deleted file mode 100644 index c2c5e1e22a..0000000000 --- a/src/drivers/ll40ls/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build the PulsedLight Lidar-Lite driver. -# - -MODULE_COMMAND = ll40ls - -SRCS = ll40ls.cpp \ - LidarLite.cpp \ - LidarLiteI2C.cpp \ - LidarLitePWM.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/lsm303d/CMakeLists.txt b/src/drivers/lsm303d/CMakeLists.txt new file mode 100644 index 0000000000..c781592137 --- /dev/null +++ b/src/drivers/lsm303d/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__lsm303d + MAIN lsm303d + STACK 1200 + COMPILE_FLAGS + -Weffc++ + -Os + SRCS + lsm303d.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/lsm303d/module.mk b/src/drivers/lsm303d/module.mk deleted file mode 100644 index 0421eb113e..0000000000 --- a/src/drivers/lsm303d/module.mk +++ /dev/null @@ -1,12 +0,0 @@ -# -# LSM303D accel/mag driver -# - -MODULE_COMMAND = lsm303d -SRCS = lsm303d.cpp - -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/mb12xx/CMakeLists.txt b/src/drivers/mb12xx/CMakeLists.txt new file mode 100644 index 0000000000..3517cf4eb0 --- /dev/null +++ b/src/drivers/mb12xx/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__mb12xx + MAIN mb12xx + COMPILE_FLAGS + -Os + SRCS + mb12xx.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/md25/CMakeLists.txt b/src/drivers/md25/CMakeLists.txt new file mode 100644 index 0000000000..d57ff5b4f5 --- /dev/null +++ b/src/drivers/md25/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__md25 + MAIN md25 + COMPILE_FLAGS + -Os + SRCS + md25.cpp + md25_main.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/meas_airspeed/CMakeLists.txt b/src/drivers/meas_airspeed/CMakeLists.txt new file mode 100644 index 0000000000..16e0f97b59 --- /dev/null +++ b/src/drivers/meas_airspeed/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__meas_airspeed + MAIN meas_airspeed + STACK 1200 + COMPILE_FLAGS + -Weffc++ + -Os + SRCS + meas_airspeed.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/mkblctrl/CMakeLists.txt b/src/drivers/mkblctrl/CMakeLists.txt new file mode 100644 index 0000000000..1a711bdfa0 --- /dev/null +++ b/src/drivers/mkblctrl/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__mkblctrl + MAIN mkblctrl + COMPILE_FLAGS + -Os + SRCS + mkblctrl.cpp + mkblctrl_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/mkblctrl/module.mk b/src/drivers/mkblctrl/module.mk deleted file mode 100644 index 10468509ef..0000000000 --- a/src/drivers/mkblctrl/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012,2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Interface driver for the Mikrokopter BLCtrl -# - -MODULE_COMMAND = mkblctrl - -SRCS = mkblctrl.cpp \ - mkblctrl_params.c - -INCLUDE_DIRS += $(TOPDIR)/arch/arm/src/stm32 $(TOPDIR)/arch/arm/src/common - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/mpu6000/CMakeLists.txt b/src/drivers/mpu6000/CMakeLists.txt new file mode 100644 index 0000000000..1a1e7a639e --- /dev/null +++ b/src/drivers/mpu6000/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__mpu6000 + MAIN mpu6000 + STACK 1200 + COMPILE_FLAGS + -Weffc++ + -Os + SRCS + mpu6000.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/mpu6000/module.mk b/src/drivers/mpu6000/module.mk deleted file mode 100644 index da9fcc0fc4..0000000000 --- a/src/drivers/mpu6000/module.mk +++ /dev/null @@ -1,46 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build the MPU6000 driver. -# - -MODULE_COMMAND = mpu6000 - -SRCS = mpu6000.cpp - -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/mpu9250/CMakeLists.txt b/src/drivers/mpu9250/CMakeLists.txt new file mode 100644 index 0000000000..0c1b6e6fb8 --- /dev/null +++ b/src/drivers/mpu9250/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__mpu9250 + MAIN mpu9250 + STACK 1200 + COMPILE_FLAGS + -Weffc++ + -Os + SRCS + mpu9250.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/mpu9250/module.mk b/src/drivers/mpu9250/module.mk deleted file mode 100644 index 80ee992da4..0000000000 --- a/src/drivers/mpu9250/module.mk +++ /dev/null @@ -1,46 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build the MPU6000 driver. -# - -MODULE_COMMAND = mpu9250 - -SRCS = mpu9250.cpp - -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/ms5611/CMakeLists.txt b/src/drivers/ms5611/CMakeLists.txt new file mode 100644 index 0000000000..7359bd9507 --- /dev/null +++ b/src/drivers/ms5611/CMakeLists.txt @@ -0,0 +1,59 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +set(srcs + ms5611_spi.cpp + ms5611_i2c.cpp + ) + +if(${OS} STREQUAL "nuttx") + list(APPEND srcs + ms5611_nuttx.cpp + ) +else() + list(APPEND srcs + ms5611_posix.cpp + ms5611_sim.cpp + ) + +endif() + +px4_add_module( + MODULE drivers__ms5611 + MAIN ms5611 + COMPILE_FLAGS + -Os + SRCS ${srcs} + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/ms5611/module.mk b/src/drivers/ms5611/module.mk deleted file mode 100644 index 7ff49d7354..0000000000 --- a/src/drivers/ms5611/module.mk +++ /dev/null @@ -1,46 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# MS5611 driver -# - -MODULE_COMMAND = ms5611 - -ifeq ($(PX4_TARGET_OS),nuttx) -SRCS = ms5611_nuttx.cpp ms5611_spi.cpp ms5611_i2c.cpp -else -SRCS = ms5611_posix.cpp ms5611_spi.cpp ms5611_i2c.cpp ms5611_sim.cpp -endif - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/ms5611/ms5611.h b/src/drivers/ms5611/ms5611.h index a7e305b2aa..cc3e4c5920 100644 --- a/src/drivers/ms5611/ms5611.h +++ b/src/drivers/ms5611/ms5611.h @@ -80,7 +80,7 @@ extern bool crc4(uint16_t *n_prom); } /* namespace */ /* interface factories */ -extern device::Device *MS5611_spi_interface(ms5611::prom_u &prom_buf, uint8_t busnum) __attribute__((weak)); -extern device::Device *MS5611_i2c_interface(ms5611::prom_u &prom_buf, uint8_t busnum) __attribute__((weak)); -extern device::Device *MS5611_sim_interface(ms5611::prom_u &prom_buf, uint8_t busnum) __attribute__((weak)); +extern device::Device *MS5611_spi_interface(ms5611::prom_u &prom_buf, uint8_t busnum); +extern device::Device *MS5611_i2c_interface(ms5611::prom_u &prom_buf, uint8_t busnum); +extern device::Device *MS5611_sim_interface(ms5611::prom_u &prom_buf, uint8_t busnum); typedef device::Device *(*MS5611_constructor)(ms5611::prom_u &prom_buf, uint8_t busnum); diff --git a/src/drivers/ms5611/ms5611_i2c.cpp b/src/drivers/ms5611/ms5611_i2c.cpp index 74f67c0f26..3a86a7f064 100644 --- a/src/drivers/ms5611/ms5611_i2c.cpp +++ b/src/drivers/ms5611/ms5611_i2c.cpp @@ -45,7 +45,6 @@ #include #include #include -//#include #include #include @@ -71,20 +70,16 @@ public: virtual ~MS5611_I2C(); virtual int init(); - virtual ssize_t read(device::file_t *handlep, char *data, size_t count); - virtual int ioctl(device::file_t *handlep, int cmd, unsigned long arg); + virtual int read(unsigned offset, void *data, unsigned count); + virtual int ioctl(unsigned operation, unsigned &arg); -#ifdef __PX4_NUTTX protected: virtual int probe(); -#endif private: ms5611::prom_u &_prom; -#ifdef __PX4_NUTTX int _probe_address(uint8_t address); -#endif /** * Send a reset command to the MS5611. @@ -116,13 +111,7 @@ MS5611_i2c_interface(ms5611::prom_u &prom_buf, uint8_t busnum) } MS5611_I2C::MS5611_I2C(uint8_t bus, ms5611::prom_u &prom) : - I2C("MS5611_I2C", -#ifdef __PX4_NUTTX - nullptr, bus, 0, 400000 -#else - "/dev/MS5611_I2C", bus, 0 -#endif - ), + I2C("MS5611_I2C", nullptr, bus, 0, 400000), _prom(prom) { } @@ -138,8 +127,8 @@ MS5611_I2C::init() return I2C::init(); } -ssize_t -MS5611_I2C::read(device::file_t *handlep, char *data, size_t buflen) +int +MS5611_I2C::read(unsigned offset, void *data, unsigned count) { union _cvt { uint8_t b[4]; @@ -163,11 +152,11 @@ MS5611_I2C::read(device::file_t *handlep, char *data, size_t buflen) } int -MS5611_I2C::ioctl(device::file_t *handlep, int cmd, unsigned long arg) +MS5611_I2C::ioctl(unsigned operation, unsigned &arg) { int ret; - switch (cmd) { + switch (operation) { case IOCTL_RESET: ret = _reset(); break; @@ -183,7 +172,6 @@ MS5611_I2C::ioctl(device::file_t *handlep, int cmd, unsigned long arg) return ret; } -#ifdef __PX4_NUTTX int MS5611_I2C::probe() { @@ -220,8 +208,6 @@ MS5611_I2C::_probe_address(uint8_t address) return PX4_OK; } -#endif - int MS5611_I2C::_reset() @@ -266,6 +252,9 @@ MS5611_I2C::_read_prom() */ usleep(3000); + uint8_t last_val = 0; + bool bits_stuck = true; + /* read and convert PROM words */ for (int i = 0; i < 8; i++) { uint8_t cmd = ADDR_PROM_SETUP + (i * 2); @@ -274,6 +263,16 @@ MS5611_I2C::_read_prom() break; } + /* check if all bytes are zero */ + if (i == 0) { + /* initalize to first byte read */ + last_val = prom_buf[0]; + } + + if (prom_buf[0] != last_val || prom_buf[1] != last_val) { + bits_stuck = false; + } + /* assemble 16 bit value and convert from big endian (sensor) to little endian (MCU) */ cvt.b[0] = prom_buf[1]; cvt.b[1] = prom_buf[0]; @@ -281,5 +280,5 @@ MS5611_I2C::_read_prom() } /* calculate CRC and return success/failure accordingly */ - return ms5611::crc4(&_prom.c[0]) ? PX4_OK : -EIO; + return (ms5611::crc4(&_prom.c[0]) && !bits_stuck) ? PX4_OK : -EIO; } diff --git a/src/drivers/ms5611/ms5611_nuttx.cpp b/src/drivers/ms5611/ms5611_nuttx.cpp index 7c336dfcab..91dd785bc6 100644 --- a/src/drivers/ms5611/ms5611_nuttx.cpp +++ b/src/drivers/ms5611/ms5611_nuttx.cpp @@ -963,7 +963,7 @@ start(enum MS5611_BUS busid) continue; } - started |= start_bus(bus_options[i]); + started = started || start_bus(bus_options[i]); } if (!started) { diff --git a/src/drivers/oreoled/CMakeLists.txt b/src/drivers/oreoled/CMakeLists.txt new file mode 100644 index 0000000000..f0407c71f6 --- /dev/null +++ b/src/drivers/oreoled/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__oreoled + MAIN oreoled + COMPILE_FLAGS + -Os + SRCS + oreoled.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/oreoled/module.mk b/src/drivers/oreoled/module.mk deleted file mode 100644 index 96afdd5fdc..0000000000 --- a/src/drivers/oreoled/module.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -# Oreo LED driver -# - -MODULE_COMMAND = oreoled -SRCS = oreoled.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/pca8574/CMakeLists.txt b/src/drivers/pca8574/CMakeLists.txt new file mode 100644 index 0000000000..4b00076be4 --- /dev/null +++ b/src/drivers/pca8574/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__pca8574 + MAIN pca8574 + COMPILE_FLAGS + -Os + SRCS + pca8574.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/pca8574/module.mk b/src/drivers/pca8574/module.mk deleted file mode 100644 index c53ed9ab2b..0000000000 --- a/src/drivers/pca8574/module.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -# PCA8574 driver for RGB LED -# - -MODULE_COMMAND = pca8574 -SRCS = pca8574.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/airspeed/module.mk b/src/drivers/pca9685/CMakeLists.txt similarity index 88% rename from src/drivers/airspeed/module.mk rename to src/drivers/pca9685/CMakeLists.txt index 5fbc75309c..e5053ab8f6 100644 --- a/src/drivers/airspeed/module.mk +++ b/src/drivers/pca9685/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -30,11 +30,12 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - -# -# Makefile to build the generic airspeed driver. -# - -SRCS = airspeed.cpp - -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE drivers__pca9685 + MAIN pca9685 + SRCS + pca9685.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/pca9685/module.mk b/src/drivers/pca9685/module.mk deleted file mode 100644 index 7a5c7996ec..0000000000 --- a/src/drivers/pca9685/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Driver for the PCA9685 I2C PWM controller -# The chip is used on the adafruit I2C PWM converter, -# which allows to control servos via I2C. -# https://www.adafruit.com/product/815 - -MODULE_COMMAND = pca9685 - -SRCS = pca9685.cpp diff --git a/src/drivers/pwm_input/CMakeLists.txt b/src/drivers/pwm_input/CMakeLists.txt new file mode 100644 index 0000000000..81c79fd842 --- /dev/null +++ b/src/drivers/pwm_input/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__pwm_input + MAIN pwm_input + COMPILE_FLAGS + -Wno-pmf-conversions + + SRCS + pwm_input.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/pwm_input/module.mk b/src/drivers/pwm_input/module.mk deleted file mode 100644 index a135ce777e..0000000000 --- a/src/drivers/pwm_input/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build the PWM input driver. -# - -MODULE_COMMAND = pwm_input - -SRCS = pwm_input.cpp - -EXTRACXXFLAGS = -Wno-pmf-conversions diff --git a/src/drivers/pwm_out_sim/CMakeLists.txt b/src/drivers/pwm_out_sim/CMakeLists.txt new file mode 100644 index 0000000000..0febaa0bea --- /dev/null +++ b/src/drivers/pwm_out_sim/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__pwm_out_sim + MAIN pwm_out_sim + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + pwm_out_sim.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/pwm_out_sim/module.mk b/src/drivers/pwm_out_sim/module.mk deleted file mode 100644 index 286b4d21f1..0000000000 --- a/src/drivers/pwm_out_sim/module.mk +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Hardware in the Loop (HIL) simulation actuator output bank -# - -MODULE_COMMAND = pwm_out_sim - -SRCS = pwm_out_sim.cpp - -MAXOPTIMIZATION = -Os - -MODULE_STACKSIZE = 1200 diff --git a/src/drivers/px4flow/CMakeLists.txt b/src/drivers/px4flow/CMakeLists.txt new file mode 100644 index 0000000000..21bfa4526e --- /dev/null +++ b/src/drivers/px4flow/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__px4flow + MAIN px4flow + STACK 1200 + COMPILE_FLAGS + -Wno-attributes + -Os + SRCS + px4flow.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/px4flow/i2c_frame.h b/src/drivers/px4flow/i2c_frame.h index b391b1f6a8..43e10e417c 100644 --- a/src/drivers/px4flow/i2c_frame.h +++ b/src/drivers/px4flow/i2c_frame.h @@ -40,8 +40,9 @@ #ifndef I2C_FRAME_H_ #define I2C_FRAME_H_ -#include +#define __STDC_FORMAT_MACROS +#include typedef struct i2c_frame { diff --git a/src/drivers/px4flow/px4flow.cpp b/src/drivers/px4flow/px4flow.cpp index db0f45ec1f..134ce6a52b 100644 --- a/src/drivers/px4flow/px4flow.cpp +++ b/src/drivers/px4flow/px4flow.cpp @@ -216,6 +216,10 @@ PX4FLOW::~PX4FLOW() if (_reports != nullptr) { delete _reports; } + + perf_free(_sample_perf); + perf_free(_comms_errors); + perf_free(_buffer_overflows); } int diff --git a/src/drivers/px4fmu/CMakeLists.txt b/src/drivers/px4fmu/CMakeLists.txt new file mode 100644 index 0000000000..492aad5939 --- /dev/null +++ b/src/drivers/px4fmu/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__px4fmu + MAIN fmu + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + fmu.cpp + px4fmu_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index 3db4fb5e13..4d82ef9e08 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -133,14 +133,16 @@ private: unsigned _pwm_alt_rate; uint32_t _pwm_alt_rate_channels; unsigned _current_update_rate; - int _task; + struct work_s _work; int _armed_sub; int _param_sub; + struct rc_input_values _rc_in; + orb_advert_t _to_input_rc; orb_advert_t _outputs_pub; unsigned _num_outputs; int _class_instance; - volatile bool _task_should_exit; + volatile bool _initialized; bool _servo_armed; bool _pwm_on; @@ -166,8 +168,11 @@ private: static bool arm_nothrottle() { return (_armed.prearmed && !_armed.armed); } - static void task_main_trampoline(int argc, char *argv[]); - void task_main(); + static void cycle_trampoline(void *arg); + + void cycle(); + void work_start(); + void work_stop(); static int control_callback(uintptr_t handle, uint8_t control_group, @@ -255,19 +260,21 @@ PX4FMU *g_fmu; } // namespace PX4FMU::PX4FMU() : - CDev("fmuservo", PX4FMU_DEVICE_PATH), + CDev("fmu", PX4FMU_DEVICE_PATH), _mode(MODE_NONE), _pwm_default_rate(50), _pwm_alt_rate(50), _pwm_alt_rate_channels(0), _current_update_rate(0), - _task(-1), + _work{}, _armed_sub(-1), _param_sub(-1), + _rc_in{}, + _to_input_rc(nullptr), _outputs_pub(nullptr), _num_outputs(0), _class_instance(0), - _task_should_exit(false), + _initialized(false), _servo_armed(false), _pwm_on(false), _mixers(nullptr), @@ -294,29 +301,30 @@ PX4FMU::PX4FMU() : memset(_controls, 0, sizeof(_controls)); memset(_poll_fds, 0, sizeof(_poll_fds)); +#ifdef HRT_PPM_CHANNEL + // rc input, published to ORB + memset(&_rc_in, 0, sizeof(_rc_in)); + _rc_in.input_source = input_rc_s::RC_INPUT_SOURCE_PX4FMU_PPM; +#endif + /* only enable this during development */ _debug_enabled = false; } PX4FMU::~PX4FMU() { - if (_task != -1) { + if (_initialized) { /* tell the task we want it to go away */ - _task_should_exit = true; + work_stop(); - unsigned i = 10; + int i = 10; do { /* wait 50ms - it should wake every 100ms or so worst-case */ usleep(50000); + i--; - /* if we have given up, kill it */ - if (--i == 0) { - task_delete(_task); - break; - } - - } while (_task != -1); + } while (_initialized && i > 0); } /* clean up the alternate device node */ @@ -330,7 +338,7 @@ PX4FMU::init() { int ret; - ASSERT(_task == -1); + ASSERT(!_initialized); /* do regular cdev init */ ret = CDev::init(); @@ -348,31 +356,11 @@ PX4FMU::init() warnx("FAILED registering class device"); } - /* reset GPIOs */ - gpio_reset(); - - /* start the IO interface task */ - _task = px4_task_spawn_cmd("fmuservo", - SCHED_DEFAULT, - SCHED_PRIORITY_DEFAULT, - 1200, - (main_t)&PX4FMU::task_main_trampoline, - nullptr); - - if (_task < 0) { - DEVICE_DEBUG("task start failed: %d", errno); - return -errno; - } + work_start(); return OK; } -void -PX4FMU::task_main_trampoline(int argc, char *argv[]) -{ - g_fmu->task_main(); -} - int PX4FMU::set_mode(Mode mode) { @@ -600,222 +588,236 @@ PX4FMU::publish_pwm_outputs(uint16_t *values, size_t numvalues) void -PX4FMU::task_main() +PX4FMU::work_start() { - /* force a reset of the update rate */ - _current_update_rate = 0; + /* schedule a cycle to start things */ + work_queue(HPWORK, &_work, (worker_t)&PX4FMU::cycle_trampoline, this, 0); +} - _armed_sub = orb_subscribe(ORB_ID(actuator_armed)); - _param_sub = orb_subscribe(ORB_ID(parameter_update)); +void +PX4FMU::cycle_trampoline(void *arg) +{ + PX4FMU *dev = reinterpret_cast(arg); -#ifdef HRT_PPM_CHANNEL - // rc input, published to ORB - struct rc_input_values rc_in; - orb_advert_t to_input_rc = 0; + dev->cycle(); +} - memset(&rc_in, 0, sizeof(rc_in)); - rc_in.input_source = input_rc_s::RC_INPUT_SOURCE_PX4FMU_PPM; -#endif +void +PX4FMU::cycle() +{ + if (!_initialized) { + /* reset GPIOs */ + gpio_reset(); - /* initialize PWM limit lib */ - pwm_limit_init(&_pwm_limit); + /* force a reset of the update rate */ + _current_update_rate = 0; - update_pwm_rev_mask(); + _armed_sub = orb_subscribe(ORB_ID(actuator_armed)); + _param_sub = orb_subscribe(ORB_ID(parameter_update)); - /* loop until killed */ - while (!_task_should_exit) { - if (_groups_subscribed != _groups_required) { - subscribe(); - _groups_subscribed = _groups_required; - /* force setting update rate */ - _current_update_rate = 0; + /* initialize PWM limit lib */ + pwm_limit_init(&_pwm_limit); + + update_pwm_rev_mask(); + + _initialized = true; + } + + + if (_groups_subscribed != _groups_required) { + subscribe(); + _groups_subscribed = _groups_required; + /* force setting update rate */ + _current_update_rate = 0; + } + + /* + * Adjust actuator topic update rate to keep up with + * the highest servo update rate configured. + * + * We always mix at max rate; some channels may update slower. + */ + unsigned max_rate = (_pwm_default_rate > _pwm_alt_rate) ? _pwm_default_rate : _pwm_alt_rate; + + if (_current_update_rate != max_rate) { + _current_update_rate = max_rate; + int update_rate_in_ms = int(1000 / _current_update_rate); + + /* reject faster than 500 Hz updates */ + if (update_rate_in_ms < 2) { + update_rate_in_ms = 2; } - /* - * Adjust actuator topic update rate to keep up with - * the highest servo update rate configured. - * - * We always mix at max rate; some channels may update slower. - */ - unsigned max_rate = (_pwm_default_rate > _pwm_alt_rate) ? _pwm_default_rate : _pwm_alt_rate; - - if (_current_update_rate != max_rate) { - _current_update_rate = max_rate; - int update_rate_in_ms = int(1000 / _current_update_rate); - - /* reject faster than 500 Hz updates */ - if (update_rate_in_ms < 2) { - update_rate_in_ms = 2; - } - - /* reject slower than 10 Hz updates */ - if (update_rate_in_ms > 100) { - update_rate_in_ms = 100; - } - - DEVICE_DEBUG("adjusted actuator update interval to %ums", update_rate_in_ms); - - for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) { - if (_control_subs[i] > 0) { - orb_set_interval(_control_subs[i], update_rate_in_ms); - } - } - - // set to current max rate, even if we are actually checking slower/faster - _current_update_rate = max_rate; + /* reject slower than 10 Hz updates */ + if (update_rate_in_ms > 100) { + update_rate_in_ms = 100; } - /* sleep waiting for data, stopping to check for PPM - * input at 50Hz */ - int ret = ::poll(_poll_fds, _poll_fds_num, CONTROL_INPUT_DROP_LIMIT_MS); + DEVICE_DEBUG("adjusted actuator update interval to %ums", update_rate_in_ms); - /* this would be bad... */ - if (ret < 0) { - DEVICE_LOG("poll error %d", errno); - continue; + for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) { + if (_control_subs[i] > 0) { + orb_set_interval(_control_subs[i], update_rate_in_ms); + } + } - } else if (ret == 0) { - /* timeout: no control data, switch to failsafe values */ + // set to current max rate, even if we are actually checking slower/faster + _current_update_rate = max_rate; + } + + /* check if anything updated */ + int ret = ::poll(_poll_fds, _poll_fds_num, 0); + + /* this would be bad... */ + if (ret < 0) { + DEVICE_LOG("poll error %d", errno); + + } else if (ret == 0) { + /* timeout: no control data, switch to failsafe values */ // warnx("no PWM: failsafe"); - } else { + } else { - /* get controls for required topics */ - unsigned poll_id = 0; + /* get controls for required topics */ + unsigned poll_id = 0; - for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) { - if (_control_subs[i] > 0) { - if (_poll_fds[poll_id].revents & POLLIN) { - orb_copy(_control_topics[i], _control_subs[i], &_controls[i]); - } - - poll_id++; - } - } - - /* can we mix? */ - if (_mixers != nullptr) { - - size_t num_outputs; - - switch (_mode) { - case MODE_2PWM: - num_outputs = 2; - break; - - case MODE_4PWM: - num_outputs = 4; - break; - - case MODE_6PWM: - num_outputs = 6; - break; - - case MODE_8PWM: - num_outputs = 8; - break; - - default: - num_outputs = 0; - break; + for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) { + if (_control_subs[i] > 0) { + if (_poll_fds[poll_id].revents & POLLIN) { + orb_copy(_control_topics[i], _control_subs[i], &_controls[i]); } - /* do mixing */ - float outputs[_max_actuators]; - num_outputs = _mixers->mix(outputs, num_outputs, NULL); - - /* disable unused ports by setting their output to NaN */ - for (size_t i = 0; i < sizeof(outputs) / sizeof(outputs[0]); i++) { - if (i >= num_outputs) { - outputs[i] = NAN_VALUE; - } - } - - uint16_t pwm_limited[_max_actuators]; - - /* the PWM limit call takes care of out of band errors, NaN and constrains */ - pwm_limit_calc(_servo_armed, arm_nothrottle(), num_outputs, _reverse_pwm_mask, _disarmed_pwm, _min_pwm, _max_pwm, - outputs, pwm_limited, &_pwm_limit); - - /* output to the servos */ - for (size_t i = 0; i < num_outputs; i++) { - up_pwm_servo_set(i, pwm_limited[i]); - } - - publish_pwm_outputs(pwm_limited, num_outputs); + poll_id++; } } - /* check arming state */ - bool updated = false; - orb_check(_armed_sub, &updated); + /* can we mix? */ + if (_mixers != nullptr) { - if (updated) { - orb_copy(ORB_ID(actuator_armed), _armed_sub, &_armed); + size_t num_outputs; - /* update the armed status and check that we're not locked down */ - bool set_armed = (_armed.armed || _armed.prearmed) && !_armed.lockdown; + switch (_mode) { + case MODE_2PWM: + num_outputs = 2; + break; - if (_servo_armed != set_armed) { - _servo_armed = set_armed; + case MODE_4PWM: + num_outputs = 4; + break; + + case MODE_6PWM: + num_outputs = 6; + break; + + case MODE_8PWM: + num_outputs = 8; + break; + + default: + num_outputs = 0; + break; } - /* update PWM status if armed or if disarmed PWM values are set */ - bool pwm_on = (set_armed || _num_disarmed_set > 0); + /* do mixing */ + float outputs[_max_actuators]; + num_outputs = _mixers->mix(outputs, num_outputs, NULL); - if (_pwm_on != pwm_on) { - _pwm_on = pwm_on; - up_pwm_servo_arm(pwm_on); + /* disable unused ports by setting their output to NaN */ + for (size_t i = 0; i < sizeof(outputs) / sizeof(outputs[0]); i++) { + if (i >= num_outputs) { + outputs[i] = NAN_VALUE; + } } + + uint16_t pwm_limited[_max_actuators]; + + /* the PWM limit call takes care of out of band errors, NaN and constrains */ + pwm_limit_calc(_servo_armed, arm_nothrottle(), num_outputs, _reverse_pwm_mask, _disarmed_pwm, _min_pwm, _max_pwm, + outputs, pwm_limited, &_pwm_limit); + + /* output to the servos */ + for (size_t i = 0; i < num_outputs; i++) { + up_pwm_servo_set(i, pwm_limited[i]); + } + + publish_pwm_outputs(pwm_limited, num_outputs); + } + } + + /* check arming state */ + bool updated = false; + orb_check(_armed_sub, &updated); + + if (updated) { + orb_copy(ORB_ID(actuator_armed), _armed_sub, &_armed); + + /* update the armed status and check that we're not locked down */ + bool set_armed = (_armed.armed || _armed.prearmed) && !_armed.lockdown; + + if (_servo_armed != set_armed) { + _servo_armed = set_armed; } - orb_check(_param_sub, &updated); + /* update PWM status if armed or if disarmed PWM values are set */ + bool pwm_on = (set_armed || _num_disarmed_set > 0); - if (updated) { - parameter_update_s pupdate; - orb_copy(ORB_ID(parameter_update), _param_sub, &pupdate); - - update_pwm_rev_mask(); + if (_pwm_on != pwm_on) { + _pwm_on = pwm_on; + up_pwm_servo_arm(pwm_on); } + } + + orb_check(_param_sub, &updated); + + if (updated) { + parameter_update_s pupdate; + orb_copy(ORB_ID(parameter_update), _param_sub, &pupdate); + + update_pwm_rev_mask(); + } #ifdef HRT_PPM_CHANNEL - // see if we have new PPM input data - if (ppm_last_valid_decode != rc_in.timestamp_last_signal) { - // we have a new PPM frame. Publish it. - rc_in.channel_count = ppm_decoded_channels; + // see if we have new PPM input data + if (ppm_last_valid_decode != _rc_in.timestamp_last_signal) { + // we have a new PPM frame. Publish it. + _rc_in.channel_count = ppm_decoded_channels; - if (rc_in.channel_count > input_rc_s::RC_INPUT_MAX_CHANNELS) { - rc_in.channel_count = input_rc_s::RC_INPUT_MAX_CHANNELS; - } - - for (uint8_t i = 0; i < rc_in.channel_count; i++) { - rc_in.values[i] = ppm_buffer[i]; - } - - rc_in.timestamp_publication = ppm_last_valid_decode; - rc_in.timestamp_last_signal = ppm_last_valid_decode; - - rc_in.rc_ppm_frame_length = ppm_frame_length; - rc_in.rssi = RC_INPUT_RSSI_MAX; - rc_in.rc_failsafe = false; - rc_in.rc_lost = false; - rc_in.rc_lost_frame_count = 0; - rc_in.rc_total_frame_count = 0; - - /* lazily advertise on first publication */ - if (to_input_rc == 0) { - to_input_rc = orb_advertise(ORB_ID(input_rc), &rc_in); - - } else { - orb_publish(ORB_ID(input_rc), to_input_rc, &rc_in); - } + if (_rc_in.channel_count > input_rc_s::RC_INPUT_MAX_CHANNELS) { + _rc_in.channel_count = input_rc_s::RC_INPUT_MAX_CHANNELS; } -#endif + for (uint8_t i = 0; i < _rc_in.channel_count; i++) { + _rc_in.values[i] = ppm_buffer[i]; + } + _rc_in.timestamp_publication = ppm_last_valid_decode; + _rc_in.timestamp_last_signal = ppm_last_valid_decode; + + _rc_in.rc_ppm_frame_length = ppm_frame_length; + _rc_in.rssi = RC_INPUT_RSSI_MAX; + _rc_in.rc_failsafe = false; + _rc_in.rc_lost = false; + _rc_in.rc_lost_frame_count = 0; + _rc_in.rc_total_frame_count = 0; + + /* lazily advertise on first publication */ + if (_to_input_rc == nullptr) { + _to_input_rc = orb_advertise(ORB_ID(input_rc), &_rc_in); + + } else { + orb_publish(ORB_ID(input_rc), _to_input_rc, &_rc_in); + } } +#endif + work_queue(HPWORK, &_work, (worker_t)&PX4FMU::cycle_trampoline, this, USEC2TICK(CONTROL_INPUT_DROP_LIMIT_MS * 1000)); +} + +void PX4FMU::work_stop() +{ + work_cancel(HPWORK, &_work); + for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) { if (_control_subs[i] > 0) { ::close(_control_subs[i]); @@ -834,8 +836,7 @@ PX4FMU::task_main() /* note - someone else is responsible for restoring the GPIO config */ /* tell the dtor that we are exiting */ - _task = -1; - _exit(0); + _initialized = false; } int diff --git a/src/drivers/px4fmu/module.mk b/src/drivers/px4fmu/module.mk deleted file mode 100644 index 5a2806f4b5..0000000000 --- a/src/drivers/px4fmu/module.mk +++ /dev/null @@ -1,13 +0,0 @@ -# -# Interface driver for the PX4FMU board -# - -MODULE_COMMAND = fmu -SRCS = fmu.cpp \ - px4fmu_params.c - -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/px4io/CMakeLists.txt b/src/drivers/px4io/CMakeLists.txt new file mode 100644 index 0000000000..5c180c6f82 --- /dev/null +++ b/src/drivers/px4io/CMakeLists.txt @@ -0,0 +1,48 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__px4io + MAIN px4io + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + px4io.cpp + px4io_uploader.cpp + px4io_serial.cpp + px4io_i2c.cpp + px4io_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/px4io/module.mk b/src/drivers/px4io/module.mk deleted file mode 100644 index 9033d24b61..0000000000 --- a/src/drivers/px4io/module.mk +++ /dev/null @@ -1,53 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Interface driver for the PX4IO board. -# - -MODULE_COMMAND = px4io - -SRCS = px4io.cpp \ - px4io_uploader.cpp \ - px4io_serial.cpp \ - px4io_i2c.cpp \ - px4io_params.c - -# XXX prune to just get UART registers -INCLUDE_DIRS += $(NUTTX_SRC)/arch/arm/src/stm32 $(NUTTX_SRC)/arch/arm/src/common - -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index 9a91f35a16..3c7c0d2994 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -99,8 +99,7 @@ #include "modules/dataman/dataman.h" -extern device::Device *PX4IO_i2c_interface() weak_function; -extern device::Device *PX4IO_serial_interface() weak_function; +#include "px4io_driver.h" #define PX4IO_SET_DEBUG _IOC(0xff00, 0) #define PX4IO_INAIR_RESTART_ENABLE _IOC(0xff00, 1) @@ -869,7 +868,7 @@ PX4IO::init() _task = px4_task_spawn_cmd("px4io", SCHED_DEFAULT, SCHED_PRIORITY_ACTUATOR_OUTPUTS, - 1800, + 1500, (main_t)&PX4IO::task_main_trampoline, nullptr); @@ -2973,10 +2972,9 @@ get_interface() #ifndef CONFIG_ARCH_BOARD_PX4FMU_V1 - /* try for a serial interface */ - if (PX4IO_serial_interface != nullptr) { - interface = PX4IO_serial_interface(); - } +#ifdef PX4IO_SERIAL_BASE + interface = PX4IO_serial_interface(); +#endif if (interface != nullptr) { goto got; @@ -2984,10 +2982,9 @@ get_interface() #endif - /* try for an I2C interface if we haven't got a serial one */ - if (PX4IO_i2c_interface != nullptr) { - interface = PX4IO_i2c_interface(); - } +#ifdef PX4_I2C_OBDEV_PX4IO + interface = PX4IO_i2c_interface(); +#endif if (interface != nullptr) { goto got; diff --git a/makefiles/posix-arm/ld.script b/src/drivers/px4io/px4io_driver.h similarity index 84% rename from makefiles/posix-arm/ld.script rename to src/drivers/px4io/px4io_driver.h index 32478e1e14..591c3920d2 100644 --- a/makefiles/posix-arm/ld.script +++ b/src/drivers/px4io/px4io_driver.h @@ -1,8 +1,6 @@ /**************************************************************************** - * ld.script * - * Copyright (C) 2015 Mark Charlebois. All rights reserved. - * Author: Mark Charlebois + * Copyright (c) 2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,14 +31,20 @@ * ****************************************************************************/ -SECTIONS -{ - /* - * Construction data for parameters. - */ - __param : ALIGN(8) { - __param_start = .; - KEEP(*(__param*)) - __param_end = .; - } -} +/** + * @file px4io_driver.h + * + * Interface for PX4IO + */ + +#pragma once + +#include + +#ifdef PX4_I2C_OBDEV_PX4IO +device::Device *PX4IO_i2c_interface(); +#endif + +#ifdef PX4IO_SERIAL_BASE +device::Device *PX4IO_serial_interface(); +#endif diff --git a/src/drivers/px4io/px4io_i2c.cpp b/src/drivers/px4io/px4io_i2c.cpp index 574a58f52a..4574ec732a 100755 --- a/src/drivers/px4io/px4io_i2c.cpp +++ b/src/drivers/px4io/px4io_i2c.cpp @@ -53,9 +53,9 @@ #include -#ifdef PX4_I2C_OBDEV_PX4IO +#include "px4io_driver.h" -device::Device *PX4IO_i2c_interface(); +#ifdef PX4_I2C_OBDEV_PX4IO class PX4IO_I2C : public device::I2C { diff --git a/src/drivers/px4io/px4io_serial.cpp b/src/drivers/px4io/px4io_serial.cpp index 93f55f9486..2c38c0dd3c 100644 --- a/src/drivers/px4io/px4io_serial.cpp +++ b/src/drivers/px4io/px4io_serial.cpp @@ -39,6 +39,7 @@ /* XXX trim includes */ #include +#include #include #include @@ -68,9 +69,9 @@ #include -#ifdef PX4IO_SERIAL_BASE +#include "px4io_driver.h" -device::Device *PX4IO_serial_interface(); +#ifdef PX4IO_SERIAL_BASE /* serial register accessors */ #define REG(_x) (*(volatile uint32_t *)(PX4IO_SERIAL_BASE + _x)) @@ -116,10 +117,10 @@ private: volatile unsigned _rx_dma_status; /** bus-ownership lock */ - sem_t _bus_semaphore; + px4_sem_t _bus_semaphore; /** client-waiting lock/signal */ - sem_t _completion_semaphore; + px4_sem_t _completion_semaphore; /** * Start the transaction with IO and wait for it to complete. @@ -219,8 +220,8 @@ PX4IO_serial::~PX4IO_serial() stm32_unconfiggpio(PX4IO_SERIAL_RX_GPIO); /* and kill our semaphores */ - sem_destroy(&_completion_semaphore); - sem_destroy(&_bus_semaphore); + px4_sem_destroy(&_completion_semaphore); + px4_sem_destroy(&_bus_semaphore); perf_free(_pc_txns); perf_free(_pc_dmasetup); @@ -280,8 +281,8 @@ PX4IO_serial::init() rCR1 = USART_CR1_RE | USART_CR1_TE | USART_CR1_UE | USART_CR1_IDLEIE; /* create semaphores */ - sem_init(&_completion_semaphore, 0, 0); - sem_init(&_bus_semaphore, 0, 1); + px4_sem_init(&_completion_semaphore, 0, 0); + px4_sem_init(&_bus_semaphore, 0, 1); /* XXX this could try talking to IO */ @@ -366,7 +367,7 @@ PX4IO_serial::write(unsigned address, void *data, unsigned count) return -EINVAL; } - sem_wait(&_bus_semaphore); + px4_sem_wait(&_bus_semaphore); int result; @@ -403,7 +404,7 @@ PX4IO_serial::write(unsigned address, void *data, unsigned count) perf_count(_pc_retries); } - sem_post(&_bus_semaphore); + px4_sem_post(&_bus_semaphore); if (result == OK) { result = count; @@ -423,7 +424,7 @@ PX4IO_serial::read(unsigned address, void *data, unsigned count) return -EINVAL; } - sem_wait(&_bus_semaphore); + px4_sem_wait(&_bus_semaphore); int result; @@ -468,7 +469,7 @@ PX4IO_serial::read(unsigned address, void *data, unsigned count) perf_count(_pc_retries); } - sem_post(&_bus_semaphore); + px4_sem_post(&_bus_semaphore); if (result == OK) { result = count; @@ -627,7 +628,7 @@ PX4IO_serial::_do_rx_dma_callback(unsigned status) rCR3 &= ~(USART_CR3_DMAT | USART_CR3_DMAR); /* complete now */ - sem_post(&_completion_semaphore); + px4_sem_post(&_completion_semaphore); } } diff --git a/src/drivers/rgbled/CMakeLists.txt b/src/drivers/rgbled/CMakeLists.txt new file mode 100644 index 0000000000..d833567467 --- /dev/null +++ b/src/drivers/rgbled/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__rgbled + MAIN rgbled + COMPILE_FLAGS + -Os + SRCS + rgbled.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/rgbled/module.mk b/src/drivers/rgbled/module.mk deleted file mode 100644 index f4f4e41427..0000000000 --- a/src/drivers/rgbled/module.mk +++ /dev/null @@ -1,10 +0,0 @@ -# -# TCA62724FMG driver for RGB LED -# - -MODULE_COMMAND = rgbled - -SRCS = rgbled.cpp \ - rgbled_params.c - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/roboclaw/CMakeLists.txt b/src/drivers/roboclaw/CMakeLists.txt new file mode 100644 index 0000000000..c2eac724e6 --- /dev/null +++ b/src/drivers/roboclaw/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__roboclaw + MAIN roboclaw + COMPILE_FLAGS + -Os + SRCS + roboclaw_main.cpp + RoboClaw.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/sf0x/CMakeLists.txt b/src/drivers/sf0x/CMakeLists.txt new file mode 100644 index 0000000000..a90d1da824 --- /dev/null +++ b/src/drivers/sf0x/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__sf0x + MAIN sf0x + COMPILE_FLAGS + -Os + SRCS + sf0x.cpp + sf0x_parser.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/stm32/CMakeLists.txt b/src/drivers/stm32/CMakeLists.txt new file mode 100644 index 0000000000..e81bf50277 --- /dev/null +++ b/src/drivers/stm32/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__stm32 + COMPILE_FLAGS + -Os + SRCS + drv_hrt.c + drv_pwm_servo.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/mb12xx/module.mk b/src/drivers/stm32/adc/CMakeLists.txt similarity index 87% rename from src/drivers/mb12xx/module.mk rename to src/drivers/stm32/adc/CMakeLists.txt index d751e93e4d..72205cdac7 100644 --- a/src/drivers/mb12xx/module.mk +++ b/src/drivers/stm32/adc/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -30,13 +30,14 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - -# -# Makefile to build the Maxbotix Sonar driver. -# - -MODULE_COMMAND = mb12xx - -SRCS = mb12xx.cpp - -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE drivers__stm32__adc + MAIN adc + COMPILE_FLAGS + -Os + SRCS + adc.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/stm32/module.mk b/src/drivers/stm32/module.mk deleted file mode 100644 index 54428e270d..0000000000 --- a/src/drivers/stm32/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# STM32 driver support code -# -# Modules in this directory are compiled for all STM32 targets. -# - -SRCS = drv_hrt.c \ - drv_pwm_servo.c - -INCLUDE_DIRS += $(NUTTX_SRC)/arch/arm/src/stm32 $(NUTTX_SRC)/arch/arm/src/common - -MAXOPTIMIZATION = -Os diff --git a/src/drivers/stm32/tone_alarm/CMakeLists.txt b/src/drivers/stm32/tone_alarm/CMakeLists.txt new file mode 100644 index 0000000000..d01a1ff59b --- /dev/null +++ b/src/drivers/stm32/tone_alarm/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE drivers__stm32__tone_alarm + MAIN tone_alarm + COMPILE_FLAGS + -Os + SRCS + tone_alarm.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/ets_airspeed/module.mk b/src/drivers/trone/CMakeLists.txt similarity index 86% rename from src/drivers/ets_airspeed/module.mk rename to src/drivers/trone/CMakeLists.txt index 8aaaf0ebb0..e0166dd333 100644 --- a/src/drivers/ets_airspeed/module.mk +++ b/src/drivers/trone/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -30,15 +30,15 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - -# -# Makefile to build the Eagle Tree Airspeed V3 driver. -# - -MODULE_COMMAND = ets_airspeed - -SRCS = ets_airspeed.cpp - -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE drivers__trone + MAIN trone + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + trone.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/fixedwing_control/CMakeLists.txt b/src/examples/fixedwing_control/CMakeLists.txt new file mode 100644 index 0000000000..e1032db305 --- /dev/null +++ b/src/examples/fixedwing_control/CMakeLists.txt @@ -0,0 +1,46 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__fixedwing_control + MAIN ex_fixedwing_control + STACK 1200 + COMPILE_FLAGS + -Wframe-larger-than=1300 + + SRCS + main.c + params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/fixedwing_control/module.mk b/src/examples/fixedwing_control/module.mk deleted file mode 100644 index da96054d3b..0000000000 --- a/src/examples/fixedwing_control/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Fixedwing Attitude Control Demo / Example Application -# - -MODULE_COMMAND = ex_fixedwing_control - -SRCS = main.c \ - params.c - -MODULE_STACKSIZE = 1200 - -EXTRACFLAGS = -Wframe-larger-than=1300 diff --git a/src/examples/flow_position_estimator/flow_position_estimator_main.c b/src/examples/flow_position_estimator/flow_position_estimator_main.c deleted file mode 100644 index bcf13c4de5..0000000000 --- a/src/examples/flow_position_estimator/flow_position_estimator_main.c +++ /dev/null @@ -1,465 +0,0 @@ -/**************************************************************************** - * - * Copyright (C) 2008-2013 PX4 Development Team. All rights reserved. - * Author: Samuel Zihlmann - * Lorenz Meier - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name PX4 nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/** - * @file flow_position_estimator_main.c - * - * Optical flow position estimator - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "flow_position_estimator_params.h" - -__EXPORT int flow_position_estimator_main(int argc, char *argv[]); -static bool thread_should_exit = false; /**< Daemon exit flag */ -static bool thread_running = false; /**< Daemon status flag */ -static int daemon_task; /**< Handle of daemon task / thread */ - -int flow_position_estimator_thread_main(int argc, char *argv[]); -static void usage(const char *reason); - -static void usage(const char *reason) -{ - if (reason) { - fprintf(stderr, "%s\n", reason); - } - - fprintf(stderr, "usage: daemon {start|stop|status} [-p ]\n\n"); - exit(1); -} - -/** - * The daemon app only briefly exists to start - * the background job. The stack size assigned in the - * Makefile does only apply to this management task. - * - * The actual stack size should be set in the call - * to px4_task_spawn_cmd(). - */ -int flow_position_estimator_main(int argc, char *argv[]) -{ - if (argc < 2) { - usage("missing command"); - } - - if (!strcmp(argv[1], "start")) { - if (thread_running) { - printf("flow position estimator already running\n"); - /* this is not an error */ - exit(0); - } - - thread_should_exit = false; - daemon_task = px4_task_spawn_cmd("flow_position_estimator", - SCHED_DEFAULT, - SCHED_PRIORITY_MAX - 5, - 4000, - flow_position_estimator_thread_main, - (argv) ? (char *const *)&argv[2] : (char *const *)NULL); - exit(0); - } - - if (!strcmp(argv[1], "stop")) { - thread_should_exit = true; - exit(0); - } - - if (!strcmp(argv[1], "status")) { - if (thread_running) { - printf("\tflow position estimator is running\n"); - - } else { - printf("\tflow position estimator not started\n"); - } - - exit(0); - } - - usage("unrecognized command"); - exit(1); -} - -int flow_position_estimator_thread_main(int argc, char *argv[]) -{ - /* welcome user */ - thread_running = true; - printf("[flow position estimator] starting\n"); - - /* rotation matrix for transformation of optical flow speed vectors */ - static const int8_t rotM_flow_sensor[3][3] = {{ 0, -1, 0 }, - { 1, 0, 0 }, - { 0, 0, 1 } - }; // 90deg rotated - const float time_scale = powf(10.0f, -6.0f); - static float speed[3] = {0.0f, 0.0f, 0.0f}; - static float flow_speed[3] = {0.0f, 0.0f, 0.0f}; - static float global_speed[3] = {0.0f, 0.0f, 0.0f}; - static uint32_t counter = 0; - static uint64_t time_last_flow = 0; // in ms - static float dt = 0.0f; // seconds - static float sonar_last = 0.0f; - static bool sonar_valid = false; - static float sonar_lp = 0.0f; - - /* subscribe to vehicle status, attitude, sensors and flow*/ - struct actuator_armed_s armed; - memset(&armed, 0, sizeof(armed)); - struct vehicle_control_mode_s control_mode; - memset(&control_mode, 0, sizeof(control_mode)); - struct vehicle_attitude_s att; - memset(&att, 0, sizeof(att)); - struct vehicle_attitude_setpoint_s att_sp; - memset(&att_sp, 0, sizeof(att_sp)); - struct optical_flow_s flow; - memset(&flow, 0, sizeof(flow)); - - /* subscribe to parameter changes */ - int parameter_update_sub = orb_subscribe(ORB_ID(parameter_update)); - - /* subscribe to armed topic */ - int armed_sub = orb_subscribe(ORB_ID(actuator_armed)); - - /* subscribe to safety topic */ - int control_mode_sub = orb_subscribe(ORB_ID(vehicle_control_mode)); - - /* subscribe to attitude */ - int vehicle_attitude_sub = orb_subscribe(ORB_ID(vehicle_attitude)); - - /* subscribe to attitude setpoint */ - int vehicle_attitude_setpoint_sub = orb_subscribe(ORB_ID(vehicle_attitude_setpoint)); - - /* subscribe to optical flow*/ - int optical_flow_sub = orb_subscribe(ORB_ID(optical_flow)); - - /* init local position and filtered flow struct */ - struct vehicle_local_position_s local_pos = { - .x = 0.0f, - .y = 0.0f, - .z = 0.0f, - .vx = 0.0f, - .vy = 0.0f, - .vz = 0.0f - }; - struct filtered_bottom_flow_s filtered_flow = { - .sumx = 0.0f, - .sumy = 0.0f, - .vx = 0.0f, - .vy = 0.0f - }; - - /* advert pub messages */ - orb_advert_t local_pos_pub = orb_advertise(ORB_ID(vehicle_local_position), &local_pos); - orb_advert_t filtered_flow_pub = orb_advertise(ORB_ID(filtered_bottom_flow), &filtered_flow); - - /* vehicle flying status parameters */ - bool vehicle_liftoff = false; - bool sensors_ready = false; - - /* parameters init*/ - struct flow_position_estimator_params params; - struct flow_position_estimator_param_handles param_handles; - parameters_init(¶m_handles); - parameters_update(¶m_handles, ¶ms); - - perf_counter_t mc_loop_perf = perf_alloc(PC_ELAPSED, "flow_position_estimator_runtime"); - perf_counter_t mc_interval_perf = perf_alloc(PC_INTERVAL, "flow_position_estimator_interval"); - perf_counter_t mc_err_perf = perf_alloc(PC_COUNT, "flow_position_estimator_err"); - - while (!thread_should_exit) { - - if (sensors_ready) { - /*This runs at the rate of the sensors */ - struct pollfd fds[2] = { - { .fd = optical_flow_sub, .events = POLLIN }, - { .fd = parameter_update_sub, .events = POLLIN } - }; - - /* wait for a sensor update, check for exit condition every 500 ms */ - int ret = poll(fds, 2, 500); - - if (ret < 0) { - /* poll error, count it in perf */ - perf_count(mc_err_perf); - - } else if (ret == 0) { - /* no return value, ignore */ -// printf("[flow position estimator] no bottom flow.\n"); - } else { - - /* parameter update available? */ - if (fds[1].revents & POLLIN) { - /* read from param to clear updated flag */ - struct parameter_update_s update; - orb_copy(ORB_ID(parameter_update), parameter_update_sub, &update); - - parameters_update(¶m_handles, ¶ms); - printf("[flow position estimator] parameters updated.\n"); - } - - /* only if flow data changed */ - if (fds[0].revents & POLLIN) { - perf_begin(mc_loop_perf); - - orb_copy(ORB_ID(optical_flow), optical_flow_sub, &flow); - /* got flow, updating attitude and status as well */ - orb_copy(ORB_ID(vehicle_attitude), vehicle_attitude_sub, &att); - orb_copy(ORB_ID(vehicle_attitude_setpoint), vehicle_attitude_setpoint_sub, &att_sp); - orb_copy(ORB_ID(actuator_armed), armed_sub, &armed); - orb_copy(ORB_ID(vehicle_control_mode), control_mode_sub, &control_mode); - - /* vehicle state estimation */ - float sonar_new = flow.ground_distance_m; - - /* set liftoff boolean - * -> at bottom sonar sometimes does not work correctly, and has to be calibrated (distance higher than 0.3m) - * -> accept sonar measurements after reaching calibration distance (values between 0.3m and 1.0m for some time) - * -> minimum sonar value 0.3m - */ - - if (!vehicle_liftoff) { - if (armed.armed && att_sp.thrust > params.minimum_liftoff_thrust && sonar_new > 0.3f && sonar_new < 1.0f) { - vehicle_liftoff = true; - } - - } else { - if (!armed.armed || (att_sp.thrust < params.minimum_liftoff_thrust && sonar_new <= 0.3f)) { - vehicle_liftoff = false; - } - } - - /* calc dt between flow timestamps */ - /* ignore first flow msg */ - if (time_last_flow == 0) { - time_last_flow = flow.timestamp; - continue; - } - - dt = (float)(flow.timestamp - time_last_flow) * time_scale ; - time_last_flow = flow.timestamp; - - /* only make position update if vehicle is lift off or DEBUG is activated*/ - if (vehicle_liftoff || params.debug) { - /* copy flow */ - if (flow.integration_timespan > 0) { - flow_speed[0] = flow.pixel_flow_x_integral / (flow.integration_timespan / 1e6f) * flow.ground_distance_m; - flow_speed[1] = flow.pixel_flow_y_integral / (flow.integration_timespan / 1e6f) * flow.ground_distance_m; - - } else { - flow_speed[0] = 0; - flow_speed[1] = 0; - } - - flow_speed[2] = 0.0f; - - /* convert to bodyframe velocity */ - for (uint8_t i = 0; i < 3; i++) { - float sum = 0.0f; - - for (uint8_t j = 0; j < 3; j++) { - sum = sum + flow_speed[j] * rotM_flow_sensor[j][i]; - } - - speed[i] = sum; - } - - /* update filtered flow */ - filtered_flow.sumx = filtered_flow.sumx + speed[0] * dt; - filtered_flow.sumy = filtered_flow.sumy + speed[1] * dt; - filtered_flow.vx = speed[0]; - filtered_flow.vy = speed[1]; - - // TODO add yaw rotation correction (with distance to vehicle zero) - - /* convert to globalframe velocity - * -> local position is currently not used for position control - */ - for (uint8_t i = 0; i < 3; i++) { - float sum = 0.0f; - - for (uint8_t j = 0; j < 3; j++) { - sum = sum + speed[j] * PX4_R(att.R, i, j); - } - - global_speed[i] = sum; - } - - local_pos.x = local_pos.x + global_speed[0] * dt; - local_pos.y = local_pos.y + global_speed[1] * dt; - local_pos.vx = global_speed[0]; - local_pos.vy = global_speed[1]; - local_pos.xy_valid = true; - local_pos.v_xy_valid = true; - - } else { - /* set speed to zero and let position as it is */ - filtered_flow.vx = 0; - filtered_flow.vy = 0; - local_pos.vx = 0; - local_pos.vy = 0; - local_pos.xy_valid = false; - local_pos.v_xy_valid = false; - } - - /* filtering ground distance */ - if (!vehicle_liftoff || !armed.armed) { - /* not possible to fly */ - sonar_valid = false; - local_pos.z = 0.0f; - local_pos.z_valid = false; - - } else { - sonar_valid = true; - } - - if (sonar_valid || params.debug) { - /* simple lowpass sonar filtering */ - /* if new value or with sonar update frequency */ - if (sonar_new != sonar_last || counter % 10 == 0) { - sonar_lp = 0.05f * sonar_new + 0.95f * sonar_lp; - sonar_last = sonar_new; - } - - float height_diff = sonar_new - sonar_lp; - - /* if over 1/2m spike follow lowpass */ - if (height_diff < -params.sonar_lower_lp_threshold || height_diff > params.sonar_upper_lp_threshold) { - local_pos.z = -sonar_lp; - - } else { - local_pos.z = -sonar_new; - } - - local_pos.z_valid = true; - } - - filtered_flow.timestamp = hrt_absolute_time(); - local_pos.timestamp = hrt_absolute_time(); - - /* publish local position */ - if (isfinite(local_pos.x) && isfinite(local_pos.y) && isfinite(local_pos.z) - && isfinite(local_pos.vx) && isfinite(local_pos.vy)) { - orb_publish(ORB_ID(vehicle_local_position), local_pos_pub, &local_pos); - } - - /* publish filtered flow */ - if (isfinite(filtered_flow.sumx) && isfinite(filtered_flow.sumy) && isfinite(filtered_flow.vx) - && isfinite(filtered_flow.vy)) { - orb_publish(ORB_ID(filtered_bottom_flow), filtered_flow_pub, &filtered_flow); - } - - /* measure in what intervals the position estimator runs */ - perf_count(mc_interval_perf); - perf_end(mc_loop_perf); - - } - } - - } else { - /* sensors not ready waiting for first attitude msg */ - - /* polling */ - struct pollfd fds[1] = { - { .fd = vehicle_attitude_sub, .events = POLLIN }, - }; - - /* wait for a attitude message, check for exit condition every 5 s */ - int ret = poll(fds, 1, 5000); - - if (ret < 0) { - /* poll error, count it in perf */ - perf_count(mc_err_perf); - - } else if (ret == 0) { - /* no return value, ignore */ - printf("[flow position estimator] no attitude received.\n"); - - } else { - if (fds[0].revents & POLLIN) { - sensors_ready = true; - printf("[flow position estimator] initialized.\n"); - } - } - } - - counter++; - } - - printf("[flow position estimator] exiting.\n"); - thread_running = false; - - close(vehicle_attitude_setpoint_sub); - close(vehicle_attitude_sub); - close(armed_sub); - close(control_mode_sub); - close(parameter_update_sub); - close(optical_flow_sub); - - perf_print_counter(mc_loop_perf); - perf_free(mc_loop_perf); - - fflush(stdout); - return 0; -} - - diff --git a/src/examples/flow_position_estimator/module.mk b/src/examples/flow_position_estimator/module.mk deleted file mode 100644 index 5c6e29f8f6..0000000000 --- a/src/examples/flow_position_estimator/module.mk +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Build position estimator -# - -MODULE_COMMAND = flow_position_estimator - -SRCS = flow_position_estimator_main.c \ - flow_position_estimator_params.c - -EXTRACFLAGS = -Wno-float-equal diff --git a/src/drivers/sf0x/module.mk b/src/examples/hwtest/CMakeLists.txt similarity index 88% rename from src/drivers/sf0x/module.mk rename to src/examples/hwtest/CMakeLists.txt index 26e77d1cc6..31548df813 100644 --- a/src/drivers/sf0x/module.mk +++ b/src/examples/hwtest/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2014 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -30,14 +30,12 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - -# -# Makefile to build the Lightware laser range finder driver. -# - -MODULE_COMMAND = sf0x - -SRCS = sf0x.cpp \ - sf0x_parser.cpp - -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE examples__hwtest + MAIN ex_hwtest + SRCS + hwtest.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/hwtest/hwtest.c b/src/examples/hwtest/hwtest.c index a403f2fa24..97a525a8e9 100644 --- a/src/examples/hwtest/hwtest.c +++ b/src/examples/hwtest/hwtest.c @@ -57,8 +57,10 @@ __EXPORT int ex_hwtest_main(int argc, char *argv[]); int ex_hwtest_main(int argc, char *argv[]) { - warnx("DO NOT FORGET TO STOP THE COMMANDER APP!"); - warnx("(run to do so)"); + warnx("DO NOT FORGET TO STOP THE DEFAULT CONTROL APPS!"); + warnx("(run ,)"); + warnx("( and)"); + warnx("( to do so)"); warnx("usage: http://px4.io/dev/examples/write_output"); struct actuator_controls_s actuators; diff --git a/src/examples/hwtest/module.mk b/src/examples/hwtest/module.mk deleted file mode 100644 index 6e70863edb..0000000000 --- a/src/examples/hwtest/module.mk +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Hardware test example application -# - -MODULE_COMMAND = ex_hwtest - -SRCS = hwtest.c diff --git a/src/examples/matlab_csv_serial/CMakeLists.txt b/src/examples/matlab_csv_serial/CMakeLists.txt new file mode 100644 index 0000000000..516acda092 --- /dev/null +++ b/src/examples/matlab_csv_serial/CMakeLists.txt @@ -0,0 +1,41 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__matlab_csv_serial + MAIN matlab_csv_serial + SRCS + matlab_csv_serial.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/publisher/CMakeLists.txt b/src/examples/publisher/CMakeLists.txt new file mode 100644 index 0000000000..d48aebf6c1 --- /dev/null +++ b/src/examples/publisher/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__publisher + MAIN publisher + STACK 1200 + SRCS + publisher_main.cpp + publisher_start_nuttx.cpp + publisher_example.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/publisher/module.mk b/src/examples/publisher/module.mk deleted file mode 100644 index 62a5f8dd1f..0000000000 --- a/src/examples/publisher/module.mk +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -# -# Copyright (c) 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Publisher Example Application -# - -MODULE_COMMAND = publisher - -SRCS = publisher_main.cpp \ - publisher_start_nuttx.cpp \ - publisher_example.cpp - -MODULE_STACKSIZE = 1200 diff --git a/src/examples/px4_daemon_app/CMakeLists.txt b/src/examples/px4_daemon_app/CMakeLists.txt new file mode 100644 index 0000000000..2d455353d9 --- /dev/null +++ b/src/examples/px4_daemon_app/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__px4_daemon_app + MAIN px4_daemon_app + STACK 1200 + SRCS + px4_daemon_app.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/px4_daemon_app/module.mk b/src/examples/px4_daemon_app/module.mk deleted file mode 100644 index fc42231425..0000000000 --- a/src/examples/px4_daemon_app/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Daemon application -# - -MODULE_COMMAND = px4_daemon_app - -SRCS = px4_daemon_app.c - -MODULE_STACKSIZE = 1200 diff --git a/src/examples/px4_mavlink_debug/CMakeLists.txt b/src/examples/px4_mavlink_debug/CMakeLists.txt new file mode 100644 index 0000000000..2f1b5a6a2f --- /dev/null +++ b/src/examples/px4_mavlink_debug/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__px4_mavlink_debug + MAIN px4_mavlink_debug + STACK 2000 + SRCS + px4_mavlink_debug.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/px4_mavlink_debug/module.mk b/src/examples/px4_mavlink_debug/module.mk deleted file mode 100644 index c7ef97fc45..0000000000 --- a/src/examples/px4_mavlink_debug/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Basic example application -# - -MODULE_COMMAND = px4_mavlink_debug - -SRCS = px4_mavlink_debug.c - -MODULE_STACKSIZE = 2000 diff --git a/src/examples/px4_simple_app/CMakeLists.txt b/src/examples/px4_simple_app/CMakeLists.txt new file mode 100644 index 0000000000..5ba6781c60 --- /dev/null +++ b/src/examples/px4_simple_app/CMakeLists.txt @@ -0,0 +1,41 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__px4_simple_app + MAIN px4_simple_app + SRCS + px4_simple_app.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/rover_steering_control/CMakeLists.txt b/src/examples/rover_steering_control/CMakeLists.txt new file mode 100644 index 0000000000..0ba4b03f52 --- /dev/null +++ b/src/examples/rover_steering_control/CMakeLists.txt @@ -0,0 +1,46 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__rover_steering_control + MAIN rover_steering_control + STACK 1200 + COMPILE_FLAGS + -Wframe-larger-than=1300 + + SRCS + main.cpp + params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/rover_steering_control/module.mk b/src/examples/rover_steering_control/module.mk deleted file mode 100644 index 8f7a7ed3af..0000000000 --- a/src/examples/rover_steering_control/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Rover Steering Demo / Example Application -# - -MODULE_COMMAND = rover_steering_control - -SRCS = main.cpp \ - params.c - -MODULE_STACKSIZE = 1200 - -EXTRACFLAGS = -Wframe-larger-than=1300 diff --git a/src/examples/subscriber/CMakeLists.txt b/src/examples/subscriber/CMakeLists.txt new file mode 100644 index 0000000000..817d309d20 --- /dev/null +++ b/src/examples/subscriber/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE examples__subscriber + MAIN subscriber + STACK 2400 + SRCS + subscriber_main.cpp + subscriber_start_nuttx.cpp + subscriber_example.cpp + subscriber_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/examples/subscriber/module.mk b/src/examples/subscriber/module.mk deleted file mode 100644 index 0e02c65b45..0000000000 --- a/src/examples/subscriber/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Subscriber Example Application -# - -MODULE_COMMAND = subscriber - -SRCS = subscriber_main.cpp \ - subscriber_start_nuttx.cpp \ - subscriber_example.cpp \ - subscriber_params.c - -MODULE_STACKSIZE = 2400 diff --git a/src/firmware/nuttx/CMakeLists.txt b/src/firmware/nuttx/CMakeLists.txt new file mode 100644 index 0000000000..6304ab2642 --- /dev/null +++ b/src/firmware/nuttx/CMakeLists.txt @@ -0,0 +1,109 @@ +px4_nuttx_generate_builtin_commands( + OUT builtin_commands.c + MODULE_LIST + ${module_libraries} + ${config_extra_builtin_cmds} + ) + +px4_nuttx_add_romfs(OUT romfs + ROOT ROMFS/px4fmu_common + EXTRAS ${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}_${LABEL}.bin + ) + +add_dependencies(romfs fw_io) + +# add executable +add_executable(firmware_nuttx + builtin_commands.c) + + +set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) + +set(link_libs + romfs apps nuttx m gcc + ) + +if(NOT ${BOARD} STREQUAL "sim") + list(APPEND link_libs nosys) + set(main_link_flags + "-T${nuttx_export_dir}/build/ld.script" + "-Wl,-Map=${CMAKE_BINARY_DIR}/${BOARD}/main.map" + ) + px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") + set_target_properties(firmware_nuttx PROPERTIES LINK_FLAGS ${main_link_flags}) +endif() + +set(fw_file ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.px4) + +target_link_libraries(firmware_nuttx + -Wl,--start-group + ${module_libraries} + ${config_extra_libs} + ${link_libs} + -Wl,--end-group) + +add_custom_target(check_weak + COMMAND ${NM} firmware_nuttx | ${GREP} " w " | cat + DEPENDS firmware_nuttx + VERBATIM + ) + +if(NOT ${BOARD} STREQUAL "sim") + set(fw_file + ${CMAKE_CURRENT_BINARY_DIR}/${OS}-${BOARD}-${LABEL}.px4) + + px4_nuttx_add_firmware(OUT ${fw_file} + BOARD ${BOARD} + EXE ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx + PARAM_XML ${CMAKE_BINARY_DIR}/parameters.xml + AIRFRAMES_XML ${CMAKE_BINARY_DIR}/airframes.xml + ) + + configure_file(gdbinit.in .gdbinit) + + add_custom_target(debug + COMMAND ${GDB} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx + DEPENDS firmware_nuttx + ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) + + add_custom_target(debug_tui + COMMAND ${GDBTUI} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx + DEPENDS firmware_nuttx + ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) + + add_custom_target(debug_ddd + COMMAND ${DDD} --debugger ${GDB} ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx + DEPENDS firmware_nuttx + ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) + + add_custom_target(debug_io + COMMAND ${GDB} + ${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}_${LABEL} + DEPENDS firmware_nuttx + ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) + + add_custom_target(debug_io_tui + COMMAND ${GDBTUI} + ${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}_${LABEL} + DEPENDS firmware_nuttx + ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) + + add_custom_target(debug_io_ddd + COMMAND ${DDD} --debugger ${GDB} + ${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}_${LABEL} + DEPENDS firmware_nuttx + ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit + ) + + px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD} + BUNDLE ${fw_file}) +endif() + +install(FILES ${fw_file} DESTINATION .) + +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/firmware/nuttx/gdbinit.in b/src/firmware/nuttx/gdbinit.in new file mode 100644 index 0000000000..e820673b21 --- /dev/null +++ b/src/firmware/nuttx/gdbinit.in @@ -0,0 +1,7 @@ +target extended ${DEBUG_PORT} +monitor swdp_scan +attach 1 +monitor vector_catch disable hard +set mem inaccessible-by-default off +set print pretty +source ${CMAKE_SOURCE_DIR}/Debug/PX4 diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt new file mode 100644 index 0000000000..7c30f1dfa6 --- /dev/null +++ b/src/firmware/posix/CMakeLists.txt @@ -0,0 +1,34 @@ +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + + +px4_posix_generate_builtin_commands( + OUT apps.h + MODULE_LIST ${module_libraries}) + +add_executable(mainapp + ${CMAKE_SOURCE_DIR}/src/platforms/posix/main.cpp + apps.h + ) + +if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + target_link_libraries(mainapp + -Wl,--start-group + ${module_libraries} + pthread m rt + -Wl,--end-group + ) +else() + if (APPLE) + target_link_libraries(mainapp + ${module_libraries} + pthread m + ) + else() + target_link_libraries(mainapp + ${module_libraries} + pthread m rt + ) + endif() +endif() + +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/firmware/qurt/CMakeLists.txt b/src/firmware/qurt/CMakeLists.txt new file mode 100644 index 0000000000..b6d743186f --- /dev/null +++ b/src/firmware/qurt/CMakeLists.txt @@ -0,0 +1,31 @@ +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +px4_qurt_generate_builtin_commands( + OUT ${CMAKE_BINARY_DIR}/apps.h + MODULE_LIST ${module_libraries}) + +# Clear -rdynamic flag which fails for hexagon +# this change is scoped in this directory and below +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +# Enable build without HexagonSDK to check link dependencies +if ("${QURT_ENABLE_STUBS}" STREQUAL "1") + add_executable(mainapp + ${CMAKE_SOURCE_DIR}/src/platforms/qurt/dspal/dspal_stub.c + ${CMAKE_BINARY_DIR}/apps.h) +else() + add_library(mainapp + ${CMAKE_SOURCE_DIR}/src/platforms/qurt/dspal/dspal_stub.c + ${CMAKE_BINARY_DIR}/apps.h) +endif() + +target_link_libraries(mainapp + -Wl,--whole-archive + ${module_libraries} + ${target_libraries} + m + -Wl,--no-whole-archive + -Wl,${TOOLSLIB}/pic/libstdc++.a) + +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/conversion/CMakeLists.txt b/src/lib/conversion/CMakeLists.txt new file mode 100644 index 0000000000..78f39e99aa --- /dev/null +++ b/src/lib/conversion/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE lib__conversion + COMPILE_FLAGS + -Os + SRCS + rotation.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/conversion/module.mk b/src/lib/conversion/module.mk deleted file mode 100644 index 4593c48871..0000000000 --- a/src/lib/conversion/module.mk +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################ -# -# Copyright (C) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Conversion library -# - -SRCS = rotation.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/lib/dspal b/src/lib/dspal index 229f2f4d84..95e91546f4 160000 --- a/src/lib/dspal +++ b/src/lib/dspal @@ -1 +1 @@ -Subproject commit 229f2f4d8471564f01fe8330e5de1554a9b7aeb6 +Subproject commit 95e91546f42e6d88d34a2bb29d0f428a8706c9e4 diff --git a/src/lib/ecl/CMakeLists.txt b/src/lib/ecl/CMakeLists.txt new file mode 100644 index 0000000000..0fd5b5f5e9 --- /dev/null +++ b/src/lib/ecl/CMakeLists.txt @@ -0,0 +1,48 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE lib__ecl + COMPILE_FLAGS + -Os + SRCS + attitude_fw/ecl_controller.cpp + attitude_fw/ecl_pitch_controller.cpp + attitude_fw/ecl_roll_controller.cpp + attitude_fw/ecl_yaw_controller.cpp + l1/ecl_l1_pos_controller.cpp + validation/data_validator.cpp + validation/data_validator_group.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/ecl/module.mk b/src/lib/ecl/module.mk deleted file mode 100644 index 747a7c5be0..0000000000 --- a/src/lib/ecl/module.mk +++ /dev/null @@ -1,46 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013 Estimation and Control Library (ECL). All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Estimation and Control Library -# - -SRCS = attitude_fw/ecl_controller.cpp \ - attitude_fw/ecl_pitch_controller.cpp \ - attitude_fw/ecl_roll_controller.cpp \ - attitude_fw/ecl_yaw_controller.cpp \ - l1/ecl_l1_pos_controller.cpp \ - validation/data_validator.cpp \ - validation/data_validator_group.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/lib/ecl/validation/data_validator.cpp b/src/lib/ecl/validation/data_validator.cpp index 037cb88645..737d9ea1a3 100644 --- a/src/lib/ecl/validation/data_validator.cpp +++ b/src/lib/ecl/validation/data_validator.cpp @@ -44,9 +44,10 @@ DataValidator::DataValidator(DataValidator *prev_sibling) : _time_last(0), - _timeout_interval(70000), + _timeout_interval(20000), _event_count(0), _error_count(0), + _error_density(0), _priority(0), _mean{0.0f}, _lp{0.0f}, @@ -68,6 +69,13 @@ void DataValidator::put(uint64_t timestamp, float val[3], uint64_t error_count_in, int priority_in) { _event_count++; + + if (error_count_in > _error_count) { + _error_density += (error_count_in - _error_count); + } else if (_error_density > 0) { + _error_density--; + } + _error_count = error_count_in; _priority = priority_in; @@ -123,7 +131,13 @@ DataValidator::confidence(uint64_t timestamp) return 0.0f; } - return 1.0f; + /* cap error density counter at window size */ + if (_error_density > ERROR_DENSITY_WINDOW) { + _error_density = ERROR_DENSITY_WINDOW; + } + + /* return local error density for last N measurements */ + return 1.0f - (_error_density / ERROR_DENSITY_WINDOW); } int @@ -136,12 +150,13 @@ void DataValidator::print() { if (_time_last == 0) { - ECL_INFO("\tno data\n"); + ECL_INFO("\tno data"); return; } for (unsigned i = 0; i < _dimensions; i++) { - ECL_INFO("\tval: %8.4f, lp: %8.4f mean dev: %8.4f RMS: %8.4f\n", - (double) _value[i], (double)_lp[i], (double)_mean[i], (double)_rms[i]); + ECL_INFO("\tval: %8.4f, lp: %8.4f mean dev: %8.4f RMS: %8.4f conf: %8.4f", + (double) _value[i], (double)_lp[i], (double)_mean[i], + (double)_rms[i], (double)confidence(hrt_absolute_time())); } } diff --git a/src/lib/ecl/validation/data_validator.h b/src/lib/ecl/validation/data_validator.h index 686a810c4e..dde9cb51aa 100644 --- a/src/lib/ecl/validation/data_validator.h +++ b/src/lib/ecl/validation/data_validator.h @@ -81,6 +81,12 @@ public: */ float* value() { return _value; } + /** + * Get the used status of this validator + * @return true if this validator ever saw data + */ + bool used() { return (_time_last > 0); } + /** * Get the priority of this validator * @return the stored priority @@ -112,6 +118,7 @@ private: uint64_t _timeout_interval; /**< interval in which the datastream times out in us */ uint64_t _event_count; /**< total data counter */ uint64_t _error_count; /**< error count */ + int _error_density; /**< ratio between successful reads and errors */ int _priority; /**< sensor nominal priority */ float _mean[_dimensions]; /**< mean of value */ float _lp[3]; /**< low pass value */ @@ -120,7 +127,8 @@ private: float _value[3]; /**< last value */ float _value_equal_count; /**< equal values in a row */ DataValidator *_sibling; /**< sibling in the group */ - const unsigned NORETURN_ERRCOUNT = 100; /**< if the error count reaches this value, return sensor as invalid */ + const unsigned NORETURN_ERRCOUNT = 10000; /**< if the error count reaches this value, return sensor as invalid */ + const float ERROR_DENSITY_WINDOW = 100.0f; /**< window in measurement counts for errors */ const unsigned VALUE_EQUAL_COUNT_MAX = 100; /**< if the sensor value is the same (accumulated also between axes) this many times, flag it */ /* we don't want this class to be copied */ diff --git a/src/lib/ecl/validation/data_validator_group.cpp b/src/lib/ecl/validation/data_validator_group.cpp index cdd1f6a677..ac4bcc8b9b 100644 --- a/src/lib/ecl/validation/data_validator_group.cpp +++ b/src/lib/ecl/validation/data_validator_group.cpp @@ -97,24 +97,35 @@ DataValidatorGroup::get_best(uint64_t timestamp, int *index) // XXX This should eventually also include voting int pre_check_best = _curr_best; + float pre_check_confidence = 1.0f; + int pre_check_prio = -1; float max_confidence = -1.0f; int max_priority = -1000; int max_index = -1; - uint64_t min_error_count = 30000; DataValidator *best = nullptr; unsigned i = 0; while (next != nullptr) { float confidence = next->confidence(timestamp); - if (confidence > max_confidence || - (fabsf(confidence - max_confidence) < 0.01f && - ((next->error_count() < min_error_count) && - (next->priority() >= max_priority)))) { + + if (static_cast(i) == pre_check_best) { + pre_check_prio = next->priority(); + pre_check_confidence = confidence; + } + + /* + * Switch if: + * 1) the confidence is higher and priority is equal or higher + * 2) the confidence is no less than 1% different and the priority is higher + */ + if (((max_confidence < MIN_REGULAR_CONFIDENCE) && (confidence >= MIN_REGULAR_CONFIDENCE)) || + (confidence > max_confidence && (next->priority() >= max_priority)) || + (fabsf(confidence - max_confidence) < 0.01f && (next->priority() > max_priority)) + ) { max_index = i; max_confidence = confidence; max_priority = next->priority(); - min_error_count = next->error_count(); best = next; } @@ -125,17 +136,29 @@ DataValidatorGroup::get_best(uint64_t timestamp, int *index) /* the current best sensor is not matching the previous best sensor */ if (max_index != _curr_best) { + bool true_failsafe = true; + + /* check wether the switch was a failsafe or preferring a higher priority sensor */ + if (pre_check_prio != -1 && pre_check_prio < max_priority && + fabsf(pre_check_confidence - max_confidence) < 0.1f) { + /* this is not a failover */ + true_failsafe = false; + } + /* if we're no initialized, initialize the bookkeeping but do not count a failsafe */ if (_curr_best < 0) { _prev_best = max_index; } else { /* we were initialized before, this is a real failsafe */ _prev_best = pre_check_best; - _toggle_count++; - /* if this is the first time, log when we failed */ - if (_first_failover_time == 0) { - _first_failover_time = timestamp; + if (true_failsafe) { + _toggle_count++; + + /* if this is the first time, log when we failed */ + if (_first_failover_time == 0) { + _first_failover_time = timestamp; + } } } @@ -185,8 +208,10 @@ DataValidatorGroup::print() unsigned i = 0; while (next != nullptr) { - ECL_INFO("sensor #%u:\n", i); - next->print(); + if (next->used()) { + ECL_INFO("sensor #%u, prio: %d", i, next->priority()); + next->print(); + } next = next->sibling(); i++; } diff --git a/src/lib/ecl/validation/data_validator_group.h b/src/lib/ecl/validation/data_validator_group.h index f35e0d71c1..3756be2638 100644 --- a/src/lib/ecl/validation/data_validator_group.h +++ b/src/lib/ecl/validation/data_validator_group.h @@ -100,6 +100,7 @@ private: int _prev_best; /**< the previous best index */ uint64_t _first_failover_time; /**< timestamp where the first failover occured or zero if none occured */ unsigned _toggle_count; /**< number of back and forth switches between two sensors */ + static constexpr float MIN_REGULAR_CONFIDENCE = 0.9f; /* we don't want this class to be copied */ DataValidatorGroup(const DataValidatorGroup&); diff --git a/src/lib/external_lgpl/CMakeLists.txt b/src/lib/external_lgpl/CMakeLists.txt new file mode 100644 index 0000000000..b46af5006d --- /dev/null +++ b/src/lib/external_lgpl/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE lib__external_lgpl + COMPILE_FLAGS + -Os + SRCS + tecs/tecs.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/external_lgpl/module.mk b/src/lib/external_lgpl/module.mk deleted file mode 100644 index 29d3514f68..0000000000 --- a/src/lib/external_lgpl/module.mk +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################ -# -# Copyright (C) 2012 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# W A R N I N G: The contents of this directory are license-incompatible -# with the rest of the codebase. Do NOT copy any parts of it -# into other folders. -# -# Acknowledgements: -# -# The algorithms in this folder have been developed by Paul Riseborough -# with support from Andrew Tridgell. -# Originally licensed as LGPL for APM. As this is built as library and -# linked, use of this code does not change the usability of PX4 in general -# or any of the license implications. -# - -SRCS = tecs/tecs.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/examples/matlab_csv_serial/module.mk b/src/lib/geo/CMakeLists.txt similarity index 89% rename from src/examples/matlab_csv_serial/module.mk rename to src/lib/geo/CMakeLists.txt index 1629c2ce46..14b80ef2a5 100644 --- a/src/examples/matlab_csv_serial/module.mk +++ b/src/lib/geo/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2014 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -30,11 +30,11 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - -# -# Build position estimator -# - -MODULE_COMMAND = matlab_csv_serial - -SRCS = matlab_csv_serial.c +px4_add_module( + MODULE lib__geo + SRCS + geo.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/geo/module.mk b/src/lib/geo/module.mk deleted file mode 100644 index d08ca4532f..0000000000 --- a/src/lib/geo/module.mk +++ /dev/null @@ -1,38 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Geo library -# - -SRCS = geo.c diff --git a/src/lib/geo_lookup/CMakeLists.txt b/src/lib/geo_lookup/CMakeLists.txt new file mode 100644 index 0000000000..ea13af025d --- /dev/null +++ b/src/lib/geo_lookup/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE lib__geo_lookup + COMPILE_FLAGS + -Os + SRCS + geo_mag_declination.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/geo_lookup/module.mk b/src/lib/geo_lookup/module.mk deleted file mode 100644 index d7a10df2db..0000000000 --- a/src/lib/geo_lookup/module.mk +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################ -# -# Copyright (c) 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Geo lookup table / data library -# - -SRCS = geo_mag_declination.c - -MAXOPTIMIZATION = -Os diff --git a/src/lib/launchdetection/CMakeLists.txt b/src/lib/launchdetection/CMakeLists.txt new file mode 100644 index 0000000000..7ea0c18788 --- /dev/null +++ b/src/lib/launchdetection/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE lib__launchdetection + COMPILE_FLAGS + -Os + SRCS + LaunchDetector.cpp + CatapultLaunchMethod.cpp + launchdetection_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/launchdetection/CatapultLaunchMethod.cpp b/src/lib/launchdetection/CatapultLaunchMethod.cpp index d514d895f4..b5692cc7e7 100644 --- a/src/lib/launchdetection/CatapultLaunchMethod.cpp +++ b/src/lib/launchdetection/CatapultLaunchMethod.cpp @@ -78,13 +78,13 @@ void CatapultLaunchMethod::update(float accel_x) if (integrator > thresholdTime.get()) { if (motorDelay.get() > 0.0f) { state = LAUNCHDETECTION_RES_DETECTED_ENABLECONTROL; - warnx("Launch detected: state: enablecontrol, waiting %.2fs until using full" - " throttle", (double)motorDelay.get()); + warnx("Launch detected: enablecontrol, waiting %8.4fs until full throttle", + double(motorDelay.get())); } else { /* No motor delay set: go directly to enablemotors state */ state = LAUNCHDETECTION_RES_DETECTED_ENABLEMOTORS; - warnx("Launch detected: state: enablemotors (delay not activated)"); + warnx("Launch detected: enablemotors (delay not activated)"); } } diff --git a/src/lib/launchdetection/module.mk b/src/lib/launchdetection/module.mk deleted file mode 100644 index d92f0bb45a..0000000000 --- a/src/lib/launchdetection/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013, 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Launchdetection Library -# - -SRCS = LaunchDetector.cpp \ - CatapultLaunchMethod.cpp \ - launchdetection_params.c - -MAXOPTIMIZATION = -Os diff --git a/src/lib/mathlib/CMakeLists.txt b/src/lib/mathlib/CMakeLists.txt new file mode 100644 index 0000000000..6bfe964d79 --- /dev/null +++ b/src/lib/mathlib/CMakeLists.txt @@ -0,0 +1,41 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE lib__mathlib + SRCS + math/test/test.cpp + math/Limits.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/mathlib/math/filter/CMakeLists.txt b/src/lib/mathlib/math/filter/CMakeLists.txt new file mode 100644 index 0000000000..785b2f2c6c --- /dev/null +++ b/src/lib/mathlib/math/filter/CMakeLists.txt @@ -0,0 +1,40 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE lib__mathlib__math__filter + SRCS + LowPassFilter2p.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/mathlib/math/filter/LowPassFilter2p.cpp b/src/lib/mathlib/math/filter/LowPassFilter2p.cpp index 7e2778e445..c3d44588fd 100644 --- a/src/lib/mathlib/math/filter/LowPassFilter2p.cpp +++ b/src/lib/mathlib/math/filter/LowPassFilter2p.cpp @@ -41,6 +41,10 @@ #include "LowPassFilter2p.hpp" #include "math.h" +#ifndef M_PI_F +#define M_PI_F 3.14159f +#endif + namespace math { diff --git a/src/lib/rc/CMakeLists.txt b/src/lib/rc/CMakeLists.txt new file mode 100644 index 0000000000..686f398e27 --- /dev/null +++ b/src/lib/rc/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE lib__rc + COMPILE_FLAGS + -Os + SRCS + st24.c + sumd.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/lib/rc/module.mk b/src/lib/rc/module.mk deleted file mode 100644 index 20f89c8473..0000000000 --- a/src/lib/rc/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Yuntec ST24 transmitter protocol decoder -# Graupnet HoTT transmitter protocol decoder -# - -SRCS = st24.c \ - sumd.c - -MAXOPTIMIZATION = -Os diff --git a/src/lib/uavcan b/src/lib/uavcan deleted file mode 160000 index 3ae5400aa5..0000000000 --- a/src/lib/uavcan +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3ae5400aa5ead18139106d30f730114d5e9b65dd diff --git a/src/modules/attitude_estimator_ekf/CMakeLists.txt b/src/modules/attitude_estimator_ekf/CMakeLists.txt new file mode 100644 index 0000000000..8c68904661 --- /dev/null +++ b/src/modules/attitude_estimator_ekf/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__attitude_estimator_ekf + MAIN attitude_estimator_ekf + STACK 1200 + COMPILE_FLAGS + -Wno-float-equal + SRCS + attitude_estimator_ekf_main.cpp + codegen/AttitudeEKF.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp b/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp index 14f5470425..e408fb3c99 100755 --- a/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp +++ b/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp @@ -108,6 +108,46 @@ usage(const char *reason) fprintf(stderr, "usage: attitude_estimator_ekf {start|stop|status} [-p ]\n\n"); } +int parameters_init(struct attitude_estimator_ekf_param_handles *h) +{ + /* PID parameters */ + h->q0 = param_find("EKF_ATT_V3_Q0"); + h->q1 = param_find("EKF_ATT_V3_Q1"); + h->q2 = param_find("EKF_ATT_V3_Q2"); + h->q3 = param_find("EKF_ATT_V3_Q3"); + + h->r0 = param_find("EKF_ATT_V4_R0"); + h->r1 = param_find("EKF_ATT_V4_R1"); + h->r2 = param_find("EKF_ATT_V4_R2"); + + h->moment_inertia_J[0] = param_find("ATT_J11"); + h->moment_inertia_J[1] = param_find("ATT_J22"); + h->moment_inertia_J[2] = param_find("ATT_J33"); + h->use_moment_inertia = param_find("ATT_J_EN"); + + return OK; +} + +int parameters_update(const struct attitude_estimator_ekf_param_handles *h, struct attitude_estimator_ekf_params *p) +{ + param_get(h->q0, &(p->q[0])); + param_get(h->q1, &(p->q[1])); + param_get(h->q2, &(p->q[2])); + param_get(h->q3, &(p->q[3])); + + param_get(h->r0, &(p->r[0])); + param_get(h->r1, &(p->r[1])); + param_get(h->r2, &(p->r[2])); + + for (int i = 0; i < 3; i++) { + param_get(h->moment_inertia_J[i], &(p->moment_inertia_J[3 * i + i])); + } + + param_get(h->use_moment_inertia, &(p->use_moment_inertia)); + + return OK; +} + /** * The attitude_estimator_ekf app only briefly exists to start * the background job. The stack size assigned in the diff --git a/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_params.c b/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_params.c index 30eb2a96e0..92156c93e8 100755 --- a/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_params.c +++ b/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_params.c @@ -95,19 +95,6 @@ PARAM_DEFINE_FLOAT(EKF_ATT_V4_R1, 10000.0f); */ PARAM_DEFINE_FLOAT(EKF_ATT_V4_R2, 100.0f); -/** - * EKF attitude estimator enabled - * - * If enabled, it uses the older EKF filter. - * However users can enable the new quaternion - * based complimentary filter by setting EKF_ATT_ENABLED = 0. - * - * @min 0 - * @max 1 - * @group Attitude EKF estimator - */ -PARAM_DEFINE_INT32(EKF_ATT_ENABLED, 1); - /** * Moment of inertia matrix diagonal entry (1, 1) * @@ -142,43 +129,3 @@ PARAM_DEFINE_FLOAT(ATT_J33, 0.0037); * @max 1 */ PARAM_DEFINE_INT32(ATT_J_EN, 0); - -int parameters_init(struct attitude_estimator_ekf_param_handles *h) -{ - /* PID parameters */ - h->q0 = param_find("EKF_ATT_V3_Q0"); - h->q1 = param_find("EKF_ATT_V3_Q1"); - h->q2 = param_find("EKF_ATT_V3_Q2"); - h->q3 = param_find("EKF_ATT_V3_Q3"); - - h->r0 = param_find("EKF_ATT_V4_R0"); - h->r1 = param_find("EKF_ATT_V4_R1"); - h->r2 = param_find("EKF_ATT_V4_R2"); - - h->moment_inertia_J[0] = param_find("ATT_J11"); - h->moment_inertia_J[1] = param_find("ATT_J22"); - h->moment_inertia_J[2] = param_find("ATT_J33"); - h->use_moment_inertia = param_find("ATT_J_EN"); - - return OK; -} - -int parameters_update(const struct attitude_estimator_ekf_param_handles *h, struct attitude_estimator_ekf_params *p) -{ - param_get(h->q0, &(p->q[0])); - param_get(h->q1, &(p->q[1])); - param_get(h->q2, &(p->q[2])); - param_get(h->q3, &(p->q[3])); - - param_get(h->r0, &(p->r[0])); - param_get(h->r1, &(p->r[1])); - param_get(h->r2, &(p->r[2])); - - for (int i = 0; i < 3; i++) { - param_get(h->moment_inertia_J[i], &(p->moment_inertia_J[3 * i + i])); - } - - param_get(h->use_moment_inertia, &(p->use_moment_inertia)); - - return OK; -} diff --git a/src/modules/attitude_estimator_ekf/module.mk b/src/modules/attitude_estimator_ekf/module.mk deleted file mode 100644 index 716b0aefe4..0000000000 --- a/src/modules/attitude_estimator_ekf/module.mk +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Attitude estimator (Extended Kalman Filter) -# - -MODULE_COMMAND = attitude_estimator_ekf - -SRCS = attitude_estimator_ekf_main.cpp \ - attitude_estimator_ekf_params.c \ - codegen/AttitudeEKF.c - -MODULE_STACKSIZE = 1200 - -EXTRACFLAGS = -Wno-float-equal -Wframe-larger-than=3700 - -ifeq ($(PX4_TARGET_OS),nuttx) -EXTRACXXFLAGS = -Wframe-larger-than=2600 -endif diff --git a/src/modules/attitude_estimator_q/CMakeLists.txt b/src/modules/attitude_estimator_q/CMakeLists.txt new file mode 100644 index 0000000000..c74993ad67 --- /dev/null +++ b/src/modules/attitude_estimator_q/CMakeLists.txt @@ -0,0 +1,47 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################# +set(MODULE_CFLAGS) +if (${OS} STREQUAL "nuttx") + list(APPEND MODULE_CFLAGS -Wframe-larger-than=1400) +endif() +px4_add_module( + MODULE modules__attitude_estimator_q + MAIN attitude_estimator_q + COMPILE_FLAGS ${MODULE_CFLAGS} + STACK 1200 + SRCS + attitude_estimator_q_main.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp b/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp index 9b60701413..efe8a2ea99 100644 --- a/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp +++ b/src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp @@ -40,6 +40,7 @@ */ #include +#include #include #include #include diff --git a/src/modules/attitude_estimator_q/attitude_estimator_q_params.c b/src/modules/attitude_estimator_q/attitude_estimator_q_params.c index d4d9d10eb4..d72f62dc61 100644 --- a/src/modules/attitude_estimator_q/attitude_estimator_q_params.c +++ b/src/modules/attitude_estimator_q/attitude_estimator_q_params.c @@ -116,4 +116,4 @@ PARAM_DEFINE_FLOAT(ATT_BIAS_MAX, 0.05f); * @min 0.001 * @max 100 */ -PARAM_DEFINE_FLOAT(ATT_VIBE_THRESH, 0.1f); +PARAM_DEFINE_FLOAT(ATT_VIBE_THRESH, 0.2f); diff --git a/src/modules/bottle_drop/CMakeLists.txt b/src/modules/bottle_drop/CMakeLists.txt new file mode 100644 index 0000000000..7c77cac340 --- /dev/null +++ b/src/modules/bottle_drop/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__bottle_drop + MAIN bottle_drop + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + bottle_drop.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/bottle_drop/module.mk b/src/modules/bottle_drop/module.mk deleted file mode 100644 index df9f5473b0..0000000000 --- a/src/modules/bottle_drop/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Daemon application -# - -MODULE_COMMAND = bottle_drop - -SRCS = bottle_drop.cpp \ - bottle_drop_params.c - -MAXOPTIMIZATION = -Os - -MODULE_STACKSIZE = 1200 diff --git a/src/modules/commander/CMakeLists.txt b/src/modules/commander/CMakeLists.txt new file mode 100644 index 0000000000..5ca0ff2ca6 --- /dev/null +++ b/src/modules/commander/CMakeLists.txt @@ -0,0 +1,60 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +set(MODULE_CFLAGS -Os) +if(${OS} STREQUAL "nuttx") + list(APPEND MODULE_CFLAGS -Wframe-larger-than=2300) +endif() +px4_add_module( + MODULE modules__commander + MAIN commander + STACK 1200 + COMPILE_FLAGS + ${MODULE_CFLAGS} + -Os + SRCS + commander.cpp + state_machine_helper.cpp + commander_helper.cpp + calibration_routines.cpp + accelerometer_calibration.cpp + gyro_calibration.cpp + mag_calibration.cpp + baro_calibration.cpp + rc_calibration.cpp + airspeed_calibration.cpp + esc_calibration.cpp + PreflightCheck.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/commander/PreflightCheck.cpp b/src/modules/commander/PreflightCheck.cpp index bbf5f8ec6b..2a8a0695cf 100644 --- a/src/modules/commander/PreflightCheck.cpp +++ b/src/modules/commander/PreflightCheck.cpp @@ -71,7 +71,50 @@ namespace Commander { -static bool magnometerCheck(int mavlink_fd, unsigned instance, bool optional) + +static int check_calibration(int fd, const char* param_template, int &devid); + +int check_calibration(int fd, const char* param_template, int &devid) +{ + bool calibration_found; + + /* new style: ask device for calibration state */ + int ret = px4_ioctl(fd, SENSORIOCCALTEST, 0); + + calibration_found = (ret == OK); + + devid = px4_ioctl(fd, DEVIOCGDEVICEID, 0); + + char s[20]; + int instance = 0; + + /* old style transition: check param values */ + while (!calibration_found) { + sprintf(s, param_template, instance); + param_t parm = param_find(s); + + /* if the calibration param is not present, abort */ + if (parm == PARAM_INVALID) { + break; + } + + /* if param get succeeds */ + int calibration_devid; + if (!param_get(parm, &(calibration_devid))) { + + /* if the devid matches, exit early */ + if (devid == calibration_devid) { + calibration_found = true; + break; + } + } + instance++; + } + + return !calibration_found; +} + +static bool magnometerCheck(int mavlink_fd, unsigned instance, bool optional, int &device_id) { bool success = true; @@ -88,13 +131,9 @@ static bool magnometerCheck(int mavlink_fd, unsigned instance, bool optional) return false; } - int calibration_devid; - int ret; - int devid = px4_ioctl(fd, DEVIOCGDEVICEID, 0); - sprintf(s, "CAL_MAG%u_ID", instance); - param_get(param_find(s), &(calibration_devid)); + int ret = check_calibration(fd, "CAL_MAG%u_ID", device_id); - if (devid != calibration_devid) { + if (ret) { mavlink_and_console_log_critical(mavlink_fd, "PREFLIGHT FAIL: MAG #%u UNCALIBRATED", instance); success = false; @@ -115,7 +154,7 @@ out: return success; } -static bool accelerometerCheck(int mavlink_fd, unsigned instance, bool optional, bool dynamic) +static bool accelerometerCheck(int mavlink_fd, unsigned instance, bool optional, bool dynamic, int &device_id) { bool success = true; @@ -132,13 +171,9 @@ static bool accelerometerCheck(int mavlink_fd, unsigned instance, bool optional, return false; } - int calibration_devid; - int ret; - int devid = px4_ioctl(fd, DEVIOCGDEVICEID, 0); - sprintf(s, "CAL_ACC%u_ID", instance); - param_get(param_find(s), &(calibration_devid)); + int ret = check_calibration(fd, "CAL_ACC%u_ID", device_id); - if (devid != calibration_devid) { + if (ret) { mavlink_and_console_log_critical(mavlink_fd, "PREFLIGHT FAIL: ACCEL #%u UNCALIBRATED", instance); success = false; @@ -184,7 +219,7 @@ out: return success; } -static bool gyroCheck(int mavlink_fd, unsigned instance, bool optional) +static bool gyroCheck(int mavlink_fd, unsigned instance, bool optional, int &device_id) { bool success = true; @@ -201,13 +236,9 @@ static bool gyroCheck(int mavlink_fd, unsigned instance, bool optional) return false; } - int calibration_devid; - int ret; - int devid = px4_ioctl(fd, DEVIOCGDEVICEID, 0); - sprintf(s, "CAL_GYRO%u_ID", instance); - param_get(param_find(s), &(calibration_devid)); + int ret = check_calibration(fd, "CAL_GYRO%u_ID", device_id); - if (devid != calibration_devid) { + if (ret) { mavlink_and_console_log_critical(mavlink_fd, "PREFLIGHT FAIL: GYRO #%u UNCALIBRATED", instance); success = false; @@ -228,7 +259,7 @@ out: return success; } -static bool baroCheck(int mavlink_fd, unsigned instance, bool optional) +static bool baroCheck(int mavlink_fd, unsigned instance, bool optional, int &device_id) { bool success = true; @@ -245,6 +276,20 @@ static bool baroCheck(int mavlink_fd, unsigned instance, bool optional) return false; } + device_id = -1000; + + // TODO: There is no baro calibration yet, since no external baros exist + // int ret = check_calibration(fd, "CAL_BARO%u_ID"); + + // if (ret) { + // mavlink_and_console_log_critical(mavlink_fd, + // "PREFLIGHT FAIL: BARO #%u UNCALIBRATED", instance); + // success = false; + // goto out; + // } + +//out: + px4_close(fd); return success; } @@ -311,49 +356,110 @@ bool preflightCheck(int mavlink_fd, bool checkMag, bool checkAcc, bool checkGyro /* ---- MAG ---- */ if (checkMag) { + bool prime_found = false; + int32_t prime_id = 0; + param_get(param_find("CAL_MAG_PRIME"), &prime_id); + /* check all sensors, but fail only for mandatory ones */ for (unsigned i = 0; i < max_optional_mag_count; i++) { bool required = (i < max_mandatory_mag_count); + int device_id = -1; - if (!magnometerCheck(mavlink_fd, i, !required) && required) { + if (!magnometerCheck(mavlink_fd, i, !required, device_id) && required) { failed = true; } + + if (device_id == prime_id) { + prime_found = true; + } + } + + /* check if the primary device is present */ + if (!prime_found && prime_id != 0) { + mavlink_log_critical(mavlink_fd, "warning: primary compass not operational"); + failed = true; } } /* ---- ACCEL ---- */ if (checkAcc) { + bool prime_found = false; + int32_t prime_id = 0; + param_get(param_find("CAL_ACC_PRIME"), &prime_id); + /* check all sensors, but fail only for mandatory ones */ for (unsigned i = 0; i < max_optional_accel_count; i++) { bool required = (i < max_mandatory_accel_count); + int device_id = -1; - if (!accelerometerCheck(mavlink_fd, i, !required, checkDynamic) && required) { + if (!accelerometerCheck(mavlink_fd, i, !required, checkDynamic, device_id) && required) { failed = true; } + + if (device_id == prime_id) { + prime_found = true; + } + } + + /* check if the primary device is present */ + if (!prime_found && prime_id != 0) { + mavlink_log_critical(mavlink_fd, "warning: primary accelerometer not operational"); + failed = true; } } /* ---- GYRO ---- */ if (checkGyro) { + bool prime_found = false; + int32_t prime_id = 0; + param_get(param_find("CAL_GYRO_PRIME"), &prime_id); + /* check all sensors, but fail only for mandatory ones */ for (unsigned i = 0; i < max_optional_gyro_count; i++) { bool required = (i < max_mandatory_gyro_count); + int device_id = -1; - if (!gyroCheck(mavlink_fd, i, !required) && required) { + if (!gyroCheck(mavlink_fd, i, !required, device_id) && required) { failed = true; } + + if (device_id == prime_id) { + prime_found = true; + } + } + + /* check if the primary device is present */ + if (!prime_found && prime_id != 0) { + mavlink_log_critical(mavlink_fd, "warning: primary gyro not operational"); + failed = true; } } /* ---- BARO ---- */ if (checkBaro) { + bool prime_found = false; + int32_t prime_id = 0; + param_get(param_find("CAL_BARO_PRIME"), &prime_id); + /* check all sensors, but fail only for mandatory ones */ for (unsigned i = 0; i < max_optional_baro_count; i++) { bool required = (i < max_mandatory_baro_count); + int device_id = -1; - if (!baroCheck(mavlink_fd, i, !required) && required) { + if (!baroCheck(mavlink_fd, i, !required, device_id) && required) { failed = true; } + + if (device_id == prime_id) { + prime_found = true; + } + } + + // TODO there is no logic in place to calibrate the primary baro yet + // // check if the primary device is present + if (!prime_found && prime_id != 0) { + mavlink_log_critical(mavlink_fd, "warning: primary barometer not operational"); + failed = true; } } @@ -367,12 +473,13 @@ bool preflightCheck(int mavlink_fd, bool checkMag, bool checkAcc, bool checkGyro /* ---- RC CALIBRATION ---- */ if (checkRC) { if (rc_calibration_check(mavlink_fd) != OK) { + mavlink_log_critical(mavlink_fd, "RC calibration check failed"); failed = true; } } /* ---- Global Navigation Satellite System receiver ---- */ - if(checkGNSS) { + if (checkGNSS) { if(!gnssCheck(mavlink_fd)) { failed = true; } diff --git a/src/modules/commander/accelerometer_calibration.cpp b/src/modules/commander/accelerometer_calibration.cpp index 6a38d54cb6..d7a58e6254 100644 --- a/src/modules/commander/accelerometer_calibration.cpp +++ b/src/modules/commander/accelerometer_calibration.cpp @@ -156,6 +156,10 @@ static const int ERROR = -1; static const char *sensor_name = "accel"; +static int32_t device_id[max_accel_sens]; +static int device_prio_max = 0; +static int32_t device_id_primary = 0; + calibrate_return do_accel_calibration_measurements(int mavlink_fd, float (&accel_offs)[max_accel_sens][3], float (&accel_T)[max_accel_sens][3][3], unsigned *active_sensors); calibrate_return read_accelerometer_avg(int (&subs)[max_accel_sens], float (&accel_avg)[max_accel_sens][detect_orientation_side_count][3], unsigned orient, unsigned samples_num); int mat_invert3(float src[3][3], float dst[3][3]); @@ -172,7 +176,6 @@ typedef struct { int do_accel_calibration(int mavlink_fd) { int fd; - int32_t device_id[max_accel_sens]; mavlink_and_console_log_info(mavlink_fd, CAL_QGC_STARTED_MSG, sensor_name); @@ -259,6 +262,8 @@ int do_accel_calibration(int mavlink_fd) bool failed = false; + failed = failed || (OK != param_set_no_notification(param_find("CAL_ACC_PRIME"), &(device_id_primary))); + /* set parameters */ (void)sprintf(str, "CAL_ACC%u_XOFF", i); failed |= (OK != param_set_no_notification(param_find(str), &(accel_scale.x_offset))); @@ -370,6 +375,15 @@ calibrate_return do_accel_calibration_measurements(int mavlink_fd, float (&accel struct accel_report arp = {}; (void)orb_copy(ORB_ID(sensor_accel), worker_data.subs[i], &arp); timestamps[i] = arp.timestamp; + + // Get priority + int32_t prio; + orb_priority(worker_data.subs[i], &prio); + + if (prio > device_prio_max) { + device_prio_max = prio; + device_id_primary = device_id[i]; + } } if (result == calibrate_return_ok) { diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index f9fdd6dadb..79d0811b72 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -57,9 +58,6 @@ #include #include //#include -#ifndef __PX4_QURT -#include -#endif #include #include #include @@ -197,6 +195,13 @@ static struct offboard_control_mode_s offboard_control_mode; static struct home_position_s _home; static unsigned _last_mission_instance = 0; +static uint64_t last_manual_input = 0; +static switch_pos_t last_offboard_switch = 0; +static switch_pos_t last_return_switch = 0; +static switch_pos_t last_mode_switch = 0; +static switch_pos_t last_acro_switch = 0; +static switch_pos_t last_posctl_switch = 0; +static switch_pos_t last_loiter_switch = 0; struct vtol_vehicle_status_s vtol_status; @@ -410,7 +415,8 @@ void usage(const char *reason) void print_status() { warnx("type: %s", (status.is_rotary_wing) ? "symmetric motion" : "forward motion"); - warnx("usb powered: %s", (status.usb_connected) ? "yes" : "no"); + warnx("power: USB: %s, BRICK: %s", (status.usb_connected) ? "[OK]" : "[NO]", + (status.condition_power_input_valid) ? " [OK]" : "[NO]"); warnx("avionics rail: %6.2f V", (double)status.avionics_power_rail_voltage); warnx("home: lat = %.7f, lon = %.7f, alt = %.2f ", _home.lat, _home.lon, (double)_home.alt); warnx("home: x = %.7f, y = %.7f, z = %.2f ", (double)_home.x, (double)_home.y, (double)_home.z); @@ -587,6 +593,14 @@ bool handle_command(struct vehicle_status_s *status_local, const struct safety_s } else { cmd_result = vehicle_command_s::VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED; + + if (arming_ret == TRANSITION_DENIED) { + mavlink_log_critical(mavlink_fd, "Rejecting arming cmd"); + } + + if (main_ret == TRANSITION_DENIED) { + mavlink_log_critical(mavlink_fd, "Rejecting mode switch cmd"); + } } } break; @@ -788,6 +802,7 @@ bool handle_command(struct vehicle_status_s *status_local, const struct safety_s case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_CALIBRATION: case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_SET_SENSOR_OFFSETS: case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_STORAGE: + case vehicle_command_s::VEHICLE_CMD_PREFLIGHT_UAVCAN: case vehicle_command_s::VEHICLE_CMD_CUSTOM_0: case vehicle_command_s::VEHICLE_CMD_CUSTOM_1: case vehicle_command_s::VEHICLE_CMD_CUSTOM_2: @@ -911,16 +926,16 @@ int commander_thread_main(int argc, char *argv[]) param_t _param_eph = param_find("COM_HOME_H_T"); param_t _param_epv = param_find("COM_HOME_V_T"); - const char *main_states_str[vehicle_status_s::MAIN_STATE_MAX]; - main_states_str[vehicle_status_s::MAIN_STATE_MANUAL] = "MANUAL"; - main_states_str[vehicle_status_s::MAIN_STATE_ALTCTL] = "ALTCTL"; - main_states_str[vehicle_status_s::MAIN_STATE_POSCTL] = "POSCTL"; - main_states_str[vehicle_status_s::MAIN_STATE_AUTO_MISSION] = "AUTO_MISSION"; - main_states_str[vehicle_status_s::MAIN_STATE_AUTO_LOITER] = "AUTO_LOITER"; - main_states_str[vehicle_status_s::MAIN_STATE_AUTO_RTL] = "AUTO_RTL"; - main_states_str[vehicle_status_s::MAIN_STATE_ACRO] = "ACRO"; - main_states_str[vehicle_status_s::MAIN_STATE_STAB] = "STAB"; - main_states_str[vehicle_status_s::MAIN_STATE_OFFBOARD] = "OFFBOARD"; + // const char *main_states_str[vehicle_status_s::MAIN_STATE_MAX]; + // main_states_str[vehicle_status_s::MAIN_STATE_MANUAL] = "MANUAL"; + // main_states_str[vehicle_status_s::MAIN_STATE_ALTCTL] = "ALTCTL"; + // main_states_str[vehicle_status_s::MAIN_STATE_POSCTL] = "POSCTL"; + // main_states_str[vehicle_status_s::MAIN_STATE_AUTO_MISSION] = "AUTO_MISSION"; + // main_states_str[vehicle_status_s::MAIN_STATE_AUTO_LOITER] = "AUTO_LOITER"; + // main_states_str[vehicle_status_s::MAIN_STATE_AUTO_RTL] = "AUTO_RTL"; + // main_states_str[vehicle_status_s::MAIN_STATE_ACRO] = "ACRO"; + // main_states_str[vehicle_status_s::MAIN_STATE_STAB] = "STAB"; + // main_states_str[vehicle_status_s::MAIN_STATE_OFFBOARD] = "OFFBOARD"; const char *arming_states_str[vehicle_status_s::ARMING_STATE_MAX]; arming_states_str[vehicle_status_s::ARMING_STATE_INIT] = "INIT"; @@ -1222,13 +1237,13 @@ int commander_thread_main(int argc, char *argv[]) // Run preflight check int32_t rc_in_off = 0; param_get(_param_autostart_id, &autostart_id); + param_get(_param_rc_in_off, &rc_in_off); + status.rc_input_mode = rc_in_off; if (is_hil_setup(autostart_id)) { // HIL configuration selected: real sensors will be disabled status.condition_system_sensors_initialized = false; set_tune_override(TONE_STARTUP_TUNE); //normal boot tune } else { - param_get(_param_rc_in_off, &rc_in_off); - status.rc_input_mode = rc_in_off; status.condition_system_sensors_initialized = Commander::preflightCheck(mavlink_fd, true, true, true, true, checkAirspeed, (status.rc_input_mode == vehicle_status_s::RC_IN_MODE_DEFAULT), !status.circuit_breaker_engaged_gpsfailure_check); if (!status.condition_system_sensors_initialized) { @@ -1745,6 +1760,9 @@ int commander_thread_main(int argc, char *argv[]) if (arming_ret == TRANSITION_CHANGED) { arming_state_changed = true; + } else if (arming_ret == TRANSITION_DENIED) { + /* do not complain if not allowed into standby */ + arming_ret = TRANSITION_NOT_CHANGED; } } @@ -1885,7 +1903,7 @@ int commander_thread_main(int argc, char *argv[]) /* check if left stick is in lower left position and we are in MANUAL or AUTO_READY mode or (ASSIST mode and landed) -> disarm * do it only for rotary wings */ - if (status.is_rotary_wing && + if (status.is_rotary_wing && status.rc_input_mode != vehicle_status_s::RC_IN_MODE_OFF && (status.arming_state == vehicle_status_s::ARMING_STATE_ARMED || status.arming_state == vehicle_status_s::ARMING_STATE_ARMED_ERROR) && (status.main_state == vehicle_status_s::MAIN_STATE_MANUAL || status.main_state == vehicle_status_s::MAIN_STATE_ACRO || @@ -1915,7 +1933,7 @@ int commander_thread_main(int argc, char *argv[]) } /* check if left stick is in lower right position and we're in MANUAL mode -> arm */ - if (sp_man.r > STICK_ON_OFF_LIMIT && sp_man.z < 0.1f) { + if (sp_man.r > STICK_ON_OFF_LIMIT && sp_man.z < 0.1f && status.rc_input_mode != vehicle_status_s::RC_IN_MODE_OFF ) { if (stick_on_counter > STICK_ON_OFF_COUNTER_LIMIT) { /* we check outside of the transition function here because the requirement @@ -1932,9 +1950,9 @@ int commander_thread_main(int argc, char *argv[]) if (arming_ret == TRANSITION_CHANGED) { arming_state_changed = true; + } else { + print_reject_arm("NOT ARMING: Configuration error"); } - } else { - print_reject_arm("NOT ARMING: Configuration error"); } stick_on_counter = 0; @@ -2184,7 +2202,6 @@ int commander_thread_main(int argc, char *argv[]) // TODO handle mode changes by commands if (main_state_changed || nav_state_changed) { status_changed = true; - warnx("main state: %s nav state: %s", main_states_str[status.main_state], nav_states_str[status.nav_state]); mavlink_log_info(mavlink_fd, "Flight mode: %s", nav_states_str[status.nav_state]); main_state_changed = false; } @@ -2357,7 +2374,7 @@ control_status_leds(vehicle_status_s *status_local, const actuator_armed_s *actu } else if (status_local->battery_warning == vehicle_status_s::VEHICLE_BATTERY_WARNING_CRITICAL) { rgbled_set_color(RGBLED_COLOR_RED); } else { - if (status_local->condition_global_position_valid) { + if (status_local->condition_home_position_valid) { rgbled_set_color(RGBLED_COLOR_GREEN); } else { @@ -2413,6 +2430,27 @@ set_main_state_rc(struct vehicle_status_s *status_local, struct manual_control_s return main_state_transition(status_local,vehicle_status_s::MAIN_STATE_OFFBOARD); } + /* manual setpoint has not updated, do not re-evaluate it */ + if ((last_manual_input == sp_man->timestamp) || + ((last_offboard_switch == sp_man->offboard_switch) && + (last_return_switch == sp_man->return_switch) && + (last_mode_switch == sp_man->mode_switch) && + (last_acro_switch == sp_man->acro_switch) && + (last_posctl_switch == sp_man->posctl_switch) && + (last_loiter_switch == sp_man->loiter_switch))) { + + /* no timestamp change or no switch change -> nothing changed */ + return TRANSITION_NOT_CHANGED; + } + + last_manual_input = sp_man->timestamp; + last_offboard_switch = sp_man->offboard_switch; + last_return_switch = sp_man->return_switch; + last_mode_switch = sp_man->mode_switch; + last_acro_switch = sp_man->acro_switch; + last_posctl_switch = sp_man->posctl_switch; + last_loiter_switch = sp_man->loiter_switch; + /* offboard switch overrides main switch */ if (sp_man->offboard_switch == manual_control_setpoint_s::SWITCH_POS_ON) { res = main_state_transition(status_local,vehicle_status_s::MAIN_STATE_OFFBOARD); @@ -2804,7 +2842,7 @@ void answer_command(struct vehicle_command_s &cmd, unsigned result) void *commander_low_prio_loop(void *arg) { -#ifndef __PX4_QURT +#if defined(__PX4_LINUX) || defined(__PX4_NUTTX) /* Set thread name */ prctl(PR_SET_NAME, "commander_low_prio", getpid()); #endif diff --git a/src/modules/commander/commander_tests/CMakeLists.txt b/src/modules/commander/commander_tests/CMakeLists.txt new file mode 100644 index 0000000000..1a604136ad --- /dev/null +++ b/src/modules/commander/commander_tests/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__commander__commander_tests + MAIN commander_tests + SRCS + commander_tests.cpp + state_machine_helper_test.cpp + ../state_machine_helper.cpp + ../PreflightCheck.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/commander/gyro_calibration.cpp b/src/modules/commander/gyro_calibration.cpp index 817cbcdb0e..54866d8cb3 100644 --- a/src/modules/commander/gyro_calibration.cpp +++ b/src/modules/commander/gyro_calibration.cpp @@ -168,6 +168,9 @@ int do_gyro_calibration(int mavlink_fd) 1.0f, // z scale }; + int device_prio_max = 0; + int32_t device_id_primary = 0; + for (unsigned s = 0; s < max_gyros; s++) { char str[30]; @@ -199,6 +202,15 @@ int do_gyro_calibration(int mavlink_fd) for (unsigned s = 0; s < max_gyros; s++) { worker_data.gyro_sensor_sub[s] = orb_subscribe_multi(ORB_ID(sensor_gyro), s); + + // Get priority + int32_t prio; + orb_priority(worker_data.gyro_sensor_sub[s], &prio); + + if (prio > device_prio_max) { + device_prio_max = prio; + device_id_primary = worker_data.device_id[s]; + } } int cancel_sub = calibrate_cancel_subscribe(); @@ -258,9 +270,12 @@ int do_gyro_calibration(int mavlink_fd) } if (res == OK) { + /* set offset parameters to new values */ bool failed = false; + failed = failed || (OK != param_set_no_notification(param_find("CAL_GYRO_PRIME"), &(device_id_primary))); + for (unsigned s = 0; s < max_gyros; s++) { if (worker_data.device_id[s] != 0) { char str[30]; diff --git a/src/modules/commander/mag_calibration.cpp b/src/modules/commander/mag_calibration.cpp index 4511882c7b..eba8feec99 100644 --- a/src/modules/commander/mag_calibration.cpp +++ b/src/modules/commander/mag_calibration.cpp @@ -73,6 +73,10 @@ static constexpr unsigned int calibration_sides = 6; ///< The total number of static constexpr unsigned int calibration_total_points = 240; ///< The total points per magnetometer static constexpr unsigned int calibraton_duration_seconds = 42; ///< The total duration the routine is allowed to take +int32_t device_ids[max_mags]; +int device_prio_max = 0; +int32_t device_id_primary = 0; + calibrate_return mag_calibrate_all(int mavlink_fd, int32_t (&device_ids)[max_mags]); /// Data passed to calibration worker routine @@ -108,7 +112,6 @@ int do_mag_calibration(int mavlink_fd) // Determine which mags are available and reset each - int32_t device_ids[max_mags]; char str[30]; for (size_t i=0; i device_prio_max) { + device_prio_max = prio; + device_id_primary = device_ids[cur_mag]; + } } } } @@ -550,6 +562,9 @@ calibrate_return mag_calibrate_all(int mavlink_fd, int32_t (&device_ids)[max_mag } if (result == calibrate_return_ok) { + + (void)param_set_no_notification(param_find("CAL_MAG_PRIME"), &(device_id_primary)); + for (unsigned cur_mag=0; cur_mag #include +#include + #include #include #include @@ -64,12 +66,6 @@ #include "commander_helper.h" #include "PreflightCheck.h" -/* oddly, ERROR is not defined for c++ */ -#ifdef ERROR -# undef ERROR -#endif -static const int ERROR = -1; - // This array defines the arming state transitions. The rows are the new state, and the columns // are the current state. Using new state and current state you can index into the array which // will be true for a valid transition or false for a invalid transition. In some cases even @@ -97,6 +93,8 @@ static const char * const state_names[vehicle_status_s::ARMING_STATE_MAX] = { "ARMING_STATE_IN_AIR_RESTORE", }; +static bool sensor_feedback_provided = false; + transition_result_t arming_state_transition(struct vehicle_status_s *status, ///< current vehicle status const struct safety_s *safety, ///< current safety settings @@ -245,10 +243,12 @@ arming_state_transition(struct vehicle_status_s *status, ///< current vehicle s (new_arming_state == vehicle_status_s::ARMING_STATE_STANDBY) && (status->arming_state != vehicle_status_s::ARMING_STATE_STANDBY_ERROR) && (!status->condition_system_sensors_initialized)) { - mavlink_and_console_log_critical(mavlink_fd, "Not ready to fly: Sensors need inspection"); + if (!sensor_feedback_provided || (new_arming_state == vehicle_status_s::ARMING_STATE_ARMED)) { + mavlink_and_console_log_critical(mavlink_fd, "Not ready to fly: Sensors need inspection"); + sensor_feedback_provided = true; + } feedback_provided = true; valid_transition = false; - status->arming_state = vehicle_status_s::ARMING_STATE_STANDBY_ERROR; } // Finish up the state transition @@ -259,6 +259,12 @@ arming_state_transition(struct vehicle_status_s *status, ///< current vehicle s status->arming_state = new_arming_state; } + /* reset feedback state */ + if (status->arming_state != vehicle_status_s::ARMING_STATE_STANDBY_ERROR && + valid_transition) { + sensor_feedback_provided = false; + } + /* end of atomic state update */ #ifdef __PX4_NUTTX irqrestore(flags); @@ -266,15 +272,10 @@ arming_state_transition(struct vehicle_status_s *status, ///< current vehicle s } if (ret == TRANSITION_DENIED) { -#define WARNSTR "INVAL: %s - %s" - /* only print to console here by default as this is too technical to be useful during operation */ - warnx(WARNSTR, state_names[status->arming_state], state_names[new_arming_state]); - - /* print to MAVLink if we didn't provide any feedback yet */ + /* print to MAVLink and console if we didn't provide any feedback yet */ if (!feedback_provided) { - mavlink_log_critical(mavlink_fd, WARNSTR, state_names[status->arming_state], state_names[new_arming_state]); + mavlink_and_console_log_critical(mavlink_fd, "INVAL: %s - %s", state_names[status->arming_state], state_names[new_arming_state]); } -#undef WARNSTR } return ret; diff --git a/src/modules/controllib/CMakeLists.txt b/src/modules/controllib/CMakeLists.txt new file mode 100644 index 0000000000..1cfb2402ec --- /dev/null +++ b/src/modules/controllib/CMakeLists.txt @@ -0,0 +1,46 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__controllib + COMPILE_FLAGS + -Os + SRCS + test_params.c + block/Block.cpp + block/BlockParam.cpp + uorb/blocks.cpp + blocks.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/controllib/block/Block.hpp b/src/modules/controllib/block/Block.hpp index d169d35c5f..bb2a0e2657 100644 --- a/src/modules/controllib/block/Block.hpp +++ b/src/modules/controllib/block/Block.hpp @@ -39,6 +39,7 @@ #pragma once +#define __STDC_FORMAT_MACROS #include #include diff --git a/src/modules/controllib/blocks.cpp b/src/modules/controllib/blocks.cpp index f739446fa7..6a0b615910 100644 --- a/src/modules/controllib/blocks.cpp +++ b/src/modules/controllib/blocks.cpp @@ -39,6 +39,7 @@ #include #include +#include #include "blocks.hpp" @@ -51,6 +52,7 @@ int basicBlocksTest() blockLimitSymTest(); blockLowPassTest(); blockHighPassTest(); + blockLowPass2Test(); blockIntegralTest(); blockIntegralTrapTest(); blockDerivativeTest(); @@ -198,6 +200,47 @@ int blockHighPassTest() return 0; } +float BlockLowPass2::update(float input) +{ + if (!isfinite(getState())) { + setState(input); + } + + if (fabsf(_lp.get_cutoff_freq() - getFCutParam()) > FLT_EPSILON) { + _lp.set_cutoff_frequency(_fs, getFCutParam()); + } + _state = _lp.apply(input); + return _state; +} + +int blockLowPass2Test() +{ + printf("Test BlockLowPass2\t\t: "); + BlockLowPass2 lowPass(NULL, "TEST_LP", 100); + // test initial state + ASSERT(equal(10.0f, lowPass.getFCutParam())); + ASSERT(equal(0.0f, lowPass.getState())); + ASSERT(equal(0.0f, lowPass.getDt())); + // set dt + lowPass.setDt(0.1f); + ASSERT(equal(0.1f, lowPass.getDt())); + // set state + lowPass.setState(1.0f); + ASSERT(equal(1.0f, lowPass.getState())); + // test update + ASSERT(equal(1.06745527f, lowPass.update(2.0f))); + + // test end condition + for (int i = 0; i < 100; i++) { + lowPass.update(2.0f); + } + + ASSERT(equal(2.0f, lowPass.getState())); + ASSERT(equal(2.0f, lowPass.update(2.0f))); + printf("PASS\n"); + return 0; +}; + float BlockIntegral::update(float input) { // trapezoidal integration diff --git a/src/modules/controllib/blocks.hpp b/src/modules/controllib/blocks.hpp index 979b9541be..786bfc06d3 100644 --- a/src/modules/controllib/blocks.hpp +++ b/src/modules/controllib/blocks.hpp @@ -45,6 +45,7 @@ #include #include #include +#include #include "block/Block.hpp" #include "block/BlockParam.hpp" @@ -163,6 +164,36 @@ protected: int __EXPORT blockHighPassTest(); +/** + * A 2nd order low pass filter block which uses the default px4 2nd order low pass filter + */ +class __EXPORT BlockLowPass2 : public Block +{ +public: +// methods + BlockLowPass2(SuperBlock *parent, const char *name, float sample_freq) : + Block(parent, name), + _state(0.0 / 0.0 /* initialize to invalid val, force into is_finite() check on first call */), + _fCut(this, ""), // only one parameter, no need to name + _fs(sample_freq), + _lp(_fs, _fCut.get()) + {}; + virtual ~BlockLowPass2() {}; + float update(float input); +// accessors + float getState() { return _state; } + float getFCutParam() { return _fCut.get(); } + void setState(float state) { _state = _lp.reset(state); } +protected: +// attributes + float _state; + control::BlockParamFloat _fCut; + float _fs; + math::LowPassFilter2p _lp; +}; + +int __EXPORT blockLowPass2Test(); + /** * A rectangular integrator. * A limiter is built into the class to bound the @@ -263,6 +294,7 @@ public: void setU(float u) {_u = u;} float getU() {return _u;} float getLP() {return _lowPass.getFCut();} + float getO() { return _lowPass.getState(); } protected: // attributes float _u; /**< previous input */ diff --git a/src/modules/controllib/module.mk b/src/modules/controllib/module.mk deleted file mode 100644 index 2860d1efce..0000000000 --- a/src/modules/controllib/module.mk +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Control library -# -SRCS = test_params.c \ - block/Block.cpp \ - block/BlockParam.cpp \ - uorb/blocks.cpp \ - blocks.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/modules/dataman/CMakeLists.txt b/src/modules/dataman/CMakeLists.txt new file mode 100644 index 0000000000..b480f3695b --- /dev/null +++ b/src/modules/dataman/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__dataman + MAIN dataman + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + dataman.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/dataman/dataman.c b/src/modules/dataman/dataman.c index 6c9e9f0ee6..b10e7f7b7f 100644 --- a/src/modules/dataman/dataman.c +++ b/src/modules/dataman/dataman.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -82,7 +83,7 @@ typedef enum { /** Work task work item */ typedef struct { sq_entry_t link; /**< list linkage */ - sem_t wait_sem; + px4_sem_t wait_sem; unsigned char first; unsigned char func; ssize_t result; @@ -128,8 +129,8 @@ static const unsigned g_per_item_max_index[DM_KEY_NUM_KEYS] = { static unsigned int g_key_offsets[DM_KEY_NUM_KEYS]; /* Item type lock mutexes */ -static sem_t *g_item_locks[DM_KEY_NUM_KEYS]; -static sem_t g_sys_state_mutex; +static px4_sem_t *g_item_locks[DM_KEY_NUM_KEYS]; +static px4_sem_t g_sys_state_mutex; /* The data manager store file handle and file name */ static int g_fd = -1, g_task_fd = -1; @@ -140,7 +141,7 @@ static char *k_data_manager_device_path = NULL; typedef struct { sq_queue_t q; /* Nuttx queue */ - sem_t mutex; /* Mutual exclusion on work queue adds and deletes */ + px4_sem_t mutex; /* Mutual exclusion on work queue adds and deletes */ unsigned size; /* Current size of queue */ unsigned max_size; /* Maximum queue size reached */ } work_q_t; @@ -148,8 +149,8 @@ typedef struct { static work_q_t g_free_q; /* queue of free work items. So that we don't always need to call malloc and free*/ static work_q_t g_work_q; /* pending work items. To be consumed by worker thread */ -sem_t g_work_queued_sema; /* To notify worker thread a work item has been queued */ -sem_t g_init_sema; +static px4_sem_t g_work_queued_sema; /* To notify worker thread a work item has been queued */ +static px4_sem_t g_init_sema; static bool g_task_should_exit; /**< if true, dataman task should exit */ @@ -159,26 +160,26 @@ static const unsigned k_sector_size = DM_MAX_DATA_SIZE + DM_SECTOR_HDR_SIZE; /* static void init_q(work_q_t *q) { sq_init(&(q->q)); /* Initialize the NuttX queue structure */ - sem_init(&(q->mutex), 1, 1); /* Queue is initially unlocked */ + px4_sem_init(&(q->mutex), 1, 1); /* Queue is initially unlocked */ q->size = q->max_size = 0; /* Queue is initially empty */ } static inline void destroy_q(work_q_t *q) { - sem_destroy(&(q->mutex)); /* Destroy the queue lock */ + px4_sem_destroy(&(q->mutex)); /* Destroy the queue lock */ } static inline void lock_queue(work_q_t *q) { - sem_wait(&(q->mutex)); /* Acquire the queue lock */ + px4_sem_wait(&(q->mutex)); /* Acquire the queue lock */ } static inline void unlock_queue(work_q_t *q) { - sem_post(&(q->mutex)); /* Release the queue lock */ + px4_sem_post(&(q->mutex)); /* Release the queue lock */ } static work_q_item_t * @@ -221,7 +222,7 @@ create_work_item(void) /* If we got one then lock the item*/ if (item) { - sem_init(&item->wait_sem, 1, 0); /* Caller will wait on this... initially locked */ + px4_sem_init(&item->wait_sem, 1, 0); /* Caller will wait on this... initially locked */ } /* return the item pointer, or NULL if all failed */ @@ -233,7 +234,7 @@ create_work_item(void) static inline void destroy_work_item(work_q_item_t *item) { - sem_destroy(&item->wait_sem); /* Destroy the item lock */ + px4_sem_destroy(&item->wait_sem); /* Destroy the item lock */ /* Return the item to the free item queue for later reuse */ lock_queue(&g_free_q); sq_addfirst(&item->link, &(g_free_q.q)); @@ -277,10 +278,10 @@ enqueue_work_item_and_wait_for_result(work_q_item_t *item) unlock_queue(&g_work_q); /* tell the work thread that work is available */ - sem_post(&g_work_queued_sema); + px4_sem_post(&g_work_queued_sema); /* wait for the result */ - sem_wait(&item->wait_sem); + px4_sem_wait(&item->wait_sem); int result = item->result; @@ -628,7 +629,7 @@ dm_lock(dm_item_t item) } if (g_item_locks[item]) { - sem_wait(g_item_locks[item]); + px4_sem_wait(g_item_locks[item]); } } @@ -645,7 +646,7 @@ dm_unlock(dm_item_t item) } if (g_item_locks[item]) { - sem_post(g_item_locks[item]); + px4_sem_post(g_item_locks[item]); } } @@ -691,7 +692,7 @@ task_main(int argc, char *argv[]) } /* Initialize the item type locks, for now only DM_KEY_MISSION_STATE supports locking */ - sem_init(&g_sys_state_mutex, 1, 1); /* Initially unlocked */ + px4_sem_init(&g_sys_state_mutex, 1, 1); /* Initially unlocked */ for (unsigned i = 0; i < DM_KEY_NUM_KEYS; i++) { g_item_locks[i] = NULL; @@ -704,7 +705,7 @@ task_main(int argc, char *argv[]) init_q(&g_work_q); init_q(&g_free_q); - sem_init(&g_work_queued_sema, 1, 0); + px4_sem_init(&g_work_queued_sema, 1, 0); /* See if the data manage file exists and is a multiple of the sector size */ g_task_fd = open(k_data_manager_device_path, O_RDONLY | O_BINARY); @@ -729,14 +730,14 @@ task_main(int argc, char *argv[]) if (g_task_fd < 0) { warnx("Could not open data manager file %s", k_data_manager_device_path); - sem_post(&g_init_sema); /* Don't want to hang startup */ + px4_sem_post(&g_init_sema); /* Don't want to hang startup */ return -1; } if ((unsigned)lseek(g_task_fd, max_offset, SEEK_SET) != max_offset) { close(g_task_fd); warnx("Could not seek data manager file %s", k_data_manager_device_path); - sem_post(&g_init_sema); /* Don't want to hang startup */ + px4_sem_post(&g_init_sema); /* Don't want to hang startup */ return -1; } @@ -771,7 +772,7 @@ task_main(int argc, char *argv[]) printf(", data manager file '%s' size is %d bytes\n", k_data_manager_device_path, max_offset); /* Tell startup that the worker thread has completed its initialization */ - sem_post(&g_init_sema); + px4_sem_post(&g_init_sema); /* Start the endless loop, waiting for then processing work requests */ while (true) { @@ -784,7 +785,7 @@ task_main(int argc, char *argv[]) if (!g_task_should_exit) { /* wait for work */ - sem_wait(&g_work_queued_sema); + px4_sem_wait(&g_work_queued_sema); } /* Empty the work queue */ @@ -821,7 +822,7 @@ task_main(int argc, char *argv[]) } /* Inform the caller that work is done */ - sem_post(&work->wait_sem); + px4_sem_post(&work->wait_sem); } /* time to go???? */ @@ -846,8 +847,8 @@ task_main(int argc, char *argv[]) destroy_q(&g_work_q); destroy_q(&g_free_q); - sem_destroy(&g_work_queued_sema); - sem_destroy(&g_sys_state_mutex); + px4_sem_destroy(&g_work_queued_sema); + px4_sem_destroy(&g_sys_state_mutex); return 0; } @@ -857,17 +858,17 @@ start(void) { int task; - sem_init(&g_init_sema, 1, 0); + px4_sem_init(&g_init_sema, 1, 0); - /* start the worker thread */ - if ((task = px4_task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT, 1500, task_main, NULL)) <= 0) { + /* start the worker thread with low priority for disk IO */ + if ((task = px4_task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_DEFAULT - 10, 1200, task_main, NULL)) <= 0) { warn("task start failed"); return -1; } /* wait for the thread to actually initialize */ - sem_wait(&g_init_sema); - sem_destroy(&g_init_sema); + px4_sem_wait(&g_init_sema); + px4_sem_destroy(&g_init_sema); return 0; } @@ -888,7 +889,7 @@ stop(void) { /* Tell the worker task to shut down */ g_task_should_exit = true; - sem_post(&g_work_queued_sema); + px4_sem_post(&g_work_queued_sema); } static void diff --git a/src/modules/dataman/module.mk b/src/modules/dataman/module.mk deleted file mode 100644 index 7ebe09fb7e..0000000000 --- a/src/modules/dataman/module.mk +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Main Navigation Controller -# - -MODULE_COMMAND = dataman - -SRCS = dataman.c - -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os diff --git a/src/modules/ekf_att_pos_estimator/AttitudePositionEstimatorEKF.h b/src/modules/ekf_att_pos_estimator/AttitudePositionEstimatorEKF.h index e4d924396a..421e109eb3 100644 --- a/src/modules/ekf_att_pos_estimator/AttitudePositionEstimatorEKF.h +++ b/src/modules/ekf_att_pos_estimator/AttitudePositionEstimatorEKF.h @@ -133,6 +133,8 @@ public: */ int set_debuglevel(unsigned debug) { _debug = debug; return 0; } + static constexpr unsigned MAX_PREDICITION_STEPS = 3; /**< maximum number of prediction steps between updates */ + private: bool _task_should_exit; /**< if true, sensor task should exit */ bool _task_running; /**< if true, task is running in its mainloop */ @@ -174,6 +176,8 @@ private: hrt_abstime _last_accel; hrt_abstime _last_mag; + unsigned _prediction_steps; + uint64_t _prediction_last; struct sensor_combined_s _sensor_combined; diff --git a/src/modules/ekf_att_pos_estimator/CMakeLists.txt b/src/modules/ekf_att_pos_estimator/CMakeLists.txt new file mode 100644 index 0000000000..fc7fefd2bf --- /dev/null +++ b/src/modules/ekf_att_pos_estimator/CMakeLists.txt @@ -0,0 +1,51 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +set(MODULE_CFLAGS ) +if(NOT ${OS} STREQUAL "qurt") + list(APPEND MODULE_CFLAGS -Wframe-larger-than=3400) +endif() + +px4_add_module( + MODULE modules__ekf_att_pos_estimator + MAIN ekf_att_pos_estimator + STACK 3000 + COMPILE_FLAGS ${MODULE_CFLAGS} + SRCS + ekf_att_pos_estimator_main.cpp + estimator_22states.cpp + estimator_utilities.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp b/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp index d23dd1b9e9..61bd32a1b3 100644 --- a/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp +++ b/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp @@ -109,12 +109,6 @@ uint64_t getMicros() namespace estimator { -/* oddly, ERROR is not defined for c++ */ -#ifdef ERROR -# undef ERROR -#endif -static const int ERROR = -1; - AttitudePositionEstimatorEKF *g_estimator = nullptr; } @@ -162,6 +156,8 @@ AttitudePositionEstimatorEKF::AttitudePositionEstimatorEKF() : _last_accel(0), _last_mag(0), + _prediction_steps(0), + _prediction_last(0), _sensor_combined{}, @@ -1001,6 +997,15 @@ void AttitudePositionEstimatorEKF::updateSensorFusion(const bool fuseGPS, const _ekf->summedDelVel = _ekf->summedDelVel + _ekf->dVelIMU; _covariancePredictionDt += _ekf->dtIMU; + // only fuse every few steps + if (_prediction_steps < MAX_PREDICITION_STEPS && ((hrt_absolute_time() - _prediction_last) < 20 * 1000)) { + _prediction_steps++; + return; + } else { + _prediction_steps = 0; + _prediction_last = hrt_absolute_time(); + } + // perform a covariance prediction if the total delta angle has exceeded the limit // or the time limit will be exceeded at the next IMU update if ((_covariancePredictionDt >= (_ekf->covTimeStepMax - _ekf->dtIMU)) @@ -1117,7 +1122,7 @@ int AttitudePositionEstimatorEKF::start() _estimator_task = px4_task_spawn_cmd("ekf_att_pos_estimator", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 20, - 4800, + 3900, (px4_main_t)&AttitudePositionEstimatorEKF::task_main_trampoline, nullptr); @@ -1158,6 +1163,7 @@ void AttitudePositionEstimatorEKF::print_status() PX4_INFO("dang: %8.4f %8.4f %8.4f dang corr: %8.4f %8.4f %8.4f" , (double)_ekf->dAngIMU.x, (double)_ekf->dAngIMU.y, (double)_ekf->dAngIMU.z, (double)_ekf->correctedDelAng.x, (double)_ekf->correctedDelAng.y, (double)_ekf->correctedDelAng.z); + PX4_INFO("states (quat) [0-3]: %8.4f, %8.4f, %8.4f, %8.4f", (double)_ekf->states[0], (double)_ekf->states[1], (double)_ekf->states[2], (double)_ekf->states[3]); PX4_INFO("states (vel m/s) [4-6]: %8.4f, %8.4f, %8.4f", (double)_ekf->states[4], (double)_ekf->states[5], @@ -1177,11 +1183,12 @@ void AttitudePositionEstimatorEKF::print_status() PX4_INFO("states (terrain) [22]: %8.4f", (double)_ekf->states[22]); } else { - PX4_INFO("states (wind) [13-14]: %8.4f, %8.4f", (double)_ekf->states[13], (double)_ekf->states[14]); - PX4_INFO("states (earth mag) [15-17]: %8.4f, %8.4f, %8.4f", (double)_ekf->states[15], (double)_ekf->states[16], - (double)_ekf->states[17]); - PX4_INFO("states (body mag) [18-20]: %8.4f, %8.4f, %8.4f", (double)_ekf->states[18], (double)_ekf->states[19], - (double)_ekf->states[20]); + PX4_INFO("states (accel offs) [13]: %8.4f", (double)_ekf->states[13]); + PX4_INFO("states (wind) [14-15]: %8.4f, %8.4f", (double)_ekf->states[14], (double)_ekf->states[15]); + PX4_INFO("states (earth mag) [16-18]: %8.4f, %8.4f, %8.4f", (double)_ekf->states[16], (double)_ekf->states[17], + (double)_ekf->states[18]); + PX4_INFO("states (mag bias) [19-21]: %8.4f, %8.4f, %8.4f", (double)_ekf->states[19], (double)_ekf->states[20], + (double)_ekf->states[21]); } PX4_INFO("states: %s %s %s %s %s %s %s %s %s %s", @@ -1328,25 +1335,33 @@ void AttitudePositionEstimatorEKF::pollData() // leave this in as long as larger improvements are still being made. #if 0 - float deltaTIntegral = (_sensor_combined.gyro_integral_dt) / 1e6f; - float deltaTIntAcc = (_sensor_combined.accelerometer_integral_dt) / 1e6f; + float deltaTIntegral = (_sensor_combined.gyro_integral_dt[0]) / 1e6f; + float deltaTIntAcc = (_sensor_combined.accelerometer_integral_dt[0]) / 1e6f; static unsigned dtoverflow5 = 0; static unsigned dtoverflow10 = 0; static hrt_abstime lastprint = 0; if (hrt_elapsed_time(&lastprint) > 1000000) { - warnx("dt: %8.6f, dtg: %8.6f, dta: %8.6f, dt > 5 ms: %u, dt > 10 ms: %u", + PX4_WARN("dt: %8.6f, dtg: %8.6f, dta: %8.6f, dt > 5 ms: %u, dt > 10 ms: %u", (double)deltaT, (double)deltaTIntegral, (double)deltaTIntAcc, dtoverflow5, dtoverflow10); - warnx("DRV: dang: %8.4f %8.4f dvel: %8.4f %8.4f", + PX4_WARN("EKF: dang: %8.4f %8.4f dvel: %8.4f %8.4f %8.4f", (double)_ekf->dAngIMU.x, (double)_ekf->dAngIMU.z, - (double)_ekf->dVelIMU.x, (double)_ekf->dVelIMU.z); + (double)_ekf->dVelIMU.x, (double)_ekf->dVelIMU.y, (double)_ekf->dVelIMU.z); - warnx("EKF: dang: %8.4f %8.4f dvel: %8.4f %8.4f", + PX4_WARN("INT: dang: %8.4f %8.4f dvel: %8.4f %8.4f %8.4f", + (double)(_sensor_combined.gyro_integral_rad[0]), (double)(_sensor_combined.gyro_integral_rad[2]), + (double)(_sensor_combined.accelerometer_integral_m_s[0]), + (double)(_sensor_combined.accelerometer_integral_m_s[1]), + (double)(_sensor_combined.accelerometer_integral_m_s[2])); + + PX4_WARN("DRV: dang: %8.4f %8.4f dvel: %8.4f %8.4f %8.4f", (double)(_sensor_combined.gyro_rad_s[0] * deltaT), (double)(_sensor_combined.gyro_rad_s[2] * deltaT), - (double)(_sensor_combined.accelerometer_m_s2[0] * deltaT), (double)(_sensor_combined.accelerometer_m_s2[2] * deltaT)); + (double)(_sensor_combined.accelerometer_m_s2[0] * deltaT), + (double)(_sensor_combined.accelerometer_m_s2[1] * deltaT), + (double)((_sensor_combined.accelerometer_m_s2[2] + 9.8665f) * deltaT)); lastprint = hrt_absolute_time(); } @@ -1652,8 +1667,6 @@ int ekf_att_pos_estimator_main(int argc, char *argv[]) } if (!strcmp(argv[1], "status")) { - PX4_INFO("running"); - estimator::g_estimator->print_status(); return 0; diff --git a/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_params.c b/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_params.c index 0d33e28c91..45e2f24939 100644 --- a/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_params.c +++ b/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_params.c @@ -36,13 +36,9 @@ * * Parameters defined by the attitude and position estimator task * - * @author Lorenz Meier + * @author Lorenz Meier */ -#include - -#include - /* * Estimator parameters, accessible via MAVLink * diff --git a/src/modules/ekf_att_pos_estimator/module.mk b/src/modules/ekf_att_pos_estimator/module.mk deleted file mode 100644 index 2a582ebbb8..0000000000 --- a/src/modules/ekf_att_pos_estimator/module.mk +++ /dev/null @@ -1,46 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Main EKF Attitude and Position Estimator -# - -MODULE_COMMAND = ekf_att_pos_estimator - -SRCS = ekf_att_pos_estimator_main.cpp \ - ekf_att_pos_estimator_params.c \ - estimator_22states.cpp \ - estimator_utilities.cpp - -EXTRACXXFLAGS = -Weffc++ -Wframe-larger-than=3400 - diff --git a/src/modules/fixedwing_backside/CMakeLists.txt b/src/modules/fixedwing_backside/CMakeLists.txt new file mode 100644 index 0000000000..c2c8ec649f --- /dev/null +++ b/src/modules/fixedwing_backside/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__fixedwing_backside + MAIN fixedwing_backside + SRCS + fixedwing_backside_main.cpp + fixedwing.cpp + params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/fixedwing_backside/module.mk b/src/modules/fixedwing_backside/module.mk deleted file mode 100644 index 133728781d..0000000000 --- a/src/modules/fixedwing_backside/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Fixedwing backside controller -# - -MODULE_COMMAND = fixedwing_backside - -SRCS = fixedwing_backside_main.cpp \ - fixedwing.cpp \ - params.c diff --git a/src/modules/fw_att_control/CMakeLists.txt b/src/modules/fw_att_control/CMakeLists.txt new file mode 100644 index 0000000000..b093c71cee --- /dev/null +++ b/src/modules/fw_att_control/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__fw_att_control + MAIN fw_att_control + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + fw_att_control_main.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/fw_att_control/fw_att_control_main.cpp b/src/modules/fw_att_control/fw_att_control_main.cpp index d06e9b9a74..a455cdf8b4 100644 --- a/src/modules/fw_att_control/fw_att_control_main.cpp +++ b/src/modules/fw_att_control/fw_att_control_main.cpp @@ -1146,7 +1146,7 @@ FixedwingAttitudeControl::start() _control_task = px4_task_spawn_cmd("fw_att_control", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, - 1600, + 1300, (px4_main_t)&FixedwingAttitudeControl::task_main_trampoline, nullptr); diff --git a/src/modules/fw_att_control/fw_att_control_params.c b/src/modules/fw_att_control/fw_att_control_params.c index 5e640fcc12..51c06fabb9 100644 --- a/src/modules/fw_att_control/fw_att_control_params.c +++ b/src/modules/fw_att_control/fw_att_control_params.c @@ -40,11 +40,6 @@ * @author Thomas Gubler */ -#include - -#include - - /* * Controller parameters, accessible via MAVLink * diff --git a/src/modules/fw_att_control/module.mk b/src/modules/fw_att_control/module.mk deleted file mode 100644 index 3909926990..0000000000 --- a/src/modules/fw_att_control/module.mk +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Fixedwing attitude control application -# - -MODULE_COMMAND = fw_att_control - -SRCS = fw_att_control_main.cpp \ - fw_att_control_params.c - -# Startup handler, the actual app stack size is -# in the task_spawn command -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os diff --git a/src/modules/fw_pos_control_l1/CMakeLists.txt b/src/modules/fw_pos_control_l1/CMakeLists.txt new file mode 100644 index 0000000000..e74b6e4b37 --- /dev/null +++ b/src/modules/fw_pos_control_l1/CMakeLists.txt @@ -0,0 +1,50 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__fw_pos_control_l1 + MAIN fw_pos_control_l1 + STACK 1200 + COMPILE_FLAGS + -Wno-float-equal + -Os + SRCS + fw_pos_control_l1_main.cpp + landingslope.cpp + mtecs/mTecs.cpp + mtecs/limitoverride.cpp + DEPENDS + platforms__common + lib__external_lgpl + lib__ecl + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp index c3816f5374..fa12c5822a 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp @@ -81,6 +81,7 @@ #include #include #include +#include #include #include #include @@ -1965,7 +1966,7 @@ FixedwingPositionControl::start() _control_task = px4_task_spawn_cmd("fw_pos_control_l1", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, - 1600, + 1300, (px4_main_t)&FixedwingPositionControl::task_main_trampoline, nullptr); diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c index e06814d5f3..cfd1988f44 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c @@ -39,9 +39,6 @@ * @author Lorenz Meier */ -#include -#include - /* * Controller parameters, accessible via MAVLink */ diff --git a/src/modules/fw_pos_control_l1/module.mk b/src/modules/fw_pos_control_l1/module.mk deleted file mode 100644 index 8a8de708ee..0000000000 --- a/src/modules/fw_pos_control_l1/module.mk +++ /dev/null @@ -1,53 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Fixedwing L1 position control application -# - -MODULE_COMMAND = fw_pos_control_l1 - -SRCS = fw_pos_control_l1_main.cpp \ - fw_pos_control_l1_params.c \ - landingslope.cpp \ - mtecs/mTecs.cpp \ - mtecs/limitoverride.cpp \ - mtecs/mTecs_params.c - -# Startup handler, the actual app stack size is -# in the task_spawn command -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os - -EXTRACXXFLAGS = -Wno-float-equal diff --git a/src/modules/fw_pos_control_l1/mtecs/mTecs.cpp b/src/modules/fw_pos_control_l1/mtecs/mTecs.cpp index c07956fd6e..49e1d735e0 100644 --- a/src/modules/fw_pos_control_l1/mtecs/mTecs.cpp +++ b/src/modules/fw_pos_control_l1/mtecs/mTecs.cpp @@ -52,15 +52,17 @@ mTecs::mTecs() : _mTecsEnabled(this, "ENABLED"), _airspeedMin(this, "FW_AIRSPD_MIN", false), /* Publications */ +#if defined(__PX4_NUTTX) _status(ORB_ID(tecs_status), &getPublications()), +#endif // defined(__PX4_NUTTX) /* control blocks */ _controlTotalEnergy(this, "THR"), _controlEnergyDistribution(this, "PIT", true), _controlAltitude(this, "FPA", true), _controlAirSpeed(this, "ACC"), - _flightPathAngleLowpass(this, "FPA_LP"), - _altitudeLowpass(this, "ALT_LP"), - _airspeedLowpass(this, "A_LP"), + _flightPathAngleLowpass(this, "FPA_LP", 50), + _altitudeLowpass(this, "ALT_LP", 50), + _airspeedLowpass(this, "A_LP", 50), _airspeedDerivative(this, "AD"), _throttleSp(0.0f), _pitchSp(0.0f), @@ -107,9 +109,11 @@ int mTecs::updateAltitudeSpeed(float flightPathAngle, float altitude, float alti debug("updateAltitudeSpeed: altitudeSp %.4f, altitude %.4f, altitude filtered %.4f, flightPathAngleSp %.4f", (double)altitudeSp, (double)altitude, (double)altitudeFiltered, (double)flightPathAngleSp); } +#if defined(__PX4_NUTTX) /* Write part of the status message */ _status.altitudeSp = altitudeSp; _status.altitude_filtered = altitudeFiltered; +#endif // defined(__PX4_NUTTX) /* use flightpath angle setpoint for total energy control */ @@ -143,9 +147,11 @@ int mTecs::updateFlightPathAngleSpeed(float flightPathAngle, float flightPathAng (double)airspeedFiltered, (double)accelerationLongitudinalSp); } +#if defined(__PX4_NUTTX) /* Write part of the status message */ _status.airspeedSp = airspeedSp; _status.airspeed_filtered = airspeedFiltered; +#endif // defined(__PX4_NUTTX) /* use longitudinal acceleration setpoint for total energy control */ @@ -200,23 +206,23 @@ int mTecs::updateFlightPathAngleAcceleration(float flightPathAngle, float flight } /* Check airspeed: if below safe value switch to underspeed mode (if not in land or takeoff mode) */ - if (mode != tecs_status_s::TECS_MODE_LAND && mode != tecs_status_s::TECS_MODE_TAKEOFF && airspeedFiltered < _airspeedMin.get()) { - mode = tecs_status_s::TECS_MODE_UNDERSPEED; + if (mode != MTECS_MODE_LAND && mode != MTECS_MODE_TAKEOFF && airspeedFiltered < _airspeedMin.get()) { + mode = MTECS_MODE_UNDERSPEED; } - /* Set special output limiters if we are not in TECS_MODE_NORMAL */ + /* Set special output limiters if we are not in MTECS_MODE_NORMAL */ BlockOutputLimiter *outputLimiterThrottle = &_controlTotalEnergy.getOutputLimiter(); BlockOutputLimiter *outputLimiterPitch = &_controlEnergyDistribution.getOutputLimiter(); - if (mode == tecs_status_s::TECS_MODE_TAKEOFF) { + if (mode == MTECS_MODE_TAKEOFF) { outputLimiterThrottle = &_BlockOutputLimiterTakeoffThrottle; outputLimiterPitch = &_BlockOutputLimiterTakeoffPitch; - } else if (mode == tecs_status_s::TECS_MODE_LAND) { + } else if (mode == MTECS_MODE_LAND) { // only limit pitch but do not limit throttle outputLimiterPitch = &_BlockOutputLimiterLandPitch; - } else if (mode == tecs_status_s::TECS_MODE_LAND_THROTTLELIM) { + } else if (mode == MTECS_MODE_LAND_THROTTLELIM) { outputLimiterThrottle = &_BlockOutputLimiterLandThrottle; outputLimiterPitch = &_BlockOutputLimiterLandPitch; - } else if (mode == tecs_status_s::TECS_MODE_UNDERSPEED) { + } else if (mode == MTECS_MODE_UNDERSPEED) { outputLimiterThrottle = &_BlockOutputLimiterUnderspeedThrottle; outputLimiterPitch = &_BlockOutputLimiterUnderspeedPitch; } @@ -226,6 +232,7 @@ int mTecs::updateFlightPathAngleAcceleration(float flightPathAngle, float flight * is running) */ limitOverride.applyOverride(*outputLimiterThrottle, *outputLimiterPitch); +// #if defined(__PX4_NUTTX) // /* Write part of the status message */ // _status.flightPathAngleSp = flightPathAngleSp; // _status.flightPathAngle = flightPathAngle; @@ -237,6 +244,7 @@ int mTecs::updateFlightPathAngleAcceleration(float flightPathAngle, float flight // _status.energyDistributionRateSp = energyDistributionRateSp; // _status.energyDistributionRate = energyDistributionRate; // _status.mode = mode; +// #endif // defined(__PX4_NUTTX) /** update control blocks **/ /* update total energy rate control block */ @@ -253,8 +261,10 @@ int mTecs::updateFlightPathAngleAcceleration(float flightPathAngle, float flight (double)accelerationLongitudinalSp, (double)airspeedDerivative); } +#if defined(__PX4_NUTTX) /* publish status message */ _status.update(); +#endif // defined(__PX4_NUTTX) /* clean up */ _firstIterationAfterReset = false; diff --git a/src/modules/fw_pos_control_l1/mtecs/mTecs.h b/src/modules/fw_pos_control_l1/mtecs/mTecs.h index e114cc3ae0..09d9eec1d5 100644 --- a/src/modules/fw_pos_control_l1/mtecs/mTecs.h +++ b/src/modules/fw_pos_control_l1/mtecs/mTecs.h @@ -49,11 +49,25 @@ #include #include #include + +#if defined(__PX4_NUTTX) #include +#endif // defined(__PX4_NUTTX) namespace fwPosctrl { +/* corresponds to TECS_MODE in tecs_status.msg */ +enum MTECS_MODE { + MTECS_MODE_NORMAL = 0, + MTECS_MODE_UNDERSPEED = 1, + MTECS_MODE_TAKEOFF = 2, + MTECS_MODE_LAND = 3, + MTECS_MODE_LAND_THROTTLELIM = 4, + MTECS_MODE_BAD_DESCENT = 5, + MTECS_MODE_CLIMBOUT = 6 +}; + /* Main class of the mTecs */ class mTecs : public control::SuperBlock { @@ -94,6 +108,10 @@ public: float getThrottleSetpoint() { return _throttleSp; } float getPitchSetpoint() { return _pitchSp; } float airspeedLowpassUpdate(float input) { return _airspeedLowpass.update(input); } + float getFlightPathAngleLowpassState() { return _flightPathAngleLowpass.getState(); } + float getAltitudeLowpassState() { return _altitudeLowpass.getState(); } + float getAirspeedLowpassState() { return _airspeedLowpass.getState(); } + float getAirspeedDerivativeLowpassState() { return _airspeedDerivative.getO(); } protected: /* parameters */ @@ -101,7 +119,9 @@ protected: control::BlockParamFloat _airspeedMin; /**< minimal airspeed */ /* Publications */ +#if defined(__PX4_NUTTX) uORB::Publication _status; /**< publish internal values for logging */ +#endif // defined(__PX4_NUTTX) /* control blocks */ BlockFFPILimitedCustom _controlTotalEnergy; /**< FFPI controller for total energy control: output @@ -114,9 +134,9 @@ protected: setpoint */ /* Other calculation Blocks */ - control::BlockLowPass _flightPathAngleLowpass; /**< low pass filter for the flight path angle */ - control::BlockLowPass _altitudeLowpass; /**< low pass filter for altitude */ - control::BlockLowPass _airspeedLowpass; /**< low pass filter for airspeed */ + control::BlockLowPass2 _flightPathAngleLowpass; /**< low pass filter for the flight path angle */ + control::BlockLowPass2 _altitudeLowpass; /**< low pass filter for altitude */ + control::BlockLowPass2 _airspeedLowpass; /**< low pass filter for airspeed */ control::BlockDerivative _airspeedDerivative; /**< airspeed derivative calulation */ /* Output setpoints */ diff --git a/src/modules/fw_pos_control_l1/mtecs/mTecs_params.c b/src/modules/fw_pos_control_l1/mtecs/mTecs_params.c index 3b98454b95..0d1025f7d4 100644 --- a/src/modules/fw_pos_control_l1/mtecs/mTecs_params.c +++ b/src/modules/fw_pos_control_l1/mtecs/mTecs_params.c @@ -39,9 +39,6 @@ * @author Thomas Gubler */ -#include -#include - /* * Controller parameters, accessible via MAVLink */ diff --git a/src/modules/gpio_led/CMakeLists.txt b/src/modules/gpio_led/CMakeLists.txt new file mode 100644 index 0000000000..435d8e986a --- /dev/null +++ b/src/modules/gpio_led/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__gpio_led + MAIN gpio_led + COMPILE_FLAGS + -Os + SRCS + gpio_led.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/gpio_led/module.mk b/src/modules/gpio_led/module.mk deleted file mode 100644 index 70c75b10cb..0000000000 --- a/src/modules/gpio_led/module.mk +++ /dev/null @@ -1,41 +0,0 @@ -############################################################################ -# -# Copyright (C) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Status LED via GPIO driver -# - -MODULE_COMMAND = gpio_led -SRCS = gpio_led.c - -MAXOPTIMIZATION = -Os diff --git a/src/modules/land_detector/CMakeLists.txt b/src/modules/land_detector/CMakeLists.txt new file mode 100644 index 0000000000..3882f246c2 --- /dev/null +++ b/src/modules/land_detector/CMakeLists.txt @@ -0,0 +1,47 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__land_detector + MAIN land_detector + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + land_detector_main.cpp + LandDetector.cpp + MulticopterLandDetector.cpp + FixedwingLandDetector.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/land_detector/FixedwingLandDetector.cpp b/src/modules/land_detector/FixedwingLandDetector.cpp index dac5e6a3f9..7cfe65bb7f 100644 --- a/src/modules/land_detector/FixedwingLandDetector.cpp +++ b/src/modules/land_detector/FixedwingLandDetector.cpp @@ -40,6 +40,8 @@ #include "FixedwingLandDetector.h" +#include +#include #include #include diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index 7f719d4cef..ae6a1b5037 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -42,65 +42,77 @@ #include "LandDetector.h" #include //usleep #include +#include +#include LandDetector::LandDetector() : _landDetectedPub(0), _landDetected({0, false}), _arming_time(0), _taskShouldExit(false), - _taskIsRunning(false) + _taskIsRunning(false), + _work{} { // ctor } LandDetector::~LandDetector() { + work_cancel(LPWORK, &_work); _taskShouldExit = true; } +int LandDetector::start() +{ + /* schedule a cycle to start things */ + work_queue(LPWORK, &_work, (worker_t)&LandDetector::cycle_trampoline, this, 0); + + return 0; +} + void LandDetector::shutdown() { _taskShouldExit = true; } -void LandDetector::start() +void +LandDetector::cycle_trampoline(void *arg) { - // make sure this method has not already been called by another thread - if (isRunning()) { - return; + LandDetector *dev = reinterpret_cast(arg); + + dev->cycle(); +} + +void LandDetector::cycle() +{ + if (!_taskIsRunning) { + // advertise the first land detected uORB + _landDetected.timestamp = hrt_absolute_time(); + _landDetected.landed = false; + _landDetectedPub = orb_advertise(ORB_ID(vehicle_land_detected), &_landDetected); + + // initialize land detection algorithm + initialize(); + + // task is now running, keep doing so until shutdown() has been called + _taskIsRunning = true; + _taskShouldExit = false; } - // advertise the first land detected uORB - _landDetected.timestamp = hrt_absolute_time(); - _landDetected.landed = false; - _landDetectedPub = (uintptr_t)orb_advertise(ORB_ID(vehicle_land_detected), &_landDetected); + bool landDetected = update(); - // initialize land detection algorithm - initialize(); + // publish if land detection state has changed + if (_landDetected.landed != landDetected) { + _landDetected.timestamp = hrt_absolute_time(); + _landDetected.landed = landDetected; - // task is now running, keep doing so until shutdown() has been called - _taskIsRunning = true; - _taskShouldExit = false; - - while (isRunning()) { - - bool landDetected = update(); - - // publish if land detection state has changed - if (_landDetected.landed != landDetected) { - _landDetected.timestamp = hrt_absolute_time(); - _landDetected.landed = landDetected; - - // publish the land detected broadcast - orb_publish(ORB_ID(vehicle_land_detected), (orb_advert_t)_landDetectedPub, &_landDetected); - } - - // limit loop rate - usleep(1000000 / LAND_DETECTOR_UPDATE_RATE); + // publish the land detected broadcast + orb_publish(ORB_ID(vehicle_land_detected), (orb_advert_t)_landDetectedPub, &_landDetected); } - _taskIsRunning = false; - _exit(0); + if (!_taskShouldExit) { + work_queue(LPWORK, &_work, (worker_t)&LandDetector::cycle_trampoline, this, USEC2TICK(1000000 / LAND_DETECTOR_UPDATE_RATE)); + } } bool LandDetector::orb_update(const struct orb_metadata *meta, int handle, void *buffer) diff --git a/src/modules/land_detector/LandDetector.h b/src/modules/land_detector/LandDetector.h index 2ade4ac8c0..d28863b499 100644 --- a/src/modules/land_detector/LandDetector.h +++ b/src/modules/land_detector/LandDetector.h @@ -41,6 +41,7 @@ #ifndef __LAND_DETECTOR_H__ #define __LAND_DETECTOR_H__ +#include #include #include @@ -70,7 +71,9 @@ public: * @brief Blocking function that should be called from it's own task thread. This method will * run the underlying algorithm at the desired update rate and publish if the landing state changes. **/ - void start(); + int start(); + + static void cycle_trampoline(void *arg); protected: @@ -99,13 +102,16 @@ protected: static constexpr uint64_t LAND_DETECTOR_ARM_PHASE_TIME = 1000000; /**< time interval in which wider acceptance thresholds are used after arming */ protected: - uintptr_t _landDetectedPub; /**< publisher for position in local frame */ + orb_advert_t _landDetectedPub; /**< publisher for position in local frame */ struct vehicle_land_detected_s _landDetected; /**< local vehicle position */ uint64_t _arming_time; /**< timestamp of arming time */ private: bool _taskShouldExit; /**< true if it is requested that this task should exit */ bool _taskIsRunning; /**< task has reached main loop and is currently running */ + struct work_s _work; + + void cycle(); }; #endif //__LAND_DETECTOR_H__ diff --git a/src/modules/land_detector/land_detector_main.cpp b/src/modules/land_detector/land_detector_main.cpp index 34355c6b11..c4d0e5194d 100644 --- a/src/modules/land_detector/land_detector_main.cpp +++ b/src/modules/land_detector/land_detector_main.cpp @@ -67,47 +67,32 @@ extern "C" __EXPORT int land_detector_main(int argc, char *argv[]); //Private variables static LandDetector *land_detector_task = nullptr; -static int _landDetectorTaskID = -1; static char _currentMode[12]; -/** -* Deamon thread function -**/ -static void land_detector_deamon_thread(int argc, char *argv[]) -{ - land_detector_task->start(); -} - /** * Stop the task, force killing it if it doesn't stop by itself **/ static void land_detector_stop() { - if (land_detector_task == nullptr || _landDetectorTaskID == -1) { + if (land_detector_task == nullptr) { warnx("not running"); return; } land_detector_task->shutdown(); - //Wait for task to die + // Wait for task to die int i = 0; do { /* wait 20ms */ usleep(20000); - /* if we have given up, kill it */ - if (++i > 50) { - px4_task_delete(_landDetectorTaskID); - break; - } - } while (land_detector_task->isRunning()); + } while (land_detector_task->isRunning() && ++i < 50); delete land_detector_task; land_detector_task = nullptr; - _landDetectorTaskID = -1; warnx("land_detector has been stopped"); } @@ -116,7 +101,7 @@ static void land_detector_stop() **/ static int land_detector_start(const char *mode) { - if (land_detector_task != nullptr || _landDetectorTaskID != -1) { + if (land_detector_task != nullptr) { warnx("already running"); return -1; } @@ -140,14 +125,9 @@ static int land_detector_start(const char *mode) } //Start new thread task - _landDetectorTaskID = px4_task_spawn_cmd("land_detector", - SCHED_DEFAULT, - SCHED_PRIORITY_DEFAULT, - 1000, - (px4_main_t)&land_detector_deamon_thread, - nullptr); + int ret = land_detector_task->start(); - if (_landDetectorTaskID < 0) { + if (ret) { warnx("task start failed: %d", -errno); return -1; } diff --git a/src/modules/land_detector/land_detector_params.c b/src/modules/land_detector/land_detector_params.c index 57e616169b..d9201eb18a 100644 --- a/src/modules/land_detector/land_detector_params.c +++ b/src/modules/land_detector/land_detector_params.c @@ -38,8 +38,6 @@ * @author Johan Jansen */ -#include - /** * Multicopter max climb rate * diff --git a/src/modules/land_detector/module.mk b/src/modules/land_detector/module.mk deleted file mode 100644 index 4eb7a1cb54..0000000000 --- a/src/modules/land_detector/module.mk +++ /dev/null @@ -1,17 +0,0 @@ -# -# Land detector -# - -MODULE_COMMAND = land_detector - -SRCS = land_detector_main.cpp \ - land_detector_params.c \ - LandDetector.cpp \ - MulticopterLandDetector.cpp \ - FixedwingLandDetector.cpp - -EXTRACXXFLAGS = -Weffc++ -Os - -# Startup handler, the actual app stack size is -# in the task_spawn command -MODULE_STACKSIZE = 1200 diff --git a/src/modules/mavlink/CMakeLists.txt b/src/modules/mavlink/CMakeLists.txt new file mode 100644 index 0000000000..a863328f03 --- /dev/null +++ b/src/modules/mavlink/CMakeLists.txt @@ -0,0 +1,63 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +if (${OS} STREQUAL "nuttx") + list(APPEND MODULE_CFLAGS -Wframe-larger-than=1500) +endif() +px4_add_module( + MODULE modules__mavlink + MAIN mavlink + STACK 1200 + COMPILE_FLAGS + ${MODULE_CFLAGS} + -Wno-attributes + -Wno-packed + -DMAVLINK_COMM_NUM_BUFFERS=3 + -Wno-packed + -Wno-tautological-constant-out-of-range-compare + -Os + SRCS + mavlink.c + mavlink_main.cpp + mavlink_mission.cpp + mavlink_parameters.cpp + mavlink_orb_subscription.cpp + mavlink_messages.cpp + mavlink_stream.cpp + mavlink_rate_limiter.cpp + mavlink_receiver.cpp + mavlink_ftp.cpp + mavlink_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/mavlink/mavlink.c b/src/modules/mavlink/mavlink.c index 0c2d56173a..1073d09c20 100644 --- a/src/modules/mavlink/mavlink.c +++ b/src/modules/mavlink/mavlink.c @@ -46,75 +46,6 @@ #include "mavlink_bridge_header.h" #include -/** - * MAVLink system ID - * @group MAVLink - * @min 1 - * @max 250 - */ -PARAM_DEFINE_INT32(MAV_SYS_ID, 1); - -/** - * MAVLink component ID - * @group MAVLink - * @min 1 - * @max 250 - */ -PARAM_DEFINE_INT32(MAV_COMP_ID, 1); - -/** - * MAVLink Radio ID - * - * When non-zero the MAVLink app will attempt to configure the - * radio to this ID and re-set the parameter to 0. If the value - * is negative it will reset the complete radio config to - * factory defaults. - * - * @group MAVLink - * @min -1 - * @max 240 - */ -PARAM_DEFINE_INT32(MAV_RADIO_ID, 0); - -/** - * MAVLink airframe type - * - * @min 1 - * @group MAVLink - */ -PARAM_DEFINE_INT32(MAV_TYPE, 1); - -/** - * Use/Accept HIL GPS message even if not in HIL mode - * - * If set to 1 incoming HIL GPS messages are parsed. - * - * @group MAVLink - */ -PARAM_DEFINE_INT32(MAV_USEHILGPS, 0); - -/** - * Forward external setpoint messages - * - * If set to 1 incoming external setpoint messages will be directly forwarded - * to the controllers if in offboard control mode - * - * @group MAVLink - */ -PARAM_DEFINE_INT32(MAV_FWDEXTSP, 1); - -/** - * Test parameter - * - * This parameter is not actively used by the system. Its purpose is to allow - * testing the parameter interface on the communication level. - * - * @group MAVLink - * @min -1000 - * @max 1000 - */ -PARAM_DEFINE_INT32(MAV_TEST_PAR, 1); - mavlink_system_t mavlink_system = { 100, 50 diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index 90729fb138..297a76239b 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -178,6 +178,11 @@ Mavlink::Mavlink() : _rate_tx(0.0f), _rate_txerr(0.0f), _rate_rx(0.0f), +#ifdef __PX4_POSIX + _myaddr{}, + _src_addr{}, + _bcast_addr{}, +#endif _socket_fd(-1), _protocol(SERIAL), _network_port(14556), @@ -695,7 +700,7 @@ int Mavlink::mavlink_open_uart(int baud, const char *uart_name, struct termios * _is_usb_uart = true; } -#ifdef __PX4_LINUX +#if defined (__PX4_LINUX) || defined (__PX4_DARWIN) /* Put in raw mode */ cfmakeraw(&uart_config); #endif @@ -796,7 +801,7 @@ Mavlink::get_free_tx_buf() #ifndef __PX4_POSIX // No FIONWRITE on Linux -#if !defined(__PX4_LINUX) +#if !defined(__PX4_LINUX) && !defined(__PX4_DARWIN) (void) ioctl(_uart_fd, FIONWRITE, (unsigned long)&buf_free); #endif @@ -883,8 +888,23 @@ Mavlink::send_message(const uint8_t msgid, const void *msg, uint8_t component_ID #else if (get_protocol() == UDP) { ret = sendto(_socket_fd, buf, packet_len, 0, (struct sockaddr *)&_src_addr, sizeof(_src_addr)); + + struct telemetry_status_s &tstatus = get_rx_status(); + + /* resend heartbeat via broadcast */ + if (((hrt_elapsed_time(&tstatus.heartbeat_time) > 3 * 1000 * 1000) || + (tstatus.heartbeat_time == 0)) && + msgid == MAVLINK_MSG_ID_HEARTBEAT) { + + int bret = sendto(_socket_fd, buf, packet_len, 0, (struct sockaddr *)&_bcast_addr, sizeof(_bcast_addr)); + + if (bret <= 0) { + PX4_WARN("sending broadcast failed"); + } + } + } else if (get_protocol() == TCP) { - // not implemented, but possible to do so + /* not implemented, but possible to do so */ warnx("TCP transport pending implementation"); } #endif @@ -957,8 +977,8 @@ Mavlink::resend_message(mavlink_message_t *msg) void Mavlink::init_udp() { -#ifdef __PX4_LINUX - PX4_INFO("Setting up UDP w/port %d\n",_network_port); +#if defined (__PX4_LINUX) || defined (__PX4_DARWIN) + PX4_INFO("Setting up UDP w/port %d",_network_port); memset((char *)&_myaddr, 0, sizeof(_myaddr)); _myaddr.sin_family = AF_INET; @@ -966,21 +986,33 @@ Mavlink::init_udp() _myaddr.sin_port = htons(_network_port); if ((_socket_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - PX4_WARN("create socket failed\n"); + PX4_WARN("create socket failed"); + return; + } + + int broadcast_opt = 1; + if (setsockopt(_socket_fd, SOL_SOCKET, SO_BROADCAST, &broadcast_opt, sizeof(broadcast_opt)) < 0) { + PX4_WARN("setting broadcast permission failed"); return; } if (bind(_socket_fd, (struct sockaddr *)&_myaddr, sizeof(_myaddr)) < 0) { - PX4_WARN("bind failed\n"); + PX4_WARN("bind failed"); return; } - // set default target address + /* set default target address */ memset((char *)&_src_addr, 0, sizeof(_src_addr)); _src_addr.sin_family = AF_INET; inet_aton("127.0.0.1", &_src_addr.sin_addr); _src_addr.sin_port = htons(DEFAULT_REMOTE_PORT_UDP); + /* default broadcast address */ + memset((char *)&_bcast_addr, 0, sizeof(_bcast_addr)); + _bcast_addr.sin_family = AF_INET; + inet_aton("255.255.255.255", &_bcast_addr.sin_addr); + _bcast_addr.sin_port = htons(DEFAULT_REMOTE_PORT_UDP); + #endif } @@ -1637,20 +1669,21 @@ Mavlink::task_main(int argc, char *argv[]) switch (_mode) { case MAVLINK_MODE_NORMAL: configure_stream("SYS_STATUS", 1.0f); - configure_stream("GPS_GLOBAL_ORIGIN", 0.5f); + configure_stream("HOME_POSITION", 0.5f); configure_stream("HIGHRES_IMU", 2.0f); configure_stream("ATTITUDE", 20.0f); configure_stream("VFR_HUD", 8.0f); configure_stream("GPS_RAW_INT", 1.0f); configure_stream("GLOBAL_POSITION_INT", 3.0f); configure_stream("LOCAL_POSITION_NED", 3.0f); + configure_stream("NAMED_VALUE_FLOAT", 2.0f); configure_stream("RC_CHANNELS", 1.0f); configure_stream("SERVO_OUTPUT_RAW_0", 1.0f); configure_stream("POSITION_TARGET_GLOBAL_INT", 3.0f); configure_stream("ATTITUDE_TARGET", 8.0f); configure_stream("DISTANCE_SENSOR", 0.5f); configure_stream("OPTICAL_FLOW_RAD", 5.0f); - configure_stream("VTOL_STATE", 0.5f); + configure_stream("EXTENDED_SYS_STATE", 1.0f); break; case MAVLINK_MODE_ONBOARD: @@ -1660,7 +1693,9 @@ Mavlink::task_main(int argc, char *argv[]) configure_stream("GPS_RAW_INT", 5.0f); configure_stream("GLOBAL_POSITION_INT", 50.0f); configure_stream("LOCAL_POSITION_NED", 30.0f); + configure_stream("NAMED_VALUE_FLOAT", 10.0f); configure_stream("CAMERA_CAPTURE", 2.0f); + configure_stream("HOME_POSITION", 0.5f); configure_stream("ATTITUDE_TARGET", 10.0f); configure_stream("POSITION_TARGET_GLOBAL_INT", 10.0f); configure_stream("POSITION_TARGET_LOCAL_NED", 10.0f); @@ -1674,7 +1709,7 @@ Mavlink::task_main(int argc, char *argv[]) configure_stream("ACTUATOR_CONTROL_TARGET0", 10.0f); /* camera trigger is rate limited at the source, do not limit here */ configure_stream("CAMERA_TRIGGER", 500.0f); - configure_stream("VTOL_STATE", 2.0f); + configure_stream("EXTENDED_SYS_STATE", 2.0f); break; case MAVLINK_MODE_OSD: @@ -1683,19 +1718,24 @@ Mavlink::task_main(int argc, char *argv[]) configure_stream("VFR_HUD", 5.0f); configure_stream("GPS_RAW_INT", 1.0f); configure_stream("GLOBAL_POSITION_INT", 10.0f); + configure_stream("HOME_POSITION", 0.5f); configure_stream("ATTITUDE_TARGET", 10.0f); configure_stream("BATTERY_STATUS", 1.0f); configure_stream("SYSTEM_TIME", 1.0f); configure_stream("RC_CHANNELS", 5.0f); configure_stream("SERVO_OUTPUT_RAW_0", 1.0f); - configure_stream("VTOL_STATE", 0.5f); + configure_stream("EXTENDED_SYS_STATE", 1.0f); break; case MAVLINK_MODE_CONFIG: // Enable a number of interesting streams we want via USB + configure_stream("SYS_STATUS", 1.0f); + configure_stream("HOME_POSITION", 0.5f); + configure_stream("GLOBAL_POSITION_INT", 10.0f); + configure_stream("ATTITUDE_TARGET", 8.0f); configure_stream("PARAM_VALUE", 300.0f); configure_stream("MISSION_ITEM", 50.0f); - configure_stream("NAMED_VALUE_FLOAT", 10.0f); + configure_stream("NAMED_VALUE_FLOAT", 50.0f); configure_stream("OPTICAL_FLOW_RAD", 10.0f); configure_stream("DISTANCE_SENSOR", 10.0f); configure_stream("VFR_HUD", 20.0f); @@ -1707,10 +1747,10 @@ Mavlink::task_main(int argc, char *argv[]) configure_stream("POSITION_TARGET_GLOBAL_INT", 10.0f); configure_stream("LOCAL_POSITION_NED", 30.0f); configure_stream("MANUAL_CONTROL", 5.0f); - configure_stream("HIGHRES_IMU", 100.0f); + configure_stream("HIGHRES_IMU", 50.0f); configure_stream("GPS_RAW_INT", 20.0f); configure_stream("CAMERA_TRIGGER", 500.0f); - configure_stream("VTOL_STATE", 2.0f); + configure_stream("EXTENDED_SYS_STATE", 2.0f); default: break; diff --git a/src/modules/mavlink/mavlink_main.h b/src/modules/mavlink/mavlink_main.h index 4d28b1c6e5..ef14562ccc 100644 --- a/src/modules/mavlink/mavlink_main.h +++ b/src/modules/mavlink/mavlink_main.h @@ -417,6 +417,7 @@ private: #ifdef __PX4_POSIX struct sockaddr_in _myaddr; struct sockaddr_in _src_addr; + struct sockaddr_in _bcast_addr; #endif int _socket_fd; diff --git a/src/modules/mavlink/mavlink_messages.cpp b/src/modules/mavlink/mavlink_messages.cpp index 2068147fe7..fed42bef2b 100644 --- a/src/modules/mavlink/mavlink_messages.cpp +++ b/src/modules/mavlink/mavlink_messages.cpp @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include @@ -555,7 +556,7 @@ protected: msg.errors_count2 = status.errors_count2; msg.errors_count3 = status.errors_count3; msg.errors_count4 = status.errors_count4; - msg.battery_remaining = (msg.voltage_battery > 0) ? + msg.battery_remaining = (status.condition_battery_voltage_valid) ? status.battery_remaining * 100.0f : -1; _mavlink->send_message(MAVLINK_MSG_ID_SYS_STATUS, &msg); @@ -570,14 +571,22 @@ protected: if (i < status.battery_cell_count) { bat_msg.voltages[i] = (status.battery_voltage / status.battery_cell_count) * 1000.0f; } else { - bat_msg.voltages[i] = 0; + bat_msg.voltages[i] = UINT16_MAX; } } - bat_msg.current_battery = status.battery_current * 100.0f; - bat_msg.current_consumed = status.battery_discharged_mah; + + if (status.condition_battery_voltage_valid) { + bat_msg.current_battery = (bat_msg.current_battery >= 0.0f) ? + status.battery_current * 100.0f : -1; + bat_msg.current_consumed = (bat_msg.current_consumed >= 0.0f) ? + status.battery_discharged_mah : -1; + bat_msg.battery_remaining = status.battery_remaining * 100.0f; + } else { + bat_msg.current_battery = -1.0f; + bat_msg.current_consumed = -1.0f; + bat_msg.battery_remaining = -1.0f; + } bat_msg.energy_consumed = -1.0f; - bat_msg.battery_remaining = (status.battery_voltage > 0) ? - status.battery_remaining * 100.0f : -1; _mavlink->send_message(MAVLINK_MSG_ID_BATTERY_STATUS, &bat_msg); } @@ -1326,43 +1335,43 @@ protected: }; -class MavlinkStreamGPSGlobalOrigin : public MavlinkStream +class MavlinkStreamHomePosition : public MavlinkStream { public: const char *get_name() const { - return MavlinkStreamGPSGlobalOrigin::get_name_static(); + return MavlinkStreamHomePosition::get_name_static(); } static const char *get_name_static() { - return "GPS_GLOBAL_ORIGIN"; + return "HOME_POSITION"; } uint8_t get_id() { - return MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN; + return MAVLINK_MSG_ID_HOME_POSITION; } static MavlinkStream *new_instance(Mavlink *mavlink) { - return new MavlinkStreamGPSGlobalOrigin(mavlink); + return new MavlinkStreamHomePosition(mavlink); } unsigned get_size() { - return _home_sub->is_published() ? (MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES) : 0; + return _home_sub->is_published() ? (MAVLINK_MSG_ID_HOME_POSITION_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES) : 0; } private: MavlinkOrbSubscription *_home_sub; /* do not allow top copying this class */ - MavlinkStreamGPSGlobalOrigin(MavlinkStreamGPSGlobalOrigin &); - MavlinkStreamGPSGlobalOrigin& operator = (const MavlinkStreamGPSGlobalOrigin &); + MavlinkStreamHomePosition(MavlinkStreamHomePosition &); + MavlinkStreamHomePosition& operator = (const MavlinkStreamHomePosition &); protected: - explicit MavlinkStreamGPSGlobalOrigin(Mavlink *mavlink) : MavlinkStream(mavlink), + explicit MavlinkStreamHomePosition(Mavlink *mavlink) : MavlinkStream(mavlink), _home_sub(_mavlink->add_orb_subscription(ORB_ID(home_position))) {} @@ -1374,13 +1383,26 @@ protected: struct home_position_s home; if (_home_sub->update(&home)) { - mavlink_gps_global_origin_t msg; + mavlink_home_position_t msg; msg.latitude = home.lat * 1e7; msg.longitude = home.lon * 1e7; msg.altitude = home.alt * 1e3f; - _mavlink->send_message(MAVLINK_MSG_ID_GPS_GLOBAL_ORIGIN, &msg); + msg.x = home.x; + msg.y = home.y; + msg.z = home.z; + + msg.q[0] = 1.0f; + msg.q[1] = 0.0f; + msg.q[2] = 0.0f; + msg.q[3] = 0.0f; + + msg.approach_x = 0.0f; + msg.approach_y = 0.0f; + msg.approach_z = 0.0f; + + _mavlink->send_message(MAVLINK_MSG_ID_HOME_POSITION, &msg); } } } @@ -2348,76 +2370,96 @@ protected: } }; -class MavlinkStreamVtolState : public MavlinkStream +class MavlinkStreamExtendedSysState : public MavlinkStream { public: const char *get_name() const { - return MavlinkStreamVtolState::get_name_static(); + return MavlinkStreamExtendedSysState::get_name_static(); } static const char *get_name_static() { - return "VTOL_STATE"; + return "EXTENDED_SYS_STATE"; } uint8_t get_id() { - return MAVLINK_MSG_ID_VTOL_STATE; + return MAVLINK_MSG_ID_EXTENDED_SYS_STATE; } static MavlinkStream *new_instance(Mavlink *mavlink) { - return new MavlinkStreamVtolState(mavlink); + return new MavlinkStreamExtendedSysState(mavlink); } unsigned get_size() { - return MAVLINK_MSG_ID_VTOL_STATE_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES; + return MAVLINK_MSG_ID_EXTENDED_SYS_STATE_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES; } private: MavlinkOrbSubscription *_status_sub; + MavlinkOrbSubscription *_landed_sub; + mavlink_extended_sys_state_t _msg; /* do not allow top copying this class */ - MavlinkStreamVtolState(MavlinkStreamVtolState &); - MavlinkStreamVtolState &operator = (const MavlinkStreamVtolState &); + MavlinkStreamExtendedSysState(MavlinkStreamExtendedSysState &); + MavlinkStreamExtendedSysState &operator = (const MavlinkStreamExtendedSysState &); protected: - explicit MavlinkStreamVtolState(Mavlink *mavlink) : MavlinkStream(mavlink), - _status_sub(_mavlink->add_orb_subscription(ORB_ID(vehicle_status))) - {} + explicit MavlinkStreamExtendedSysState(Mavlink *mavlink) : MavlinkStream(mavlink), + _status_sub(_mavlink->add_orb_subscription(ORB_ID(vehicle_status))), + _landed_sub(_mavlink->add_orb_subscription(ORB_ID(vehicle_land_detected))), + _msg{} + { + + _msg.vtol_state = MAV_VTOL_STATE_UNDEFINED; + _msg.landed_state = MAV_LANDED_STATE_UNDEFINED; + } void send(const hrt_abstime t) { struct vehicle_status_s status; + struct vehicle_land_detected_s land_detected; + bool updated = false; if (_status_sub->update(&status)) { - mavlink_vtol_state_t msg; + updated = true; if (status.is_vtol) { if (status.is_rotary_wing) { if (status.in_transition_mode) { - msg.state = MAV_VTOL_STATE_TRANSITION_TO_FW; + _msg.vtol_state = MAV_VTOL_STATE_TRANSITION_TO_FW; } else { - msg.state = MAV_VTOL_STATE_MC; + _msg.vtol_state = MAV_VTOL_STATE_MC; } } else { if (status.in_transition_mode) { - msg.state = MAV_VTOL_STATE_TRANSITION_TO_MC; + _msg.vtol_state = MAV_VTOL_STATE_TRANSITION_TO_MC; } else { - msg.state = MAV_VTOL_STATE_FW; + _msg.vtol_state = MAV_VTOL_STATE_FW; } } - - } else { - msg.state = MAV_VTOL_STATE_UNDEFINED; } + } - _mavlink->send_message(MAVLINK_MSG_ID_VTOL_STATE, &msg); + if (_landed_sub->update(&land_detected)) { + updated = true; + + if (land_detected.landed) { + _msg.landed_state = MAV_LANDED_STATE_ON_GROUND; + + } else { + _msg.landed_state = MAV_LANDED_STATE_IN_AIR; + } + } + + if (updated) { + _mavlink->send_message(MAVLINK_MSG_ID_EXTENDED_SYS_STATE, &_msg); } } }; @@ -2437,7 +2479,7 @@ const StreamListItem *streams_list[] = { new StreamListItem(&MavlinkStreamGlobalPositionInt::new_instance, &MavlinkStreamGlobalPositionInt::get_name_static), new StreamListItem(&MavlinkStreamLocalPositionNED::new_instance, &MavlinkStreamLocalPositionNED::get_name_static), new StreamListItem(&MavlinkStreamAttPosMocap::new_instance, &MavlinkStreamAttPosMocap::get_name_static), - new StreamListItem(&MavlinkStreamGPSGlobalOrigin::new_instance, &MavlinkStreamGPSGlobalOrigin::get_name_static), + new StreamListItem(&MavlinkStreamHomePosition::new_instance, &MavlinkStreamHomePosition::get_name_static), new StreamListItem(&MavlinkStreamServoOutputRaw<0>::new_instance, &MavlinkStreamServoOutputRaw<0>::get_name_static), new StreamListItem(&MavlinkStreamServoOutputRaw<1>::new_instance, &MavlinkStreamServoOutputRaw<1>::get_name_static), new StreamListItem(&MavlinkStreamServoOutputRaw<2>::new_instance, &MavlinkStreamServoOutputRaw<2>::get_name_static), @@ -2457,6 +2499,6 @@ const StreamListItem *streams_list[] = { new StreamListItem(&MavlinkStreamCameraCapture::new_instance, &MavlinkStreamCameraCapture::get_name_static), new StreamListItem(&MavlinkStreamCameraTrigger::new_instance, &MavlinkStreamCameraTrigger::get_name_static), new StreamListItem(&MavlinkStreamDistanceSensor::new_instance, &MavlinkStreamDistanceSensor::get_name_static), - new StreamListItem(&MavlinkStreamVtolState::new_instance, &MavlinkStreamVtolState::get_name_static), + new StreamListItem(&MavlinkStreamExtendedSysState::new_instance, &MavlinkStreamExtendedSysState::get_name_static), nullptr }; diff --git a/src/modules/mavlink/mavlink_mission.cpp b/src/modules/mavlink/mavlink_mission.cpp index 883fcd0f34..7e9f546d26 100644 --- a/src/modules/mavlink/mavlink_mission.cpp +++ b/src/modules/mavlink/mavlink_mission.cpp @@ -779,13 +779,12 @@ MavlinkMissionManager::parse_mavlink_mission_item(const mavlink_mission_item_t * mission_item->altitude_is_relative = true; break; - case MAV_FRAME_LOCAL_NED: - case MAV_FRAME_LOCAL_ENU: - return MAV_MISSION_UNSUPPORTED_FRAME; - case MAV_FRAME_MISSION: + // This is a mission item with no coordinate + break; + default: - return MAV_MISSION_ERROR; + return MAV_MISSION_UNSUPPORTED_FRAME; } switch (mavlink_mission_item->command) { diff --git a/src/modules/mavlink/mavlink_parameters.cpp b/src/modules/mavlink/mavlink_parameters.cpp index 414b7ee96f..368712e752 100644 --- a/src/modules/mavlink/mavlink_parameters.cpp +++ b/src/modules/mavlink/mavlink_parameters.cpp @@ -41,25 +41,29 @@ #include +#include +#include + #include "mavlink_parameters.h" #include "mavlink_main.h" +ORB_DEFINE(uavcan_parameter_request, struct uavcan_parameter_request_s); +ORB_DEFINE(uavcan_parameter_value, struct uavcan_parameter_value_s); +#define HASH_PARAM "_HASH_CHECK" + MavlinkParametersManager::MavlinkParametersManager(Mavlink *mavlink) : MavlinkStream(mavlink), _send_all_index(-1), _rc_param_map_pub(nullptr), - _rc_param_map() + _rc_param_map(), + _uavcan_parameter_request_pub(nullptr), + _uavcan_parameter_value_sub(-1) { } unsigned MavlinkParametersManager::get_size() { - if (_send_all_index >= 0) { - return MAVLINK_MSG_ID_PARAM_VALUE_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES; - - } else { - return 0; - } + return MAVLINK_MSG_ID_PARAM_VALUE_LEN + MAVLINK_NUM_NON_PAYLOAD_BYTES; } void @@ -76,36 +80,75 @@ MavlinkParametersManager::handle_message(const mavlink_message_t *msg) _send_all_index = 0; } + + if (req_list.target_system == mavlink_system.sysid && req_list.target_component < 127 && + (req_list.target_component != mavlink_system.compid || req_list.target_component == MAV_COMP_ID_ALL)) { + // publish list request to UAVCAN driver via uORB. + uavcan_parameter_request_s req; + req.message_type = msg->msgid; + req.node_id = req_list.target_component; + req.param_index = 0; + + if (_uavcan_parameter_request_pub == nullptr) { + _uavcan_parameter_request_pub = orb_advertise(ORB_ID(uavcan_parameter_request), &req); + } else { + orb_publish(ORB_ID(uavcan_parameter_request), _uavcan_parameter_request_pub, &req); + } + } break; } case MAVLINK_MSG_ID_PARAM_SET: { /* set parameter */ - if (msg->msgid == MAVLINK_MSG_ID_PARAM_SET) { - mavlink_param_set_t set; - mavlink_msg_param_set_decode(msg, &set); + mavlink_param_set_t set; + mavlink_msg_param_set_decode(msg, &set); - if (set.target_system == mavlink_system.sysid && - (set.target_component == mavlink_system.compid || set.target_component == MAV_COMP_ID_ALL)) { + if (set.target_system == mavlink_system.sysid && + (set.target_component == mavlink_system.compid || set.target_component == MAV_COMP_ID_ALL)) { - /* local name buffer to enforce null-terminated string */ - char name[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN + 1]; - strncpy(name, set.param_id, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN); - /* enforce null termination */ - name[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN] = '\0'; - /* attempt to find parameter, set and send it */ - param_t param = param_find_no_notification(name); + /* local name buffer to enforce null-terminated string */ + char name[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN + 1]; + strncpy(name, set.param_id, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN); + /* enforce null termination */ + name[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN] = '\0'; + /* attempt to find parameter, set and send it */ + param_t param = param_find_no_notification(name); - if (param == PARAM_INVALID) { - char buf[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN]; - sprintf(buf, "[pm] unknown param: %s", name); - _mavlink->send_statustext_info(buf); + if (param == PARAM_INVALID) { + char buf[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN]; + sprintf(buf, "[pm] unknown param: %s", name); + _mavlink->send_statustext_info(buf); - } else { - /* set and send parameter */ - param_set(param, &(set.param_value)); - send_param(param); - } + } else { + /* set and send parameter */ + param_set(param, &(set.param_value)); + send_param(param); + } + } + + if (set.target_system == mavlink_system.sysid && set.target_component < 127 && + (set.target_component != mavlink_system.compid || set.target_component == MAV_COMP_ID_ALL)) { + // publish set request to UAVCAN driver via uORB. + uavcan_parameter_request_s req; + req.message_type = msg->msgid; + req.node_id = set.target_component; + req.param_index = -1; + strncpy(req.param_id, set.param_id, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN + 1); + req.param_id[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN] = '\0'; + if (set.param_type == MAV_PARAM_TYPE_REAL32) { + req.param_type = MAV_PARAM_TYPE_REAL32; + req.real_value = set.param_value; + } else { + int32_t val; + memcpy(&val, &set.param_value, sizeof(int32_t)); + req.param_type = MAV_PARAM_TYPE_INT64; + req.int_value = val; + } + + if (_uavcan_parameter_request_pub == nullptr) { + _uavcan_parameter_request_pub = orb_advertise(ORB_ID(uavcan_parameter_request), &req); + } else { + orb_publish(ORB_ID(uavcan_parameter_request), _uavcan_parameter_request_pub, &req); } } break; @@ -121,13 +164,27 @@ MavlinkParametersManager::handle_message(const mavlink_message_t *msg) /* when no index is given, loop through string ids and compare them */ if (req_read.param_index < 0) { - /* local name buffer to enforce null-terminated string */ - char name[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN + 1]; - strncpy(name, req_read.param_id, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN); - /* enforce null termination */ - name[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN] = '\0'; - /* attempt to find parameter and send it */ - send_param(param_find_no_notification(name)); + if (strncmp(req_read.param_id, HASH_PARAM, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN) == 0) { + /* return hash check for cached params */ + uint32_t hash = param_hash_check(); + + /* build the one-off response message */ + mavlink_param_value_t msg; + msg.param_count = param_count_used(); + msg.param_index = -1; + strncpy(msg.param_id, HASH_PARAM, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN); + msg.param_type = MAV_PARAM_TYPE_UINT32; + memcpy(&msg.param_value, &hash, sizeof(hash)); + _mavlink->send_message(MAVLINK_MSG_ID_PARAM_VALUE, &msg); + } else { + /* local name buffer to enforce null-terminated string */ + char name[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN + 1]; + strncpy(name, req_read.param_id, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN); + /* enforce null termination */ + name[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN] = '\0'; + /* attempt to find parameter and send it */ + send_param(param_find_no_notification(name)); + } } else { /* when index is >= 0, send this parameter again */ @@ -144,6 +201,23 @@ MavlinkParametersManager::handle_message(const mavlink_message_t *msg) } } } + + if (req_read.target_system == mavlink_system.sysid && req_read.target_component < 127 && + (req_read.target_component != mavlink_system.compid || req_read.target_component == MAV_COMP_ID_ALL)) { + // publish set request to UAVCAN driver via uORB. + uavcan_parameter_request_s req; + req.message_type = msg->msgid; + req.node_id = req_read.target_component; + req.param_index = req_read.param_index; + strncpy(req.param_id, req_read.param_id, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN + 1); + req.param_id[MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN] = '\0'; + + if (_uavcan_parameter_request_pub == nullptr) { + _uavcan_parameter_request_pub = orb_advertise(ORB_ID(uavcan_parameter_request), &req); + } else { + orb_publish(ORB_ID(uavcan_parameter_request), _uavcan_parameter_request_pub, &req); + } + } break; } @@ -192,11 +266,38 @@ MavlinkParametersManager::handle_message(const mavlink_message_t *msg) void MavlinkParametersManager::send(const hrt_abstime t) { - /* send all parameters if requested, but only after the system has booted */ - if (_send_all_index >= 0 && _mavlink->boot_complete()) { + bool space_available = _mavlink->get_free_tx_buf() >= get_size(); + + /* Send parameter values received from the UAVCAN topic */ + if (_uavcan_parameter_value_sub < 0) { + _uavcan_parameter_value_sub = orb_subscribe(ORB_ID(uavcan_parameter_value)); + } + + bool param_value_ready; + orb_check(_uavcan_parameter_value_sub, ¶m_value_ready); + if (space_available && param_value_ready) { + struct uavcan_parameter_value_s value; + orb_copy(ORB_ID(uavcan_parameter_value), _uavcan_parameter_value_sub, &value); + + mavlink_param_value_t msg; + msg.param_count = value.param_count; + msg.param_index = value.param_index; + strncpy(msg.param_id, value.param_id, MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN); + if (value.param_type == MAV_PARAM_TYPE_REAL32) { + msg.param_type = MAVLINK_TYPE_FLOAT; + msg.param_value = value.real_value; + } else { + int32_t val; + val = (int32_t)value.int_value; + memcpy(&msg.param_value, &val, sizeof(int32_t)); + msg.param_type = MAVLINK_TYPE_INT32_T; + } + _mavlink->send_message(MAVLINK_MSG_ID_PARAM_VALUE, &msg, value.node_id); + } else if (_send_all_index >= 0 && _mavlink->boot_complete()) { + /* send all parameters if requested, but only after the system has booted */ /* skip if no space is available */ - if (_mavlink->get_free_tx_buf() < get_size()) { + if (!space_available) { return; } diff --git a/src/modules/mavlink/mavlink_parameters.h b/src/modules/mavlink/mavlink_parameters.h index 3dfed084b3..d258f3b240 100644 --- a/src/modules/mavlink/mavlink_parameters.h +++ b/src/modules/mavlink/mavlink_parameters.h @@ -118,4 +118,7 @@ protected: orb_advert_t _rc_param_map_pub; struct rc_parameter_map_s _rc_param_map; + + orb_advert_t _uavcan_parameter_request_pub; + int _uavcan_parameter_value_sub; }; diff --git a/src/modules/mavlink/mavlink_params.c b/src/modules/mavlink/mavlink_params.c new file mode 100644 index 0000000000..4edaa7b582 --- /dev/null +++ b/src/modules/mavlink/mavlink_params.c @@ -0,0 +1,104 @@ +/**************************************************************************** + * + * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#include + +/** + * MAVLink system ID + * @group MAVLink + * @min 1 + * @max 250 + */ +PARAM_DEFINE_INT32(MAV_SYS_ID, 1); + +/** + * MAVLink component ID + * @group MAVLink + * @min 1 + * @max 250 + */ +PARAM_DEFINE_INT32(MAV_COMP_ID, 1); + +/** + * MAVLink Radio ID + * + * When non-zero the MAVLink app will attempt to configure the + * radio to this ID and re-set the parameter to 0. If the value + * is negative it will reset the complete radio config to + * factory defaults. + * + * @group MAVLink + * @min -1 + * @max 240 + */ +PARAM_DEFINE_INT32(MAV_RADIO_ID, 0); + +/** + * MAVLink airframe type + * + * @min 1 + * @group MAVLink + */ +PARAM_DEFINE_INT32(MAV_TYPE, 1); + +/** + * Use/Accept HIL GPS message even if not in HIL mode + * + * If set to 1 incoming HIL GPS messages are parsed. + * + * @group MAVLink + */ +PARAM_DEFINE_INT32(MAV_USEHILGPS, 0); + +/** + * Forward external setpoint messages + * + * If set to 1 incoming external setpoint messages will be directly forwarded + * to the controllers if in offboard control mode + * + * @group MAVLink + */ +PARAM_DEFINE_INT32(MAV_FWDEXTSP, 1); + +/** + * Test parameter + * + * This parameter is not actively used by the system. Its purpose is to allow + * testing the parameter interface on the communication level. + * + * @group MAVLink + * @min -1000 + * @max 1000 + */ +PARAM_DEFINE_INT32(MAV_TEST_PAR, 1); + diff --git a/src/modules/mavlink/mavlink_receiver.cpp b/src/modules/mavlink/mavlink_receiver.cpp index 2eae087010..d0b95b7f89 100644 --- a/src/modules/mavlink/mavlink_receiver.cpp +++ b/src/modules/mavlink/mavlink_receiver.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -62,7 +61,6 @@ #include #include #ifndef __PX4_POSIX -#include #include #endif #include @@ -128,8 +126,11 @@ MavlinkReceiver::MavlinkReceiver(Mavlink *parent) : _control_mode_sub(orb_subscribe(ORB_ID(vehicle_control_mode))), _hil_frames(0), _old_timestamp(0), + _hil_last_frame(0), _hil_local_proj_inited(0), _hil_local_alt0(0.0f), + _hil_prev_gyro{}, + _hil_prev_accel{}, _hil_local_proj_ref{}, _offboard_control_mode{}, _att_sp{}, @@ -309,6 +310,10 @@ MavlinkReceiver::handle_message_command_long(mavlink_message_t *msg) } else if (cmd_mavlink.command == MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES) { /* send autopilot version message */ _mavlink->send_autopilot_capabilites(); + + } else if (cmd_mavlink.command == MAV_CMD_GET_HOME_POSITION) { + _mavlink->configure_stream_threadsafe("HOME_POSITION", 0.5f); + } else { if (msg->sysid == mavlink_system.sysid && msg->compid == mavlink_system.compid) { @@ -365,6 +370,13 @@ MavlinkReceiver::handle_message_command_int(mavlink_message_t *msg) /* terminate other threads and this thread */ _mavlink->_task_should_exit = true; + } else if (cmd_mavlink.command == MAV_CMD_REQUEST_AUTOPILOT_CAPABILITIES) { + /* send autopilot version message */ + _mavlink->send_autopilot_capabilites(); + + } else if (cmd_mavlink.command == MAV_CMD_GET_HOME_POSITION) { + _mavlink->configure_stream_threadsafe("HOME_POSITION", 0.5f); + } else { if (msg->sysid == mavlink_system.sysid && msg->compid == mavlink_system.compid) { @@ -1292,6 +1304,17 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg) uint64_t timestamp = hrt_absolute_time(); + float dt; + + if (_hil_last_frame == 0 || + (imu.time_usec - _hil_last_frame) > (0.1f * 1e6f) || + (_hil_last_frame >= imu.time_usec)) { + dt = 0.01f; /* default to 100 Hz */ + } else { + dt = (imu.time_usec - _hil_last_frame) / 1e6f; + } + _hil_last_frame = imu.time_usec; + /* airspeed */ { struct airspeed_s airspeed; @@ -1407,10 +1430,16 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg) hil_sensors.gyro_raw[0] = imu.xgyro * 1000.0f; hil_sensors.gyro_raw[1] = imu.ygyro * 1000.0f; hil_sensors.gyro_raw[2] = imu.zgyro * 1000.0f; - hil_sensors.gyro_rad_s[0] = imu.xgyro; + hil_sensors.gyro_rad_s[0] = ((imu.xgyro * dt + _hil_prev_gyro[0]) / 2.0f) / dt; hil_sensors.gyro_rad_s[1] = imu.ygyro; hil_sensors.gyro_rad_s[2] = imu.zgyro; + hil_sensors.gyro_integral_rad[0] = (hil_sensors.gyro_rad_s[0] * dt + _hil_prev_gyro[0]) / 2.0f; + hil_sensors.gyro_integral_rad[1] = (hil_sensors.gyro_rad_s[1] * dt + _hil_prev_gyro[1]) / 2.0f; + hil_sensors.gyro_integral_rad[2] = (hil_sensors.gyro_rad_s[2] * dt + _hil_prev_gyro[2]) / 2.0f; + memcpy(&_hil_prev_gyro[0], &hil_sensors.gyro_integral_rad[0], sizeof(_hil_prev_gyro)); + hil_sensors.gyro_integral_dt[0] = dt * 1e6f; hil_sensors.gyro_timestamp[0] = timestamp; + hil_sensors.gyro_priority[0] = ORB_PRIO_HIGH; hil_sensors.accelerometer_raw[0] = imu.xacc / mg2ms2; hil_sensors.accelerometer_raw[1] = imu.yacc / mg2ms2; @@ -1418,9 +1447,15 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg) hil_sensors.accelerometer_m_s2[0] = imu.xacc; hil_sensors.accelerometer_m_s2[1] = imu.yacc; hil_sensors.accelerometer_m_s2[2] = imu.zacc; + hil_sensors.accelerometer_integral_m_s[0] = (imu.xacc * dt + _hil_prev_accel[0]) / 2.0f; + hil_sensors.accelerometer_integral_m_s[1] = (imu.yacc * dt + _hil_prev_accel[1]) / 2.0f; + hil_sensors.accelerometer_integral_m_s[2] = (imu.zacc * dt + _hil_prev_accel[2]) / 2.0f; + memcpy(&_hil_prev_accel[0], &hil_sensors.accelerometer_integral_m_s[0], sizeof(_hil_prev_accel)); + hil_sensors.accelerometer_integral_dt[0] = dt * 1e6f; hil_sensors.accelerometer_mode[0] = 0; // TODO what is this? hil_sensors.accelerometer_range_m_s2[0] = 32.7f; // int16 hil_sensors.accelerometer_timestamp[0] = timestamp; + hil_sensors.accelerometer_priority[0] = ORB_PRIO_HIGH; hil_sensors.adc_voltage_v[0] = 0.0f; hil_sensors.adc_voltage_v[1] = 0.0f; @@ -1436,6 +1471,7 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg) hil_sensors.magnetometer_mode[0] = 0; // TODO what is this hil_sensors.magnetometer_cuttoff_freq_hz[0] = 50.0f; hil_sensors.magnetometer_timestamp[0] = timestamp; + hil_sensors.magnetometer_priority[0] = ORB_PRIO_HIGH; hil_sensors.baro_pres_mbar[0] = imu.abs_pressure; hil_sensors.baro_alt_meter[0] = imu.pressure_alt; diff --git a/src/modules/mavlink/mavlink_receiver.h b/src/modules/mavlink/mavlink_receiver.h index 3f115e8718..2363516a9a 100644 --- a/src/modules/mavlink/mavlink_receiver.h +++ b/src/modules/mavlink/mavlink_receiver.h @@ -196,8 +196,11 @@ private: int _control_mode_sub; int _hil_frames; uint64_t _old_timestamp; + uint64_t _hil_last_frame; bool _hil_local_proj_inited; float _hil_local_alt0; + float _hil_prev_gyro[3]; + float _hil_prev_accel[3]; struct map_projection_reference_s _hil_local_proj_ref; struct offboard_control_mode_s _offboard_control_mode; struct vehicle_attitude_setpoint_s _att_sp; diff --git a/src/modules/mavlink/mavlink_tests/CMakeLists.txt b/src/modules/mavlink/mavlink_tests/CMakeLists.txt new file mode 100644 index 0000000000..fe902974ee --- /dev/null +++ b/src/modules/mavlink/mavlink_tests/CMakeLists.txt @@ -0,0 +1,53 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__mavlink__mavlink_tests + MAIN mavlink_tests + STACK 5000 + COMPILE_FLAGS + -Weffc++ + -DMAVLINK_FTP_UNIT_TEST + -Wno-attributes + -Wno-packed + -Wno-packed + -Os + SRCS + mavlink_tests.cpp + mavlink_ftp_test.cpp + ../mavlink_stream.cpp + ../mavlink_ftp.cpp + ../mavlink.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/mavlink/module.mk b/src/modules/mavlink/module.mk deleted file mode 100644 index f197ebb7c9..0000000000 --- a/src/modules/mavlink/module.mk +++ /dev/null @@ -1,59 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# MAVLink protocol to uORB interface process -# - -MODULE_COMMAND = mavlink - -SRCS += mavlink.c \ - mavlink_main.cpp \ - mavlink_mission.cpp \ - mavlink_parameters.cpp \ - mavlink_orb_subscription.cpp \ - mavlink_messages.cpp \ - mavlink_stream.cpp \ - mavlink_rate_limiter.cpp \ - mavlink_receiver.cpp \ - mavlink_ftp.cpp - -INCLUDE_DIRS += $(MAVLINK_SRC)/include/mavlink - -MAXOPTIMIZATION = -Os - -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Weffc++ -Wno-attributes -Wno-packed -DMAVLINK_COMM_NUM_BUFFERS=3 - -EXTRACFLAGS = -Wno-packed -DMAVLINK_COMM_NUM_BUFFERS=3 diff --git a/src/modules/mc_att_control/CMakeLists.txt b/src/modules/mc_att_control/CMakeLists.txt new file mode 100644 index 0000000000..3c08772766 --- /dev/null +++ b/src/modules/mc_att_control/CMakeLists.txt @@ -0,0 +1,47 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +if (${OS} STREQUAL "nuttx") + list(APPEND MODULE_CFLAGS -Wframe-larger-than=3500) +endif() +px4_add_module( + MODULE modules__mc_att_control + MAIN mc_att_control + STACK 1200 + COMPILE_FLAGS ${MODULE_CFLAGS} + SRCS + mc_att_control_main.cpp + mc_att_control_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/mc_att_control/module.mk b/src/modules/mc_att_control/module.mk deleted file mode 100644 index f32bc71bf2..0000000000 --- a/src/modules/mc_att_control/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Multirotor attitude controller (vector based, no Euler singularities) -# - -MODULE_COMMAND = mc_att_control - -SRCS = mc_att_control_main.cpp \ - mc_att_control_params.c - -# Startup handler, the actual app stack size is -# in the task_spawn command -MODULE_STACKSIZE = 1200 diff --git a/src/modules/mc_att_control_multiplatform/CMakeLists.txt b/src/modules/mc_att_control_multiplatform/CMakeLists.txt new file mode 100644 index 0000000000..22f9d16ee8 --- /dev/null +++ b/src/modules/mc_att_control_multiplatform/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__mc_att_control_multiplatform + MAIN mc_att_control_m + SRCS + mc_att_control_main.cpp + mc_att_control_start_nuttx.cpp + mc_att_control.cpp + mc_att_control_base.cpp + mc_att_control_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/mc_att_control_multiplatform/mc_att_control.cpp b/src/modules/mc_att_control_multiplatform/mc_att_control.cpp index 63515f497d..98435a08f0 100644 --- a/src/modules/mc_att_control_multiplatform/mc_att_control.cpp +++ b/src/modules/mc_att_control_multiplatform/mc_att_control.cpp @@ -64,11 +64,9 @@ static const int ERROR = -1; MulticopterAttitudeControlMultiplatform::MulticopterAttitudeControlMultiplatform() : MulticopterAttitudeControlBase(), - _task_should_exit(false), _actuators_0_circuit_breaker_enabled(false), /* publications */ - _att_sp_pub(nullptr), _v_rates_sp_pub(nullptr), _actuators_0_pub(nullptr), _n(_appState), diff --git a/src/modules/mc_att_control_multiplatform/mc_att_control.h b/src/modules/mc_att_control_multiplatform/mc_att_control.h index de059fc9f3..12d4beadfc 100644 --- a/src/modules/mc_att_control_multiplatform/mc_att_control.h +++ b/src/modules/mc_att_control_multiplatform/mc_att_control.h @@ -85,10 +85,8 @@ public: void spin() { _n.spin(); } private: - bool _task_should_exit; /**< if true, sensor task should exit */ bool _actuators_0_circuit_breaker_enabled; /**< circuit breaker to suppress output */ - px4::Publisher *_att_sp_pub; /**< attitude setpoint publication */ px4::Publisher *_v_rates_sp_pub; /**< rate setpoint publication */ px4::Publisher *_actuators_0_pub; /**< attitude actuator controls publication */ diff --git a/src/modules/mc_att_control_multiplatform/module.mk b/src/modules/mc_att_control_multiplatform/module.mk deleted file mode 100644 index 959f6492b0..0000000000 --- a/src/modules/mc_att_control_multiplatform/module.mk +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Multirotor attitude controller (vector based, no Euler singularities) -# - -MODULE_COMMAND = mc_att_control_m - -SRCS = mc_att_control_main.cpp \ - mc_att_control_start_nuttx.cpp \ - mc_att_control.cpp \ - mc_att_control_base.cpp \ - mc_att_control_params.c diff --git a/src/modules/mc_pos_control/CMakeLists.txt b/src/modules/mc_pos_control/CMakeLists.txt new file mode 100644 index 0000000000..3790bfd614 --- /dev/null +++ b/src/modules/mc_pos_control/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__mc_pos_control + MAIN mc_pos_control + STACK 1200 + SRCS + mc_pos_control_main.cpp + mc_pos_control_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp index dc98db02f3..36d87b9383 100644 --- a/src/modules/mc_pos_control/mc_pos_control_main.cpp +++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp @@ -803,7 +803,7 @@ void MulticopterPositionControl::control_auto(float dt) &curr_sp.data[0], &curr_sp.data[1]); curr_sp(2) = -(_pos_sp_triplet.current.alt - _ref_alt); - /* scaled space: 1 == position error resulting max allowed speed, L1 = 1 in this space */ + /* scaled space: 1 == position error resulting max allowed speed */ math::Vector<3> scale = _params.pos_p.edivide(_params.vel_max); // TODO add mult param here /* convert current setpoint to scaled space */ @@ -822,14 +822,14 @@ void MulticopterPositionControl::control_auto(float dt) if ((curr_sp - prev_sp).length() > MIN_DIST) { - /* find X - cross point of L1 sphere and trajectory */ + /* find X - cross point of unit sphere and trajectory */ math::Vector<3> pos_s = _pos.emult(scale); math::Vector<3> prev_sp_s = prev_sp.emult(scale); math::Vector<3> prev_curr_s = curr_sp_s - prev_sp_s; math::Vector<3> curr_pos_s = pos_s - curr_sp_s; float curr_pos_s_len = curr_pos_s.length(); if (curr_pos_s_len < 1.0f) { - /* copter is closer to waypoint than L1 radius */ + /* copter is closer to waypoint than unit radius */ /* check next waypoint and use it to avoid slowing down when passing via waypoint */ if (_pos_sp_triplet.next.valid) { math::Vector<3> next_sp; @@ -853,7 +853,7 @@ void MulticopterPositionControl::control_auto(float dt) if (cos_a_curr_next > 0.0f && cos_b > 0.0f) { float curr_next_s_len = curr_next_s.length(); - /* if curr - next distance is larger than L1 radius, limit it */ + /* if curr - next distance is larger than unit radius, limit it */ if (curr_next_s_len > 1.0f) { cos_a_curr_next /= curr_next_s_len; } @@ -870,7 +870,7 @@ void MulticopterPositionControl::control_auto(float dt) } else { bool near = cross_sphere_line(pos_s, 1.0f, prev_sp_s, curr_sp_s, pos_sp_s); if (near) { - /* L1 sphere crosses trajectory */ + /* unit sphere crosses trajectory */ } else { /* copter is too far from trajectory */ diff --git a/src/modules/mc_pos_control/module.mk b/src/modules/mc_pos_control/module.mk deleted file mode 100644 index 48827897a1..0000000000 --- a/src/modules/mc_pos_control/module.mk +++ /dev/null @@ -1,45 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Build multicopter position controller -# - -MODULE_COMMAND = mc_pos_control - -SRCS = mc_pos_control_main.cpp \ - mc_pos_control_params.c - -# Startup handler, the actual app stack size is -# in the task_spawn command -MODULE_STACKSIZE = 1200 diff --git a/src/modules/mc_pos_control_multiplatform/CMakeLists.txt b/src/modules/mc_pos_control_multiplatform/CMakeLists.txt new file mode 100644 index 0000000000..f36acf4e33 --- /dev/null +++ b/src/modules/mc_pos_control_multiplatform/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__mc_pos_control_multiplatform + MAIN mc_pos_control_m + SRCS + mc_pos_control_main.cpp + mc_pos_control_start_nuttx.cpp + mc_pos_control.cpp + mc_pos_control_params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/mc_pos_control_multiplatform/module.mk b/src/modules/mc_pos_control_multiplatform/module.mk deleted file mode 100644 index d6fe231e95..0000000000 --- a/src/modules/mc_pos_control_multiplatform/module.mk +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Build multicopter position controller -# - -MODULE_COMMAND = mc_pos_control_m - -SRCS = mc_pos_control_main.cpp \ - mc_pos_control_start_nuttx.cpp \ - mc_pos_control.cpp \ - mc_pos_control_params.c - -# Only NuttX has a frame size limit -ifeq ($(PX4_TARGET_OS),nuttx) -EXTRACXXFLAGS = -Wframe-larger-than=1200 -endif diff --git a/src/modules/muorb/adsp/CMakeLists.txt b/src/modules/muorb/adsp/CMakeLists.txt new file mode 100644 index 0000000000..185264a85f --- /dev/null +++ b/src/modules/muorb/adsp/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +include_directories("../../uORB") + +px4_add_module( + MODULE modules__muorb__adsp + COMPILE_FLAGS + -Os + SRCS + px4muorb.cpp + uORBFastRpcChannel.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/muorb/adsp/px4muorb.cpp b/src/modules/muorb/adsp/px4muorb.cpp index e6cad0aba3..df951eb967 100644 --- a/src/modules/muorb/adsp/px4muorb.cpp +++ b/src/modules/muorb/adsp/px4muorb.cpp @@ -31,39 +31,30 @@ * ****************************************************************************/ #include "px4muorb.hpp" -#include "qurt.h" #include "uORBFastRpcChannel.hpp" #include "uORBManager.hpp" #include #include #include -#include -#include +#include #include "px4_log.h" #include "uORB/topics/sensor_combined.h" #include "uORB.h" -#include "HAP_power.h" - -#define _ENABLE_MUORB 1 - -extern "C" { -int dspal_main(int argc, const char *argv[]); -}; - +__BEGIN_DECLS +extern int dspal_main(int argc, char *argv[]); +__END_DECLS int px4muorb_orb_initialize() { - int rc = 0; - PX4_WARN("Before calling dspal_entry() method..."); HAP_power_request(100, 100, 1000); // register the fastrpc muorb with uORBManager. uORB::Manager::get_instance()->set_uorb_communicator(uORB::FastRpcChannel::GetInstance()); - const char *argv[2] = { "dspal", "start" }; + const char *argv[] = { "dspal", "start" }; int argc = 2; - dspal_main(argc, argv); - PX4_WARN("After calling dspal_entry"); + int rc; + rc = dspal_main(argc, (char **)argv); return rc; } @@ -103,7 +94,6 @@ int px4muorb_remove_subscriber(const char *name) } return rc; - } int px4muorb_send_topic_data(const char *name, const uint8_t *data, int data_len_in_bytes) diff --git a/src/modules/muorb/krait-stubs/px4muorb_KraitRpcWrapper.hpp b/src/modules/muorb/krait-stubs/px4muorb_KraitRpcWrapper.hpp new file mode 100644 index 0000000000..d6feab2a47 --- /dev/null +++ b/src/modules/muorb/krait-stubs/px4muorb_KraitRpcWrapper.hpp @@ -0,0 +1,76 @@ +/**************************************************************************** + * + * Copyright (C) 2015 Mark Charlebois. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ +#ifndef _px4muorb_KraitRpcWrapper_hpp_ +#define _px4muorb_KraitRpcWrapper_hpp_ +#include + +namespace px4muorb +{ + class KraitRpcWrapper; +} + +class px4muorb::KraitRpcWrapper +{ +public: + /** + * Constructor + */ + KraitRpcWrapper() {} + + /** + * destructor + */ + ~KraitRpcWrapper() {} + + /** + * Initiatizes the rpc channel px4 muorb + */ + bool Initialize() { return true; } + + /** + * Terminate to clean up the resources. This should be called at program exit + */ + bool Terminate() { return true; } + + /** + * Muorb related functions to pub/sub of orb topic from krait to adsp + */ + int32_t AddSubscriber( const char* topic ) { return 1; } + int32_t RemoveSubscriber( const char* topic ) { return 1; } + int32_t SendData( const char* topic, int32_t length_in_bytes, const uint8_t* data ) { return 1; } + int32_t ReceiveData( int32_t* msg_type, char** topic, int32_t* length_in_bytes, uint8_t** data ) { return 1; } + int32_t IsSubscriberPresent( const char* topic, int32_t* status ) { return 1; } + int32_t ReceiveBulkData( uint8_t** bulk_data, int32_t* length_in_bytes, int32_t* topic_count ) { return 1; } + int32_t UnblockReceiveData() { return 1; } +}; +#endif // _px4muorb_KraitWrapper_hpp_ diff --git a/src/modules/muorb/krait/CMakeLists.txt b/src/modules/muorb/krait/CMakeLists.txt new file mode 100644 index 0000000000..1c1d6605ac --- /dev/null +++ b/src/modules/muorb/krait/CMakeLists.txt @@ -0,0 +1,46 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +if("${DSPAL_STUBS_ENABLE}" STREQUAL "1") + include_directories(../krait-stubs) +endif() + +px4_add_module( + MODULE modules__muorb__krait + MAIN muorb + SRCS + uORBKraitFastRpcChannel.cpp + muorb_main.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/muorb/krait/muorb_main.cpp b/src/modules/muorb/krait/muorb_main.cpp index 3a320e6134..006870780c 100644 --- a/src/modules/muorb/krait/muorb_main.cpp +++ b/src/modules/muorb/krait/muorb_main.cpp @@ -32,7 +32,7 @@ ****************************************************************************/ #include -#include "uORBManager.hpp" +#include "modules/uORB/uORBManager.hpp" #include "uORBKraitFastRpcChannel.hpp" extern "C" { __EXPORT int muorb_main(int argc, char *argv[]); } diff --git a/src/modules/muorb/krait/uORBKraitFastRpcChannel.hpp b/src/modules/muorb/krait/uORBKraitFastRpcChannel.hpp index a2f6850cbe..0e8d82b44b 100644 --- a/src/modules/muorb/krait/uORBKraitFastRpcChannel.hpp +++ b/src/modules/muorb/krait/uORBKraitFastRpcChannel.hpp @@ -38,7 +38,7 @@ #include #include #include "uORB/uORBCommunicator.hpp" -#include +#include "px4muorb_KraitRpcWrapper.hpp" #include #include "drivers/drv_hrt.h" diff --git a/src/modules/navigator/CMakeLists.txt b/src/modules/navigator/CMakeLists.txt new file mode 100644 index 0000000000..d8399ccafd --- /dev/null +++ b/src/modules/navigator/CMakeLists.txt @@ -0,0 +1,56 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__navigator + MAIN navigator + STACK 1200 + COMPILE_FLAGS + -Wno-sign-compare + -Os + SRCS + navigator_main.cpp + navigator_mode.cpp + mission_block.cpp + mission.cpp + loiter.cpp + rtl.cpp + mission_feasibility_checker.cpp + geofence.cpp + datalinkloss.cpp + rcloss.cpp + enginefailure.cpp + gpsfailure.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/navigator/datalinkloss_params.c b/src/modules/navigator/datalinkloss_params.c index a1ba7869ed..9eb0299ab7 100644 --- a/src/modules/navigator/datalinkloss_params.c +++ b/src/modules/navigator/datalinkloss_params.c @@ -39,10 +39,6 @@ * @author Thomas Gubler */ -#include - -#include - /* * Data Link Loss parameters, accessible via MAVLink */ diff --git a/src/modules/navigator/geofence_params.c b/src/modules/navigator/geofence_params.c index 7c1d8a266a..63eec7213d 100644 --- a/src/modules/navigator/geofence_params.c +++ b/src/modules/navigator/geofence_params.c @@ -39,10 +39,6 @@ * @author Thomas Gubler */ -#include - -#include - /* * Geofence parameters, accessible via MAVLink */ diff --git a/src/modules/navigator/gpsfailure_params.c b/src/modules/navigator/gpsfailure_params.c index ca2f540505..6c835d062e 100644 --- a/src/modules/navigator/gpsfailure_params.c +++ b/src/modules/navigator/gpsfailure_params.c @@ -39,10 +39,6 @@ * @author Thomas Gubler */ -#include - -#include - /* * GPS Failure Navigation Mode parameters, accessible via MAVLink */ diff --git a/src/modules/navigator/mission_feasibility_checker.cpp b/src/modules/navigator/mission_feasibility_checker.cpp index a30060b27a..880d4bd98e 100644 --- a/src/modules/navigator/mission_feasibility_checker.cpp +++ b/src/modules/navigator/mission_feasibility_checker.cpp @@ -51,12 +51,6 @@ #include #include -/* oddly, ERROR is not defined for c++ */ -#ifdef ERROR -# undef ERROR -#endif -static const int ERROR = -1; - MissionFeasibilityChecker::MissionFeasibilityChecker() : _mavlink_fd(-1), _capabilities_sub(-1), @@ -342,7 +336,7 @@ MissionFeasibilityChecker::check_dist_1wp(dm_item_t dm_current, size_t nMissionI } else { /* item is too far from home */ - mavlink_log_critical(_mavlink_fd, "Waypoint too far: %d m,[MIS_DIST_1WP=%d]", (int)dist_to_1wp, (int)dist_first_wp); + mavlink_log_critical(_mavlink_fd, "First waypoint too far: %d m,refusing mission", (int)dist_to_1wp, (int)dist_first_wp); warning_issued = true; return false; } diff --git a/src/modules/navigator/mission_params.c b/src/modules/navigator/mission_params.c index b2094f62e3..7c2942f53e 100644 --- a/src/modules/navigator/mission_params.c +++ b/src/modules/navigator/mission_params.c @@ -39,10 +39,6 @@ * @author Julian Oes */ -#include - -#include - /* * Mission parameters, accessible via MAVLink */ diff --git a/src/modules/navigator/module.mk b/src/modules/navigator/module.mk deleted file mode 100644 index 0d7d6b9ef1..0000000000 --- a/src/modules/navigator/module.mk +++ /dev/null @@ -1,66 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Main Navigation Controller -# - -MODULE_COMMAND = navigator - -SRCS = navigator_main.cpp \ - navigator_params.c \ - navigator_mode.cpp \ - mission_block.cpp \ - mission.cpp \ - mission_params.c \ - loiter.cpp \ - rtl.cpp \ - rtl_params.c \ - mission_feasibility_checker.cpp \ - geofence.cpp \ - geofence_params.c \ - datalinkloss.cpp \ - datalinkloss_params.c \ - rcloss.cpp \ - rcloss_params.c \ - enginefailure.cpp \ - gpsfailure.cpp \ - gpsfailure_params.c - -INCLUDE_DIRS += $(MAVLINK_SRC)/include/mavlink - -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os - -EXTRACXXFLAGS = -Wno-sign-compare diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp index 50b8746a71..bf8974cd8c 100644 --- a/src/modules/navigator/navigator_main.cpp +++ b/src/modules/navigator/navigator_main.cpp @@ -332,8 +332,8 @@ Navigator::task_main() while (!_task_should_exit) { - /* wait for up to 100ms for data */ - int pret = px4_poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 100); + /* wait for up to 200ms for data */ + int pret = px4_poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 200); if (pret == 0) { /* timed out - periodic check for _task_should_exit, etc. */ diff --git a/src/modules/navigator/navigator_params.c b/src/modules/navigator/navigator_params.c index e1d29334c6..17e580c664 100644 --- a/src/modules/navigator/navigator_params.c +++ b/src/modules/navigator/navigator_params.c @@ -40,10 +40,6 @@ * @author Thomas Gubler */ -#include - -#include - /** * Loiter radius (FW only) * diff --git a/src/modules/navigator/rcloss_params.c b/src/modules/navigator/rcloss_params.c index 3c9a6e40ef..958dab9266 100644 --- a/src/modules/navigator/rcloss_params.c +++ b/src/modules/navigator/rcloss_params.c @@ -39,10 +39,6 @@ * @author Thomas Gubler */ -#include - -#include - /* * OBC RC Loss mode parameters, accessible via MAVLink */ diff --git a/src/modules/navigator/rtl_params.c b/src/modules/navigator/rtl_params.c index a33ded28ab..e65a41b775 100644 --- a/src/modules/navigator/rtl_params.c +++ b/src/modules/navigator/rtl_params.c @@ -39,10 +39,6 @@ * @author Julian Oes */ -#include - -#include - /* * RTL parameters, accessible via MAVLink */ diff --git a/src/modules/param/CMakeLists.txt b/src/modules/param/CMakeLists.txt new file mode 100644 index 0000000000..64bff2a0e1 --- /dev/null +++ b/src/modules/param/CMakeLists.txt @@ -0,0 +1,49 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +px4_generate_parameters_source(OUT param_files + XML ${CMAKE_BINARY_DIR}/parameters.xml + DEPS xml_gen + ) + +px4_add_module( + MODULE modules__param + COMPILE_FLAGS + -Os + SRCS ${param_files} + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/position_estimator_inav/CMakeLists.txt b/src/modules/position_estimator_inav/CMakeLists.txt new file mode 100644 index 0000000000..90ab4ad74c --- /dev/null +++ b/src/modules/position_estimator_inav/CMakeLists.txt @@ -0,0 +1,48 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +if(${OS} STREQUAL "nuttx") + list(APPEND MODULE_CFLAGS -Wframe-larger-than=3800) +endif() +px4_add_module( + MODULE modules__position_estimator_inav + MAIN position_estimator_inav + STACK 1200 + COMPILE_FLAGS ${MODULE_CFLAGS} + SRCS + position_estimator_inav_main.c + position_estimator_inav_params.c + inertial_filter.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/position_estimator_inav/module.mk b/src/modules/position_estimator_inav/module.mk deleted file mode 100644 index 57b32954c5..0000000000 --- a/src/modules/position_estimator_inav/module.mk +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build position_estimator_inav -# - -MODULE_COMMAND = position_estimator_inav -SRCS = position_estimator_inav_main.c \ - position_estimator_inav_params.c \ - inertial_filter.c - -MODULE_STACKSIZE = 1200 - -ifeq ($(PX4_TARGEGT_OS),nuttx) -EXTRACFLAGS = -Wframe-larger-than=3800 -endif - diff --git a/src/modules/position_estimator_inav/position_estimator_inav_main.c b/src/modules/position_estimator_inav/position_estimator_inav_main.c index ee8359f0c3..53a7c678f6 100644 --- a/src/modules/position_estimator_inav/position_estimator_inav_main.c +++ b/src/modules/position_estimator_inav/position_estimator_inav_main.c @@ -39,6 +39,7 @@ * @author Nuno Marques */ +#include #include #include #include @@ -896,7 +897,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[]) } float dt = t_prev > 0 ? (t - t_prev) / 1000000.0f : 0.0f; - dt = fmaxf(fminf(0.02, dt), 0.002); // constrain dt from 2 to 20 ms + dt = fmaxf(fminf(0.02, dt), 0.0002); // constrain dt from 0.2 to 20 ms t_prev = t; /* increase EPH/EPV on each step */ diff --git a/src/modules/px4iofirmware/CMakeLists.txt b/src/modules/px4iofirmware/CMakeLists.txt new file mode 100644 index 0000000000..7b4c5652c6 --- /dev/null +++ b/src/modules/px4iofirmware/CMakeLists.txt @@ -0,0 +1,140 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# kill all flags above us, this is a different board (io) +set_directory_properties(PROPERTIES + INCLUDE_DIRECTORIES "" + LINK_DIRECTORIES "" + COMPILE_DEFINITIONS "" + ) +set(c_flags) +set(exe_linker_flags) +set(cxx_flags) +set(include_dirs) +set(link_dirs) +set(definitions) + +px4_os_prebuild_targets(OUT io_prebuild_targets + BOARD ${config_io_board} + THREADS ${THREADS}) + +px4_os_add_flags( + BOARD ${config_io_board} + C_FLAGS c_flags + CXX_FLAGS cxx_flags + EXE_LINKER_FLAGS exe_linker_flags + INCLUDE_DIRS include_dirs + LINK_DIRS link_dirs + DEFINITIONS definitions) + +px4_join(OUT CMAKE_EXE_LINKER_FLAGS LIST "${exe_linker_flags}" GLUE " ") +px4_join(OUT CMAKE_C_FLAGS LIST "${c_flags}" GLUE " ") +px4_join(OUT CMAKE_CXX_FLAGS LIST "${cxx_flags}" GLUE " ") + +include_directories( + ${include_dirs} + ${CMAKE_BINARY_DIR}/src/modules/systemlib/mixer + ) +link_directories(${link_dirs}) +add_definitions(${definitions}) + +set(srcs + adc.c + controls.c + dsm.c + px4io.c + registers.c + safety.c + sbus.c + ../systemlib/up_cxxinitialize.c + ../systemlib/perf_counter.c + mixer.cpp + ../systemlib/mixer/mixer.cpp + ../systemlib/mixer/mixer_group.cpp + ../systemlib/mixer/mixer_multirotor.cpp + ../systemlib/mixer/mixer_simple.cpp + ../systemlib/pwm_limit/pwm_limit.c + ../../lib/rc/st24.c + ../../lib/rc/sumd.c + ../../drivers/stm32/drv_hrt.c + ../../drivers/stm32/drv_pwm_servo.c + ../../drivers/boards/${config_io_board}/px4io_init.c + ../../drivers/boards/${config_io_board}/px4io_pwm_servo.c + ) + +if(${config_io_board} STREQUAL "px4io-v1") + list(APPEND srcs + i2c.c + ) +elseif(${config_io_board} STREQUAL "px4io-v2") + list(APPEND srcs + serial.c + ../systemlib/hx_stream.c + ) +endif() + +set(fw_io_name ${config_io_board}_${LABEL}) + +add_executable(${fw_io_name} + ${srcs}) + +add_dependencies(${fw_io_name} + nuttx_export_${config_io_board} + msg_gen + io_prebuild_targets + mixer_gen + ) + +set(nuttx_export_dir ${CMAKE_BINARY_DIR}/${config_io_board}/NuttX/nuttx-export) +set(main_link_flags + "-T${nuttx_export_dir}/build/ld.script" + "-Wl,-Map=${CMAKE_BINARY_DIR}/${config_io_board}/main.map" + ) +px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") +set_target_properties(${fw_io_name} PROPERTIES LINK_FLAGS ${main_link_flags}) + +target_link_libraries(${fw_io_name} + -Wl,--start-group + apps nuttx nosys m gcc + ${config_io_extra_libs} + -Wl,--end-group) + +px4_nuttx_create_bin(OUT ${CMAKE_CURRENT_BINARY_DIR}/${fw_io_name}.bin + EXE ${fw_io_name} + ) + +add_custom_target(fw_io + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fw_io_name}.bin) + + +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/px4iofirmware/module.mk b/src/modules/px4iofirmware/module.mk deleted file mode 100644 index 34c231174f..0000000000 --- a/src/modules/px4iofirmware/module.mk +++ /dev/null @@ -1,30 +0,0 @@ - -SRCS = adc.c \ - controls.c \ - dsm.c \ - px4io.c \ - registers.c \ - safety.c \ - sbus.c \ - ../systemlib/up_cxxinitialize.c \ - ../systemlib/perf_counter.c \ - mixer.cpp \ - ../systemlib/mixer/mixer.cpp \ - ../systemlib/mixer/mixer_group.cpp \ - ../systemlib/mixer/mixer_multirotor.cpp \ - ../systemlib/mixer/mixer_simple.cpp \ - ../systemlib/pwm_limit/pwm_limit.c \ - ../../lib/rc/st24.c \ - ../../lib/rc/sumd.c - -ifeq ($(BOARD),px4io-v1) -SRCS += i2c.c -endif -ifeq ($(BOARD),px4io-v2) -SRCS += serial.c \ - ../systemlib/hx_stream.c -endif - -SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(SELF_DIR)../systemlib/mixer/multi_tables.mk - \ No newline at end of file diff --git a/src/modules/px4iofirmware/protocol.h b/src/modules/px4iofirmware/protocol.h index 64ba0f93c4..673da0e44d 100644 --- a/src/modules/px4iofirmware/protocol.h +++ b/src/modules/px4iofirmware/protocol.h @@ -33,6 +33,7 @@ #pragma once +#define __STDC_FORMAT_MACROS #include /** diff --git a/src/modules/sdlog2/CMakeLists.txt b/src/modules/sdlog2/CMakeLists.txt new file mode 100644 index 0000000000..1e33df2a86 --- /dev/null +++ b/src/modules/sdlog2/CMakeLists.txt @@ -0,0 +1,51 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +if (${OS} STREQUAL "nuttx") + list(APPEND MODULE_CFLAGS -Wframe-larger-than=1500) +endif() +px4_add_module( + MODULE modules__sdlog2 + MAIN sdlog2 + PRIORITY "SCHED_PRIORITY_MAX-30" + STACK 1200 + COMPILE_FLAGS + ${MODULE_CFLAGS} + -Os + SRCS + sdlog2.c + logbuffer.c + params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/sdlog2/logbuffer.c b/src/modules/sdlog2/logbuffer.c index 9e25dd2f23..2768994dde 100644 --- a/src/modules/sdlog2/logbuffer.c +++ b/src/modules/sdlog2/logbuffer.c @@ -50,8 +50,8 @@ int logbuffer_init(struct logbuffer_s *lb, int size) lb->size = size; lb->write_ptr = 0; lb->read_ptr = 0; - lb->data = malloc(lb->size); - return (lb->data == 0) ? PX4_ERROR : PX4_OK; + lb->data = NULL; + return PX4_OK; } int logbuffer_count(struct logbuffer_s *lb) @@ -72,6 +72,16 @@ int logbuffer_is_empty(struct logbuffer_s *lb) bool logbuffer_write(struct logbuffer_s *lb, void *ptr, int size) { + // allocate buffer if not yet present + if (lb->data == NULL) { + lb->data = malloc(lb->size); + } + + // allocation failed, bail out + if (lb->data == NULL) { + return false; + } + // bytes available to write int available = lb->read_ptr - lb->write_ptr - 1; diff --git a/src/modules/sdlog2/module.mk b/src/modules/sdlog2/module.mk deleted file mode 100644 index 69afb39099..0000000000 --- a/src/modules/sdlog2/module.mk +++ /dev/null @@ -1,51 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# sdlog2 Application -# - -MODULE_COMMAND = sdlog2 -# The main thread only buffers to RAM, needs a high priority -MODULE_PRIORITY = "SCHED_PRIORITY_MAX-30" - -SRCS = sdlog2.c \ - logbuffer.c - -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os - -ifeq ($(PX4_TARGET_OS),nuttx) -EXTRACFLAGS = -Wframe-larger-than=1600 -endif diff --git a/src/examples/flow_position_estimator/flow_position_estimator_params.h b/src/modules/sdlog2/params.c similarity index 62% rename from src/examples/flow_position_estimator/flow_position_estimator_params.h rename to src/modules/sdlog2/params.c index 3ab4e560fc..77575e2ad3 100644 --- a/src/examples/flow_position_estimator/flow_position_estimator_params.h +++ b/src/modules/sdlog2/params.c @@ -1,8 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2008-2013 PX4 Development Team. All rights reserved. - * Author: Samuel Zihlmann - * Lorenz Meier + * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,36 +31,47 @@ * ****************************************************************************/ -/* - * @file flow_position_estimator_params.h - * - * Parameters for position estimator - */ - #include -struct flow_position_estimator_params { - float minimum_liftoff_thrust; - float sonar_upper_lp_threshold; - float sonar_lower_lp_threshold; - int debug; -}; - -struct flow_position_estimator_param_handles { - param_t minimum_liftoff_thrust; - param_t sonar_upper_lp_threshold; - param_t sonar_lower_lp_threshold; - param_t debug; -}; +/** + * Logging rate. + * + * A value of -1 indicates the commandline argument + * should be obeyed. A value of 0 sets the minimum rate, + * any other value is interpreted as rate in Hertz. This + * parameter is only read out before logging starts (which + * commonly is before arming). + * + * @min -1 + * @max 1 + * @group SD Logging + */ +PARAM_DEFINE_INT32(SDLOG_RATE, -1); /** - * Initialize all parameter handles and values + * Enable extended logging mode. * + * A value of -1 indicates the commandline argument + * should be obeyed. A value of 0 disables extended + * logging mode, a value of 1 enables it. This + * parameter is only read out before logging starts + * (which commonly is before arming). + * + * @min -1 + * @max 1 + * @group SD Logging */ -int parameters_init(struct flow_position_estimator_param_handles *h); +PARAM_DEFINE_INT32(SDLOG_EXT, -1); /** - * Update all parameters + * Use timestamps only if GPS 3D fix is available * + * A value of 1 constrains the log folder creation + * to only use the time stamp if a 3D GPS lock is + * present. + * + * @min 0 + * @max 1 + * @group SD Logging */ -int parameters_update(const struct flow_position_estimator_param_handles *h, struct flow_position_estimator_params *p); +PARAM_DEFINE_INT32(SDLOG_GPSTIME, 1); diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index 253949b26e..94719380f1 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -45,10 +45,17 @@ #include #include #include +#include +#include +#include #include #include -#include +#ifdef __PX4_DARWIN +#include +#include +#else #include +#endif #include #include #include @@ -117,56 +124,13 @@ #define PX4_EPOCH_SECS 1234567890L -/** - * Logging rate. - * - * A value of -1 indicates the commandline argument - * should be obeyed. A value of 0 sets the minimum rate, - * any other value is interpreted as rate in Hertz. This - * parameter is only read out before logging starts (which - * commonly is before arming). - * - * @min -1 - * @max 1 - * @group SD Logging - */ -PARAM_DEFINE_INT32(SDLOG_RATE, -1); - -/** - * Enable extended logging mode. - * - * A value of -1 indicates the commandline argument - * should be obeyed. A value of 0 disables extended - * logging mode, a value of 1 enables it. This - * parameter is only read out before logging starts - * (which commonly is before arming). - * - * @min -1 - * @max 1 - * @group SD Logging - */ -PARAM_DEFINE_INT32(SDLOG_EXT, -1); - -/** - * Use timestamps only if GPS 3D fix is available - * - * A value of 1 constrains the log folder creation - * to only use the time stamp if a 3D GPS lock is - * present. - * - * @min 0 - * @max 1 - * @group SD Logging - */ -PARAM_DEFINE_INT32(SDLOG_GPSTIME, 1); - #define LOGBUFFER_WRITE_AND_COUNT(_msg) if (logbuffer_write(&lb, &log_msg, LOG_PACKET_SIZE(_msg))) { \ log_msgs_written++; \ } else { \ log_msgs_skipped++; \ } -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) +#define SDLOG_MIN(X,Y) ((X) < (Y) ? (X) : (Y)) static bool main_thread_should_exit = false; /**< Deamon exit flag */ static bool thread_running = false; /**< Deamon status flag */ @@ -275,8 +239,6 @@ static int write_parameters(int fd); static bool file_exist(const char *filename); -static int file_copy(const char *file_old, const char *file_new); - /** * Check if there is still free space available */ @@ -410,7 +372,7 @@ int sdlog2_main(int argc, char *argv[]) bool get_log_time_utc_tt(struct tm *tt, bool boot_time) { struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); + px4_clock_gettime(CLOCK_REALTIME, &ts); /* use RTC time for log file naming, e.g. /fs/microsd/2014-01-19/19_37_52.px4log */ time_t utc_time_sec; @@ -1076,17 +1038,6 @@ int sdlog2_thread_main(int argc, char *argv[]) return 1; } - /* copy conversion scripts */ - const char *converter_in = "/etc/logging/conv.zip"; - char *converter_out = malloc(64); - snprintf(converter_out, 64, "%s/conv.zip", log_root); - - if (file_copy(converter_in, converter_out) != OK) { - warn("unable to copy conversion scripts"); - } - - free(converter_out); - /* initialize log buffer with specified size */ warnx("log buffer size: %i bytes", log_buffer_size); @@ -1395,7 +1346,7 @@ int sdlog2_thread_main(int argc, char *argv[]) if (copy_if_updated(ORB_ID(satellite_info), &subs.sat_info_sub, &buf.sat_info)) { /* log the SNR of each satellite for a detailed view of signal quality */ - unsigned sat_info_count = MIN(buf.sat_info.count, sizeof(buf.sat_info.snr) / sizeof(buf.sat_info.snr[0])); + unsigned sat_info_count = SDLOG_MIN(buf.sat_info.count, sizeof(buf.sat_info.snr) / sizeof(buf.sat_info.snr[0])); unsigned log_max_snr = sizeof(log_msg.body.log_GS0A.satellite_snr) / sizeof(log_msg.body.log_GS0A.satellite_snr[0]); log_msg.msg_type = LOG_GS0A_MSG; @@ -1860,11 +1811,11 @@ int sdlog2_thread_main(int argc, char *argv[]) log_msg.body.log_TECS.airspeedDerivativeSp = buf.tecs_status.airspeedDerivativeSp; log_msg.body.log_TECS.airspeedDerivative = buf.tecs_status.airspeedDerivative; log_msg.body.log_TECS.totalEnergyError = buf.tecs_status.totalEnergyError; - log_msg.body.log_TECS.energyDistributionError = buf.tecs_status.energyDistributionError; log_msg.body.log_TECS.totalEnergyRateError = buf.tecs_status.totalEnergyRateError; + log_msg.body.log_TECS.energyDistributionError = buf.tecs_status.energyDistributionError; log_msg.body.log_TECS.energyDistributionRateError = buf.tecs_status.energyDistributionRateError; - log_msg.body.log_TECS.throttle_integ = buf.tecs_status.throttle_integ; log_msg.body.log_TECS.pitch_integ = buf.tecs_status.pitch_integ; + log_msg.body.log_TECS.throttle_integ = buf.tecs_status.throttle_integ; log_msg.body.log_TECS.mode = (uint8_t)buf.tecs_status.mode; LOGBUFFER_WRITE_AND_COUNT(TECS); } @@ -1955,46 +1906,6 @@ bool file_exist(const char *filename) return stat(filename, &buffer) == 0; } -int file_copy(const char *file_old, const char *file_new) -{ - FILE *source, *target; - source = fopen(file_old, "r"); - int ret = 0; - - if (source == NULL) { - warnx("ERR: open in"); - return PX4_ERROR; - } - - target = fopen(file_new, "w"); - - if (target == NULL) { - fclose(source); - warnx("ERR: open out"); - return PX4_ERROR; - } - - char buf[128]; - int nread; - - while ((nread = fread(buf, 1, sizeof(buf), source)) > 0) { - ret = fwrite(buf, 1, nread, target); - - if (ret <= 0) { - warnx("error writing file"); - ret = PX4_ERROR; - break; - } - } - - fsync(fileno(target)); - - fclose(source); - fclose(target); - - return PX4_OK; -} - int check_free_space() { /* use statfs to determine the number of blocks left */ diff --git a/src/modules/sdlog2/sdlog2_messages.h b/src/modules/sdlog2/sdlog2_messages.h index 7f77a58e7b..1f1b979288 100644 --- a/src/modules/sdlog2/sdlog2_messages.h +++ b/src/modules/sdlog2/sdlog2_messages.h @@ -545,7 +545,7 @@ static const struct log_format_s log_formats[] = { LOG_FORMAT(GS0B, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"), LOG_FORMAT(GS1A, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"), LOG_FORMAT(GS1B, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"), - LOG_FORMAT(TECS, "ffffffffffffffB", "ASP,AF,FSP,F,AsSP,AsF,AsDSP,AsD,EE,EDE,ERE,EDRE,PtchI,ThrI,M"), + LOG_FORMAT(TECS, "ffffffffffffffB", "ASP,AF,FSP,F,AsSP,AsF,AsDSP,AsD,EE,ERE,EDE,EDRE,PtchI,ThrI,M"), LOG_FORMAT(WIND, "ffff", "X,Y,CovX,CovY"), LOG_FORMAT(ENCD, "qfqf", "cnt0,vel0,cnt1,vel1"), LOG_FORMAT(TSYN, "Q", "TimeOffset"), diff --git a/src/modules/segway/CMakeLists.txt b/src/modules/segway/CMakeLists.txt new file mode 100644 index 0000000000..6e9dd93bb2 --- /dev/null +++ b/src/modules/segway/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__segway + MAIN segway + SRCS + segway_main.cpp + BlockSegwayController.cpp + params.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/segway/module.mk b/src/modules/segway/module.mk deleted file mode 100644 index d5da856010..0000000000 --- a/src/modules/segway/module.mk +++ /dev/null @@ -1,42 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# segway controller -# - -MODULE_COMMAND = segway - -SRCS = segway_main.cpp \ - BlockSegwayController.cpp \ - params.c diff --git a/src/modules/sensors/CMakeLists.txt b/src/modules/sensors/CMakeLists.txt new file mode 100644 index 0000000000..e296ebe103 --- /dev/null +++ b/src/modules/sensors/CMakeLists.txt @@ -0,0 +1,46 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__sensors + MAIN sensors + PRIORITY "SCHED_PRIORITY_MAX-5" + STACK 1200 + COMPILE_FLAGS + -Wno-type-limits + -O3 + SRCS + sensors.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/sensors/module.mk b/src/modules/sensors/module.mk deleted file mode 100644 index d92ebc00eb..0000000000 --- a/src/modules/sensors/module.mk +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build the sensor data collector -# - -MODULE_COMMAND = sensors -MODULE_PRIORITY = "SCHED_PRIORITY_MAX-5" - -SRCS = sensors.cpp \ - sensor_params.c - -MODULE_STACKSIZE = 1200 - -MAXOPTIMIZATION = -Os - -EXTRACXXFLAGS = -Wno-type-limits diff --git a/src/modules/sensors/sensor_params.c b/src/modules/sensors/sensor_params.c index eba4d7077c..393cd63a06 100644 --- a/src/modules/sensors/sensor_params.c +++ b/src/modules/sensors/sensor_params.c @@ -585,6 +585,34 @@ PARAM_DEFINE_FLOAT(CAL_ACC2_YSCALE, 1.0f); */ PARAM_DEFINE_FLOAT(CAL_ACC2_ZSCALE, 1.0f); +/** + * Primary accel ID + * + * @group Sensor Calibration + */ +PARAM_DEFINE_INT32(CAL_ACC_PRIME, 0); + +/** + * Primary gyro ID + * + * @group Sensor Calibration + */ +PARAM_DEFINE_INT32(CAL_GYRO_PRIME, 0); + +/** + * Primary mag ID + * + * @group Sensor Calibration + */ +PARAM_DEFINE_INT32(CAL_MAG_PRIME, 0); + +/** + * Primary baro ID + * + * @group Sensor Calibration + */ +PARAM_DEFINE_INT32(CAL_BARO_PRIME, 0); + /** * Differential pressure sensor offset * @@ -1807,36 +1835,12 @@ PARAM_DEFINE_INT32(RC_DSM_BIND, -1); */ PARAM_DEFINE_INT32(BAT_V_SCALE_IO, 10000); -#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2 /** * Scaling factor for battery voltage sensor on FMU v2. * - * @board CONFIG_ARCH_BOARD_PX4FMU_V2 * @group Battery Calibration */ -PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.0082f); -#elif CONFIG_ARCH_BOARD_AEROCORE -/** - * Scaling factor for battery voltage sensor on AeroCore. - * - * For R70 = 133K, R71 = 10K --> scale = 1.8 * 143 / (4096*10) = 0.0063 - * - * @board CONFIG_ARCH_BOARD_AEROCORE - * @group Battery Calibration - */ -PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.0063f); -#else -/** - * Scaling factor for battery voltage sensor on FMU v1. - * - * FMUv1 standalone: 1/(10 / (47+10)) * (3.3 / 4095) = 0.00459340659 - * FMUv1 with PX4IO: 0.00459340659 - * FMUv1 with PX4IOAR: (3.3f * 52.0f / 5.0f / 4095.0f) = 0.00838095238 - * - * @group Battery Calibration - */ -PARAM_DEFINE_FLOAT(BAT_V_SCALING, 0.00459340659f); -#endif +PARAM_DEFINE_FLOAT(BAT_V_SCALING, -1.0f); /** * Scaling factor for battery current sensor. diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index 86df382df8..c14afb322f 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -212,7 +212,7 @@ private: unsigned _accel_count; /**< raw accel data count */ unsigned _mag_count; /**< raw mag data count */ unsigned _baro_count; /**< raw baro data count */ - + int _rc_sub; /**< raw rc channels data subscription */ int _diff_pres_sub; /**< raw differential pressure subscription */ int _vcontrol_mode_sub; /**< vehicle control mode subscription */ @@ -366,7 +366,7 @@ private: int init_sensor_class(const struct orb_metadata *meta, int *subs, - unsigned *priorities, unsigned *errcount); + uint32_t *priorities, uint32_t *errcount); /** * Update our local parameter cache. @@ -825,6 +825,19 @@ Sensors::parameters_update() /* scaling of ADC ticks to battery voltage */ if (param_get(_parameter_handles.battery_voltage_scaling, &(_parameters.battery_voltage_scaling)) != OK) { warnx("%s", paramerr); + } else if (_parameters.battery_voltage_scaling < 0.0f) { + /* apply scaling according to defaults if set to default */ + + #ifdef CONFIG_ARCH_BOARD_PX4FMU_V2 + _parameters.battery_voltage_scaling = 0.0082f; + #elif CONFIG_ARCH_BOARD_AEROCORE + _parameters.battery_voltage_scaling = 0.0063f; + #elif CONFIG_ARCH_BOARD_PX4FMU_V2 + _parameters.battery_voltage_scaling = 0.00459340659f; + #else + /* ensure a missing default trips a low voltage lockdown */ + _parameters.battery_voltage_scaling = 0.00001f; + #endif } /* scaling of ADC ticks to battery current */ @@ -1399,6 +1412,8 @@ Sensors::parameter_update_poll(bool forced) (void)sprintf(str, "CAL_MAG%u_ID", i); int device_id; failed = failed || (OK != param_get(param_find(str), &device_id)); + (void)sprintf(str, "CAL_MAG%u_ROT", i); + (void)param_find(str); if (failed) { px4_close(fd); @@ -1949,7 +1964,7 @@ Sensors::task_main_trampoline(int argc, char *argv[]) int Sensors::init_sensor_class(const struct orb_metadata *meta, int *subs, - unsigned *priorities, unsigned *errcount) + uint32_t *priorities, uint32_t *errcount) { unsigned group_count = orb_group_count(meta); @@ -1988,7 +2003,7 @@ Sensors::task_main() } while (0); if (ret) { - warnx("Sensor initialization failed"); + warnx("sensor initialization failed"); _sensors_task = -1; if (_fd_adc >=0) { px4_close(_fd_adc); @@ -2007,6 +2022,11 @@ Sensors::task_main() * do subscriptions */ + unsigned gcount_prev = _gyro_count; + unsigned mcount_prev = _mag_count; + unsigned acount_prev = _accel_count; + unsigned bcount_prev = _baro_count; + _gyro_count = init_sensor_class(ORB_ID(sensor_gyro), &_gyro_sub[0], &raw.gyro_priority[0], &raw.gyro_errcount[0]); @@ -2019,6 +2039,15 @@ Sensors::task_main() _baro_count = init_sensor_class(ORB_ID(sensor_baro), &_baro_sub[0], &raw.baro_priority[0], &raw.baro_errcount[0]); + if (gcount_prev != _gyro_count || + mcount_prev != _mag_count || + acount_prev != _accel_count || + bcount_prev != _baro_count) { + + /* reload calibration params */ + parameter_update_poll(true); + } + _rc_sub = orb_subscribe(ORB_ID(input_rc)); _diff_pres_sub = orb_subscribe(ORB_ID(differential_pressure)); _vcontrol_mode_sub = orb_subscribe(ORB_ID(vehicle_control_mode)); @@ -2068,6 +2097,8 @@ Sensors::task_main() raw.timestamp = 0; + uint64_t _last_config_update = hrt_absolute_time(); + while (!_task_should_exit) { /* wait for up to 50ms for data */ @@ -2077,7 +2108,7 @@ Sensors::task_main() /* this is undesirable but not much we can do - might want to flag unhappy status */ if (pret < 0) { - warn("poll error %d, %d", pret, errno); + warnx("poll error %d, %d", pret, errno); continue; } @@ -2086,21 +2117,6 @@ Sensors::task_main() /* check vehicle status for changes to publication state */ vehicle_control_mode_poll(); - /* keep adding sensors as long as we are not armed */ - if (!_armed) { - _gyro_count = init_sensor_class(ORB_ID(sensor_gyro), &_gyro_sub[0], - &raw.gyro_priority[0], &raw.gyro_errcount[0]); - - _mag_count = init_sensor_class(ORB_ID(sensor_mag), &_mag_sub[0], - &raw.magnetometer_priority[0], &raw.magnetometer_errcount[0]); - - _accel_count = init_sensor_class(ORB_ID(sensor_accel), &_accel_sub[0], - &raw.accelerometer_priority[0], &raw.accelerometer_errcount[0]); - - _baro_count = init_sensor_class(ORB_ID(sensor_baro), &_baro_sub[0], - &raw.baro_priority[0], &raw.baro_errcount[0]); - } - /* the timestamp of the raw struct is updated by the gyro_poll() method */ /* copy most recent sensor data */ gyro_poll(raw); @@ -2129,11 +2145,32 @@ Sensors::task_main() orb_publish(ORB_ID(sensor_combined), _sensor_pub, &raw); } - /* check parameters for updates */ - parameter_update_poll(); + /* keep adding sensors as long as we are not armed, + * when not adding sensors poll for param updates + */ + if (!_armed && hrt_elapsed_time(&_last_config_update) > 500 * 1000) { + _gyro_count = init_sensor_class(ORB_ID(sensor_gyro), &_gyro_sub[0], + &raw.gyro_priority[0], &raw.gyro_errcount[0]); - /* check rc parameter map for updates */ - rc_parameter_map_poll(); + _mag_count = init_sensor_class(ORB_ID(sensor_mag), &_mag_sub[0], + &raw.magnetometer_priority[0], &raw.magnetometer_errcount[0]); + + _accel_count = init_sensor_class(ORB_ID(sensor_accel), &_accel_sub[0], + &raw.accelerometer_priority[0], &raw.accelerometer_errcount[0]); + + _baro_count = init_sensor_class(ORB_ID(sensor_baro), &_baro_sub[0], + &raw.baro_priority[0], &raw.baro_errcount[0]); + + _last_config_update = hrt_absolute_time(); + + } else { + + /* check parameters for updates */ + parameter_update_poll(); + + /* check rc parameter map for updates */ + rc_parameter_map_poll(); + } /* Look for new r/c input data */ rc_poll(); @@ -2152,7 +2189,7 @@ Sensors::start() ASSERT(_sensors_task == -1); /* start the task */ - _sensors_task = px4_task_spawn_cmd("sensors_task", + _sensors_task = px4_task_spawn_cmd("sensors", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, 2000, diff --git a/src/modules/simulator/CMakeLists.txt b/src/modules/simulator/CMakeLists.txt new file mode 100644 index 0000000000..de452c5de4 --- /dev/null +++ b/src/modules/simulator/CMakeLists.txt @@ -0,0 +1,52 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +set(SIMULATOR_SRCS simulator.cpp) +if (NOT ${OS} STREQUAL "qurt") + list(APPEND SIMULATOR_SRCS + simulator_mavlink.cpp) +endif() + +px4_add_module( + MODULE modules__simulator + MAIN simulator + COMPILE_FLAGS + -Wno-attributes + -Wno-packed + -Wno-packed + SRCS + ${SIMULATOR_SRCS} + DEPENDS + platforms__common + ) + +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/simulator/module.mk b/src/modules/simulator/module.mk deleted file mode 100644 index 80f619477d..0000000000 --- a/src/modules/simulator/module.mk +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################ -# -# Copyright (c) 2015 MArk Charlebois. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build simulator -# - -MODULE_COMMAND = simulator - -SRCS = simulator.cpp - -ifneq ($(PX4_TARGET_OS), qurt) -SRCS += simulator_mavlink.cpp -endif - -INCLUDE_DIRS += $(MAVLINK_SRC)/include/mavlink - -EXTRACXXFLAGS = -Weffc++ -Wno-attributes -Wno-packed - -EXTRACFLAGS = -Wno-packed diff --git a/src/modules/simulator/simulator.cpp b/src/modules/simulator/simulator.cpp index 5d9e29be3a..1656a3451f 100644 --- a/src/modules/simulator/simulator.cpp +++ b/src/modules/simulator/simulator.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include "simulator.h" @@ -91,27 +91,33 @@ bool Simulator::getAirspeedSample(uint8_t *buf, int len) return _airspeed.copyData(buf, len); } -void Simulator::write_MPU_data(void *buf) { +void Simulator::write_MPU_data(void *buf) +{ _mpu.writeData(buf); } -void Simulator::write_accel_data(void *buf) { +void Simulator::write_accel_data(void *buf) +{ _accel.writeData(buf); } -void Simulator::write_mag_data(void *buf) { +void Simulator::write_mag_data(void *buf) +{ _mag.writeData(buf); } -void Simulator::write_baro_data(void *buf) { +void Simulator::write_baro_data(void *buf) +{ _baro.writeData(buf); } -void Simulator::write_gps_data(void *buf) { +void Simulator::write_gps_data(void *buf) +{ _gps.writeData(buf); } -void Simulator::write_airspeed_data(void *buf) { +void Simulator::write_airspeed_data(void *buf) +{ _airspeed.writeData(buf); } @@ -119,21 +125,23 @@ int Simulator::start(int argc, char *argv[]) { int ret = 0; _instance = new Simulator(); + if (_instance) { - PX4_INFO("Simulator started"); drv_led_start(); + if (argv[2][1] == 's') { _instance->initializeSensorData(); #ifndef __PX4_QURT // Update sensor data _instance->pollForMAVLinkMessages(false); #endif + } else { // Update sensor data _instance->pollForMAVLinkMessages(true); } - } - else { + + } else { PX4_WARN("Simulator creation failed"); ret = 1; } @@ -154,52 +162,54 @@ __END_DECLS extern "C" { -int simulator_main(int argc, char *argv[]) -{ - int ret = 0; - if (argc == 3 && strcmp(argv[1], "start") == 0) { - if (strcmp(argv[2], "-s") == 0 || strcmp(argv[2], "-p") == 0) { - if (g_sim_task >= 0) { - warnx("Simulator already started"); - return 0; - } - g_sim_task = px4_task_spawn_cmd("Simulator", - SCHED_DEFAULT, - SCHED_PRIORITY_MAX - 5, - 1500, - Simulator::start, - argv); + int simulator_main(int argc, char *argv[]) + { + int ret = 0; - // now wait for the command to complete - while(true) { - if (Simulator::getInstance() && Simulator::getInstance()->isInitialized()) { - break; - } else { - usleep(100000); + if (argc == 3 && strcmp(argv[1], "start") == 0) { + if (strcmp(argv[2], "-s") == 0 || strcmp(argv[2], "-p") == 0) { + if (g_sim_task >= 0) { + warnx("Simulator already started"); + return 0; } + + g_sim_task = px4_task_spawn_cmd("Simulator", + SCHED_DEFAULT, + SCHED_PRIORITY_MAX - 5, + 1500, + Simulator::start, + argv); + + // now wait for the command to complete + while (true) { + if (Simulator::getInstance() && Simulator::getInstance()->isInitialized()) { + break; + + } else { + usleep(100000); + } + } + + } else { + usage(); + ret = -EINVAL; } - } - else - { + + } else if (argc == 2 && strcmp(argv[1], "stop") == 0) { + if (g_sim_task < 0) { + PX4_WARN("Simulator not running"); + + } else { + px4_task_delete(g_sim_task); + g_sim_task = -1; + } + + } else { usage(); ret = -EINVAL; } - } - else if (argc == 2 && strcmp(argv[1], "stop") == 0) { - if (g_sim_task < 0) { - PX4_WARN("Simulator not running"); - } - else { - px4_task_delete(g_sim_task); - g_sim_task = -1; - } - } - else { - usage(); - ret = -EINVAL; + + return ret; } - return ret; -} - } diff --git a/src/modules/simulator/simulator.h b/src/modules/simulator/simulator.h index af4b8a746c..6f9c35bb95 100644 --- a/src/modules/simulator/simulator.h +++ b/src/modules/simulator/simulator.h @@ -38,7 +38,7 @@ #pragma once -#include +#include #include #include #include @@ -51,26 +51,28 @@ #include #include #include +#include #include #include -namespace simulator { +namespace simulator +{ // FIXME - what is the endianness of these on actual device? #pragma pack(push, 1) struct RawAccelData { - float temperature; - float x; - float y; - float z; + float temperature; + float x; + float y; + float z; }; #pragma pack(pop) #pragma pack(push, 1) struct RawMagData { - float temperature; - float x; - float y; - float z; + float temperature; + float x; + float y; + float z; }; #pragma pack(pop) @@ -103,29 +105,30 @@ struct RawAirspeedData { #pragma pack(push, 1) struct RawGPSData { - int32_t lat; - int32_t lon; - int32_t alt; - uint16_t eph; - uint16_t epv; - uint16_t vel; - int16_t vn; - int16_t ve; - int16_t vd; - uint16_t cog; - uint8_t fix_type; - uint8_t satellites_visible; + int32_t lat; + int32_t lon; + int32_t alt; + uint16_t eph; + uint16_t epv; + uint16_t vel; + int16_t vn; + int16_t ve; + int16_t vd; + uint16_t cog; + uint8_t fix_type; + uint8_t satellites_visible; }; #pragma pack(pop) -template class Report { +template class Report +{ public: Report(int readers) : _readidx(0), _max_readers(readers), _report_len(sizeof(RType)) { - sem_init(&_lock, 0, _max_readers); + px4_sem_init(&_lock, 0, _max_readers); } ~Report() {}; @@ -135,6 +138,7 @@ public: if (len != _report_len) { return false; } + read_lock(); memcpy(outbuf, &_buf[_readidx], _report_len); read_unlock(); @@ -149,23 +153,23 @@ public: } protected: - void read_lock() { sem_wait(&_lock); } - void read_unlock() { sem_post(&_lock); } + void read_lock() { px4_sem_wait(&_lock); } + void read_unlock() { px4_sem_post(&_lock); } void write_lock() { - for (int i=0; i<_max_readers; i++) { - sem_wait(&_lock); + for (int i = 0; i < _max_readers; i++) { + px4_sem_wait(&_lock); } } void write_unlock() { - for (int i=0; i<_max_readers; i++) { - sem_post(&_lock); + for (int i = 0; i < _max_readers; i++) { + px4_sem_post(&_lock); } } int _readidx; - sem_t _lock; + px4_sem_t _lock; const int _max_readers; const int _report_len; RType _buf[2]; @@ -173,7 +177,8 @@ protected: }; -class Simulator { +class Simulator +{ public: static Simulator *getInstance(); @@ -211,32 +216,32 @@ public: private: Simulator() : - _accel(1), - _mpu(1), - _baro(1), - _mag(1), - _gps(1), - _airspeed(1), - _accel_pub(nullptr), - _baro_pub(nullptr), - _gyro_pub(nullptr), - _mag_pub(nullptr), - _initialized(false) + _accel(1), + _mpu(1), + _baro(1), + _mag(1), + _gps(1), + _airspeed(1), + _accel_pub(nullptr), + _baro_pub(nullptr), + _gyro_pub(nullptr), + _mag_pub(nullptr), + _initialized(false) #ifndef __PX4_QURT - , - _rc_channels_pub(nullptr), - _actuator_outputs_sub(-1), - _vehicle_attitude_sub(-1), - _manual_sub(-1), - _vehicle_status_sub(-1), - _rc_input{}, - _actuators{}, - _attitude{}, - _manual{}, - _vehicle_status{} + , + _rc_channels_pub(nullptr), + _actuator_outputs_sub(-1), + _vehicle_attitude_sub(-1), + _manual_sub(-1), + _vehicle_status_sub(-1), + _rc_input{}, + _actuators{}, + _attitude{}, + _manual{}, + _vehicle_status{} #endif {} - ~Simulator() { _instance=NULL; } + ~Simulator() { _instance = NULL; } void initializeSensorData(); @@ -255,11 +260,13 @@ private: orb_advert_t _baro_pub; orb_advert_t _gyro_pub; orb_advert_t _mag_pub; + orb_advert_t _flow_pub; bool _initialized; // class methods int publish_sensor_topics(mavlink_hil_sensor_t *imu); + int publish_flow_topic(mavlink_hil_optical_flow_t *flow); #ifndef __PX4_QURT // uORB publisher handlers diff --git a/src/modules/simulator/simulator_mavlink.cpp b/src/modules/simulator/simulator_mavlink.cpp index ddbc79db76..a930d78c80 100644 --- a/src/modules/simulator/simulator_mavlink.cpp +++ b/src/modules/simulator/simulator_mavlink.cpp @@ -46,6 +46,14 @@ extern "C" __EXPORT hrt_abstime hrt_reset(void); #define UDP_PORT 14560 #define PIXHAWK_DEVICE "/dev/ttyACM0" +#ifndef B460800 +#define B460800 460800 +#endif + +#ifndef B921600 +#define B921600 921600 +#endif + #define PRESS_GROUND 101325.0f #define DENSITY 1.2041f #define GRAVITY 9.81f @@ -63,7 +71,8 @@ static socklen_t _addrlen = sizeof(_srcaddr); using namespace simulator; -void Simulator::pack_actuator_message(mavlink_hil_controls_t &actuator_msg) { +void Simulator::pack_actuator_message(mavlink_hil_controls_t &actuator_msg) +{ float out[8] = {}; const float pwm_center = (PWM_HIGHEST_MAX + PWM_LOWEST_MIN) / 2; @@ -88,6 +97,7 @@ void Simulator::pack_actuator_message(mavlink_hil_controls_t &actuator_msg) { out[i] = 0.0f; } } + } else { // convert back to range [-1, 1] for (unsigned i = 0; i < 8; i++) { @@ -114,29 +124,30 @@ void Simulator::pack_actuator_message(mavlink_hil_controls_t &actuator_msg) { actuator_msg.nav_mode = 0; } -void Simulator::send_controls() { +void Simulator::send_controls() +{ mavlink_hil_controls_t msg; pack_actuator_message(msg); - //PX4_WARN("Sending HIL_CONTROLS msg"); send_mavlink_message(MAVLINK_MSG_ID_HIL_CONTROLS, &msg, 200); } -static void fill_rc_input_msg(struct rc_input_values *rc, mavlink_rc_channels_t *rc_channels) { +static void fill_rc_input_msg(struct rc_input_values *rc, mavlink_rc_channels_t *rc_channels) +{ rc->timestamp_publication = hrt_absolute_time(); rc->timestamp_last_signal = hrt_absolute_time(); rc->channel_count = rc_channels->chancount; rc->rssi = rc_channels->rssi; -/* PX4_WARN("RC: %d, %d, %d, %d, %d, %d, %d, %d", - rc_channels->chan1_raw, - rc_channels->chan2_raw, - rc_channels->chan3_raw, - rc_channels->chan4_raw, - rc_channels->chan5_raw, - rc_channels->chan6_raw, - rc_channels->chan7_raw, - rc_channels->chan8_raw); -*/ + /* PX4_WARN("RC: %d, %d, %d, %d, %d, %d, %d, %d", + rc_channels->chan1_raw, + rc_channels->chan2_raw, + rc_channels->chan3_raw, + rc_channels->chan4_raw, + rc_channels->chan5_raw, + rc_channels->chan6_raw, + rc_channels->chan7_raw, + rc_channels->chan8_raw); + */ rc->values[0] = rc_channels->chan1_raw; rc->values[1] = rc_channels->chan2_raw; @@ -158,9 +169,10 @@ static void fill_rc_input_msg(struct rc_input_values *rc, mavlink_rc_channels_t rc->values[17] = rc_channels->chan18_raw; } -void Simulator::update_sensors(mavlink_hil_sensor_t *imu) { +void Simulator::update_sensors(mavlink_hil_sensor_t *imu) +{ // write sensor data to memory so that drivers can copy data from there - RawMPUData mpu; + RawMPUData mpu = {}; mpu.accel_x = imu->xacc; mpu.accel_y = imu->yacc; mpu.accel_z = imu->zacc; @@ -171,21 +183,21 @@ void Simulator::update_sensors(mavlink_hil_sensor_t *imu) { write_MPU_data((void *)&mpu); - RawAccelData accel; + RawAccelData accel = {}; accel.x = imu->xacc; accel.y = imu->yacc; accel.z = imu->zacc; write_accel_data((void *)&accel); - RawMagData mag; + RawMagData mag = {}; mag.x = imu->xmag; mag.y = imu->ymag; mag.z = imu->zmag; write_mag_data((void *)&mag); - RawBaroData baro; + RawBaroData baro = {}; // calculate air pressure from altitude (valid for low altitude) baro.pressure = (PRESS_GROUND - GRAVITY * DENSITY * imu->pressure_alt) / 100.0f; // convert from Pa to mbar baro.altitude = imu->pressure_alt; @@ -193,18 +205,19 @@ void Simulator::update_sensors(mavlink_hil_sensor_t *imu) { write_baro_data((void *)&baro); - RawAirspeedData airspeed; + RawAirspeedData airspeed = {}; airspeed.temperature = imu->temperature; airspeed.diff_pressure = imu->diff_pressure; write_airspeed_data((void *)&airspeed); } -void Simulator::update_gps(mavlink_hil_gps_t *gps_sim) { +void Simulator::update_gps(mavlink_hil_gps_t *gps_sim) +{ RawGPSData gps; - gps.lat = gps_sim->lat; - gps.lon = gps_sim->lon; - gps.alt = gps_sim->alt; + gps.lat = gps_sim->lat; + gps.lon = gps_sim->lon; + gps.alt = gps_sim->alt; gps.eph = gps_sim->eph; gps.epv = gps_sim->epv; gps.vel = gps_sim->vel; @@ -218,23 +231,34 @@ void Simulator::update_gps(mavlink_hil_gps_t *gps_sim) { write_gps_data((void *)&gps); } -void Simulator::handle_message(mavlink_message_t *msg, bool publish) { - switch(msg->msgid) { +void Simulator::handle_message(mavlink_message_t *msg, bool publish) +{ + switch (msg->msgid) { case MAVLINK_MSG_ID_HIL_SENSOR: mavlink_hil_sensor_t imu; mavlink_msg_hil_sensor_decode(msg, &imu); + if (publish) { publish_sensor_topics(&imu); } + update_sensors(&imu); break; + case MAVLINK_MSG_ID_HIL_OPTICAL_FLOW: + mavlink_hil_optical_flow_t flow; + mavlink_msg_hil_optical_flow_decode(msg, &flow); + publish_flow_topic(&flow); + break; + case MAVLINK_MSG_ID_HIL_GPS: mavlink_hil_gps_t gps_sim; mavlink_msg_hil_gps_decode(msg, &gps_sim); + if (publish) { //PX4_WARN("FIXME: Need to publish GPS topic. Not done yet."); } + update_gps(&gps_sim); break; @@ -245,17 +269,20 @@ void Simulator::handle_message(mavlink_message_t *msg, bool publish) { // publish message if (publish) { - if(_rc_channels_pub == nullptr) { + if (_rc_channels_pub == nullptr) { _rc_channels_pub = orb_advertise(ORB_ID(input_rc), &_rc_input); + } else { orb_publish(ORB_ID(input_rc), _rc_channels_pub, &_rc_input); } } + break; } } -void Simulator::send_mavlink_message(const uint8_t msgid, const void *msg, uint8_t component_ID) { +void Simulator::send_mavlink_message(const uint8_t msgid, const void *msg, uint8_t component_ID) +{ component_ID = 0; uint8_t payload_len = mavlink_message_lengths[msgid]; unsigned packet_len = payload_len + MAVLINK_NUM_NON_PAYLOAD_BYTES; @@ -272,7 +299,7 @@ void Simulator::send_mavlink_message(const uint8_t msgid, const void *msg, uint8 buf[5] = msgid; /* payload */ - memcpy(&buf[MAVLINK_NUM_HEADER_BYTES],msg, payload_len); + memcpy(&buf[MAVLINK_NUM_HEADER_BYTES], msg, payload_len); /* checksum */ uint16_t checksum; @@ -284,44 +311,51 @@ void Simulator::send_mavlink_message(const uint8_t msgid, const void *msg, uint8 buf[MAVLINK_NUM_HEADER_BYTES + payload_len + 1] = (uint8_t)(checksum >> 8); ssize_t len = sendto(_fd, buf, packet_len, 0, (struct sockaddr *)&_srcaddr, _addrlen); + if (len <= 0) { PX4_WARN("Failed sending mavlink message"); } } -void Simulator::poll_topics() { +void Simulator::poll_topics() +{ // copy new actuator data if available bool updated; orb_check(_actuator_outputs_sub, &updated); + if (updated) { orb_copy(ORB_ID(actuator_outputs), _actuator_outputs_sub, &_actuators); } orb_check(_vehicle_status_sub, &updated); + if (updated) { orb_copy(ORB_ID(vehicle_status), _vehicle_status_sub, &_vehicle_status); } } -void *Simulator::sending_trampoline(void *) { +void *Simulator::sending_trampoline(void *) +{ _instance->send(); return 0; // why do I have to put this??? } -void Simulator::send() { +void Simulator::send() +{ px4_pollfd_struct_t fds[1]; fds[0].fd = _actuator_outputs_sub; fds[0].events = POLLIN; int pret; - while(true) { + while (true) { // wait for up to 100ms for data pret = px4_poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 100); - //timed out - if (pret == 0) + // timed out + if (pret == 0) { continue; + } // this is undesirable but not much we can do if (pret < 0) { @@ -341,23 +375,35 @@ void Simulator::send() { void Simulator::initializeSensorData() { - struct baro_report baro; - memset(&baro,0,sizeof(baro)); - baro.pressure = 120000.0f; + // write sensor data to memory so that drivers can copy data from there + RawMPUData mpu = {}; + mpu.accel_z = 9.81f; - // acceleration report - struct accel_report accel; - memset(&accel,0,sizeof(accel)); + write_MPU_data((void *)&mpu); + + RawAccelData accel = {}; accel.z = 9.81f; - accel.range_m_s2 = 80.0f; - // gyro report - struct gyro_report gyro; - memset(&gyro, 0 ,sizeof(gyro)); + write_accel_data((void *)&accel); - // mag report - struct mag_report mag; - memset(&mag, 0 ,sizeof(mag)); + RawMagData mag = {}; + mag.x = 0.4f; + mag.y = 0.0f; + mag.z = 0.6f; + + write_mag_data((void *)&mag); + + RawBaroData baro = {}; + // calculate air pressure from altitude (valid for low altitude) + baro.pressure = 120000.0f; + baro.altitude = 0.0f; + baro.temperature = 25.0f; + + write_baro_data((void *)&baro); + + RawAirspeedData airspeed {}; + + write_airspeed_data((void *)&airspeed); } void Simulator::pollForMAVLinkMessages(bool publish) @@ -401,42 +447,51 @@ void Simulator::pollForMAVLinkMessages(bool publish) int serial_fd = openUart(PIXHAWK_DEVICE, 115200); if (serial_fd < 0) { - PX4_WARN("failed to open %s", PIXHAWK_DEVICE); - } + PX4_INFO("Not using %s for radio control input. Assuming joystick input via MAVLink.", PIXHAWK_DEVICE); - // tell the device to stream some messages - char command[] = "\nsh /etc/init.d/rc.usb\n"; - int w = ::write(serial_fd, command, sizeof(command)); + } else { - if (w <= 0) { - PX4_WARN("failed to send streaming command to %s", PIXHAWK_DEVICE); + // tell the device to stream some messages + char command[] = "\nsh /etc/init.d/rc.usb\n"; + int w = ::write(serial_fd, command, sizeof(command)); + + if (w <= 0) { + PX4_WARN("failed to send streaming command to %s", PIXHAWK_DEVICE); + } } char serial_buf[1024]; struct pollfd fds[2]; + unsigned fd_count = 1; fds[0].fd = _fd; fds[0].events = POLLIN; - fds[1].fd = serial_fd; - fds[1].events = POLLIN; + + if (serial_fd >= 0) { + fds[1].fd = serial_fd; + fds[1].events = POLLIN; + fd_count++; + } int len = 0; // wait for first data from simulator and respond with first controls // this is important for the UDP communication to work int pret = -1; - PX4_WARN("Waiting for initial data on UDP.. Please connect the simulator first."); + PX4_INFO("Waiting for initial data on UDP. Please start the flight simulator to proceed.."); + while (pret <= 0) { - pret = ::poll(&fds[0], (sizeof(fds[0])/sizeof(fds[0])), 100); + pret = ::poll(&fds[0], (sizeof(fds[0]) / sizeof(fds[0])), 100); } - PX4_WARN("Found initial message, pret = %d",pret); + + PX4_INFO("Found initial message, pret = %d", pret); _initialized = true; // reset system time (void)hrt_reset(); if (fds[0].revents & POLLIN) { len = recvfrom(_fd, _buf, sizeof(_buf), 0, (struct sockaddr *)&_srcaddr, &_addrlen); - PX4_WARN("Sending initial controls message to jMAVSim."); + PX4_INFO("Sending initial controls message to jMAVSim."); send_controls(); } @@ -451,11 +506,12 @@ void Simulator::pollForMAVLinkMessages(bool publish) // wait for new mavlink messages to arrive while (true) { - pret = ::poll(&fds[0], (sizeof(fds)/sizeof(fds[0])), 100); + pret = ::poll(&fds[0], fd_count, 100); //timed out - if (pret == 0) + if (pret == 0) { continue; + } // this is undesirable but not much we can do if (pret < 0) { @@ -468,13 +524,13 @@ void Simulator::pollForMAVLinkMessages(bool publish) // got data from simulator if (fds[0].revents & POLLIN) { len = recvfrom(_fd, _buf, sizeof(_buf), 0, (struct sockaddr *)&_srcaddr, &_addrlen); + if (len > 0) { mavlink_message_t msg; mavlink_status_t status; - for (int i = 0; i < len; ++i) - { - if (mavlink_parse_char(MAVLINK_COMM_0, _buf[i], &msg, &status)) - { + + for (int i = 0; i < len; ++i) { + if (mavlink_parse_char(MAVLINK_COMM_0, _buf[i], &msg, &status)) { // have a message, handle it handle_message(&msg, publish); } @@ -485,15 +541,15 @@ void Simulator::pollForMAVLinkMessages(bool publish) // got data from PIXHAWK if (fds[1].revents & POLLIN) { len = ::read(serial_fd, serial_buf, sizeof(serial_buf)); + if (len > 0) { mavlink_message_t msg; mavlink_status_t status; - for (int i = 0; i < len; ++i) - { - if (mavlink_parse_char(MAVLINK_COMM_0, serial_buf[i], &msg, &status)) - { + + for (int i = 0; i < len; ++i) { + if (mavlink_parse_char(MAVLINK_COMM_0, serial_buf[i], &msg, &status)) { // have a message, handle it - handle_message(&msg, publish); + handle_message(&msg, true); } } } @@ -603,15 +659,17 @@ int openUart(const char *uart_name, int baud) return uart_fd; } -int Simulator::publish_sensor_topics(mavlink_hil_sensor_t *imu) { +int Simulator::publish_sensor_topics(mavlink_hil_sensor_t *imu) +{ - //uint64_t timestamp = imu->time_usec; - uint64_t timestamp = hrt_absolute_time(); + //uint64_t timestamp = imu->time_usec; + uint64_t timestamp = hrt_absolute_time(); + + if ((imu->fields_updated & 0x1FFF) != 0x1FFF) { + PX4_DEBUG("All sensor fields in mavlink HIL_SENSOR packet not updated. Got %08x", imu->fields_updated); + } - if((imu->fields_updated & 0x1FFF)!=0x1FFF) { - PX4_DEBUG("All sensor fields in mavlink HIL_SENSOR packet not updated. Got %08x",imu->fields_updated); - } /* static int count=0; static uint64_t last_timestamp=0; @@ -708,5 +766,40 @@ int Simulator::publish_sensor_topics(mavlink_hil_sensor_t *imu) { } } - return OK; + return OK; +} + +int Simulator::publish_flow_topic(mavlink_hil_optical_flow_t* flow_mavlink) +{ + uint64_t timestamp = hrt_absolute_time(); + + /* flow */ + { + struct optical_flow_s flow; + memset(&flow, 0, sizeof(flow)); + + flow.sensor_id = flow_mavlink->sensor_id; + flow.timestamp = timestamp; + flow.time_since_last_sonar_update = 0; + flow.frame_count_since_last_readout = 0; // ? + flow.integration_timespan = flow_mavlink->integration_time_us; + + flow.ground_distance_m = flow_mavlink->distance; + flow.gyro_temperature = flow_mavlink->temperature; + flow.gyro_x_rate_integral = flow_mavlink->integrated_xgyro; + flow.gyro_y_rate_integral = flow_mavlink->integrated_ygyro; + flow.gyro_z_rate_integral = flow_mavlink->integrated_zgyro; + flow.pixel_flow_x_integral = flow_mavlink->integrated_x; + flow.pixel_flow_x_integral = flow_mavlink->integrated_y; + flow.quality = flow_mavlink->quality; + + if (_flow_pub == nullptr) { + _flow_pub = orb_advertise(ORB_ID(optical_flow), &flow); + + } else { + orb_publish(ORB_ID(optical_flow), _flow_pub, &flow); + } + } + + return OK; } diff --git a/src/drivers/trone/module.mk b/src/modules/systemlib/CMakeLists.txt similarity index 67% rename from src/drivers/trone/module.mk rename to src/modules/systemlib/CMakeLists.txt index 38499c6c3e..59485fe494 100644 --- a/src/drivers/trone/module.mk +++ b/src/modules/systemlib/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2014 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,14 +31,52 @@ # ############################################################################ -# -# Makefile to build the TeraRanger One range finder driver -# +# for generated files +include_directories(${CMAKE_BINARY_DIR}/src/modules/param) -MODULE_COMMAND = trone +set(SRCS + perf_counter.c + param/param.c + conversions.c + cpuload.c + pid/pid.c + airspeed.c + mavlink_log.c + rc_check.c + otp.c + board_serial.c + pwm_limit/pwm_limit.c + mcu_version.c + bson/tinybson.c + circuit_breaker.cpp + ) -SRCS = trone.cpp +if(${OS} STREQUAL "nuttx") + list(APPEND SRCS + err.c + printload.c + up_cxxinitialize.c + ) +else() + list(APPEND SRCS + print_load_posix.c + ) +endif() -MODULE_STACKSIZE = 1200 +if(NOT ${OS} STREQUAL "qurt") + list(APPEND SRCS + hx_stream.c + ) +endif() -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE modules__systemlib + COMPILE_FLAGS + -Wno-sign-compare + -Os + SRCS ${SRCS} + DEPENDS + platforms__common + modules__param + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/systemlib/circuit_breaker_params.c b/src/modules/systemlib/circuit_breaker_params.c index 20b9638d6a..36b35246db 100644 --- a/src/modules/systemlib/circuit_breaker_params.c +++ b/src/modules/systemlib/circuit_breaker_params.c @@ -42,8 +42,6 @@ * parameter needs to set to the key (magic). */ -#include - /** * Circuit breaker for power supply check * diff --git a/src/modules/systemlib/err.c b/src/modules/systemlib/err.c index 0011bca206..b7b6f0a9c3 100644 --- a/src/modules/systemlib/err.c +++ b/src/modules/systemlib/err.c @@ -40,6 +40,9 @@ #include +#define __STDC_FORMAT_MACROS +#include + #include #include #include diff --git a/src/modules/systemlib/mcu_version.c b/src/modules/systemlib/mcu_version.c index e4623c2ce0..be614f7d7a 100644 --- a/src/modules/systemlib/mcu_version.c +++ b/src/modules/systemlib/mcu_version.c @@ -62,7 +62,7 @@ /** Copy the 96bit MCU Unique ID into the provided pointer */ void mcu_unique_id(uint32_t *uid_96_bit) { -#ifdef __PX4_NUTTX +#ifdef CONFIG_ARCH_CHIP_STM32 uid_96_bit[0] = getreg32(UNIQUE_ID); uid_96_bit[1] = getreg32(UNIQUE_ID + 4); uid_96_bit[2] = getreg32(UNIQUE_ID + 8); diff --git a/src/drivers/md25/module.mk b/src/modules/systemlib/mixer/CMakeLists.txt similarity index 73% rename from src/drivers/md25/module.mk rename to src/modules/systemlib/mixer/CMakeLists.txt index 3f9cf2d891..20187eb97f 100644 --- a/src/drivers/md25/module.mk +++ b/src/modules/systemlib/mixer/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,14 +31,25 @@ # ############################################################################ -# -# MD25 I2C Based Motor Controller -# http://www.robot-electronics.co.uk/htm/md25tech.htm -# +include_directories(${CMAKE_CURRENT_BINARY_DIR}) -MODULE_COMMAND = md25 +add_custom_command(OUTPUT mixer_multirotor.generated.h + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/multi_tables.py + > mixer_multirotor.generated.h) -SRCS = md25.cpp \ - md25_main.cpp +add_custom_target(mixer_gen + DEPENDS mixer_multirotor.generated.h) -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE modules__systemlib__mixer + SRCS + mixer.cpp + mixer_group.cpp + mixer_multirotor.cpp + mixer_simple.cpp + mixer_load.c + mixer_multirotor.generated.h + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/systemlib/module.mk b/src/modules/systemlib/module.mk deleted file mode 100644 index 3232adf3e7..0000000000 --- a/src/modules/systemlib/module.mk +++ /dev/null @@ -1,70 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# System utility library -# - -SRCS = \ - perf_counter.c \ - param/param.c \ - conversions.c \ - cpuload.c \ - pid/pid.c \ - airspeed.c \ - system_params.c \ - mavlink_log.c \ - rc_check.c \ - otp.c \ - board_serial.c \ - pwm_limit/pwm_limit.c \ - mcu_version.c \ - bson/tinybson.c \ - circuit_breaker.cpp \ - circuit_breaker_params.c - -ifeq ($(PX4_TARGET_OS),nuttx) -SRCS += err.c \ - printload.c \ - up_cxxinitialize.c -else -SRCS += print_load_posix.c -endif - -ifneq ($(PX4_TARGET_OS),qurt) -SRCS += hx_stream.c -endif - -MAXOPTIMIZATION = -Os - -EXTRACFLAGS = -Wno-sign-compare diff --git a/src/modules/systemlib/param/param.c b/src/modules/systemlib/param/param.c index c85e8dbda8..f606f20702 100644 --- a/src/modules/systemlib/param/param.c +++ b/src/modules/systemlib/param/param.c @@ -63,6 +63,9 @@ #include "uORB/uORB.h" #include "uORB/topics/parameter_update.h" +#include "px4_parameters.h" + +#include #if 0 # define debug(fmt, args...) do { warnx(fmt, ##args); } while(0) @@ -86,12 +89,11 @@ extern struct param_info_s param_array[]; extern struct param_info_s *param_info_base; extern struct param_info_s *param_info_limit; #else -extern char __param_start, __param_end; -static const struct param_info_s *param_info_base = (struct param_info_s *) &__param_start; -static const struct param_info_s *param_info_limit = (struct param_info_s *) &__param_end; +// FIXME - start and end are reversed +static const struct param_info_s *param_info_base = (const struct param_info_s *) &px4_parameters; #endif -#define param_info_count ((unsigned)(param_info_limit - param_info_base)) +#define param_info_count px4_parameters.param_count /** * Storage for modified parameters. @@ -147,14 +149,14 @@ static param_t param_find_internal(const char *name, bool notification); static void param_lock(void) { - //do {} while (sem_wait(¶m_sem) != 0); + //do {} while (px4_sem_wait(¶m_sem) != 0); } /** unlock the parameter store */ static void param_unlock(void) { - //sem_post(¶m_sem); + //px4_sem_post(¶m_sem); } /** assert that the parameter store is locked */ @@ -1035,3 +1037,26 @@ param_foreach(void (*func)(void *arg, param_t param), void *arg, bool only_chang func(arg, param); } } + +uint32_t param_hash_check(void) +{ + uint32_t param_hash = 0; + + param_lock(); + + /* compute the CRC32 over all string param names and 4 byte values */ + for (param_t param = 0; handle_in_range(param); param++) { + if (!param_used(param)) { + continue; + } + + const char *name = param_name(param); + const void *val = param_get_value_ptr(param); + param_hash = crc32part((const uint8_t *)name, strlen(name), param_hash); + param_hash = crc32part(val, sizeof(union param_value_u), param_hash); + } + + param_unlock(); + + return param_hash; +} diff --git a/src/modules/systemlib/param/param.h b/src/modules/systemlib/param/param.h index caa0635dce..f8334361f1 100644 --- a/src/modules/systemlib/param/param.h +++ b/src/modules/systemlib/param/param.h @@ -333,6 +333,13 @@ __EXPORT int param_save_default(void); */ __EXPORT int param_load_default(void); +/** + * Generate the hash of all parameters and their values + * + * @return CRC32 hash of all param_ids and values + */ +__EXPORT uint32_t param_hash_check(void); + /* * Macros creating static parameter definitions. * @@ -346,34 +353,13 @@ __EXPORT int param_load_default(void); */ /** define an int32 parameter */ -#define PARAM_DEFINE_INT32(_name, _default) \ - static const \ - __attribute__((used, section("__param"))) \ - struct param_info_s __param__##_name = { \ - #_name, \ - PARAM_TYPE_INT32, \ - .val.i = _default \ - } +#define PARAM_DEFINE_INT32(_name, _default) /** define a float parameter */ -#define PARAM_DEFINE_FLOAT(_name, _default) \ - static const \ - __attribute__((used, section("__param"))) \ - struct param_info_s __param__##_name = { \ - #_name, \ - PARAM_TYPE_FLOAT, \ - .val.f = _default \ - } +#define PARAM_DEFINE_FLOAT(_name, _default) /** define a parameter that points to a structure */ -#define PARAM_DEFINE_STRUCT(_name, _default) \ - static const \ - __attribute__((used, section("__param"))) \ - struct param_info_s __param__##_name = { \ - #_name, \ - PARAM_TYPE_STRUCT + sizeof(_default), \ - .val.p = &_default \ - } +#define PARAM_DEFINE_STRUCT(_name, _default) /** * Parameter value union. diff --git a/src/modules/systemlib/perf_counter.c b/src/modules/systemlib/perf_counter.c index 8ec9b1a444..a9d9db9748 100644 --- a/src/modules/systemlib/perf_counter.c +++ b/src/modules/systemlib/perf_counter.c @@ -47,6 +47,9 @@ #ifdef __PX4_QURT #define dprintf(...) +#define ddeclare(...) +#else +#define ddeclare(...) __VA_ARGS__ #endif /** @@ -417,8 +420,8 @@ perf_print_counter_fd(int fd, perf_counter_t handle) break; case PC_ELAPSED: { - struct perf_ctr_elapsed *pce = (struct perf_ctr_elapsed *)handle; - float rms = sqrtf(pce->M2 / (pce->event_count - 1)); + ddeclare(struct perf_ctr_elapsed *pce = (struct perf_ctr_elapsed *)handle;) + ddeclare(float rms = sqrtf(pce->M2 / (pce->event_count - 1));) dprintf(fd, "%s: %llu events, %llu overruns, %lluus elapsed, %lluus avg, min %lluus max %lluus %5.3fus rms\n", handle->name, (unsigned long long)pce->event_count, @@ -432,8 +435,8 @@ perf_print_counter_fd(int fd, perf_counter_t handle) } case PC_INTERVAL: { - struct perf_ctr_interval *pci = (struct perf_ctr_interval *)handle; - float rms = sqrtf(pci->M2 / (pci->event_count - 1)); + ddeclare(struct perf_ctr_interval *pci = (struct perf_ctr_interval *)handle;) + ddeclare(float rms = sqrtf(pci->M2 / (pci->event_count - 1));) dprintf(fd, "%s: %llu events, %lluus avg, min %lluus max %lluus %5.3fus rms\n", handle->name, diff --git a/src/modules/systemlib/printload.c b/src/modules/systemlib/printload.c index 23dde1ce44..a179ddc51b 100644 --- a/src/modules/systemlib/printload.c +++ b/src/modules/systemlib/printload.c @@ -261,7 +261,11 @@ void print_load(uint64_t t, int fd, struct print_load_s *print_state) stack_size - stack_free, stack_size, system_load.tasks[i].tcb->sched_priority, +#if CONFIG_ARCH_BOARD_SIM + 0); +#else system_load.tasks[i].tcb->base_priority); +#endif #if CONFIG_RR_INTERVAL > 0 /* print scheduling info with RR time slice */ diff --git a/src/modules/systemlib/system_params.c b/src/modules/systemlib/system_params.c index a1632e53c9..8170e17bd1 100644 --- a/src/modules/systemlib/system_params.c +++ b/src/modules/systemlib/system_params.c @@ -37,9 +37,6 @@ * System wide parameters */ -#include -#include - /** * Auto-start script index. * diff --git a/src/modules/systemlib/uthash/uthash.h b/src/modules/systemlib/uthash/uthash.h index 9f83fc34f1..a8642833f6 100644 --- a/src/modules/systemlib/uthash/uthash.h +++ b/src/modules/systemlib/uthash/uthash.h @@ -61,6 +61,7 @@ do { typedef unsigned int uint32_t; typedef unsigned char uint8_t; #else +#define __STDC_FORMAT_MACROS #include /* uint32_t */ #endif diff --git a/src/modules/uORB/CMakeLists.txt b/src/modules/uORB/CMakeLists.txt new file mode 100644 index 0000000000..840b1307ae --- /dev/null +++ b/src/modules/uORB/CMakeLists.txt @@ -0,0 +1,83 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# this includes the generated topics directory +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ) + +set(SRCS + objects_common.cpp + uORBUtils.cpp + uORB.cpp + uORBMain.cpp + Publication.cpp + Subscription.cpp + ) + +if(${OS} STREQUAL "nuttx") + list(APPEND SRCS + uORBDevices_nuttx.cpp + uORBTest_UnitTest.cpp + uORBManager_nuttx.cpp + ) +elseif(${OS} STREQUAL "posix") + list(APPEND SRCS + uORBDevices_posix.cpp + uORBManager_posix.cpp + uORBTest_UnitTest.cpp + ) +elseif(${OS} STREQUAL "posix-arm") + list(APPEND SRCS + uORBDevices_posix.cpp + uORBManager_posix.cpp + uORBTest_UnitTest.cpp + ) +elseif(${OS} STREQUAL "qurt") + list(APPEND SRCS + uORBDevices_posix.cpp + uORBManager_posix.cpp + ) +endif() + +px4_add_module( + MODULE modules__uORB + MAIN uorb + STACK 2048 + COMPILE_FLAGS + -Os + SRCS ${SRCS} + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/uORB/module.mk b/src/modules/uORB/module.mk deleted file mode 100644 index b483c00a80..0000000000 --- a/src/modules/uORB/module.mk +++ /dev/null @@ -1,66 +0,0 @@ -############################################################################ -# -# Copyright (c) 2012-2015 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build uORB -# - -MODULE_COMMAND = uorb - -MODULE_STACKSIZE = 2048 - -ifeq ($(PX4_TARGET_OS),nuttx) -SRCS = uORBDevices_nuttx.cpp \ - uORBTest_UnitTest.cpp \ - uORBManager_nuttx.cpp - -else -SRCS = uORBDevices_posix.cpp \ - uORBManager_posix.cpp -endif - -ifeq ($(PX4_TARGET_OS),posix) -SRCS += uORBTest_UnitTest.cpp -endif -ifeq ($(PX4_TARGET_OS),posix-arm) -SRCS += uORBTest_UnitTest.cpp -endif - -SRCS += objects_common.cpp \ - uORBUtils.cpp \ - uORB.cpp \ - uORBMain.cpp \ - Publication.cpp \ - Subscription.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/modules/uORB/uORB.h b/src/modules/uORB/uORB.h index c887925fcf..6ead26186b 100644 --- a/src/modules/uORB/uORB.h +++ b/src/modules/uORB/uORB.h @@ -89,20 +89,14 @@ enum ORB_PRIO { /** * Declare (prototype) the uORB metadata for a topic. * - * Note that optional topics are declared weak; this allows a potential - * subscriber to attempt to subscribe to a topic that is not known to the - * system at runtime. The ORB_ID() macro will return NULL/nullptr for - * such a topic, and attempts to advertise or subscribe to it will - * return -1/ENOENT (see below). - * * @param _name The name of the topic. */ #if defined(__cplusplus) # define ORB_DECLARE(_name) extern "C" const struct orb_metadata __orb_##_name __EXPORT -# define ORB_DECLARE_OPTIONAL(_name) extern "C" const struct orb_metadata __orb_##_name __EXPORT __attribute__((weak)) +# define ORB_DECLARE_OPTIONAL(_name) extern "C" const struct orb_metadata __orb_##_name __EXPORT #else # define ORB_DECLARE(_name) extern const struct orb_metadata __orb_##_name __EXPORT -# define ORB_DECLARE_OPTIONAL(_name) extern const struct orb_metadata __orb_##_name __EXPORT __attribute__((weak)) +# define ORB_DECLARE_OPTIONAL(_name) extern const struct orb_metadata __orb_##_name __EXPORT #endif /** diff --git a/src/modules/mavlink/mavlink_tests/module.mk b/src/modules/uavcan/CMakeLists.txt similarity index 55% rename from src/modules/mavlink/mavlink_tests/module.mk rename to src/modules/uavcan/CMakeLists.txt index e104860937..b8c899840a 100644 --- a/src/modules/mavlink/mavlink_tests/module.mk +++ b/src/modules/uavcan/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2014 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,23 +31,57 @@ # ############################################################################ -# -# System state machine tests. -# +set(UAVCAN_USE_CPP03 ON CACHE BOOL "uavcan cpp03") +set(UAVCAN_PLATFORM stm32 CACHE STRING "uavcan platform") -MODULE_COMMAND = mavlink_tests -SRCS = mavlink_tests.cpp \ - mavlink_ftp_test.cpp \ - ../mavlink_stream.cpp \ - ../mavlink_ftp.cpp \ - ../mavlink.c +string(TOUPPER "${OS}" OS_UPPER) +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_USE_EXTERNAL_SNPRINT + ) -INCLUDE_DIRS += $(MAVLINK_SRC)/include/mavlink +add_subdirectory(libuavcan EXCLUDE_FROM_ALL) +add_dependencies(uavcan platforms__nuttx) -MODULE_STACKSIZE = 5000 +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) -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE modules__uavcan + MAIN uavcan + STACK 3200 + COMPILE_FLAGS + -Wframe-larger-than=1500 + -Wno-deprecated-declarations + -Os + SRCS + # Main + uavcan_main.cpp + uavcan_servers.cpp + uavcan_params.c -EXTRACXXFLAGS = -Weffc++ -DMAVLINK_FTP_UNIT_TEST -Wno-attributes -Wno-packed + # Actuators + actuators/esc.cpp -EXTRACFLAGS = -Wno-packed + # Sensors + sensors/sensor_bridge.cpp + sensors/gnss.cpp + sensors/mag.cpp + sensors/baro.cpp + + DEPENDS + platforms__common + 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 diff --git a/src/modules/uavcan/module.mk b/src/modules/uavcan/module.mk deleted file mode 100644 index da62e55634..0000000000 --- a/src/modules/uavcan/module.mk +++ /dev/null @@ -1,94 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. -# Author: Pavel Kirienko -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# UAVCAN <--> uORB bridge -# - -MODULE_COMMAND = uavcan - -MAXOPTIMIZATION = -O3 -MODULE_STACKSIZE = 3200 -WFRAME_LARGER_THAN = 1400 - -# Main -SRCS += uavcan_main.cpp \ - uavcan_servers.cpp \ - uavcan_clock.cpp \ - uavcan_params.c - -# Actuators -SRCS += actuators/esc.cpp - -# Sensors -SRCS += sensors/sensor_bridge.cpp \ - sensors/gnss.cpp \ - sensors/mag.cpp \ - sensors/baro.cpp - -# -# libuavcan -# -include $(PX4_LIB_DIR)uavcan/libuavcan/include.mk -# Use the relitive path to keep the genrated files in the BUILD_DIR -SRCS += $(subst $(PX4_MODULE_SRC),../../,$(LIBUAVCAN_SRC)) -INCLUDE_DIRS += $(LIBUAVCAN_INC) -# Since actual compiler mode is C++11, the library will default to UAVCAN_CPP11, but it will fail to compile -# because this platform lacks most of the standard library and STL. Hence we need to force C++03 mode. -override EXTRADEFINES := $(EXTRADEFINES) \ --DUAVCAN_CPP_VERSION=UAVCAN_CPP03 \ --DUAVCAN_NO_ASSERTIONS \ --DUAVCAN_MEM_POOL_BLOCK_SIZE=48 \ --DUAVCAN_MAX_NETWORK_SIZE_HINT=16 - -# -# libuavcan drivers for STM32 -# -include $(PX4_LIB_DIR)uavcan/libuavcan_drivers/stm32/driver/include.mk -# Use the relitive path to keep the genrated files in the BUILD_DIR -SRCS += $(subst $(PX4_MODULE_SRC),../../,$(LIBUAVCAN_STM32_SRC)) -INCLUDE_DIRS += $(LIBUAVCAN_STM32_INC) -override EXTRADEFINES := $(EXTRADEFINES) -DUAVCAN_STM32_NUTTX -DUAVCAN_STM32_NUM_IFACES=2 - -# -# libuavcan drivers for posix -# -include $(PX4_LIB_DIR)uavcan/libuavcan_drivers/posix/include.mk -INCLUDE_DIRS += $(LIBUAVCAN_POSIX_INC) - -# -# Invoke DSDL compiler -# -$(info $(shell $(LIBUAVCAN_DSDLC) $(UAVCAN_DSDL_DIR))) -INCLUDE_DIRS += dsdlc_generated diff --git a/src/modules/uavcan/sensors/baro.cpp b/src/modules/uavcan/sensors/baro.cpp index 1986de4247..694a3988a1 100644 --- a/src/modules/uavcan/sensors/baro.cpp +++ b/src/modules/uavcan/sensors/baro.cpp @@ -159,7 +159,14 @@ void UavcanBarometerBridge::air_pressure_sub_cb(const { baro_report report; - report.timestamp = msg.getMonotonicTimestamp().toUSec(); + /* + * FIXME HACK + * This code used to rely on msg.getMonotonicTimestamp().toUSec() instead of HRT. + * It stopped working when the time sync feature has been introduced, because it caused libuavcan + * to use an independent time source (based on hardware TIM5) instead of HRT. + * The proper solution is to be developed. + */ + report.timestamp = hrt_absolute_time(); report.temperature = last_temperature_kelvin - 273.15F; report.pressure = msg.static_pressure / 100.0F; // Convert to millibar report.error_count = 0; diff --git a/src/modules/uavcan/sensors/gnss.cpp b/src/modules/uavcan/sensors/gnss.cpp index 0830aba4ee..d80b4b425d 100644 --- a/src/modules/uavcan/sensors/gnss.cpp +++ b/src/modules/uavcan/sensors/gnss.cpp @@ -96,7 +96,15 @@ void UavcanGnssBridge::gnss_fix_sub_cb(const uavcan::ReceivedDataStructure +#include + //todo:The Inclusion of file_server_backend is killing // #include and leaving OK undefined # define OK 0 @@ -77,7 +79,11 @@ UavcanNode::UavcanNode(uavcan::ICanDriver &can_driver, uavcan::ISystemClock &sys CDev("uavcan", UAVCAN_DEVICE_PATH), _node(can_driver, system_clock), _node_mutex(), - _esc_controller(_node) + _esc_controller(_node), + _time_sync_master(_node), + _time_sync_slave(_node), + _master_timer(_node), + _setget_response(0) { _task_should_exit = false; _fw_server_action = None; @@ -94,7 +100,7 @@ UavcanNode::UavcanNode(uavcan::ICanDriver &can_driver, uavcan::ISystemClock &sys std::abort(); } - res = sem_init(&_server_command_sem, 0 , 0); + res = px4_sem_init(&_server_command_sem, 0 , 0); if (res < 0) { std::abort(); @@ -158,7 +164,7 @@ UavcanNode::~UavcanNode() perf_free(_perfcnt_esc_mixer_output_elapsed); perf_free(_perfcnt_esc_mixer_total_elapsed); pthread_mutex_destroy(&_node_mutex); - sem_destroy(&_server_command_sem); + px4_sem_destroy(&_server_command_sem); } @@ -186,6 +192,239 @@ int UavcanNode::getHardwareVersion(uavcan::protocol::HardwareVersion &hwver) return rv; } +int UavcanNode::print_params(uavcan::protocol::param::GetSet::Response &resp) +{ + if (resp.value.is(uavcan::protocol::param::Value::Tag::integer_value)) { + return std::printf("name: %s %lld\n", resp.name.c_str(), + resp.value.to()); + + } else if (resp.value.is(uavcan::protocol::param::Value::Tag::real_value)) { + return std::printf("name: %s %.4f\n", resp.name.c_str(), + static_cast(resp.value.to())); + + } else if (resp.value.is(uavcan::protocol::param::Value::Tag::boolean_value)) { + return std::printf("name: %s %d\n", resp.name.c_str(), + resp.value.to()); + + } else if (resp.value.is(uavcan::protocol::param::Value::Tag::string_value)) { + return std::printf("name: %s '%s'\n", resp.name.c_str(), + resp.value.to().c_str()); + } + + return -1; +} + +void UavcanNode::cb_opcode(const uavcan::ServiceCallResult &result) +{ + uavcan::protocol::param::ExecuteOpcode::Response resp; + _callback_success = result.isSuccessful(); + resp = result.getResponse(); + _callback_success &= resp.ok; +} + +int UavcanNode::save_params(int remote_node_id) +{ + uavcan::protocol::param::ExecuteOpcode::Request opcode_req; + opcode_req.opcode = opcode_req.OPCODE_SAVE; + uavcan::ServiceClient client(_node); + client.setCallback(ExecuteOpcodeCallback(this, &UavcanNode::cb_opcode)); + _callback_success = false; + int call_res = client.call(remote_node_id, opcode_req); + + if (call_res >= 0) { + while (client.hasPendingCalls()) { + usleep(10000); + } + } + + if (!_callback_success) { + std::printf("Failed to save parameters: %d\n", call_res); + return -1; + } + + return 0; +} + +void UavcanNode::cb_restart(const uavcan::ServiceCallResult &result) +{ + uavcan::protocol::RestartNode::Response resp; + _callback_success = result.isSuccessful(); + resp = result.getResponse(); + _callback_success &= resp.ok; +} + +int UavcanNode::reset_node(int remote_node_id) +{ + uavcan::protocol::RestartNode::Request restart_req; + restart_req.magic_number = restart_req.MAGIC_NUMBER; + uavcan::ServiceClient client(_node); + client.setCallback(RestartNodeCallback(this, &UavcanNode::cb_restart)); + _callback_success = false; + int call_res = client.call(remote_node_id, restart_req); + + if (call_res >= 0) { + while (client.hasPendingCalls()) { + usleep(10000); + } + } + + if (!call_res) { + std::printf("Failed to reset node: %d\n", remote_node_id); + return -1; + } + + return 0; +} + +int UavcanNode::list_params(int remote_node_id) +{ + int rv = 0; + int index = 0; + uavcan::protocol::param::GetSet::Response resp; + set_setget_response(&resp); + + while (true) { + uavcan::protocol::param::GetSet::Request req; + req.index = index++; + _callback_success = false; + int call_res = get_set_param(remote_node_id, nullptr, req); + + if (call_res < 0 || !_callback_success) { + std::printf("Failed to get param: %d\n", call_res); + rv = -1; + break; + } + + if (resp.name.empty()) { // Empty name means no such param, which means we're finished + break; + } + + print_params(resp); + } + + free_setget_response(); + return rv; +} + + +void UavcanNode::cb_setget(const uavcan::ServiceCallResult &result) +{ + _callback_success = result.isSuccessful(); + *_setget_response = result.getResponse(); +} + +int UavcanNode::get_set_param(int remote_node_id, const char *name, uavcan::protocol::param::GetSet::Request &req) +{ + if (name != nullptr) { + req.name = name; + } + + uavcan::ServiceClient client(_node); + client.setCallback(GetSetCallback(this, &UavcanNode::cb_setget)); + _callback_success = false; + int call_res = client.call(remote_node_id, req); + + if (call_res >= 0) { + + while (client.hasPendingCalls()) { + usleep(10000); + } + + if (!_callback_success) { + call_res = -1; + } + } + + return call_res; +} + +int UavcanNode::set_param(int remote_node_id, const char *name, char *value) +{ + uavcan::protocol::param::GetSet::Request req; + uavcan::protocol::param::GetSet::Response resp; + set_setget_response(&resp); + int rv = get_set_param(remote_node_id, name, req); + + if (rv < 0 || resp.name.empty()) { + std::printf("Failed to retrieve param: %s\n", name); + rv = -1; + + } else { + + rv = 0; + req = {}; + + if (resp.value.is(uavcan::protocol::param::Value::Tag::integer_value)) { + int64_t i = std::strtoull(value, NULL, 10); + int64_t min = resp.min_value.to(); + int64_t max = resp.max_value.to(); + + if (i >= min && i <= max) { + req.value.to() = i; + + } else { + std::printf("Invalid value for: %s must be between %lld and %lld\n", name, min, max); + rv = -1; + } + + } else if (resp.value.is(uavcan::protocol::param::Value::Tag::real_value)) { + float f = static_cast(std::atof(value)); + float min = resp.min_value.to(); + float max = resp.max_value.to(); + + if (f >= min && f <= max) { + req.value.to() = f; + + } else { + std::printf("Invalid value for: %s must be between %.4f and %.4f\n", name, static_cast(min), + static_cast(max)); + rv = -1; + } + + } else if (resp.value.is(uavcan::protocol::param::Value::Tag::boolean_value)) { + int8_t i = (value[0] == '1' || value[0] == 't') ? 1 : 0; + req.value.to() = i; + + } else if (resp.value.is(uavcan::protocol::param::Value::Tag::string_value)) { + req.value.to() = value; + } + + if (rv == 0) { + rv = get_set_param(remote_node_id, name, req); + + if (rv < 0 || resp.name.empty()) { + std::printf("Failed to set param: %s\n", name); + return -1; + } + + return 0; + } + } + + free_setget_response(); + return rv; +} + +int UavcanNode::get_param(int remote_node_id, const char *name) +{ + uavcan::protocol::param::GetSet::Request req; + uavcan::protocol::param::GetSet::Response resp; + set_setget_response(&resp); + int rv = get_set_param(remote_node_id, name, req); + + if (rv < 0 || resp.name.empty()) { + std::printf("Failed to get param: %s\n", name); + rv = -1; + + } else { + print_params(resp); + rv = 0; + } + + free_setget_response(); + return rv; +} + int UavcanNode::start_fw_server() { int rv = -1; @@ -208,7 +447,7 @@ int UavcanNode::start_fw_server() } _fw_server_action = None; - sem_post(&_server_command_sem); + px4_sem_post(&_server_command_sem); return rv; } @@ -224,7 +463,7 @@ int UavcanNode::request_fw_check() } _fw_server_action = None; - sem_post(&_server_command_sem); + px4_sem_post(&_server_command_sem); return rv; } @@ -248,7 +487,7 @@ int UavcanNode::stop_fw_server() } _fw_server_action = None; - sem_post(&_server_command_sem); + px4_sem_post(&_server_command_sem); return rv; } @@ -263,7 +502,7 @@ int UavcanNode::fw_server(eServerAction action) case CheckFW: if (_fw_server_action == None) { _fw_server_action = action; - sem_wait(&_server_command_sem); + px4_sem_wait(&_server_command_sem); rv = _fw_server_status; } @@ -291,8 +530,10 @@ int UavcanNode::start(uavcan::NodeID node_id, uint32_t bitrate) * If no transceiver is connected, the RX pin will float, occasionally causing CAN controller to * fail during initialization. */ + #ifdef GPIO_CAN1_RX stm32_configgpio(GPIO_CAN1_RX); stm32_configgpio(GPIO_CAN1_TX); + #endif stm32_configgpio(GPIO_CAN2_RX | GPIO_PULLUP); stm32_configgpio(GPIO_CAN2_TX); @@ -459,6 +700,48 @@ int UavcanNode::add_poll_fd(int fd) } +void UavcanNode::handle_time_sync(const uavcan::TimerEvent &) +{ + + /* + * Check whether there are higher priority masters in the network. + * If there are, we need to activate the local slave in order to sync with them. + */ + if (_time_sync_slave.isActive()) { // "Active" means that the slave tracks at least one remote master in the network + if (_node.getNodeID() < _time_sync_slave.getMasterNodeID()) { + /* + * We're the highest priority master in the network. + * We need to suppress the slave now to prevent it from picking up unwanted sync messages from + * lower priority masters. + */ + _time_sync_slave.suppress(true); // SUPPRESS + + } else { + /* + * There is at least one higher priority master in the network. + * We need to allow the slave to adjust our local clock in order to be in sync. + */ + _time_sync_slave.suppress(false); // UNSUPPRESS + } + + } else { + /* + * There are no other time sync masters in the network, so we're the only time source. + * The slave must be suppressed anyway to prevent it from disrupting the local clock if a new + * lower priority master suddenly appears in the network. + */ + _time_sync_slave.suppress(true); + } + + /* + * Publish the sync message now, even if we're not a higher priority master. + * Other nodes will be able to pick the right master anyway. + */ + _time_sync_master.publish(); +} + + + int UavcanNode::run() { (void)pthread_mutex_lock(&_node_mutex); @@ -472,6 +755,28 @@ int UavcanNode::run() memset(&_outputs, 0, sizeof(_outputs)); + /* + * Set up the time synchronization + */ + + const int slave_init_res = _time_sync_slave.start(); + + if (slave_init_res < 0) { + warnx("Failed to start time_sync_slave"); + _task_should_exit = true; + } + + /* When we have a system wide notion of time update (i.e the transition from the initial + * System RTC setting to the GPS) we would call uavcan_stm32::clock::setUtc() when that + * happens, but for now we use adjustUtc with a correction of the hrt so that the + * time bases are the same + */ + uavcan_stm32::clock::adjustUtc(uavcan::UtcDuration::fromUSec(hrt_absolute_time())); + _master_timer.setCallback(TimerCallback(this, &UavcanNode::handle_time_sync)); + _master_timer.startPeriodic(uavcan::MonotonicDuration::fromMSec(1000)); + + + const int busevent_fd = ::open(uavcan_stm32::BusEvent::DevName, 0); if (busevent_fd < 0) { @@ -678,7 +983,7 @@ UavcanNode::control_callback(uintptr_t handle, uint8_t control_group, uint8_t co int UavcanNode::teardown() { - sem_post(&_server_command_sem); + px4_sem_post(&_server_command_sem); for (unsigned i = 0; i < actuator_controls_s::NUM_ACTUATOR_CONTROL_GROUPS; i++) { if (_control_subs[i] > 0) { @@ -870,7 +1175,7 @@ UavcanNode::print_info() static void print_usage() { warnx("usage: \n" - "\tuavcan {start [fw]|status|stop [all|fw]|arm|disarm|update fw}"); + "\tuavcan {start [fw]|status|stop [all|fw]|arm|disarm|update fw|param [set|get|list|save] nodeid [name] [value]|reset nodeid}"); } extern "C" __EXPORT int uavcan_main(int argc, char *argv[]); @@ -956,6 +1261,60 @@ int uavcan_main(int argc, char *argv[]) ::exit(0); } + /* + * Parameter setting commands + * + * uavcan param list + * uavcan param save + * uavcan param get + * uavcan param set + * + */ + int node_arg = !std::strcmp(argv[1], "reset") ? 2 : 3; + + if (!std::strcmp(argv[1], "param") || node_arg == 2) { + if (argc < node_arg + 1) { + errx(1, "Node id required"); + } + + int nodeid = atoi(argv[node_arg]); + + if (nodeid == 0 || nodeid > 127 || nodeid == inst->get_node().getNodeID().get()) { + errx(1, "Invalid Node id"); + } + + if (node_arg == 2) { + + return inst->reset_node(nodeid); + + } else if (!std::strcmp(argv[2], "list")) { + + return inst->list_params(nodeid); + + } else if (!std::strcmp(argv[2], "save")) { + + return inst->save_params(nodeid); + + } else if (!std::strcmp(argv[2], "get")) { + if (argc < 5) { + errx(1, "Name required"); + } + + return inst->get_param(nodeid, argv[4]); + + } else if (!std::strcmp(argv[2], "set")) { + if (argc < 5) { + errx(1, "Name required"); + } + + if (argc < 6) { + errx(1, "Value required"); + } + + return inst->set_param(nodeid, argv[4], argv[5]); + } + } + if (!std::strcmp(argv[1], "stop")) { if (fw) { diff --git a/src/modules/uavcan/uavcan_main.hpp b/src/modules/uavcan/uavcan_main.hpp index acc1c32843..6a1d2f391d 100644 --- a/src/modules/uavcan/uavcan_main.hpp +++ b/src/modules/uavcan/uavcan_main.hpp @@ -36,6 +36,12 @@ #include #include +#include +#include +#include +#include +#include + #include #include @@ -48,7 +54,7 @@ #include "actuators/esc.hpp" #include "sensors/sensor_bridge.hpp" -# include "uavcan_servers.hpp" +#include "uavcan_servers.hpp" /** * @file uavcan_main.hpp @@ -88,7 +94,7 @@ class UavcanNode : public device::CDev */ static constexpr unsigned RxQueueLenPerIface = FramePerMSecond * PollTimeoutMs; // At - static constexpr unsigned StackSize = 1600; + static constexpr unsigned StackSize = 1800; public: typedef uavcan::Node Node; @@ -119,8 +125,13 @@ public: static int getHardwareVersion(uavcan::protocol::HardwareVersion &hwver); int fw_server(eServerAction action); void attachITxQueueInjector(ITxQueueInjector *injector) {_tx_injector = injector;} - + int list_params(int remote_node_id); + int save_params(int remote_node_id); + int set_param(int remote_node_id, const char *name, char *value); + int get_param(int remote_node_id, const char *name); + int reset_node(int remote_node_id); private: + void fill_node_info(); int init(uavcan::NodeID node_id); void node_spin_once(); @@ -129,6 +140,16 @@ private: int start_fw_server(); int stop_fw_server(); int request_fw_check(); + int print_params(uavcan::protocol::param::GetSet::Response &resp); + int get_set_param(int nodeid, const char *name, uavcan::protocol::param::GetSet::Request &req); + void set_setget_response(uavcan::protocol::param::GetSet::Response *resp) + { + _setget_response = resp; + } + void free_setget_response(void) + { + _setget_response = nullptr; + } int _task = -1; ///< handle to the OS task bool _task_should_exit = false; ///< flag to indicate to tear down the CAN driver @@ -148,8 +169,10 @@ private: Node _node; ///< library instance pthread_mutex_t _node_mutex; - sem_t _server_command_sem; + px4_sem_t _server_command_sem; UavcanEscController _esc_controller; + uavcan::GlobalTimeSyncMaster _time_sync_master; + uavcan::GlobalTimeSyncSlave _time_sync_slave; List _sensor_bridges; ///< List of active sensor bridges @@ -175,4 +198,22 @@ private: perf_counter_t _perfcnt_node_spin_elapsed = perf_alloc(PC_ELAPSED, "uavcan_node_spin_elapsed"); perf_counter_t _perfcnt_esc_mixer_output_elapsed = perf_alloc(PC_ELAPSED, "uavcan_esc_mixer_output_elapsed"); perf_counter_t _perfcnt_esc_mixer_total_elapsed = perf_alloc(PC_ELAPSED, "uavcan_esc_mixer_total_elapsed"); + + void handle_time_sync(const uavcan::TimerEvent &); + + typedef uavcan::MethodBinder TimerCallback; + uavcan::TimerEventForwarder _master_timer; + + bool _callback_success; + uavcan::protocol::param::GetSet::Response *_setget_response; + typedef uavcan::MethodBinder &)> GetSetCallback; + typedef uavcan::MethodBinder &)> ExecuteOpcodeCallback; + typedef uavcan::MethodBinder &)> RestartNodeCallback; + void cb_setget(const uavcan::ServiceCallResult &result); + void cb_opcode(const uavcan::ServiceCallResult &result); + void cb_restart(const uavcan::ServiceCallResult &result); + }; diff --git a/src/modules/uavcan/uavcan_servers.cpp b/src/modules/uavcan/uavcan_servers.cpp index 52f0ce9697..713a4e00f7 100644 --- a/src/modules/uavcan/uavcan_servers.cpp +++ b/src/modules/uavcan/uavcan_servers.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -53,14 +54,22 @@ #include "uavcan_servers.hpp" #include "uavcan_virtual_can_driver.hpp" -# include -# include -# include +#include +#include +#include + +#include +#include +#include + +#include //todo:The Inclusion of file_server_backend is killing // #include and leaving OK undefined # define OK 0 + + /** * @file uavcan_servers.cpp * @@ -87,8 +96,29 @@ UavcanServers::UavcanServers(uavcan::INode &main_node) : _node_info_retriever(_subnode), _fw_upgrade_trigger(_subnode, _fw_version_checker), _fw_server(_subnode, _fileserver_backend), + _count_in_progress(false), + _count_index(0), + _param_in_progress(0), + _param_index(0), + _param_list_in_progress(false), + _param_list_all_nodes(false), + _param_list_node_id(1), + _param_dirty_bitmap{0, 0, 0, 0}, + _param_save_opcode(0), + _cmd_in_progress(false), + _param_response_pub(nullptr), + _param_getset_client(_subnode), + _param_opcode_client(_subnode), + _param_restartnode_client(_subnode), _mutex_inited(false), - _check_fw(false) + _check_fw(false), + _esc_enumeration_active(false), + _esc_enumeration_index(0), + _beep_pub(_subnode), + _enumeration_indication_sub(_subnode), + _enumeration_client(_subnode), + _enumeration_getset_client(_subnode), + _enumeration_save_client(_subnode) { } @@ -98,6 +128,7 @@ UavcanServers::~UavcanServers() if (_mutex_inited) { (void)Lock::deinit(_subnode_mutex); } + _main_node.getDispatcher().removeRxFrameListener(); } @@ -164,9 +195,9 @@ int UavcanServers::start(uavcan::INode &main_node) rv = pthread_create(&_instance->_subnode_thread, &tattr, static_cast(run_trampoline), NULL); - if (rv < 0) { - warnx("pthread_create() failed: %d", errno); - rv = -errno; + if (rv != 0) { + rv = -rv; + warnx("pthread_create() failed: %d", rv); delete _instance; _instance = nullptr; } @@ -269,11 +300,40 @@ int UavcanServers::init() return OK; } -__attribute__((optimize("-O0"))) pthread_addr_t UavcanServers::run(pthread_addr_t) { + prctl(PR_SET_NAME, "uavcan fw srv", 0); + Lock lock(_subnode_mutex); + /* + Copy any firmware bundled in the ROMFS to the appropriate location on the + SD card, unless the user has copied other firmware for that device. + */ + unpackFwFromROMFS(UAVCAN_FIRMWARE_PATH, UAVCAN_ROMFS_FW_PATH); + + /* the subscribe call needs to happen in the same thread, + * so not in the constructor */ + int cmd_sub = orb_subscribe(ORB_ID(vehicle_command)); + int param_request_sub = orb_subscribe(ORB_ID(uavcan_parameter_request)); + int armed_sub = orb_subscribe(ORB_ID(actuator_armed)); + + /* Set up shared service clients */ + _param_getset_client.setCallback(GetSetCallback(this, &UavcanServers::cb_getset)); + _param_opcode_client.setCallback(ExecuteOpcodeCallback(this, &UavcanServers::cb_opcode)); + _param_restartnode_client.setCallback(RestartNodeCallback(this, &UavcanServers::cb_restart)); + _enumeration_client.setCallback(EnumerationBeginCallback(this, &UavcanServers::cb_enumeration_begin)); + _enumeration_indication_sub.start(EnumerationIndicationCallback(this, &UavcanServers::cb_enumeration_indication)); + _enumeration_getset_client.setCallback(GetSetCallback(this, &UavcanServers::cb_enumeration_getset)); + _enumeration_save_client.setCallback(ExecuteOpcodeCallback(this, &UavcanServers::cb_enumeration_save)); + + _count_in_progress = _param_in_progress = _param_list_in_progress = _cmd_in_progress = _param_list_all_nodes = false; + memset(_param_counts, 0, sizeof(_param_counts)); + + _esc_enumeration_active = false; + memset(_esc_enumeration_ids, 0, sizeof(_esc_enumeration_ids)); + _esc_enumeration_index = 0; + while (1) { if (_check_fw == true) { @@ -281,14 +341,799 @@ pthread_addr_t UavcanServers::run(pthread_addr_t) _node_info_retriever.invalidateAll(); } - const int spin_res = _subnode.spin(uavcan::MonotonicDuration::fromMSec(100)); - + const int spin_res = _subnode.spin(uavcan::MonotonicDuration::fromMSec(10)); if (spin_res < 0) { warnx("node spin error %i", spin_res); } + + // Check for parameter requests (get/set/list) + bool param_request_ready; + orb_check(param_request_sub, ¶m_request_ready); + + if (param_request_ready && !_param_list_in_progress && !_param_in_progress && !_count_in_progress) { + struct uavcan_parameter_request_s request; + orb_copy(ORB_ID(uavcan_parameter_request), param_request_sub, &request); + + if (_param_counts[request.node_id]) { + /* + * We know how many parameters are exposed by this node, so + * process the request. + */ + if (request.message_type == MAVLINK_MSG_ID_PARAM_REQUEST_READ) { + uavcan::protocol::param::GetSet::Request req; + if (request.param_index >= 0) { + req.index = request.param_index; + } else { + req.name = (char*)request.param_id; + } + + int call_res = _param_getset_client.call(request.node_id, req); + if (call_res < 0) { + warnx("UAVCAN command bridge: couldn't send GetSet: %d", call_res); + } else { + _param_in_progress = true; + _param_index = request.param_index; + } + } else if (request.message_type == MAVLINK_MSG_ID_PARAM_SET) { + uavcan::protocol::param::GetSet::Request req; + if (request.param_index >= 0) { + req.index = request.param_index; + } else { + req.name = (char*)request.param_id; + } + + if (request.param_type == MAV_PARAM_TYPE_REAL32) { + req.value.to() = request.real_value; + } else if (request.param_type == MAV_PARAM_TYPE_UINT8) { + req.value.to() = request.int_value; + } else { + req.value.to() = request.int_value; + } + + // Set the dirty bit for this node + set_node_params_dirty(request.node_id); + + int call_res = _param_getset_client.call(request.node_id, req); + if (call_res < 0) { + warnx("UAVCAN command bridge: couldn't send GetSet: %d", call_res); + } else { + _param_in_progress = true; + _param_index = request.param_index; + } + } else if (request.message_type == MAVLINK_MSG_ID_PARAM_REQUEST_LIST) { + // This triggers the _param_list_in_progress case below. + _param_index = 0; + _param_list_in_progress = true; + _param_list_node_id = request.node_id; + _param_list_all_nodes = false; + + warnx("UAVCAN command bridge: starting component-specific param list"); + } + } else if (request.node_id == MAV_COMP_ID_ALL) { + if (request.message_type == MAVLINK_MSG_ID_PARAM_REQUEST_LIST) { + /* + * This triggers the _param_list_in_progress case below, + * but additionally iterates over all active nodes. + */ + _param_index = 0; + _param_list_in_progress = true; + _param_list_node_id = get_next_active_node_id(1); + _param_list_all_nodes = true; + + warnx("UAVCAN command bridge: starting global param list with node %hhu", _param_list_node_id); + + if (_param_counts[_param_list_node_id] == 0) { + param_count(_param_list_node_id); + } + } + } else { + /* + * Need to know how many parameters this node has before we can + * continue; count them now and then process the request. + */ + param_count(request.node_id); + } + } + + // Handle parameter listing index/node ID advancement + if (_param_list_in_progress && !_param_in_progress && !_count_in_progress) { + if (_param_index >= _param_counts[_param_list_node_id]) { + warnx("UAVCAN command bridge: completed param list for node %hhu", _param_list_node_id); + // Reached the end of the current node's parameter set. + _param_list_in_progress = false; + + if (_param_list_all_nodes) { + // We're listing all parameters for all nodes -- get the next node ID + uint8_t next_id = get_next_active_node_id(_param_list_node_id); + if (next_id < 128) { + _param_list_node_id = next_id; + /* + * If there is a next node ID, check if that node's parameters + * have been counted before. If not, do it now. + */ + if (_param_counts[_param_list_node_id] == 0) { + param_count(_param_list_node_id); + } + // Keep on listing. + _param_index = 0; + _param_list_in_progress = true; + warnx("UAVCAN command bridge: started param list for node %hhu", _param_list_node_id); + } + } + } + } + + // Check if we're still listing, and need to get the next parameter + if (_param_list_in_progress && !_param_in_progress && !_count_in_progress) { + // Ready to request the next value -- _param_index is incremented + // after each successful fetch by cb_getset + uavcan::protocol::param::GetSet::Request req; + req.index = _param_index; + + int call_res = _param_getset_client.call(_param_list_node_id, req); + if (call_res < 0) { + _param_list_in_progress = false; + warnx("UAVCAN command bridge: couldn't send param list GetSet: %d", call_res); + } else { + _param_in_progress = true; + } + } + + // Check for ESC enumeration commands + bool cmd_ready; + orb_check(cmd_sub, &cmd_ready); + + if (cmd_ready && !_cmd_in_progress) { + struct vehicle_command_s cmd; + orb_copy(ORB_ID(vehicle_command), cmd_sub, &cmd); + + if (cmd.command == vehicle_command_s::VEHICLE_CMD_PREFLIGHT_UAVCAN) { + int command_id = static_cast(cmd.param1 + 0.5f); + int node_id = static_cast(cmd.param2 + 0.5f); + int call_res; + + warnx("UAVCAN command bridge: received UAVCAN command ID %d, node ID %d", command_id, node_id); + + switch (command_id) { + case 0: + case 1: { + _esc_enumeration_active = command_id; + _esc_enumeration_index = 0; + _esc_count = 0; + uavcan::protocol::enumeration::Begin::Request req; + req.parameter_name = "esc_index"; + req.timeout_sec = _esc_enumeration_active ? 65535 : 0; + call_res = _enumeration_client.call(get_next_active_node_id(1), req); + if (call_res < 0) { + warnx("UAVCAN ESC enumeration: couldn't send initial Begin request: %d", call_res); + } + break; + } + default: { + warnx("UAVCAN command bridge: unknown command ID %d", command_id); + break; + } + } + } else if (cmd.command == vehicle_command_s::VEHICLE_CMD_PREFLIGHT_STORAGE) { + int command_id = static_cast(cmd.param1 + 0.5f); + + warnx("UAVCAN command bridge: received storage command ID %d", command_id); + + switch (command_id) { + case 1: { + // Param save request + _param_save_opcode = uavcan::protocol::param::ExecuteOpcode::Request::OPCODE_SAVE; + param_opcode(get_next_dirty_node_id(1)); + break; + } + case 2: { + // Command is a param erase request -- apply it to all active nodes by setting the dirty bit + _param_save_opcode = uavcan::protocol::param::ExecuteOpcode::Request::OPCODE_ERASE; + for (int i = 1; i < 128; i = get_next_active_node_id(i)) { + set_node_params_dirty(i); + } + param_opcode(get_next_dirty_node_id(1)); + break; + } + } + } + } + + // Shut down once armed + // TODO (elsewhere): start up again once disarmed? + bool updated; + orb_check(armed_sub, &updated); + if (updated) { + struct actuator_armed_s armed; + orb_copy(ORB_ID(actuator_armed), armed_sub, &armed); + + if (armed.armed && !armed.lockdown) { + warnx("UAVCAN command bridge: system armed, exiting now."); + break; + } + } } warnx("exiting."); return (pthread_addr_t) 0; } +void UavcanServers::cb_getset(const uavcan::ServiceCallResult &result) +{ + if (_count_in_progress) { + /* + * Currently in parameter count mode: + * Iterate over all parameters for the node to which the request was + * originally sent, in order to find the maximum parameter ID. If a + * request fails, set the node's parameter count to zero. + */ + uint8_t node_id = result.getCallID().server_node_id.get(); + + if (result.isSuccessful()) { + uavcan::protocol::param::GetSet::Response resp = result.getResponse(); + if (resp.name.size()) { + _param_counts[node_id] = _count_index++; + + uavcan::protocol::param::GetSet::Request req; + req.index = _count_index; + + int call_res = _param_getset_client.call(result.getCallID().server_node_id, req); + if (call_res < 0) { + _count_in_progress = false; + _count_index = 0; + warnx("UAVCAN command bridge: couldn't send GetSet during param count: %d", call_res); + } + } else { + _count_in_progress = false; + _count_index = 0; + warnx("UAVCAN command bridge: completed param count for node %hhu: %hhu", node_id, _param_counts[node_id]); + } + } else { + _param_counts[node_id] = 0; + _count_in_progress = false; + _count_index = 0; + warnx("UAVCAN command bridge: GetSet error during param count"); + } + } else { + /* + * Currently in parameter get/set mode: + * Publish a uORB uavcan_parameter_value message containing the current value + * of the parameter. + */ + if (result.isSuccessful()) { + uavcan::protocol::param::GetSet::Response param = result.getResponse(); + + struct uavcan_parameter_value_s response; + response.node_id = result.getCallID().server_node_id.get(); + strncpy(response.param_id, param.name.c_str(), sizeof(response.param_id) - 1); + response.param_id[16] = '\0'; + response.param_index = _param_index; + response.param_count = _param_counts[response.node_id]; + + if (param.value.is(uavcan::protocol::param::Value::Tag::integer_value)) { + response.param_type = MAV_PARAM_TYPE_INT64; + response.int_value = param.value.to(); + } else if (param.value.is(uavcan::protocol::param::Value::Tag::real_value)) { + response.param_type = MAV_PARAM_TYPE_REAL32; + response.real_value = param.value.to(); + } else if (param.value.is(uavcan::protocol::param::Value::Tag::boolean_value)) { + response.param_type = MAV_PARAM_TYPE_UINT8; + response.int_value = param.value.to(); + } + + if (_param_response_pub == nullptr) { + _param_response_pub = orb_advertise(ORB_ID(uavcan_parameter_value), &response); + } else { + orb_publish(ORB_ID(uavcan_parameter_value), _param_response_pub, &response); + } + } else { + warnx("UAVCAN command bridge: GetSet error"); + } + + _param_in_progress = false; + _param_index++; + } +} + +void UavcanServers::param_count(uavcan::NodeID node_id) +{ + uavcan::protocol::param::GetSet::Request req; + req.index = 0; + int call_res = _param_getset_client.call(node_id, req); + if (call_res < 0) { + warnx("UAVCAN command bridge: couldn't start parameter count: %d", call_res); + } else { + _count_in_progress = true; + _count_index = 0; + warnx("UAVCAN command bridge: starting param count"); + } +} + +void UavcanServers::param_opcode(uavcan::NodeID node_id) +{ + uavcan::protocol::param::ExecuteOpcode::Request opcode_req; + opcode_req.opcode = _param_save_opcode; + int call_res = _param_opcode_client.call(node_id, opcode_req); + if (call_res < 0) { + warnx("UAVCAN command bridge: couldn't send ExecuteOpcode: %d", call_res); + } else { + _cmd_in_progress = true; + warnx("UAVCAN command bridge: sent ExecuteOpcode"); + } +} + +void UavcanServers::cb_opcode(const uavcan::ServiceCallResult &result) +{ + bool success = result.isSuccessful(); + uint8_t node_id = result.getCallID().server_node_id.get(); + uavcan::protocol::param::ExecuteOpcode::Response resp = result.getResponse(); + success &= resp.ok; + _cmd_in_progress = false; + + if (!result.isSuccessful()) { + warnx("UAVCAN command bridge: save request for node %hhu timed out.", node_id); + } else if (!result.getResponse().ok) { + warnx("UAVCAN command bridge: save request for node %hhu rejected.", node_id); + } else { + warnx("UAVCAN command bridge: save request for node %hhu completed OK, restarting.", node_id); + + uavcan::protocol::RestartNode::Request restart_req; + restart_req.magic_number = restart_req.MAGIC_NUMBER; + int call_res = _param_restartnode_client.call(node_id, restart_req); + if (call_res < 0) { + warnx("UAVCAN command bridge: couldn't send RestartNode: %d", call_res); + } else { + warnx("UAVCAN command bridge: sent RestartNode"); + _cmd_in_progress = true; + } + } + + if (!_cmd_in_progress) { + /* + * Something went wrong, so cb_restart is never going to be called as a result of this request. + * To ensure we try to execute the opcode on all nodes that permit it, get the next dirty node + * ID and keep processing here. The dirty bit on the current node is still set, so the + * save/erase attempt will occur when the next save/erase command is received over MAVLink. + */ + node_id = get_next_dirty_node_id(node_id); + if (node_id < 128) { + param_opcode(node_id); + } + } +} + +void UavcanServers::cb_restart(const uavcan::ServiceCallResult &result) +{ + bool success = result.isSuccessful(); + uint8_t node_id = result.getCallID().server_node_id.get(); + uavcan::protocol::RestartNode::Response resp = result.getResponse(); + success &= resp.ok; + _cmd_in_progress = false; + + if (success) { + warnx("UAVCAN command bridge: restart request for node %hhu completed OK.", node_id); + // Clear the dirty flag + clear_node_params_dirty(node_id); + } else { + warnx("UAVCAN command bridge: restart request for node %hhu failed.", node_id); + } + + // Get the next dirty node ID and send the same command to it + node_id = get_next_dirty_node_id(node_id); + if (node_id < 128) { + param_opcode(node_id); + } +} + +uint8_t UavcanServers::get_next_active_node_id(uint8_t base) +{ + base++; + for (; base < 128 && (!_node_info_retriever.isNodeKnown(base) || + _subnode.getNodeID().get() == base); base++); + return base; +} + +uint8_t UavcanServers::get_next_dirty_node_id(uint8_t base) +{ + base++; + for (; base < 128 && !are_node_params_dirty(base); base++); + return base; +} + +void UavcanServers::cb_enumeration_begin(const uavcan::ServiceCallResult &result) +{ + uint8_t next_id = get_next_active_node_id(result.getCallID().server_node_id.get()); + + if (!result.isSuccessful()) { + warnx("UAVCAN ESC enumeration: begin request for node %hhu timed out.", result.getCallID().server_node_id.get()); + } else if (result.getResponse().error) { + warnx("UAVCAN ESC enumeration: begin request for node %hhu rejected: %hhu", result.getCallID().server_node_id.get(), result.getResponse().error); + } else { + _esc_count++; + warnx("UAVCAN ESC enumeration: begin request for node %hhu completed OK.", result.getCallID().server_node_id.get()); + } + + if (next_id < 128) { + // Still other active nodes to send the request to + uavcan::protocol::enumeration::Begin::Request req; + req.parameter_name = "esc_index"; + req.timeout_sec = _esc_enumeration_active ? 65535 : 0; + + int call_res = _enumeration_client.call(next_id, req); + if (call_res < 0) { + warnx("UAVCAN ESC enumeration: couldn't send Begin request: %d", call_res); + } else { + warnx("UAVCAN ESC enumeration: sent Begin request"); + } + } else { + warnx("UAVCAN ESC enumeration: begun enumeration on all nodes."); + } +} + +void UavcanServers::cb_enumeration_indication(const uavcan::ReceivedDataStructure &msg) +{ + // Called whenever an ESC thinks it has received user input. + warnx("UAVCAN ESC enumeration: got indication"); + + if (!_esc_enumeration_active) { + // Ignore any messages received when we're not expecting them + return; + } + + // First, check if we've already seen an indication from this ESC. If so, + // just re-issue the previous get/set request. + int i; + for (i = 0; i < _esc_enumeration_index; i++) { + if (_esc_enumeration_ids[i] == msg.getSrcNodeID().get()) { + warnx("UAVCAN ESC enumeration: already enumerated ESC ID %hhu as index %d", _esc_enumeration_ids[i], i); + break; + } + } + + uavcan::protocol::param::GetSet::Request req; + req.name = "esc_index"; + req.value.to() = i; + + int call_res = _enumeration_getset_client.call(msg.getSrcNodeID(), req); + if (call_res < 0) { + warnx("UAVCAN ESC enumeration: couldn't send GetSet: %d", call_res); + } else { + warnx("UAVCAN ESC enumeration: sent GetSet to node %hhu (index %d)", _esc_enumeration_ids[i], i); + } +} + +void UavcanServers::cb_enumeration_getset(const uavcan::ServiceCallResult &result) +{ + if (!result.isSuccessful()) { + warnx("UAVCAN ESC enumeration: save request for node %hhu timed out.", result.getCallID().server_node_id.get()); + } else { + warnx("UAVCAN ESC enumeration: save request for node %hhu completed OK.", result.getCallID().server_node_id.get()); + + uavcan::protocol::param::GetSet::Response resp = result.getResponse(); + uint8_t esc_index = (uint8_t)resp.value.to(); + esc_index = std::min((uint8_t)(uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize - 1), esc_index); + _esc_enumeration_index = std::max(_esc_enumeration_index, (uint8_t)(esc_index + 1)); + + _esc_enumeration_ids[esc_index] = result.getCallID().server_node_id.get(); + + uavcan::protocol::param::ExecuteOpcode::Request opcode_req; + opcode_req.opcode = opcode_req.OPCODE_SAVE; + int call_res = _enumeration_save_client.call(result.getCallID().server_node_id, opcode_req); + if (call_res < 0) { + warnx("UAVCAN ESC enumeration: couldn't send ExecuteOpcode: %d", call_res); + } else { + warnx("UAVCAN ESC enumeration: sent ExecuteOpcode to node %hhu (index %hhu)", _esc_enumeration_ids[esc_index], esc_index); + } + } +} + +void UavcanServers::cb_enumeration_save(const uavcan::ServiceCallResult &result) +{ + uavcan::equipment::indication::BeepCommand beep; + + if (!result.isSuccessful()) { + warnx("UAVCAN ESC enumeration: save request for node %hhu timed out.", result.getCallID().server_node_id.get()); + beep.frequency = 880.0f; + beep.duration = 1.0f; + } else if (!result.getResponse().ok) { + warnx("UAVCAN ESC enumeration: save request for node %hhu rejected", result.getCallID().server_node_id.get()); + beep.frequency = 880.0f; + beep.duration = 1.0f; + } else { + warnx("UAVCAN ESC enumeration: save request for node %hhu completed OK.", result.getCallID().server_node_id.get()); + beep.frequency = 440.0f; + beep.duration = 0.25f; + } + + (void)_beep_pub.broadcast(beep); + + warnx("UAVCAN ESC enumeration: completed %hhu of %hhu", _esc_enumeration_index, _esc_count); + + if (_esc_enumeration_index == uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize - 1 || + _esc_enumeration_index == _esc_count) { + _esc_enumeration_active = false; + + // Tell all ESCs to stop enumerating + uavcan::protocol::enumeration::Begin::Request req; + req.parameter_name = "esc_index"; + req.timeout_sec = 0; + int call_res = _enumeration_client.call(get_next_active_node_id(1), req); + if (call_res < 0) { + warnx("UAVCAN ESC enumeration: couldn't send Begin request to stop enumeration: %d", call_res); + } else { + warnx("UAVCAN ESC enumeration: sent Begin request to stop enumeration"); + } + } +} + +void UavcanServers::unpackFwFromROMFS(const char* sd_path, const char* romfs_path) { + /* + Copy the ROMFS firmware directory to the appropriate location on SD, without + overriding any firmware the user has already loaded there. + + The SD firmware directory structure is along the lines of: + + /fs/microsd/fw + - /c + - - /1a2b3c4d.bin cache file (copy of /fs/microsd/fw/org.pixhawk.nodename-v1/1.1/1a2b3c4d.bin) + - /org.pixhawk.nodename-v1 device directory for org.pixhawk.nodename-v1 + - - /1.0 version directory for hardware 1.0 + - - /1.1 version directory for hardware 1.1 + - - - /1a2b3c4d.bin firmware file for org.pixhawk.nodename-v1 nodes, hardware version 1.1 + - /com.example.othernode-v3 device directory for com.example.othernode-v3 + - - /1.0 version directory for hardawre 1.0 + - - - /deadbeef.bin firmware file for com.example.othernode-v3, hardware version 1.0 + + The ROMFS directory structure is the same, but located at /etc/uavcan/fw + + We iterate over all device directories in the ROMFS base directory, and create + corresponding device directories on the SD card if they don't already exist. + + In each device directory, we iterate over each version directory and create a + corresponding version directory on the SD card if it doesn't already exist. + + In each version directory, we remove any files with a name starting with "romfs_" + in the corresponding directory on the SD card that don't match the bundled firmware + filename; if the directory is empty after that process, we copy the bundled firmware. + */ + const size_t maxlen = UAVCAN_MAX_PATH_LENGTH; + const size_t sd_path_len = strlen(sd_path); + const size_t romfs_path_len = strlen(romfs_path); + struct stat sb; + int rv; + char dstpath[maxlen + 1]; + char srcpath[maxlen + 1]; + + DIR* const romfs_dir = opendir(romfs_path); + if (!romfs_dir) { + warnx("base: couldn't open %s", romfs_path); + return; + } + + memcpy(dstpath, sd_path, sd_path_len + 1); + memcpy(srcpath, romfs_path, romfs_path_len + 1); + + // Iterate over all device directories in ROMFS + struct dirent* dev_dirent = NULL; + while ((dev_dirent = readdir(romfs_dir)) != NULL) { + // Skip if not a directory + if (!DIRENT_ISDIRECTORY(dev_dirent->d_type)) { + continue; + } + + // Make sure the path fits + size_t dev_dirname_len = strlen(dev_dirent->d_name); + size_t srcpath_dev_len = romfs_path_len + 1 + dev_dirname_len; + if (srcpath_dev_len > maxlen) { + warnx("dev: srcpath '%s/%s' too long", romfs_path, dev_dirent->d_name); + continue; + } + size_t dstpath_dev_len = sd_path_len + 1 + dev_dirname_len; + if (dstpath_dev_len > maxlen) { + warnx("dev: dstpath '%s/%s' too long", sd_path, dev_dirent->d_name); + continue; + } + + // Create the device name directory on the SD card if it doesn't already exist + dstpath[sd_path_len] = '/'; + memcpy(&dstpath[sd_path_len + 1], dev_dirent->d_name, dev_dirname_len + 1); + + if (stat(dstpath, &sb) != 0 || !S_ISDIR(sb.st_mode)) { + rv = mkdir(dstpath, S_IRWXU | S_IRWXG | S_IRWXO); + if (rv != 0) { + warnx("dev: couldn't create '%s'", dstpath); + continue; + } + } + + // Set up the source path + srcpath[romfs_path_len] = '/'; + memcpy(&srcpath[romfs_path_len + 1], dev_dirent->d_name, dev_dirname_len + 1); + + DIR* const dev_dir = opendir(srcpath); + if (!dev_dir) { + warnx("dev: couldn't open '%s'", srcpath); + continue; + } + + // Iterate over all version directories in the current ROMFS device directory + struct dirent* ver_dirent = NULL; + while ((ver_dirent = readdir(dev_dir)) != NULL) { + // Skip if not a directory + if (!DIRENT_ISDIRECTORY(ver_dirent->d_type)) { + continue; + } + + // Make sure the path fits + size_t ver_dirname_len = strlen(ver_dirent->d_name); + size_t srcpath_ver_len = srcpath_dev_len + 1 + ver_dirname_len; + if (srcpath_ver_len > maxlen) { + warnx("ver: srcpath '%s/%s' too long", srcpath, ver_dirent->d_name); + continue; + } + size_t dstpath_ver_len = dstpath_dev_len + 1 + ver_dirname_len; + if (dstpath_ver_len > maxlen) { + warnx("ver: dstpath '%s/%s' too long", dstpath, ver_dirent->d_name); + continue; + } + + // Create the device version directory on the SD card if it doesn't already exist + dstpath[dstpath_dev_len] = '/'; + memcpy(&dstpath[dstpath_dev_len + 1], ver_dirent->d_name, ver_dirname_len + 1); + + if (stat(dstpath, &sb) != 0 || !S_ISDIR(sb.st_mode)) { + rv = mkdir(dstpath, S_IRWXU | S_IRWXG | S_IRWXO); + if (rv != 0) { + warnx("ver: couldn't create '%s'", dstpath); + continue; + } + } + + // Set up the source path + srcpath[srcpath_dev_len] = '/'; + memcpy(&srcpath[srcpath_dev_len + 1], ver_dirent->d_name, ver_dirname_len + 1); + + // Find the name of the bundled firmware file, or move on to the + // next directory if there's no file here. + DIR* const src_ver_dir = opendir(srcpath); + if (!src_ver_dir) { + warnx("ver: couldn't open '%s'", srcpath); + continue; + } + + struct dirent* src_fw_dirent = NULL; + while ((src_fw_dirent = readdir(src_ver_dir)) != NULL && + !DIRENT_ISFILE(src_fw_dirent->d_type)); + + if (!src_fw_dirent) { + (void)closedir(src_ver_dir); + continue; + } + + size_t fw_len = strlen(src_fw_dirent->d_name); + + bool copy_fw = true; + + // Clear out any romfs_ files in the version directory on the SD card + DIR* const dst_ver_dir = opendir(dstpath); + if (!dst_ver_dir) { + warnx("unlink: couldn't open '%s'", dstpath); + } else { + struct dirent* fw_dirent = NULL; + while ((fw_dirent = readdir(dst_ver_dir)) != NULL) { + // Skip if not a file + if (!DIRENT_ISFILE(fw_dirent->d_type)) { + continue; + } + + if (!memcmp(&fw_dirent->d_name[sizeof(UAVCAN_ROMFS_FW_PREFIX) - 1], src_fw_dirent->d_name, fw_len)) { + /* + * Exact match between SD card filename and ROMFS filename; must be the same version + * so don't bother deleting and rewriting it. + */ + copy_fw = false; + } else if (!memcmp(fw_dirent->d_name, UAVCAN_ROMFS_FW_PREFIX, sizeof(UAVCAN_ROMFS_FW_PREFIX) - 1)) { + size_t fw_len = strlen(fw_dirent->d_name); + size_t dstpath_fw_len = dstpath_ver_len + sizeof(UAVCAN_ROMFS_FW_PREFIX) + fw_len; + if (dstpath_fw_len > maxlen) { + // sizeof(prefix) includes trailing NUL, cancelling out the +1 for the path separator + warnx("unlink: path '%s/%s%s' too long", dstpath, UAVCAN_ROMFS_FW_PREFIX, fw_dirent->d_name); + } else { + // File name starts with "romfs_", delete it. + dstpath[dstpath_ver_len] = '/'; + memcpy(&dstpath[dstpath_ver_len + 1], fw_dirent->d_name, fw_len + 1); + unlink(dstpath); + + warnx("unlink: removed '%s/%s%s'", dstpath, UAVCAN_ROMFS_FW_PREFIX, fw_dirent->d_name); + } + } else { + // User file, don't copy firmware + copy_fw = false; + } + } + (void)closedir(dst_ver_dir); + } + + // If we need to, copy the file from ROMFS to the SD card + if (copy_fw) { + size_t srcpath_fw_len = srcpath_ver_len + 1 + fw_len; + size_t dstpath_fw_len = dstpath_ver_len + sizeof(UAVCAN_ROMFS_FW_PREFIX) + fw_len; + + if (srcpath_fw_len > maxlen) { + warnx("copy: srcpath '%s/%s' too long", srcpath, src_fw_dirent->d_name); + } else if (dstpath_fw_len > maxlen) { + warnx("copy: dstpath '%s/%s%s' too long", dstpath, UAVCAN_ROMFS_FW_PREFIX, src_fw_dirent->d_name); + } else { + // All OK, make the paths and copy the file + srcpath[srcpath_ver_len] = '/'; + memcpy(&srcpath[srcpath_ver_len + 1], src_fw_dirent->d_name, fw_len + 1); + + dstpath[dstpath_ver_len] = '/'; + memcpy(&dstpath[dstpath_ver_len + 1], UAVCAN_ROMFS_FW_PREFIX, sizeof(UAVCAN_ROMFS_FW_PREFIX)); + memcpy(&dstpath[dstpath_ver_len + sizeof(UAVCAN_ROMFS_FW_PREFIX)], src_fw_dirent->d_name, fw_len + 1); + + rv = copyFw(dstpath, srcpath); + if (rv != 0) { + warnx("copy: '%s' -> '%s' failed: %d", srcpath, dstpath, rv); + } else { + warnx("copy: '%s' -> '%s' succeeded", srcpath, dstpath); + } + } + } + + (void)closedir(src_ver_dir); + } + + (void)closedir(dev_dir); + } + + (void)closedir(romfs_dir); +} + +int UavcanServers::copyFw(const char* dst, const char* src) { + int rv = 0; + int dfd, sfd; + uint8_t buffer[512]; + + dfd = open(dst, O_WRONLY | O_CREAT, 0666); + if (dfd < 0) { + warnx("copyFw: couldn't open dst"); + return -errno; + } + + sfd = open(src, O_RDONLY, 0); + if (sfd < 0) { + (void)close(dfd); + warnx("copyFw: couldn't open src"); + return -errno; + } + + ssize_t size = 0; + do { + size = read(sfd, buffer, sizeof(buffer)); + if (size < 0) { + warnx("copyFw: couldn't read"); + rv = -errno; + } else if (size > 0) { + rv = 0; + ssize_t remaining = size; + ssize_t total_written = 0; + ssize_t written = 0; + do { + written = write(dfd, &buffer[total_written], remaining); + if (written < 0) { + warnx("copyFw: couldn't write"); + rv = -errno; + } else { + total_written += written; + remaining -= written; + } + } while (written > 0 && remaining > 0); + } + } while (rv == 0 && size != 0); + + (void)close(dfd); + (void)close(sfd); + + return rv; +} diff --git a/src/modules/uavcan/uavcan_servers.hpp b/src/modules/uavcan/uavcan_servers.hpp index 9d21b8f93f..0b83baa941 100644 --- a/src/modules/uavcan/uavcan_servers.hpp +++ b/src/modules/uavcan/uavcan_servers.hpp @@ -42,16 +42,20 @@ #include #include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -# include "uavcan_virtual_can_driver.hpp" +#include "uavcan_virtual_can_driver.hpp" /** * @file uavcan_servers.hpp @@ -65,6 +69,9 @@ #define UAVCAN_DEVICE_PATH "/dev/uavcan/esc" #define UAVCAN_NODE_DB_PATH "/fs/microsd/uavcan.db" #define UAVCAN_FIRMWARE_PATH "/fs/microsd/fw" +#define UAVCAN_ROMFS_FW_PATH "/etc/uavcan/fw" +#define UAVCAN_ROMFS_FW_PREFIX "romfs_" +#define UAVCAN_MAX_PATH_LENGTH (128 + 40) #define UAVCAN_LOG_FILE UAVCAN_NODE_DB_PATH"/trace.log" /** @@ -88,7 +95,7 @@ class UavcanServers static constexpr unsigned QueuePoolSize = (NumIfaces * uavcan::MemPoolBlockSize * MaxCanFramesPerTransfer); - static constexpr unsigned StackSize = 3500; + static constexpr unsigned StackSize = 6000; static constexpr unsigned Priority = 120; typedef uavcan::SubNode SubNode; @@ -140,7 +147,84 @@ private: uavcan::FirmwareUpdateTrigger _fw_upgrade_trigger; uavcan::BasicFileServer _fw_server; + /* + * The MAVLink parameter bridge needs to know the maximum parameter index + * of each node so that clients can determine when parameter listings have + * finished. We do that by querying a node's entire parameter set whenever + * a parameter message is received for a node with a zero _param_count, + * and storing the count here. If a node doesn't respond, or doesn't have + * any parameters, its count will stay at zero and we'll try to query the + * set again next time. + * + * The node's UAVCAN ID is used as the index into the _param_counts array. + */ + uint8_t _param_counts[128]; + bool _count_in_progress; + uint8_t _count_index; + + bool _param_in_progress; + uint8_t _param_index; + bool _param_list_in_progress; + bool _param_list_all_nodes; + uint8_t _param_list_node_id; + + uint32_t _param_dirty_bitmap[4]; + uint8_t _param_save_opcode; + + bool _cmd_in_progress; + + // uORB topic handle for MAVLink parameter responses + orb_advert_t _param_response_pub; + + typedef uavcan::MethodBinder &)> GetSetCallback; + typedef uavcan::MethodBinder &)> ExecuteOpcodeCallback; + typedef uavcan::MethodBinder &)> RestartNodeCallback; + void cb_getset(const uavcan::ServiceCallResult &result); + void cb_count(const uavcan::ServiceCallResult &result); + void cb_opcode(const uavcan::ServiceCallResult &result); + void cb_restart(const uavcan::ServiceCallResult &result); + + uavcan::ServiceClient _param_getset_client; + uavcan::ServiceClient _param_opcode_client; + uavcan::ServiceClient _param_restartnode_client; + void param_count(uavcan::NodeID node_id); + void param_opcode(uavcan::NodeID node_id); + + uint8_t get_next_active_node_id(uint8_t base); + uint8_t get_next_dirty_node_id(uint8_t base); + void set_node_params_dirty(uint8_t node_id) { _param_dirty_bitmap[node_id >> 5] |= 1 << (node_id & 31); } + void clear_node_params_dirty(uint8_t node_id) { _param_dirty_bitmap[node_id >> 5] &= ~(1 << (node_id & 31)); } + bool are_node_params_dirty(uint8_t node_id) const { return bool((_param_dirty_bitmap[node_id >> 5] >> (node_id & 31)) & 1); } + bool _mutex_inited; volatile bool _check_fw; + // ESC enumeration + bool _esc_enumeration_active; + uint8_t _esc_enumeration_ids[uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize]; + uint8_t _esc_enumeration_index; + uint8_t _esc_set_index; + uint8_t _esc_count; + + typedef uavcan::MethodBinder &)> EnumerationBeginCallback; + typedef uavcan::MethodBinder&)> + EnumerationIndicationCallback; + void cb_enumeration_begin(const uavcan::ServiceCallResult &result); + void cb_enumeration_indication(const uavcan::ReceivedDataStructure &msg); + void cb_enumeration_getset(const uavcan::ServiceCallResult &result); + void cb_enumeration_save(const uavcan::ServiceCallResult &result); + + uavcan::Publisher _beep_pub; + uavcan::Subscriber _enumeration_indication_sub; + uavcan::ServiceClient _enumeration_client; + uavcan::ServiceClient _enumeration_getset_client; + uavcan::ServiceClient _enumeration_save_client; + + void unpackFwFromROMFS(const char* sd_path, const char* romfs_path); + int copyFw(const char* dst, const char* src); }; diff --git a/src/modules/uavcan/uavcan_virtual_can_driver.hpp b/src/modules/uavcan/uavcan_virtual_can_driver.hpp index 5ef9de0d87..1c861e481c 100644 --- a/src/modules/uavcan/uavcan_virtual_can_driver.hpp +++ b/src/modules/uavcan/uavcan_virtual_can_driver.hpp @@ -395,7 +395,7 @@ class VirtualCanDriver : public uavcan::ICanDriver, int rv = sem_getvalue(&sem, &count); if (rv > 0 && count <= 0) { - sem_post(&sem); + px4_sem_post(&sem); } } }; diff --git a/src/modules/unit_test/CMakeLists.txt b/src/modules/unit_test/CMakeLists.txt new file mode 100644 index 0000000000..6fd63d931d --- /dev/null +++ b/src/modules/unit_test/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__unit_test + COMPILE_FLAGS + -Os + SRCS + unit_test.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/unit_test/module.mk b/src/modules/unit_test/module.mk deleted file mode 100644 index 5000790a59..0000000000 --- a/src/modules/unit_test/module.mk +++ /dev/null @@ -1,40 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# Makefile to build the unit test library. -# - -SRCS = unit_test.cpp - -MAXOPTIMIZATION = -Os diff --git a/src/modules/vtol_att_control/CMakeLists.txt b/src/modules/vtol_att_control/CMakeLists.txt new file mode 100644 index 0000000000..6af889f52a --- /dev/null +++ b/src/modules/vtol_att_control/CMakeLists.txt @@ -0,0 +1,51 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE modules__vtol_att_control + MAIN vtol_att_control + COMPILE_FLAGS + -Wno-write-strings + + SRCS + vtol_att_control_main.cpp + vtol_att_control_params.c + tiltrotor_params.c + tiltrotor.cpp + vtol_type.cpp + tailsitter.cpp + standard_params.c + standard.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/vtol_att_control/module.mk b/src/modules/vtol_att_control/module.mk deleted file mode 100644 index d3f9326b04..0000000000 --- a/src/modules/vtol_att_control/module.mk +++ /dev/null @@ -1,49 +0,0 @@ -############################################################################ -# -# Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name PX4 nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# -# VTOL attitude controller -# - -MODULE_COMMAND = vtol_att_control - -SRCS = vtol_att_control_main.cpp \ - vtol_att_control_params.c \ - tiltrotor_params.c \ - tiltrotor.cpp \ - vtol_type.cpp \ - tailsitter.cpp \ - standard_params.c \ - standard.cpp - -EXTRACXXFLAGS = -Wno-write-strings diff --git a/src/platforms/common/CMakeLists.txt b/src/platforms/common/CMakeLists.txt new file mode 100644 index 0000000000..7b50768ac1 --- /dev/null +++ b/src/platforms/common/CMakeLists.txt @@ -0,0 +1,51 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +set(depends + msg_gen + prebuild_targets + git_mavlink + git_uavcan + ) + +if(${OS} STREQUAL "posix" OR ${BOARD} STREQUAL "sim") + list(APPEND depends git_eigen) +endif() + +px4_add_module( + MODULE platforms__common + SRCS + px4_getopt.c + DEPENDS + ${depends} + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/drivers/camera_trigger/module.mk b/src/platforms/nuttx/CMakeLists.txt similarity index 87% rename from src/drivers/camera_trigger/module.mk rename to src/platforms/nuttx/CMakeLists.txt index 54098cc855..37c2ac4879 100644 --- a/src/drivers/camera_trigger/module.mk +++ b/src/platforms/nuttx/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (C) 2015 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -30,13 +30,13 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ - -# -# External camera-IMU synchronisation via GPIO -# - -MODULE_COMMAND = camera_trigger -SRCS = camera_trigger.cpp \ - camera_trigger_params.c - -MAXOPTIMIZATION = -Os +px4_add_module( + MODULE platforms__nuttx + COMPILE_FLAGS + -Os + SRCS + px4_nuttx_impl.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/nuttx/px4_layer/CMakeLists.txt b/src/platforms/nuttx/px4_layer/CMakeLists.txt new file mode 100644 index 0000000000..86dc1ebb48 --- /dev/null +++ b/src/platforms/nuttx/px4_layer/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__nuttx__px4_layer + COMPILE_FLAGS + -Os + SRCS + px4_nuttx_tasks.c + ../../posix/px4_layer/px4_log.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c b/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c index e9b722de4c..1849374fb2 100644 --- a/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c +++ b/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c @@ -50,7 +50,9 @@ #include #include +#ifndef CONFIG_ARCH_BOARD_SIM #include +#endif #include @@ -61,7 +63,9 @@ void px4_systemreset(bool to_bootloader) { if (to_bootloader) { +#ifndef CONFIG_ARCH_BOARD_SIM stm32_pwr_enablebkp(); +#endif /* XXX wow, this is evil - write a magic number into backup register zero */ *(uint32_t *)0x40002850 = 0xb007b007; diff --git a/src/platforms/posix/drivers/accelsim/CMakeLists.txt b/src/platforms/posix/drivers/accelsim/CMakeLists.txt new file mode 100644 index 0000000000..e5b1a92147 --- /dev/null +++ b/src/platforms/posix/drivers/accelsim/CMakeLists.txt @@ -0,0 +1,41 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__drivers__accelsim + MAIN accelsim + SRCS + accelsim.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/drivers/accelsim/accelsim.cpp b/src/platforms/posix/drivers/accelsim/accelsim.cpp index 174c522383..fa0a256605 100644 --- a/src/platforms/posix/drivers/accelsim/accelsim.cpp +++ b/src/platforms/posix/drivers/accelsim/accelsim.cpp @@ -448,6 +448,9 @@ ACCELSIM::init() { int ret = ERROR; + struct mag_report mrp = {}; + struct accel_report arp = {}; + /* do SIM init first */ if (VDev::init() != OK) { PX4_WARN("SIM init failed"); @@ -478,7 +481,6 @@ ACCELSIM::init() measure(); /* advertise sensor topic, measure manually to initialize valid report */ - struct mag_report mrp; _mag_reports->get(&mrp); /* measurement will have generated a report, publish */ @@ -493,7 +495,6 @@ ACCELSIM::init() _accel_class_instance = register_class_devname(ACCEL_BASE_DEVICE_PATH); /* advertise sensor topic, measure manually to initialize valid report */ - struct accel_report arp; _accel_reports->get(&arp); /* measurement will have generated a report, publish */ @@ -1014,7 +1015,7 @@ ACCELSIM::measure() } raw_accel_report; #pragma pack(pop) - accel_report accel_report; + accel_report accel_report = {}; /* start the performance counter */ perf_begin(_accel_sample_perf); @@ -1023,7 +1024,7 @@ ACCELSIM::measure() memset(&raw_accel_report, 0, sizeof(raw_accel_report)); raw_accel_report.cmd = DIR_READ | ACC_READ; - if(OK != transfer((uint8_t *)&raw_accel_report, (uint8_t *)&raw_accel_report, sizeof(raw_accel_report))) { + if (OK != transfer((uint8_t *)&raw_accel_report, (uint8_t *)&raw_accel_report, sizeof(raw_accel_report))) { return; } diff --git a/src/platforms/posix/drivers/adcsim/CMakeLists.txt b/src/platforms/posix/drivers/adcsim/CMakeLists.txt new file mode 100644 index 0000000000..93cdd95a0f --- /dev/null +++ b/src/platforms/posix/drivers/adcsim/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__drivers__adcsim + MAIN adcsim + COMPILE_FLAGS + -Os + SRCS + adcsim.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/drivers/airspeedsim/CMakeLists.txt b/src/platforms/posix/drivers/airspeedsim/CMakeLists.txt new file mode 100644 index 0000000000..8c2a410862 --- /dev/null +++ b/src/platforms/posix/drivers/airspeedsim/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__drivers__airspeedsim + MAIN measairspeedsim + COMPILE_FLAGS + -Os + SRCS + airspeedsim.cpp + meas_airspeed_sim.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/drivers/airspeedsim/meas_airspeed_sim.cpp b/src/platforms/posix/drivers/airspeedsim/meas_airspeed_sim.cpp index 5aca386acb..3474b0bcaa 100644 --- a/src/platforms/posix/drivers/airspeedsim/meas_airspeed_sim.cpp +++ b/src/platforms/posix/drivers/airspeedsim/meas_airspeed_sim.cpp @@ -354,12 +354,6 @@ MEASAirspeedSim::voltage_correction(float &diff_press_pa, float &temperature) namespace meas_airspeed_sim { -/* oddly, ERROR is not defined for c++ */ -#ifdef ERROR -# undef ERROR -#endif -const int ERROR = -1; - MEASAirspeedSim *g_dev = nullptr; int start(int i2c_bus); @@ -589,7 +583,7 @@ measairspeedsim_main(int argc, char *argv[]) } } - int ret; + int ret = 0; /* * Start/load the driver. diff --git a/src/platforms/posix/drivers/barosim/CMakeLists.txt b/src/platforms/posix/drivers/barosim/CMakeLists.txt new file mode 100644 index 0000000000..15963f87eb --- /dev/null +++ b/src/platforms/posix/drivers/barosim/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__drivers__barosim + MAIN barosim + COMPILE_FLAGS + -Os + SRCS + baro.cpp + baro_sim.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/drivers/barosim/baro.cpp b/src/platforms/posix/drivers/barosim/baro.cpp index 1d4e63f94f..f69363fd40 100644 --- a/src/platforms/posix/drivers/barosim/baro.cpp +++ b/src/platforms/posix/drivers/barosim/baro.cpp @@ -72,12 +72,6 @@ enum BAROSIM_BUS { BAROSIM_BUS_SIM_EXTERNAL }; -/* oddly, ERROR is not defined for c++ */ -#ifdef ERROR -# undef ERROR -#endif -static const int ERROR = -1; - /* helper macro for handling report buffer indices */ #define INCREMENT(_x, _lim) do { __typeof__(_x) _tmp = _x+1; if (_tmp >= _lim) _tmp = 0; _x = _tmp; } while(0) diff --git a/src/platforms/posix/drivers/barosim/barosim.h b/src/platforms/posix/drivers/barosim/barosim.h index 8eaa0c21f5..bac176d400 100644 --- a/src/platforms/posix/drivers/barosim/barosim.h +++ b/src/platforms/posix/drivers/barosim/barosim.h @@ -80,5 +80,5 @@ extern bool crc4(uint16_t *n_prom); } /* namespace */ /* interface factories */ -extern device::Device *BAROSIM_sim_interface(barosim::prom_u &prom_buf, uint8_t busnum) __attribute__((weak)); +extern device::Device *BAROSIM_sim_interface(barosim::prom_u &prom_buf, uint8_t busnum); typedef device::Device *(*BAROSIM_constructor)(barosim::prom_u &prom_buf, uint8_t busnum); diff --git a/src/platforms/posix/drivers/gpssim/CMakeLists.txt b/src/platforms/posix/drivers/gpssim/CMakeLists.txt new file mode 100644 index 0000000000..2c580d7757 --- /dev/null +++ b/src/platforms/posix/drivers/gpssim/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__drivers__gpssim + MAIN gpssim + COMPILE_FLAGS + -Os + SRCS + gpssim.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/drivers/gpssim/gpssim.cpp b/src/platforms/posix/drivers/gpssim/gpssim.cpp index 9108a6f228..d94fc35f8a 100644 --- a/src/platforms/posix/drivers/gpssim/gpssim.cpp +++ b/src/platforms/posix/drivers/gpssim/gpssim.cpp @@ -37,7 +37,8 @@ */ #include -#include +#define __STDC_FORMAT_MACROS +#include #include #include #include diff --git a/src/platforms/posix/drivers/gyrosim/CMakeLists.txt b/src/platforms/posix/drivers/gyrosim/CMakeLists.txt new file mode 100644 index 0000000000..335bee65d6 --- /dev/null +++ b/src/platforms/posix/drivers/gyrosim/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__drivers__gyrosim + MAIN gyrosim + STACK 1200 + COMPILE_FLAGS + -Os + SRCS + gyrosim.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/drivers/gyrosim/gyrosim.cpp b/src/platforms/posix/drivers/gyrosim/gyrosim.cpp index 5eb8ff7fea..cbe1dbef41 100644 --- a/src/platforms/posix/drivers/gyrosim/gyrosim.cpp +++ b/src/platforms/posix/drivers/gyrosim/gyrosim.cpp @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -419,6 +418,9 @@ GYROSIM::init() return ret; } + struct accel_report arp = {}; + struct gyro_report grp = {}; + /* allocate basic report buffers */ _accel_reports = new ringbuffer::RingBuffer(2, sizeof(accel_report)); if (_accel_reports == nullptr) { @@ -466,7 +468,6 @@ GYROSIM::init() measure(); /* advertise sensor topic, measure manually to initialize valid report */ - struct accel_report arp; _accel_reports->get(&arp); /* measurement will have generated a report, publish */ @@ -482,7 +483,6 @@ GYROSIM::init() /* advertise sensor topic, measure manually to initialize valid report */ - struct gyro_report grp; _gyro_reports->get(&grp); _gyro->_gyro_topic = orb_advertise_multi(ORB_ID(sensor_gyro), &grp, @@ -511,8 +511,10 @@ GYROSIM::transfer(uint8_t *send, uint8_t *recv, unsigned len) if (cmd == MPUREAD) { // Get data from the simulator Simulator *sim = Simulator::getInstance(); - if (sim == NULL) + if (sim == NULL) { + PX4_WARN("failed accessing simulator"); return ENODEV; + } // FIXME - not sure what interrupt status should be recv[1] = 0; @@ -529,6 +531,7 @@ GYROSIM::transfer(uint8_t *send, uint8_t *recv, unsigned len) if (recv) memcpy(&recv[1], &_regdata[reg-MPUREG_PRODUCT_ID], len-1); } + return PX4_OK; } @@ -765,8 +768,9 @@ GYROSIM::ioctl(device::file_t *filp, int cmd, unsigned long arg) bool want_start = (_call_interval == 0); /* if we need to start the poll state machine, do it */ - if (want_start) + if (want_start) { start(); + } return OK; } @@ -1012,7 +1016,7 @@ GYROSIM::measure() x++; } #endif - struct MPUReport mpu_report; + struct MPUReport mpu_report = {}; /* start measuring */ perf_begin(_sample_perf); @@ -1031,8 +1035,8 @@ GYROSIM::measure() /* * Report buffers. */ - accel_report arb; - gyro_report grb; + accel_report arb = {}; + gyro_report grb = {}; // for now use local time but this should be the timestamp of the simulator grb.timestamp = hrt_absolute_time(); diff --git a/src/platforms/posix/drivers/tonealrmsim/CMakeLists.txt b/src/platforms/posix/drivers/tonealrmsim/CMakeLists.txt new file mode 100644 index 0000000000..0ac134ea9c --- /dev/null +++ b/src/platforms/posix/drivers/tonealrmsim/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__drivers__tonealrmsim + MAIN tone_alarm + COMPILE_FLAGS + -Os + SRCS + tone_alarm.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/include/hrt_work.h b/src/platforms/posix/include/hrt_work.h index 4584baf258..47cdf5872a 100644 --- a/src/platforms/posix/include/hrt_work.h +++ b/src/platforms/posix/include/hrt_work.h @@ -32,6 +32,7 @@ ****************************************************************************/ #include +#include #include #include @@ -39,7 +40,7 @@ __BEGIN_DECLS -extern sem_t _hrt_work_lock; +extern px4_sem_t _hrt_work_lock; extern struct wqueue_s g_hrt_work; void hrt_work_queue_init(void); @@ -49,15 +50,13 @@ void hrt_work_cancel(struct work_s *work); static inline void hrt_work_lock(void); static inline void hrt_work_lock() { - //PX4_INFO("hrt_work_lock"); - sem_wait(&_hrt_work_lock); + px4_sem_wait(&_hrt_work_lock); } static inline void hrt_work_unlock(void); static inline void hrt_work_unlock() { - //PX4_INFO("hrt_work_unlock"); - sem_post(&_hrt_work_lock); + px4_sem_post(&_hrt_work_lock); } __END_DECLS diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index be2eae5090..fd9fdef5c6 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -61,16 +61,21 @@ extern "C" { void _SigIntHandler(int sig_num); void _SigIntHandler(int sig_num) { - _ExitFlag = true; + cout.flush(); + cout << endl << "Exiting.." << endl; + cout.flush(); + _exit(0); } } static void print_prompt() { + cout.flush(); cout << "pxh> "; + cout.flush(); } -static void run_cmd(const vector &appargs) +static void run_cmd(const vector &appargs, bool exit_on_fail) { // command is appargs[0] string command = appargs[0]; @@ -86,7 +91,11 @@ static void run_cmd(const vector &appargs) } arg[i] = (char *)0; - apps[command](i, (char **)arg); + int retval = apps[command](i, (char **)arg); + + if (exit_on_fail && retval) { + exit(retval); + } usleep(65000); } else if (command.compare("help") == 0) { @@ -113,13 +122,13 @@ static void usage() cout << " -h - help/usage information" << std::endl; } -static void process_line(string &line) +static void process_line(string &line, bool exit_on_fail) { vector appargs(8); stringstream(line) >> appargs[0] >> appargs[1] >> appargs[2] >> appargs[3] >> appargs[4] >> appargs[5] >> appargs[6] >> appargs[7]; - run_cmd(appargs); + run_cmd(appargs, exit_on_fail); } int main(int argc, char **argv) @@ -175,7 +184,7 @@ int main(int argc, char **argv) if (infile.is_open()) { for (string line; getline(infile, line, '\n');) { - process_line(line); + process_line(line, false); } } else { @@ -198,7 +207,7 @@ int main(int argc, char **argv) if (ret > 0) { getline(cin, mystr); - process_line(mystr); + process_line(mystr, !daemon_mode); mystr = ""; } } @@ -212,10 +221,10 @@ int main(int argc, char **argv) if (px4_task_is_running("muorb")) { // sending muorb stop is needed if it is running to exit cleanly vector muorb_stop_cmd = { "muorb", "stop" }; - run_cmd(muorb_stop_cmd); + run_cmd(muorb_stop_cmd, !daemon_mode); } vector shutdown_cmd = { "shutdown" }; - run_cmd(shutdown_cmd); + run_cmd(shutdown_cmd, true); } } diff --git a/src/platforms/posix/px4_layer/CMakeLists.txt b/src/platforms/posix/px4_layer/CMakeLists.txt new file mode 100644 index 0000000000..402e66e097 --- /dev/null +++ b/src/platforms/posix/px4_layer/CMakeLists.txt @@ -0,0 +1,47 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__px4_layer + COMPILE_FLAGS + -Os + SRCS + px4_posix_impl.cpp + px4_posix_tasks.cpp + px4_sem.cpp + lib_crc32.c + drv_hrt.c + px4_log.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/px4_layer/drv_hrt.c b/src/platforms/posix/px4_layer/drv_hrt.c index 2fbe8cd70a..10792b3089 100644 --- a/src/platforms/posix/px4_layer/drv_hrt.c +++ b/src/platforms/posix/px4_layer/drv_hrt.c @@ -37,12 +37,15 @@ * High-resolution timer with callouts and timekeeping. */ +#include #include #include #include #include #include +#define __STDC_FORMAT_MACROS #include +#include #include "hrt_work.h" static struct sq_queue_s callout_queue; @@ -59,7 +62,7 @@ static void hrt_call_reschedule(void); #define HRT_INTERVAL_MIN 50 #define HRT_INTERVAL_MAX 50000000 -static sem_t _hrt_lock; +static px4_sem_t _hrt_lock; static struct work_s _hrt_work; static hrt_abstime px4_timestart = 0; @@ -70,14 +73,12 @@ __EXPORT hrt_abstime hrt_reset(void); static void hrt_lock(void) { - //printf("hrt_lock\n"); - sem_wait(&_hrt_lock); + px4_sem_wait(&_hrt_lock); } static void hrt_unlock(void) { - //printf("hrt_unlock\n"); - sem_post(&_hrt_lock); + px4_sem_post(&_hrt_lock); } #ifdef __PX4_DARWIN @@ -86,32 +87,38 @@ static void hrt_unlock(void) #define MAC_NANO (+1.0E-9) #define MAC_GIGA UINT64_C(1000000000) #define CLOCK_MONOTONIC 1 -#define clockid_t int +#define HRT_LOCK_NAME "/hrt_lock" static double px4_timebase = 0.0; -int clock_gettime(clockid_t clk_id, struct timespec *t) +int px4_clock_gettime(clockid_t clk_id, struct timespec *tp) { if (clk_id != CLOCK_MONOTONIC) { return 1; } - // XXX multithreading locking if (!px4_timestart) { - mach_timebase_info_data_t tb = { 0 }; + mach_timebase_info_data_t tb = {}; mach_timebase_info(&tb); px4_timebase = tb.numer; px4_timebase /= tb.denom; - px4_timestart = mach_absolute_time(); + // px4_timestart = mach_absolute_time(); } - memset(t, 0, sizeof(*t)); + memset(tp, 0, sizeof(*tp)); - double diff = (mach_absolute_time() - px4_timestart) * px4_timebase; - t->tv_sec = diff * MAC_NANO; - t->tv_nsec = diff - (t->tv_sec * MAC_GIGA); + double diff = mach_absolute_time() * px4_timebase; + tp->tv_sec = diff * MAC_NANO; + tp->tv_nsec = diff - (tp->tv_sec * MAC_GIGA); return 0; } + +int px4_clock_settime(clockid_t clk_id, struct timespec *tp) +{ + /* do nothing right now */ + return 0; +} + #endif /* @@ -122,11 +129,11 @@ hrt_abstime hrt_absolute_time(void) struct timespec ts; if (!px4_timestart) { - clock_gettime(CLOCK_MONOTONIC, &ts); + px4_clock_gettime(CLOCK_MONOTONIC, &ts); px4_timestart = ts_to_abstime(&ts); } - clock_gettime(CLOCK_MONOTONIC, &ts); + px4_clock_gettime(CLOCK_MONOTONIC, &ts); return ts_to_abstime(&ts) - px4_timestart; } @@ -227,9 +234,13 @@ void hrt_call_delay(struct hrt_call *entry, hrt_abstime delay) */ void hrt_init(void) { - //printf("hrt_init\n"); sq_init(&callout_queue); - sem_init(&_hrt_lock, 0, 1); + + int sem_ret = px4_sem_init(&_hrt_lock, 0, 1); + if (sem_ret) { + PX4_ERR("SEM INIT FAIL: %s", strerror(errno)); + } + memset(&_hrt_work, 0, sizeof(_hrt_work)); } @@ -335,7 +346,7 @@ hrt_call_reschedule() static void hrt_call_internal(struct hrt_call *entry, hrt_abstime deadline, hrt_abstime interval, hrt_callout callout, void *arg) { - //PX4_INFO("hrt_call_internal deadline=%lu interval = %lu", deadline, interval); + PX4_DEBUG("hrt_call_internal deadline=%lu interval = %lu", deadline, interval); hrt_lock(); //PX4_INFO("hrt_call_internal after lock"); @@ -351,7 +362,7 @@ hrt_call_internal(struct hrt_call *entry, hrt_abstime deadline, hrt_abstime inte sq_rem(&entry->link, &callout_queue); } -#if 0 +#if 1 // Use this to debug busy CPU that keeps rescheduling with 0 period time if (interval < HRT_INTERVAL_MIN) { diff --git a/src/platforms/posix/px4_layer/px4_posix_impl.cpp b/src/platforms/posix/px4_layer/px4_posix_impl.cpp index 94387f648b..19747556a9 100644 --- a/src/platforms/posix/px4_layer/px4_posix_impl.cpp +++ b/src/platforms/posix/px4_layer/px4_posix_impl.cpp @@ -48,6 +48,7 @@ #include "systemlib/param/param.h" #include "hrt_work.h" #include +#include "px4_time.h" extern pthread_t _shell_task_id; @@ -55,8 +56,6 @@ __BEGIN_DECLS long PX4_TICKS_PER_SEC = sysconf(_SC_CLK_TCK); -extern void hrt_init(void); - __END_DECLS namespace px4 @@ -67,7 +66,7 @@ void init_once(void); void init_once(void) { _shell_task_id = pthread_self(); - PX4_INFO("Shell id is %lu", _shell_task_id); + printf("[init] shell id: %lu\n", (unsigned long)_shell_task_id); work_queues_init(); hrt_work_queue_init(); hrt_init(); @@ -75,7 +74,18 @@ void init_once(void) void init(int argc, char *argv[], const char *app_name) { - printf("App name: %s\n", app_name); + printf("[init] task name: %s\n", app_name); + printf("\n"); + printf("______ __ __ ___ \n"); + printf("| ___ \\ \\ \\ / / / |\n"); + printf("| |_/ / \\ V / / /| |\n"); + printf("| __/ / \\ / /_| |\n"); + printf("| | / /^\\ \\ \\___ |\n"); + printf("\\_| \\/ \\/ |_/\n"); + printf("\n"); + printf("Ready to fly.\n"); + printf("\n"); + printf("\n"); } uint64_t get_time_micros() diff --git a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp b/src/platforms/posix/px4_layer/px4_posix_tasks.cpp index c8f8d801c5..f112290cb3 100644 --- a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp +++ b/src/platforms/posix/px4_layer/px4_posix_tasks.cpp @@ -135,7 +135,7 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int taskdata->argc = argc; for (i=0; iargv[i] = (char *)offset; strcpy((char *)offset, argv[i]); offset+=strlen(argv[i])+1; @@ -271,7 +271,7 @@ void px4_show_tasks() for (idx=0; idx < PX4_MAX_TASKS; idx++) { if (taskmap[idx].isused) { - PX4_INFO(" %-10s %lu", taskmap[idx].name.c_str(), taskmap[idx].pid); + PX4_INFO(" %-10s %lu", taskmap[idx].name.c_str(), (unsigned long)taskmap[idx].pid); count++; } } diff --git a/src/examples/flow_position_estimator/flow_position_estimator_params.c b/src/platforms/posix/px4_layer/px4_sem.cpp similarity index 56% rename from src/examples/flow_position_estimator/flow_position_estimator_params.c rename to src/platforms/posix/px4_layer/px4_sem.cpp index b565797874..70d9431c05 100644 --- a/src/examples/flow_position_estimator/flow_position_estimator_params.c +++ b/src/platforms/posix/px4_layer/px4_sem.cpp @@ -1,8 +1,6 @@ /**************************************************************************** * - * Copyright (C) 2008-2013 PX4 Development Team. All rights reserved. - * Author: Samuel Zihlmann - * Lorenz Meier + * Copyright (c) 2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -33,40 +31,77 @@ * ****************************************************************************/ -/* - * @file flow_position_estimator_params.c +/** + * @file px4_sem.cpp * - * Parameters for position estimator + * PX4 Middleware Wrapper Linux Implementation */ -#include "flow_position_estimator_params.h" +#include +#include +#include +#include +#include +#include -/* Extended Kalman Filter covariances */ +#ifdef __PX4_DARWIN -/* controller parameters */ -PARAM_DEFINE_FLOAT(FPE_LO_THRUST, 0.4f); -PARAM_DEFINE_FLOAT(FPE_SONAR_LP_U, 0.5f); -PARAM_DEFINE_FLOAT(FPE_SONAR_LP_L, 0.2f); -PARAM_DEFINE_INT32(FPE_DEBUG, 0); +#include +#include -int parameters_init(struct flow_position_estimator_param_handles *h) +int px4_sem_init(px4_sem_t *s, int pshared, unsigned value) { - /* PID parameters */ - h->minimum_liftoff_thrust = param_find("FPE_LO_THRUST"); - h->sonar_upper_lp_threshold = param_find("FPE_SONAR_LP_U"); - h->sonar_lower_lp_threshold = param_find("FPE_SONAR_LP_L"); - h->debug = param_find("FPE_DEBUG"); + // We do not used the process shared arg + (void)pshared; + s->value = value; + pthread_cond_init(&(s->wait), NULL); + pthread_mutex_init(&(s->lock), NULL); - return OK; + return 0; } -int parameters_update(const struct flow_position_estimator_param_handles *h, struct flow_position_estimator_params *p) +int px4_sem_wait(px4_sem_t *s) { - param_get(h->minimum_liftoff_thrust, &(p->minimum_liftoff_thrust)); - param_get(h->sonar_upper_lp_threshold, &(p->sonar_upper_lp_threshold)); - param_get(h->sonar_lower_lp_threshold, &(p->sonar_lower_lp_threshold)); - param_get(h->debug, &(p->debug)); + pthread_mutex_lock(&(s->lock)); + s->value--; + if(s->value < 0) { + pthread_cond_wait(&(s->wait), &(s->lock)); + } + pthread_mutex_unlock(&(s->lock)); - return OK; + return 0; } + +int px4_sem_post(px4_sem_t *s) +{ + pthread_mutex_lock(&(s->lock)); + s->value++; + if(s->value <= 0) { + pthread_cond_signal(&(s->wait)); + } + pthread_mutex_unlock(&(s->lock)); + + return 0; +} + +int px4_sem_getvalue(px4_sem_t *s, int *sval) +{ + pthread_mutex_lock(&(s->lock)); + *sval = s->value; + pthread_mutex_unlock(&(s->lock)); + + return 0; +} + +int px4_sem_destroy(px4_sem_t *s) +{ + pthread_mutex_lock(&(s->lock)); + pthread_cond_destroy(&(s->wait)); + pthread_mutex_unlock(&(s->lock)); + pthread_mutex_destroy(&(s->lock)); + + return 0; +} + +#endif diff --git a/src/platforms/posix/tests/hello/CMakeLists.txt b/src/platforms/posix/tests/hello/CMakeLists.txt new file mode 100644 index 0000000000..f19e4eb872 --- /dev/null +++ b/src/platforms/posix/tests/hello/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__tests__hello + MAIN hello + SRCS + hello_main.cpp + hello_start_posix.cpp + hello_example.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/tests/hrt_test/CMakeLists.txt b/src/platforms/posix/tests/hrt_test/CMakeLists.txt new file mode 100644 index 0000000000..3a67f630ea --- /dev/null +++ b/src/platforms/posix/tests/hrt_test/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__tests__hrt_test + MAIN hrttest + SRCS + hrt_test_main.cpp + hrt_test_start_posix.cpp + hrt_test.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/tests/muorb/CMakeLists.txt b/src/platforms/posix/tests/muorb/CMakeLists.txt new file mode 100644 index 0000000000..967a598cb4 --- /dev/null +++ b/src/platforms/posix/tests/muorb/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__tests__muorb + MAIN muorb_test + SRCS + muorb_test_main.cpp + muorb_test_start_posix.cpp + muorb_test_example.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/tests/vcdev_test/CMakeLists.txt b/src/platforms/posix/tests/vcdev_test/CMakeLists.txt new file mode 100644 index 0000000000..b7ff2cc9e2 --- /dev/null +++ b/src/platforms/posix/tests/vcdev_test/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__tests__vcdev_test + MAIN vcdevtest + SRCS + vcdevtest_main.cpp + vcdevtest_start_posix.cpp + vcdevtest_example.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/tests/wqueue/CMakeLists.txt b/src/platforms/posix/tests/wqueue/CMakeLists.txt new file mode 100644 index 0000000000..6efd698949 --- /dev/null +++ b/src/platforms/posix/tests/wqueue/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__tests__wqueue + MAIN wqueue_test + SRCS + wqueue_main.cpp + wqueue_start_posix.cpp + wqueue_test.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/work_queue/CMakeLists.txt b/src/platforms/posix/work_queue/CMakeLists.txt new file mode 100644 index 0000000000..1ee2dec52d --- /dev/null +++ b/src/platforms/posix/work_queue/CMakeLists.txt @@ -0,0 +1,55 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__posix__work_queue + COMPILE_FLAGS + -Os + SRCS + hrt_thread.c + hrt_queue.c + hrt_work_cancel.c + work_thread.c + work_lock.c + work_queue.c + work_cancel.c + queue.c + dq_addlast.c + dq_remfirst.c + sq_addlast.c + sq_remfirst.c + sq_addafter.c + dq_rem.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/posix/work_queue/hrt_thread.c b/src/platforms/posix/work_queue/hrt_thread.c index 9ba01d9eee..efe09ea860 100644 --- a/src/platforms/posix/work_queue/hrt_thread.c +++ b/src/platforms/posix/work_queue/hrt_thread.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -67,7 +68,7 @@ struct wqueue_s g_hrt_work; /**************************************************************************** * Private Variables ****************************************************************************/ -sem_t _hrt_work_lock; +px4_sem_t _hrt_work_lock; /**************************************************************************** * Private Functions @@ -262,7 +263,7 @@ static int work_hrtthread(int argc, char *argv[]) void hrt_work_queue_init(void) { - sem_init(&_hrt_work_lock, 0, 1); + px4_sem_init(&_hrt_work_lock, 0, 1); // Create high priority worker thread g_hrt_work.pid = px4_task_spawn_cmd("wkr_hrt", diff --git a/src/platforms/posix/work_queue/work_lock.c b/src/platforms/posix/work_queue/work_lock.c index 3547362816..31fa1b7562 100644 --- a/src/platforms/posix/work_queue/work_lock.c +++ b/src/platforms/posix/work_queue/work_lock.c @@ -31,21 +31,19 @@ * ****************************************************************************/ #include -#include +#include #include #include "work_lock.h" -extern sem_t _work_lock[]; +extern px4_sem_t _work_lock[]; void work_lock(int id) { - //PX4_INFO("work_lock %d", id); - sem_wait(&_work_lock[id]); + px4_sem_wait(&_work_lock[id]); } void work_unlock(int id) { - //PX4_INFO("work_unlock %d", id); - sem_post(&_work_lock[id]); + px4_sem_post(&_work_lock[id]); } diff --git a/src/platforms/posix/work_queue/work_thread.c b/src/platforms/posix/work_queue/work_thread.c index 9e3a507a4d..ec565bcfcc 100644 --- a/src/platforms/posix/work_queue/work_thread.c +++ b/src/platforms/posix/work_queue/work_thread.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -68,7 +69,7 @@ struct wqueue_s g_work[NWORKERS]; /**************************************************************************** * Private Variables ****************************************************************************/ -sem_t _work_lock[NWORKERS]; +px4_sem_t _work_lock[NWORKERS]; /**************************************************************************** * Private Functions @@ -187,10 +188,10 @@ static void work_process(struct wqueue_s *wqueue, int lock_id) ****************************************************************************/ void work_queues_init(void) { - sem_init(&_work_lock[HPWORK], 0, 1); - sem_init(&_work_lock[LPWORK], 0, 1); + px4_sem_init(&_work_lock[HPWORK], 0, 1); + px4_sem_init(&_work_lock[LPWORK], 0, 1); #ifdef CONFIG_SCHED_USRWORK - sem_init(&_work_lock[USRWORK], 0, 1); + px4_sem_init(&_work_lock[USRWORK], 0, 1); #endif // Create high priority worker thread diff --git a/src/platforms/px4_defines.h b/src/platforms/px4_defines.h index 8660276405..69dc2d64eb 100644 --- a/src/platforms/px4_defines.h +++ b/src/platforms/px4_defines.h @@ -144,9 +144,13 @@ typedef param_t px4_param_t; /* FIXME - Used to satisfy build */ #define getreg32(a) (*(volatile uint32_t *)(a)) +#ifdef __PX4_QURT +#define PX4_TICKS_PER_SEC 1000L +#else __BEGIN_DECLS extern long PX4_TICKS_PER_SEC; __END_DECLS +#endif #define USEC_PER_TICK (1000000UL/PX4_TICKS_PER_SEC) #define USEC2TICK(x) (((x)+(USEC_PER_TICK/2))/USEC_PER_TICK) diff --git a/src/platforms/px4_log.h b/src/platforms/px4_log.h index a8208313e6..55bf3a55bc 100644 --- a/src/platforms/px4_log.h +++ b/src/platforms/px4_log.h @@ -63,40 +63,40 @@ static inline void do_nothing(int level, ...) #define PX4_ERR(...) ROS_WARN(__VA_ARGS__) #define PX4_WARN(...) ROS_WARN(__VA_ARGS__) #define PX4_INFO(...) ROS_WARN(__VA_ARGS__) -#define PX4_DEBUG(...) +#define PX4_DEBUG(...) #elif defined(__PX4_QURT) #include "qurt_log.h" /**************************************************************************** * Messages that should never be filtered or compiled out ****************************************************************************/ -#define PX4_LOG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ALWAYS, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_INFO(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ALWAYS, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_LOG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ALWAYS, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_INFO(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ALWAYS, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #if defined(TRACE_BUILD) /**************************************************************************** * Extremely Verbose settings for a Trace build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_DEBUG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_DEBUG, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_DEBUG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_DEBUG, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #elif defined(DEBUG_BUILD) /**************************************************************************** * Verbose settings for a Debug build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_DEBUG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_DEBUG, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_DEBUG(FMT, ...) qurt_log(_PX4_LOG_LEVEL_DEBUG, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #elif defined(RELEASE_BUILD) /**************************************************************************** * Non-verbose settings for a Release build to minimize strings in build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #define PX4_WARN(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_WARN, FMT, ##__VA_ARGS__) #define PX4_DEBUG(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_DEBUG, FMT, ##__VA_ARGS__) @@ -104,14 +104,14 @@ static inline void do_nothing(int level, ...) /**************************************************************************** * Medium verbose settings for a default build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) -#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILENAME__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) qurt_log(_PX4_LOG_LEVEL_PANIC, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) qurt_log(_PX4_LOG_LEVEL_ERROR, __FILE__, __LINE__, FMT, ##__VA_ARGS__) +#define PX4_WARN(FMT, ...) qurt_log(_PX4_LOG_LEVEL_WARN, __FILE__, __LINE__, FMT, ##__VA_ARGS__) #define PX4_DEBUG(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_DEBUG, FMT, ##__VA_ARGS__) #endif -#define PX4_LOG_NAMED(name, FMT, ...) qurt_log( _PX4_LOG_LEVEL_ALWAYS, __FILENAME__, __LINE__, "%s " FMT, name, ##__VA_ARGS__) -#define PX4_LOG_NAMED_COND(name, cond, FMT, ...) if( cond ) qurt_log( _PX4_LOG_LEVEL_ALWAYS, __FILENAME__, __LINE__, "%s " FMT, name, ##__VA_ARGS__) +#define PX4_LOG_NAMED(name, FMT, ...) qurt_log( _PX4_LOG_LEVEL_ALWAYS, __FILE__, __LINE__, "%s " FMT, name, ##__VA_ARGS__) +#define PX4_LOG_NAMED_COND(name, cond, FMT, ...) if( cond ) qurt_log( _PX4_LOG_LEVEL_ALWAYS, __FILE__, __LINE__, "%s " FMT, name, ##__VA_ARGS__) #else @@ -130,20 +130,20 @@ __EXPORT extern int __px4_log_level_current; __END_DECLS // __px4_log_level_current will be initialized to PX4_LOG_LEVEL_AT_RUN_TIME -#define PX4_LOG_LEVEL_AT_RUN_TIME _PX4_LOG_LEVEL_WARN +#define PX4_LOG_LEVEL_AT_RUN_TIME _PX4_LOG_LEVEL_ERROR /**************************************************************************** * Implementation of log section formatting based on printf * * To write to a specific stream for each message type, open the streams and * set __px4__log_startline to something like: - * if (level <= __px4_log_level_current) printf(_px4_fd[level], + * if (level <= __px4_log_level_current) printf(_px4_fd[level], * * Additional behavior can be added using "{\" for __px4__log_startline and * "}" for __px4__log_endline and any other required setup or teardown steps ****************************************************************************/ -#define __px4__log_startcond(cond) if (cond) printf( -#define __px4__log_startline(level) if (level <= __px4_log_level_current) printf( +#define __px4__log_printcond(cond, ...) if (cond) printf(__VA_ARGS__) +#define __px4__log_printline(level, ...) if (level <= __px4_log_level_current) printf(__VA_ARGS__) #define __px4__log_timestamp_fmt "%-10" PRIu64 " " #define __px4__log_timestamp_arg ,hrt_absolute_time() @@ -172,12 +172,12 @@ __END_DECLS * if the first arg/condition is true. ****************************************************************************/ #define __px4_log_named_cond(name, cond, FMT, ...) \ - __px4__log_startcond(cond)\ + __px4__log_printcond(cond,\ "%s " \ FMT\ __px4__log_end_fmt \ ,name, ##__VA_ARGS__\ - __px4__log_endline + ) /**************************************************************************** * __px4_log: @@ -187,12 +187,12 @@ __END_DECLS * printf("%-5s val is %d\n", __px4_log_level_str[3], val); ****************************************************************************/ #define __px4_log(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt \ FMT\ __px4__log_end_fmt \ __px4__log_level_arg(level), ##__VA_ARGS__\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_timestamp: @@ -203,7 +203,7 @@ __END_DECLS * hrt_absolute_time(), val); ****************************************************************************/ #define __px4_log_timestamp(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ FMT\ @@ -211,7 +211,7 @@ __END_DECLS __px4__log_level_arg(level)\ __px4__log_timestamp_arg\ , ##__VA_ARGS__\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_timestamp_thread: @@ -222,7 +222,7 @@ __END_DECLS * hrt_absolute_time(), pthread_self(), val); ****************************************************************************/ #define __px4_log_timestamp_thread(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ __px4__log_thread_fmt\ @@ -232,18 +232,18 @@ __END_DECLS __px4__log_timestamp_arg\ __px4__log_thread_arg\ , ##__VA_ARGS__\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_file_and_line: * Convert a message in the form: * PX4_WARN("val is %d", val); * to - * printf("%-5s val is %d (file %s line %u)\n", + * printf("%-5s val is %d (file %s line %u)\n", * __px4_log_level_str[3], val, __FILE__, __LINE__); ****************************************************************************/ #define __px4_log_file_and_line(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ FMT\ @@ -253,19 +253,19 @@ __END_DECLS __px4__log_timestamp_arg\ , ##__VA_ARGS__\ __px4__log_file_and_line_arg\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_timestamp_file_and_line: * Convert a message in the form: * PX4_WARN("val is %d", val); * to - * printf("%-5s %-10lu val is %d (file %s line %u)\n", + * printf("%-5s %-10lu val is %d (file %s line %u)\n", * __px4_log_level_str[3], hrt_absolute_time(), * val, __FILE__, __LINE__); ****************************************************************************/ #define __px4_log_timestamp_file_and_line(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ FMT\ @@ -275,19 +275,19 @@ __END_DECLS __px4__log_timestamp_arg\ , ##__VA_ARGS__\ __px4__log_file_and_line_arg\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_thread_file_and_line: * Convert a message in the form: * PX4_WARN("val is %d", val); * to - * printf("%-5s %#X val is %d (file %s line %u)\n", - * __px4_log_level_str[3], pthread_self(), + * printf("%-5s %#X val is %d (file %s line %u)\n", + * __px4_log_level_str[3], pthread_self(), * val, __FILE__, __LINE__); ****************************************************************************/ #define __px4_log_thread_file_and_line(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_thread_fmt\ FMT\ @@ -297,19 +297,19 @@ __END_DECLS __px4__log_thread_arg\ , ##__VA_ARGS__\ __px4__log_file_and_line_arg\ - __px4__log_endline + ) /**************************************************************************** * __px4_log_timestamp_thread_file_and_line: * Convert a message in the form: * PX4_WARN("val is %d", val); * to - * printf("%-5s %-10lu %#X val is %d (file %s line %u)\n", - * __px4_log_level_str[3], hrt_absolute_time(), + * printf("%-5s %-10lu %#X val is %d (file %s line %u)\n", + * __px4_log_level_str[3], hrt_absolute_time(), * pthread_self(), val, __FILE__, __LINE__); ****************************************************************************/ #define __px4_log_timestamp_thread_file_and_line(level, FMT, ...) \ - __px4__log_startline(level)\ + __px4__log_printline(level,\ __px4__log_level_fmt\ __px4__log_timestamp_fmt\ __px4__log_thread_fmt\ @@ -321,7 +321,7 @@ __END_DECLS __px4__log_thread_arg\ , ##__VA_ARGS__\ __px4__log_file_and_line_arg\ - __px4__log_endline + ) /**************************************************************************** @@ -357,8 +357,8 @@ __END_DECLS /**************************************************************************** * Non-verbose settings for a Release build to minimize strings in build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) __px4_log_file_and_line(_PX4_LOG_LEVEL_PANIC, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) __px4_log_file_and_line(_PX4_LOG_LEVEL_ERROR, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) __px4_log(_PX4_LOG_LEVEL_PANIC, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) __px4_log(_PX4_LOG_LEVEL_ERROR, FMT, ##__VA_ARGS__) #define PX4_WARN(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_WARN, FMT, ##__VA_ARGS__) #define PX4_DEBUG(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_DEBUG, FMT, ##__VA_ARGS__) @@ -366,9 +366,9 @@ __END_DECLS /**************************************************************************** * Medium verbose settings for a default build ****************************************************************************/ -#define PX4_PANIC(FMT, ...) __px4_log_file_and_line(_PX4_LOG_LEVEL_PANIC, FMT, ##__VA_ARGS__) -#define PX4_ERR(FMT, ...) __px4_log_file_and_line(_PX4_LOG_LEVEL_ERROR, FMT, ##__VA_ARGS__) -#define PX4_WARN(FMT, ...) __px4_log_file_and_line(_PX4_LOG_LEVEL_WARN, FMT, ##__VA_ARGS__) +#define PX4_PANIC(FMT, ...) __px4_log(_PX4_LOG_LEVEL_PANIC, FMT, ##__VA_ARGS__) +#define PX4_ERR(FMT, ...) __px4_log(_PX4_LOG_LEVEL_ERROR, FMT, ##__VA_ARGS__) +#define PX4_WARN(FMT, ...) __px4_log(_PX4_LOG_LEVEL_WARN, FMT, ##__VA_ARGS__) #define PX4_DEBUG(FMT, ...) __px4_log_omit(_PX4_LOG_LEVEL_DEBUG, FMT, ##__VA_ARGS__) #endif diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index b0deef16c1..497f3be04c 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -48,6 +48,7 @@ /* includes when building for ros */ #include "ros/ros.h" #include +#define __STDC_FORMAT_MACROS #include #include #else diff --git a/src/platforms/px4_posix.h b/src/platforms/px4_posix.h index d4309b11b0..bd682d9ce5 100644 --- a/src/platforms/px4_posix.h +++ b/src/platforms/px4_posix.h @@ -48,6 +48,45 @@ #include +/* Semaphore handling */ + +#ifdef __PX4_DARWIN + +__BEGIN_DECLS + +typedef struct +{ + pthread_mutex_t lock; + pthread_cond_t wait; + int value; +} px4_sem_t; + +__EXPORT int px4_sem_init(px4_sem_t *s, int pshared, unsigned value); +__EXPORT int px4_sem_wait(px4_sem_t *s); +__EXPORT int px4_sem_post(px4_sem_t *s); +__EXPORT int px4_sem_getvalue(px4_sem_t *s, int *sval); +__EXPORT int px4_sem_destroy(px4_sem_t *s); + +__END_DECLS + +#else + +__BEGIN_DECLS + +typedef sem_t px4_sem_t; + +#define px4_sem_init sem_init +#define px4_sem_wait sem_wait +#define px4_sem_post sem_post +#define px4_sem_getvalue sem_getvalue +#define px4_sem_destroy sem_destroy + +__END_DECLS + +#endif + +//################################### + #ifdef __PX4_NUTTX #define PX4_F_RDONLY 1 @@ -85,7 +124,7 @@ typedef struct { pollevent_t revents; /* The output event flags */ /* Required for PX4 compatability */ - sem_t *sem; /* Pointer to semaphore used to post output event */ + px4_sem_t *sem; /* Pointer to semaphore used to post output event */ void *priv; /* For use by drivers */ } px4_pollfd_struct_t; diff --git a/src/platforms/px4_subscriber.h b/src/platforms/px4_subscriber.h index 9b0ca1319a..e92c82fc66 100644 --- a/src/platforms/px4_subscriber.h +++ b/src/platforms/px4_subscriber.h @@ -38,8 +38,10 @@ */ #pragma once +#ifndef CONFIG_ARCH_BOARD_SIM #include #include +#endif #if defined(__PX4_ROS) /* includes when building for ros */ @@ -219,10 +221,12 @@ public: protected: uORB::SubscriptionBase * _uorb_sub; /**< Handle to the subscription */ +#ifndef CONFIG_ARCH_BOARD_SIM typename std::remove_referencedata())>::type getUORBData() { return (typename std::remove_referencedata())>::type)*_uorb_sub; } +#endif /** * Get void pointer to last message value @@ -242,8 +246,13 @@ public: * @param cbf Callback, executed on receiving a new message * @param interval Minimal interval between calls to callback */ - SubscriberUORBCallback(unsigned interval, - std::function cbf) : + SubscriberUORBCallback(unsigned interval +#ifndef CONFIG_ARCH_BOARD_SIM + ,std::function cbf) +#else + ) +#endif + : SubscriberUORB(interval), _cbf(cbf) {} @@ -277,7 +286,9 @@ public: }; protected: +#ifndef CONFIG_ARCH_BOARD_SIM std::function _cbf; /**< Callback that the user provided on the subscription */ +#endif }; #endif diff --git a/src/platforms/px4_tasks.h b/src/platforms/px4_tasks.h index 3d36a65cfd..9dc237e63b 100644 --- a/src/platforms/px4_tasks.h +++ b/src/platforms/px4_tasks.h @@ -80,6 +80,12 @@ typedef int px4_task_t; #error "No target OS defined" #endif +#if defined (__PX4_LINUX) || defined(__PX4_NUTTX) +#include +#else +#define prctl(_action, _string, _pid) +#endif + typedef int px4_task_t; typedef struct { diff --git a/src/platforms/px4_time.h b/src/platforms/px4_time.h index 5a93dedf40..22751b3a99 100644 --- a/src/platforms/px4_time.h +++ b/src/platforms/px4_time.h @@ -8,6 +8,20 @@ #define px4_clock_gettime clock_gettime #define px4_clock_settime clock_settime +#elif defined(__PX4_DARWIN) + +__BEGIN_DECLS + +#define clockid_t unsigned +#define CLOCK_REALTIME 0 + +int px4_clock_gettime(clockid_t clk_id, struct timespec *tp); +int px4_clock_settime(clockid_t clk_id, struct timespec *tp); + +__EXPORT unsigned int sleep(unsigned int sec); + +__END_DECLS + #elif defined(__PX4_QURT) #include diff --git a/src/platforms/qurt/dspal/dspal_stub.c b/src/platforms/qurt/dspal/dspal_stub.c index 996a279d87..fc736a169c 100644 --- a/src/platforms/qurt/dspal/dspal_stub.c +++ b/src/platforms/qurt/dspal/dspal_stub.c @@ -33,20 +33,16 @@ #include #include -#define STACK_SIZE 0x8000 -static char __attribute__ ((aligned (16))) stack1[STACK_SIZE]; +//#define STACK_SIZE 0x8000 +//static char __attribute__ ((aligned (16))) stack1[STACK_SIZE]; -int main(int argc, char* argv[]) +static void do_dlopen() { - int ret = 0; - char *builtin[]={"libgcc.so", "libc.so", "libstdc++.so"}; +#if 0 void *handle; char *error; void (*entry_function)() = NULL; - printf("In DSPAL main\n"); - dlinit(3, builtin); -#if 0 handle = dlopen ("libdspal_client.so", RTLD_LAZY); if (!handle) { printf("Error opening libdspal_client.so\n"); @@ -59,6 +55,18 @@ int main(int argc, char* argv[]) } dlclose(handle); #endif +} + + +int main(int argc, char* argv[]) +{ + int ret = 0; + char *builtin[]={"libgcc.so", "libc.so", "libstdc++.so"}; + + printf("In DSPAL main\n"); + dlinit(3, builtin); + + do_dlopen(); return ret; } diff --git a/src/drivers/px4flow/module.mk b/src/platforms/qurt/px4_layer/CMakeLists.txt similarity index 66% rename from src/drivers/px4flow/module.mk rename to src/platforms/qurt/px4_layer/CMakeLists.txt index 8d6964d103..b1b99b63f2 100644 --- a/src/drivers/px4flow/module.mk +++ b/src/platforms/qurt/px4_layer/CMakeLists.txt @@ -1,6 +1,6 @@ ############################################################################ # -# Copyright (c) 2013 PX4 Development Team. All rights reserved. +# Copyright (c) 2015 PX4 Development Team. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -31,16 +31,43 @@ # ############################################################################ -# -# Makefile to build the PX4FLOW driver. -# +set(QURT_LAYER_SRCS + px4_qurt_impl.cpp + px4_qurt_tasks.cpp + lib_crc32.c + drv_hrt.c + qurt_stubs.c + main.cpp + params.c + ) +if ("${QURT_ENABLE_STUBS}" STREQUAL "1") + list(APPEND QURT_LAYER_SRCS + ../stubs/stubs_posix.c + ../stubs/stubs_qurt.c + ) +endif() -MODULE_COMMAND = px4flow +# For Eagle, the commands are specific to the build config label +# e.g. config_qurt_eagle_hil uses commands_hil.c +if ("${BOARD}" STREQUAL "eagle") -SRCS = px4flow.cpp + # The CI test target can use the hil commands + if ("${LABEL}" STREQUAL "travis") + set(CONFIG_SRC commands_hil.c) + else() + set(CONFIG_SRC commands_${LABEL}.c) + endif() -MAXOPTIMIZATION = -Os +endif() -MODULE_STACKSIZE = 1200 - -EXTRACXXFLAGS = -Wno-attributes +px4_add_module( + MODULE platforms__qurt__px4_layer + COMPILE_FLAGS + -Os + SRCS + ${QURT_LAYER_SRCS} + ${CONFIG_SRC} + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/qurt/px4_layer/commands_hil.c b/src/platforms/qurt/px4_layer/commands_hil.c index b338aeb7ed..3ff299b89d 100644 --- a/src/platforms/qurt/px4_layer/commands_hil.c +++ b/src/platforms/qurt/px4_layer/commands_hil.c @@ -37,6 +37,7 @@ * @author Mark Charlebois */ +const char *get_commands(void); const char *get_commands() { diff --git a/src/platforms/qurt/px4_layer/commands_muorb_test.c b/src/platforms/qurt/px4_layer/commands_muorb.c similarity index 100% rename from src/platforms/qurt/px4_layer/commands_muorb_test.c rename to src/platforms/qurt/px4_layer/commands_muorb.c diff --git a/src/platforms/qurt/px4_layer/commands_adsp.c b/src/platforms/qurt/px4_layer/commands_release.c similarity index 100% rename from src/platforms/qurt/px4_layer/commands_adsp.c rename to src/platforms/qurt/px4_layer/commands_release.c diff --git a/src/platforms/qurt/px4_layer/commands_default.c b/src/platforms/qurt/px4_layer/commands_test.c similarity index 100% rename from src/platforms/qurt/px4_layer/commands_default.c rename to src/platforms/qurt/px4_layer/commands_test.c diff --git a/src/platforms/qurt/px4_layer/drv_hrt.c b/src/platforms/qurt/px4_layer/drv_hrt.c index 45be19ec8a..b5d6bd20ff 100644 --- a/src/platforms/qurt/px4_layer/drv_hrt.c +++ b/src/platforms/qurt/px4_layer/drv_hrt.c @@ -37,10 +37,12 @@ * High-resolution timer with callouts and timekeeping. */ +#include #include #include #include #include +#include #include #include diff --git a/src/platforms/qurt/px4_layer/main.cpp b/src/platforms/qurt/px4_layer/main.cpp index 45a6e4cec8..15907ded78 100644 --- a/src/platforms/qurt/px4_layer/main.cpp +++ b/src/platforms/qurt/px4_layer/main.cpp @@ -1,6 +1,5 @@ /**************************************************************************** - * - * Copyright (C) 2015 Mark Charlebois. All rights reserved. + * Copyright (C) 2015 Mark Charlebois. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -42,10 +41,12 @@ #include #include #include +#include #include #include #include #include +#include using namespace std; @@ -99,19 +100,9 @@ static void process_commands(map &apps, const char *cmds) bool found_first_char = false; char arg[256]; - // This is added because it is a parameter used by commander, yet created by mavlink. Since mavlink is not - // running on QURT, we need to manually define it so it is available to commander. "2" is for quadrotor. - - // Following is hack to prevent duplicate parameter definition error in param parser - /** - * @board QuRT_App - */ - PARAM_DEFINE_INT32(MAV_TYPE,2); - // Eat leading whitespace eat_whitespace(b, i); - for(;;) { // End of command line if (b[i] == '\n' || b[i] == '\0') { @@ -152,7 +143,7 @@ extern void init_once(void); }; __BEGIN_DECLS -extern int dspal_main(int argc, char *argv[]); +int dspal_main(int argc, char *argv[]); __END_DECLS @@ -164,13 +155,13 @@ int dspal_entry( int argc, char* argv[] ) px4::init_once(); px4::init(argc, (char **)argv, "mainapp"); process_commands(apps, get_commands()); - usleep( 1000000 ); // give time for all commands to execute before starting external function + sleep(1); // give time for all commands to execute before starting external function if(qurt_external_hook) { qurt_external_hook(); } - for( ;; ){ - usleep( 1000000 ); + for(;;){ + sleep(1); } return 0; } diff --git a/src/modules/uavcan/uavcan_clock.cpp b/src/platforms/qurt/px4_layer/params.c similarity index 68% rename from src/modules/uavcan/uavcan_clock.cpp rename to src/platforms/qurt/px4_layer/params.c index fe8ba406a5..3ad35a6a12 100644 --- a/src/modules/uavcan/uavcan_clock.cpp +++ b/src/platforms/qurt/px4_layer/params.c @@ -1,6 +1,5 @@ /**************************************************************************** - * - * Copyright (c) 2014 PX4 Development Team. All rights reserved. + * Copyright (C) 2015 Mark Charlebois. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -31,51 +30,14 @@ * ****************************************************************************/ -#include -#include +#include +// This is added because it is a parameter used by commander, yet created by mavlink. Since mavlink is not +// running on QURT, we need to manually define it so it is available to commander. "2" is for quadrotor. + +// Following is hack to prevent duplicate parameter definition error in param parser /** - * @file uavcan_clock.cpp - * - * Implements a clock for the CAN node. - * - * @author Pavel Kirienko + * @board QuRT_App */ - -namespace uavcan_stm32 -{ -namespace clock -{ - -uavcan::MonotonicTime getMonotonic() -{ - return uavcan::MonotonicTime::fromUSec(hrt_absolute_time()); -} - -uavcan::UtcTime getUtc() -{ - return uavcan::UtcTime(); -} - -void adjustUtc(uavcan::UtcDuration adjustment) -{ - (void)adjustment; -} - -uavcan::uint64_t getUtcUSecFromCanInterrupt(); - -uavcan::uint64_t getUtcUSecFromCanInterrupt() -{ - return 0; -} - -} // namespace clock - -SystemClock &SystemClock::instance() -{ - static SystemClock inst; - return inst; -} - -} +PARAM_DEFINE_INT32(MAV_TYPE,2); diff --git a/src/platforms/qurt/px4_layer/px4_qurt_impl.cpp b/src/platforms/qurt/px4_layer/px4_qurt_impl.cpp index 9925e05dfa..14ef3304bc 100644 --- a/src/platforms/qurt/px4_layer/px4_qurt_impl.cpp +++ b/src/platforms/qurt/px4_layer/px4_qurt_impl.cpp @@ -59,7 +59,7 @@ __BEGIN_DECLS extern uint64_t get_ticks_per_us(); -long PX4_TICKS_PER_SEC = 1000; +//long PX4_TICKS_PER_SEC = 1000L; unsigned int sleep(unsigned int sec) { diff --git a/src/platforms/qurt/px4_layer/qurt_stubs.c b/src/platforms/qurt/px4_layer/qurt_stubs.c index 937393bc65..1ec8f2e71f 100644 --- a/src/platforms/qurt/px4_layer/qurt_stubs.c +++ b/src/platforms/qurt/px4_layer/qurt_stubs.c @@ -31,93 +31,90 @@ * ****************************************************************************/ #include "px4_log.h" -//extern "C" { +#include + +void block_indefinite(void); +void _Read_uleb(void); +void _Parse_fde_instr(void); +void _Parse_csd(void); +void _Valbytes(void); +void _Get_eh_data(void); +void _Parse_lsda(void); +void __cxa_guard_release(void); +void _Read_enc_ptr(void); +void _Read_sleb(void); +void __cxa_guard_acquire(void); +void __cxa_pure_virtual(void); void block_indefinite( void ) { - for(;;) - { - volatile int x = 0; - ++x; - } + sem_t forever; + sem_init(&forever, 0, 0); + sem_wait(&forever); } void _Read_uleb( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void _Parse_fde_instr( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void _Parse_csd( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); -} - -void _Locksyslock( int x ) -{ - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); -} - -void _Unlocksyslock( int x ) -{ - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void _Valbytes( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void _Get_eh_data( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void _Parse_lsda( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void __cxa_guard_release( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void _Read_enc_ptr( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void _Read_sleb( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void __cxa_guard_acquire( void ) { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } void __cxa_pure_virtual() { - PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); - block_indefinite(); + PX4_WARN( "Error: Calling unresolved symbol stub[%s]", __FUNCTION__ ); + block_indefinite(); } - -//} diff --git a/src/platforms/qurt/stubs/stubs_posix.c b/src/platforms/qurt/stubs/stubs_posix.c new file mode 100644 index 0000000000..991a0b4a85 --- /dev/null +++ b/src/platforms/qurt/stubs/stubs_posix.c @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include + +int sem_init(sem_t *sem, int pshared, unsigned int value) +{ + return 1; +} + +int sem_wait(sem_t *sem) +{ + return 1; +} + +int sem_destroy(sem_t *sem) +{ + return 1; +} + +int sem_post(sem_t *sem) +{ + return 1; +} + +int sem_getvalue(sem_t *sem, int *sval) +{ + return 1; +} + +int usleep(useconds_t usec) +{ + return 0; +} + +pthread_t pthread_self(void) +{ + pthread_t x = 0; + return x; +} + + +int pthread_kill(pthread_t thread, int sig) +{ + return 1; +} + +void pthread_exit(void *retval) +{ +} + +int pthread_join(pthread_t thread, void **retval) +{ + return 1; +} + +int pthread_cancel(pthread_t thread) +{ + return 1; +} +int pthread_attr_init(pthread_attr_t *attr) +{ + return 1; +} + +int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) +{ + return 1; +} + +int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) +{ + return 1; +} + +int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param) +{ + return 1; +} + +int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg) +{ + return 1; +} +int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param) +{ + return 1; +} + +int pthread_attr_destroy(pthread_attr_t *attr) +{ + return 1; +} + +int clock_gettime(clockid_t clk_id, struct timespec *tp) +{ + return 1; +} diff --git a/src/platforms/qurt/stubs/stubs_qurt.c b/src/platforms/qurt/stubs/stubs_qurt.c new file mode 100644 index 0000000000..f114791c4d --- /dev/null +++ b/src/platforms/qurt/stubs/stubs_qurt.c @@ -0,0 +1,16 @@ +#include +#include +#include + +void HAP_debug(const char *msg, int level, const char *filename, int line) +{ +} + +void HAP_power_request(int a, int b, int c) +{ +} + +int dlinit(int a, char **b) +{ + return 1; +} diff --git a/src/platforms/qurt/tests/hello/CMakeLists.txt b/src/platforms/qurt/tests/hello/CMakeLists.txt new file mode 100644 index 0000000000..4664b35f89 --- /dev/null +++ b/src/platforms/qurt/tests/hello/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__qurt__tests__hello + MAIN hello + SRCS + hello_main.cpp + hello_start_qurt.cpp + hello_example.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/qurt/tests/muorb/CMakeLists.txt b/src/platforms/qurt/tests/muorb/CMakeLists.txt new file mode 100644 index 0000000000..ac233a1202 --- /dev/null +++ b/src/platforms/qurt/tests/muorb/CMakeLists.txt @@ -0,0 +1,42 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE platforms__qurt__tests__muorb + MAIN muorb_test + SRCS + muorb_test_start_qurt.cpp + muorb_test_example.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/platforms/qurt/tests/muorb/muorb_test_example.cpp b/src/platforms/qurt/tests/muorb/muorb_test_example.cpp index 2628b56a3b..3b932b5f13 100644 --- a/src/platforms/qurt/tests/muorb/muorb_test_example.cpp +++ b/src/platforms/qurt/tests/muorb/muorb_test_example.cpp @@ -45,7 +45,7 @@ #include #include "uORB/topics/sensor_combined.h" #include "uORB/topics/pwm_input.h" -#include "uORB.h" +#include "modules/uORB/uORB.h" #include "px4_middleware.h" #include "px4_defines.h" #include diff --git a/src/systemcmds/bl_update/CMakeLists.txt b/src/systemcmds/bl_update/CMakeLists.txt new file mode 100644 index 0000000000..5b9d7953e5 --- /dev/null +++ b/src/systemcmds/bl_update/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__bl_update + MAIN bl_update + STACK 4096 + COMPILE_FLAGS + -Os + SRCS + bl_update.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/config/CMakeLists.txt b/src/systemcmds/config/CMakeLists.txt new file mode 100644 index 0000000000..c2e876ff28 --- /dev/null +++ b/src/systemcmds/config/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__config + MAIN config + STACK 4096 + COMPILE_FLAGS + -Os + SRCS + config.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/dumpfile/CMakeLists.txt b/src/systemcmds/dumpfile/CMakeLists.txt new file mode 100644 index 0000000000..5935d7ec06 --- /dev/null +++ b/src/systemcmds/dumpfile/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__dumpfile + MAIN dumpfile + COMPILE_FLAGS + -Os + SRCS + dumpfile.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/esc_calib/CMakeLists.txt b/src/systemcmds/esc_calib/CMakeLists.txt new file mode 100644 index 0000000000..229271b1d8 --- /dev/null +++ b/src/systemcmds/esc_calib/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__esc_calib + MAIN esc_calib + STACK 4096 + COMPILE_FLAGS + -Os + SRCS + esc_calib.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/esc_calib/esc_calib.c b/src/systemcmds/esc_calib/esc_calib.c index 8da9580207..86939ff686 100644 --- a/src/systemcmds/esc_calib/esc_calib.c +++ b/src/systemcmds/esc_calib/esc_calib.c @@ -233,7 +233,10 @@ esc_calib_main(int argc, char *argv[]) ret = poll(&fds, 1, 0); if (ret > 0) { - read(0, &c, 1); + if (read(0, &c, 1) <= 0) { + printf("ESC calibration read error\n"); + return 0; + } if (c == 'y' || c == 'Y') { break; @@ -315,7 +318,10 @@ esc_calib_main(int argc, char *argv[]) ret = poll(&fds, 1, 0); if (ret > 0) { - read(0, &c, 1); + if (read(0, &c, 1) <= 0) { + printf("ESC calibration read error\n"); + goto done; + } if (c == 13) { break; @@ -352,7 +358,10 @@ esc_calib_main(int argc, char *argv[]) ret = poll(&fds, 1, 0); if (ret > 0) { - read(0, &c, 1); + if (read(0, &c, 1) <= 0) { + printf("ESC calibration read error\n"); + goto done; + } if (c == 13) { break; diff --git a/src/systemcmds/i2c/CMakeLists.txt b/src/systemcmds/i2c/CMakeLists.txt new file mode 100644 index 0000000000..04a2b00884 --- /dev/null +++ b/src/systemcmds/i2c/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__i2c + MAIN i2c + COMPILE_FLAGS + -Os + SRCS + i2c.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/mixer/CMakeLists.txt b/src/systemcmds/mixer/CMakeLists.txt new file mode 100644 index 0000000000..703d8210fb --- /dev/null +++ b/src/systemcmds/mixer/CMakeLists.txt @@ -0,0 +1,50 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +set(MIXER_CFLAGS -Os) +if(${OS} STREQUAL "qurt") + list(APPEND MIXER_CFLAGS -Wframe-larger-than=2176) +else() + list(APPEND MIXER_CFLAGS -Wframe-larger-than=2100) +endif() + +px4_add_module( + MODULE systemcmds__mixer + MAIN mixer + STACK 4096 + COMPILE_FLAGS ${MIXER_CFLAGS} + SRCS + mixer.cpp + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/motor_test/CMakeLists.txt b/src/systemcmds/motor_test/CMakeLists.txt new file mode 100644 index 0000000000..77e9905178 --- /dev/null +++ b/src/systemcmds/motor_test/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__motor_test + MAIN motor_test + STACK 4096 + COMPILE_FLAGS + -Os + SRCS + motor_test.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/mtd/CMakeLists.txt b/src/systemcmds/mtd/CMakeLists.txt new file mode 100644 index 0000000000..7c67196736 --- /dev/null +++ b/src/systemcmds/mtd/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__mtd + MAIN mtd + COMPILE_FLAGS + -Wno-error + -Os + SRCS + mtd.c + 24xxxx_mtd.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/nshterm/CMakeLists.txt b/src/systemcmds/nshterm/CMakeLists.txt new file mode 100644 index 0000000000..30c2e58a51 --- /dev/null +++ b/src/systemcmds/nshterm/CMakeLists.txt @@ -0,0 +1,45 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__nshterm + MAIN nshterm + PRIORITY "SCHED_PRIORITY_DEFAULT-30" + STACK 1500 + COMPILE_FLAGS + -Os + SRCS + nshterm.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/param/CMakeLists.txt b/src/systemcmds/param/CMakeLists.txt new file mode 100644 index 0000000000..cd35b0da04 --- /dev/null +++ b/src/systemcmds/param/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__param + MAIN param + STACK 1800 + COMPILE_FLAGS + -Os + SRCS + param.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/param/param.c b/src/systemcmds/param/param.c index 69d56dffcd..88f5197d27 100644 --- a/src/systemcmds/param/param.c +++ b/src/systemcmds/param/param.c @@ -244,7 +244,7 @@ do_load(const char *param_file_name) int fd = open(param_file_name, O_RDONLY); if (fd < 0) { - warn("open '%s'", param_file_name); + warn("open failed '%s'", param_file_name); return 1; } @@ -431,10 +431,6 @@ do_set(const char *name, const char *val, bool fail_on_not_found) return (fail_on_not_found) ? 1 : 0; } - printf("%c %s: ", - param_value_unsaved(param) ? '*' : (param_value_is_default(param) ? ' ' : '+'), - param_name(param)); - /* * Set parameter if type is known and conversion from string to value turns out fine */ @@ -447,10 +443,10 @@ do_set(const char *name, const char *val, bool fail_on_not_found) char *end; int32_t newval = strtol(val, &end, 10); - if (i == newval) { - printf("unchanged\n"); - - } else { + if (i != newval) { + printf("%c %s: ", + param_value_unsaved(param) ? '*' : (param_value_is_default(param) ? ' ' : '+'), + param_name(param)); printf("curr: %ld", (long)i); param_set(param, &newval); printf(" -> new: %ld\n", (long)newval); @@ -468,11 +464,11 @@ do_set(const char *name, const char *val, bool fail_on_not_found) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" - if (f == newval) { + if (f != newval) { #pragma GCC diagnostic pop - printf("unchanged\n"); - - } else { + printf("%c %s: ", + param_value_unsaved(param) ? '*' : (param_value_is_default(param) ? ' ' : '+'), + param_name(param)); printf("curr: %4.4f", (double)f); param_set(param, &newval); printf(" -> new: %4.4f\n", (double)newval); diff --git a/src/systemcmds/perf/CMakeLists.txt b/src/systemcmds/perf/CMakeLists.txt new file mode 100644 index 0000000000..8a0a3a815c --- /dev/null +++ b/src/systemcmds/perf/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__perf + MAIN perf + STACK 1800 + COMPILE_FLAGS + -Os + SRCS + perf.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/pwm/CMakeLists.txt b/src/systemcmds/pwm/CMakeLists.txt new file mode 100644 index 0000000000..df1c6088c9 --- /dev/null +++ b/src/systemcmds/pwm/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__pwm + MAIN pwm + STACK 1800 + COMPILE_FLAGS + -Os + SRCS + pwm.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/reboot/CMakeLists.txt b/src/systemcmds/reboot/CMakeLists.txt new file mode 100644 index 0000000000..635b88b95d --- /dev/null +++ b/src/systemcmds/reboot/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__reboot + MAIN reboot + STACK 800 + COMPILE_FLAGS + -Os + SRCS + reboot.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/reflect/CMakeLists.txt b/src/systemcmds/reflect/CMakeLists.txt new file mode 100644 index 0000000000..f7fcda35cd --- /dev/null +++ b/src/systemcmds/reflect/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__reflect + MAIN reflect + COMPILE_FLAGS + -Os + SRCS + reflect.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/tests/CMakeLists.txt b/src/systemcmds/tests/CMakeLists.txt new file mode 100644 index 0000000000..25cad8505c --- /dev/null +++ b/src/systemcmds/tests/CMakeLists.txt @@ -0,0 +1,81 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +set(srcs + test_adc.c + test_bson.c + test_float.c + test_gpio.c + test_hott_telemetry.c + test_hrt.c + test_int.c + test_jig_voltages.c + test_led.c + test_sensors.c + test_servo.c + test_sleep.c + test_uart_baudchange.c + test_uart_console.c + test_uart_loopback.c + test_uart_send.c + test_mixer.cpp + test_mathlib.cpp + test_file.c + test_file2.c + tests_main.c + test_params.c + test_ppm_loopback.c + test_rc.c + test_conv.cpp + test_mount.c + test_eigen.cpp + ) + +if(${OS} STREQUAL "nuttx") + list(APPEND srcs + test_time.c + ) +endif() + +px4_add_module( + MODULE systemcmds__tests + MAIN tests + STACK 60000 + COMPILE_FLAGS + -Wframe-larger-than=6000 + -O0 + SRCS ${srcs} + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/tests/test_dataman.c b/src/systemcmds/tests/test_dataman.c index da73f68964..3478077b21 100644 --- a/src/systemcmds/tests/test_dataman.c +++ b/src/systemcmds/tests/test_dataman.c @@ -59,7 +59,7 @@ #include "dataman/dataman.h" -static sem_t *sems; +static px4_sem_t *sems; static int task_main(int argc, char *argv[]) @@ -137,12 +137,12 @@ task_main(int argc, char *argv[]) rend = hrt_absolute_time(); warnx("Test %d pass, hit %d, miss %d, io time read %llums. write %llums.", my_id, hit, miss, (rend - rstart) / NUM_MISSIONS_SUPPORTED / 1000, (wend - wstart) / NUM_MISSIONS_SUPPORTED / 1000); - sem_post(sems + my_id); + px4_sem_post(sems + my_id); return 0; fail: warnx("Test %d fail, buffer %02x %02x %02x %02x %02x %02x", my_id, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); - sem_post(sems + my_id); + px4_sem_post(sems + my_id); return -1; } @@ -155,7 +155,7 @@ int test_dataman(int argc, char *argv[]) num_tasks = atoi(argv[1]); } - sems = (sem_t *)malloc(num_tasks * sizeof(sem_t)); + sems = (px4_sem_t *)malloc(num_tasks * sizeof(px4_sem_t)); warnx("Running %d tasks", num_tasks); for (i = 0; i < num_tasks; i++) { @@ -165,7 +165,7 @@ int test_dataman(int argc, char *argv[]) const char *av[2]; av[0] = a; av[1] = 0; - sem_init(sems + i, 1, 0); + px4_sem_init(sems + i, 1, 0); /* start the task */ if ((task = px4_task_spawn_cmd("dataman", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, 2048, task_main, av)) <= 0) { @@ -174,8 +174,8 @@ int test_dataman(int argc, char *argv[]) } for (i = 0; i < num_tasks; i++) { - sem_wait(sems + i); - sem_destroy(sems + i); + px4_sem_wait(sems + i); + px4_sem_destroy(sems + i); } free(sems); diff --git a/src/systemcmds/tests/test_int.c b/src/systemcmds/tests/test_int.c index 051a48e6c2..01092aa2d4 100644 --- a/src/systemcmds/tests/test_int.c +++ b/src/systemcmds/tests/test_int.c @@ -57,7 +57,6 @@ #include #include -#include /**************************************************************************** diff --git a/src/systemcmds/tests/test_param.c b/src/systemcmds/tests/test_params.c similarity index 100% rename from src/systemcmds/tests/test_param.c rename to src/systemcmds/tests/test_params.c diff --git a/src/systemcmds/top/CMakeLists.txt b/src/systemcmds/top/CMakeLists.txt new file mode 100644 index 0000000000..0bf73a923c --- /dev/null +++ b/src/systemcmds/top/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__top + MAIN top + STACK 1700 + COMPILE_FLAGS + -Os + SRCS + top.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/topic_listener/CMakeLists.txt b/src/systemcmds/topic_listener/CMakeLists.txt new file mode 100644 index 0000000000..eb3071f41b --- /dev/null +++ b/src/systemcmds/topic_listener/CMakeLists.txt @@ -0,0 +1,55 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +add_custom_command(OUTPUT topic_listener.cpp + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Tools/generate_listener.py ${CMAKE_SOURCE_DIR} > topic_listener.cpp + ) + +add_custom_target(generate_topic_listener + DEPENDS + topic_listener.cpp + ${CMAKE_SOURCE_DIR}/Tools/generate_listener.py) + +px4_add_module( + MODULE systemcmds__topic_listener + MAIN listener + STACK 1800 + COMPILE_FLAGS + -Os + SRCS + topic_listener.cpp + DEPENDS + platforms__common + generate_topic_listener + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/usb_connected/CMakeLists.txt b/src/systemcmds/usb_connected/CMakeLists.txt new file mode 100644 index 0000000000..7d9966229e --- /dev/null +++ b/src/systemcmds/usb_connected/CMakeLists.txt @@ -0,0 +1,43 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__usb_connected + MAIN usb_connected + COMPILE_FLAGS + -Os + SRCS + usb_connected.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/ver/CMakeLists.txt b/src/systemcmds/ver/CMakeLists.txt new file mode 100644 index 0000000000..f6676b1883 --- /dev/null +++ b/src/systemcmds/ver/CMakeLists.txt @@ -0,0 +1,44 @@ +############################################################################ +# +# Copyright (c) 2015 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ +px4_add_module( + MODULE systemcmds__ver + MAIN ver + STACK 1024 + COMPILE_FLAGS + -Os + SRCS + ver.c + DEPENDS + platforms__common + ) +# vim: set noet ft=cmake fenc=utf-8 ff=unix :