Use dummy bridge stub if fastrtpsgen not found

If the build config specifies RTPS topics to import/export and fastrtpsgen is not installed
on the build machine, then a dummy stub is used for the RTPS bridge.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2017-08-01 22:32:43 +02:00
committed by Lorenz Meier
parent d24503242e
commit f3e2648747
4 changed files with 89 additions and 8 deletions
@@ -207,8 +207,6 @@ set(config_module_list
examples/ekf_att_pos_estimator
)
set(GENERATE_RTPS_BRIDGE on)
set(config_rtps_send_topics
sensor_combined
)
-2
View File
@@ -184,8 +184,6 @@ set(config_extra_builtin_cmds
sercon
)
set(GENERATE_RTPS_BRIDGE on)
set(config_rtps_send_topics
sensor_baro
)
@@ -31,7 +31,26 @@
#
############################################################################
if(NOT GENERATE_RTPS_BRIDGE MATCHES "off")
find_program(FASTRTPSGEN fastrtpsgen)
if(NOT FASTRTPSGEN)
message(WARNING "WARNING: Unable to find fastrtpsgen")
set(GENERATE_RTPS_BRIDGE off)
else()
set(GENERATE_RTPS_BRIDGE on)
endif()
if(GENERATE_RTPS_BRIDGE MATCHES "off")
message(WARNING "WARNING: Building PX4 without RTPS bridge support")
px4_add_module(
MODULE modules__micrortps_bridge__micrortps_client
MAIN micrortps_client
SRCS
microRTPS_client_dummy.cpp
DEPENDS
platforms__common
)
else()
include_directories(.)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
@@ -72,8 +91,6 @@ if(NOT GENERATE_RTPS_BRIDGE MATCHES "off")
set(receive_topic_opt "-r")
endif()
message("SEND ${send_topic_files_opt}")
message("RECV ${receive_topic_files_opt}")
add_custom_command(OUTPUT ${topic_bridge_files_out}
COMMAND ${PYTHON_EXECUTABLE}
${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py
@@ -87,7 +104,6 @@ if(NOT GENERATE_RTPS_BRIDGE MATCHES "off")
VERBATIM
)
endif()
endif()
px4_add_module(
MODULE modules__micrortps_bridge__micrortps_client
@@ -101,4 +117,5 @@ px4_add_module(
DEPENDS
platforms__common
)
endif()
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
@@ -0,0 +1,68 @@
/****************************************************************************
*
* Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
*
* 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 of the copyright holder 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 HOLDER 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 <px4_config.h>
#include <px4_posix.h>
#include <px4_tasks.h>
extern "C" __EXPORT int micrortps_client_main(int argc, char *argv[]);
static void usage(const char *name)
{
PX4_INFO("usage: %s start|stop\n\n", name);
}
int micrortps_client_main(int argc, char *argv[])
{
if (argc < 2)
{
usage(argv[0]);
return -1;
}
if (!strcmp(argv[1], "start"))
{
PX4_WARN("PX4 built without RTPS bridge support, EXITING...\n");
return -1;
}
if (!strcmp(argv[1], "stop"))
{
PX4_INFO("Not running");
return -1;
}
usage(argv[0]);
return -1;
}