diff --git a/Makefile b/Makefile index 201187e021dae06fdc069134c4544001a710ba94..3715beb6ba7adde450b4097174415e7dd762bba5 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,9 @@ GIT_DESC := $(shell git log -1 --pretty=format:%H) ifneq ($(words $(GIT_DESC)),1) GIT_DESC := "unknown_git_version" endif -export GIT_DESC + +$(shell echo "#include \"git_version.h\"" > src/modules/systemlib/git_version.c) +$(shell echo "const char* px4_git_version = \"$(GIT_DESC)\";" >> src/modules/systemlib/git_version.c) # # Canned firmware configurations that we (know how to) build. diff --git a/msg/vehicle_status.msg b/msg/vehicle_status.msg index 4913a02f575561283aac9de344f0a76cd490c64e..c5d5ee9a163cd19cec8f9de977741505a5808df3 100644 --- a/msg/vehicle_status.msg +++ b/msg/vehicle_status.msg @@ -97,8 +97,6 @@ int32 system_type # system type, inspired by MAVLink's VEHICLE_TYPE enum int32 system_id # system id, inspired by MAVLink's system ID field int32 component_id # subsystem / component id, inspired by MAVLink's component ID field -uint64 autopilot_capabilites # bitmask which gives info about autopilot capabilites - bool is_rotary_wing # True if system is in rotary wing configuration, so for a VTOL this is only true while flying as a multicopter bool is_vtol # True if the system is VTOL capable bool vtol_fw_permanent_stab # True if vtol should stabilize attitude for fw in manual mode diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index b30ab6fc64a182bb3a54e2c7ef6d0a65da97d3c4..3a0d1c1f68156229b0bbdd802d06f236d3a2f27a 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -66,6 +66,8 @@ #include <systemlib/err.h> #include <systemlib/perf_counter.h> #include <systemlib/systemlib.h> +#include <systemlib/mcu_version.h> +#include <systemlib/git_version.h> #include <geo/geo.h> #include <dataman/dataman.h> #include <mathlib/mathlib.h> @@ -918,8 +920,39 @@ void Mavlink::send_autopilot_capabilites() { MavlinkOrbSubscription *status_sub = this->add_orb_subscription(ORB_ID(vehicle_status)); if (status_sub->update(&status)) { - mavlink_autopilot_version_t msg; - msg.capabilities = status.autopilot_capabilites; + mavlink_autopilot_version_t msg = {}; + + const char* git_version = px4_git_version; + + msg.capabilities = MAV_PROTOCOL_CAPABILITY_MISSION_FLOAT; + msg.capabilities |= MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT; + msg.capabilities |= MAV_PROTOCOL_CAPABILITY_COMMAND_INT; + msg.capabilities |= MAV_PROTOCOL_CAPABILITY_FTP; + msg.capabilities |= MAV_PROTOCOL_CAPABILITY_FTP; + msg.capabilities |= MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET; + msg.capabilities |= MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED; + msg.capabilities |= MAV_PROTOCOL_CAPABILITY_SET_ACTUATOR_TARGET; + msg.flight_sw_version = 0; + msg.middleware_sw_version = 0; + msg.os_sw_version = 0; + msg.board_version = 0; + memcpy(&msg.flight_custom_version, git_version, sizeof(msg.flight_custom_version)); + memcpy(&msg.middleware_custom_version, git_version, sizeof(msg.middleware_custom_version)); + memset(&msg.os_custom_version, 0, sizeof(msg.os_custom_version)); + #ifdef CONFIG_CDCACM_VENDORID + msg.vendor_id = CONFIG_CDCACM_VENDORID; + #else + msg.vendor_id = 0; + #endif + #ifdef CONFIG_CDCACM_PRODUCTID + msg.product_id = CONFIG_CDCACM_PRODUCTID; + #else + msg.product_id = 0; + #endif + uint32_t uid[3]; + mcu_unique_id(uid); + msg.uid = (((uint64_t)uid[1]) << 32) | uid[2]; + this->send_message(MAVLINK_MSG_ID_AUTOPILOT_VERSION, &msg); } } diff --git a/src/modules/sdlog2/module.mk b/src/modules/sdlog2/module.mk index 6964acf3390ee90fa79431862c7be4020d866036..08dddf219bdbd915a50b4ccd327f8876f3b1d780 100644 --- a/src/modules/sdlog2/module.mk +++ b/src/modules/sdlog2/module.mk @@ -47,5 +47,3 @@ MODULE_STACKSIZE = 1200 MAXOPTIMIZATION = -Os EXTRACFLAGS = -Wframe-larger-than=1400 - -EXTRADEFINES = -DGIT_VERSION='"$(GIT_DESC)"' diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index 37234ca5d373fa44735d4816292b601bf63d733f..b88400c27610da7f45462a061bcb0829fd2ab3e8 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -104,6 +104,7 @@ #include <systemlib/systemlib.h> #include <systemlib/param/param.h> #include <systemlib/perf_counter.h> +#include <systemlib/git_version.h> #include <version/version.h> #include <mavlink/mavlink_log.h> @@ -795,7 +796,7 @@ int write_version(int fd) }; /* fill version message and write it */ - strncpy(log_msg_VER.body.fw_git, GIT_VERSION, sizeof(log_msg_VER.body.fw_git)); + strncpy(log_msg_VER.body.fw_git, px4_git_version, sizeof(log_msg_VER.body.fw_git)); strncpy(log_msg_VER.body.arch, HW_ARCH, sizeof(log_msg_VER.body.arch)); return write(fd, &log_msg_VER, sizeof(log_msg_VER)); } diff --git a/src/modules/systemlib/.gitignore b/src/modules/systemlib/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..58031bb1319e473fa0f21098a5532a589dc61533 --- /dev/null +++ b/src/modules/systemlib/.gitignore @@ -0,0 +1 @@ +git_version.c diff --git a/src/modules/systemlib/git_version.h b/src/modules/systemlib/git_version.h new file mode 100644 index 0000000000000000000000000000000000000000..cd8dc564ed52ac45c9a7533e03302a987bd868fc --- /dev/null +++ b/src/modules/systemlib/git_version.h @@ -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. + * + ****************************************************************************/ + +/** + * @file git_version.h + * + * GIT repository version + */ + +#pragma once + +__BEGIN_DECLS + +__EXPORT extern const char* px4_git_version; + +__END_DECLS diff --git a/src/modules/systemlib/module.mk b/src/modules/systemlib/module.mk index f2499bbb13b46809b1ee68593ca65e84d0d45f91..40b77231070f77d19f076a20adf35510375e6cab 100644 --- a/src/modules/systemlib/module.mk +++ b/src/modules/systemlib/module.mk @@ -55,7 +55,8 @@ SRCS = err.c \ pwm_limit/pwm_limit.c \ circuit_breaker.cpp \ circuit_breaker_params.c \ - mcu_version.c + mcu_version.c \ + git_version.c MAXOPTIMIZATION = -Os diff --git a/src/modules/uavcan/module.mk b/src/modules/uavcan/module.mk index 437feb301483ddd1864c10ae8cd0095281d06e1f..e3fd31a9a1a74cba7d08748406f7909b0c1855b5 100644 --- a/src/modules/uavcan/module.mk +++ b/src/modules/uavcan/module.mk @@ -63,7 +63,7 @@ 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) -DGIT_VERSION='"$(GIT_DESC)"' -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 -DUAVCAN_NO_ASSERTIONS +override EXTRADEFINES := $(EXTRADEFINES) -DUAVCAN_CPP_VERSION=UAVCAN_CPP03 -DUAVCAN_NO_ASSERTIONS # diff --git a/src/modules/uavcan/uavcan_main.cpp b/src/modules/uavcan/uavcan_main.cpp index f04ab9f17c1d240cb3f086f95b70814413487796..474739bd6605d0ee58ef2b012065461bc065a39e 100644 --- a/src/modules/uavcan/uavcan_main.cpp +++ b/src/modules/uavcan/uavcan_main.cpp @@ -42,6 +42,7 @@ #include <systemlib/mixer/mixer.h> #include <systemlib/board_serial.h> #include <systemlib/scheduling_priorities.h> +#include <systemlib/git_version.h> #include <version/version.h> #include <arch/board/board.h> #include <arch/chip/chip.h> @@ -212,7 +213,7 @@ void UavcanNode::fill_node_info() // Extracting the first 8 hex digits of GIT_VERSION and converting them to int char fw_git_short[9] = {}; - std::memmove(fw_git_short, GIT_VERSION, 8); + std::memmove(fw_git_short, px4_git_version, 8); assert(fw_git_short[8] == '\0'); char *end = nullptr; swver.vcs_commit = std::strtol(fw_git_short, &end, 16); diff --git a/src/systemcmds/ver/module.mk b/src/systemcmds/ver/module.mk index 4597b5f1107f1cbb9479db9648e3f3dbf33433f6..2eeb80b616c03c51971deeff58f472b929cf8f20 100644 --- a/src/systemcmds/ver/module.mk +++ b/src/systemcmds/ver/module.mk @@ -42,5 +42,3 @@ SRCS = ver.c MODULE_STACKSIZE = 1024 MAXOPTIMIZATION = -Os - -EXTRADEFINES = -DGIT_VERSION='"$(GIT_DESC)"' diff --git a/src/systemcmds/ver/ver.c b/src/systemcmds/ver/ver.c index b794e8b2fa77e92881e4e2321e7c71b639bdaa35..a248dfb79c28da633ebd9e8be635f96a088ed335 100644 --- a/src/systemcmds/ver/ver.c +++ b/src/systemcmds/ver/ver.c @@ -45,6 +45,7 @@ #include <version/version.h> #include <systemlib/err.h> #include <systemlib/mcu_version.h> +#include <systemlib/git_version.h> /* string constants for version commands */ static const char sz_ver_hw_str[] = "hw"; @@ -101,7 +102,7 @@ int ver_main(int argc, char *argv[]) } if (show_all || !strncmp(argv[1], sz_ver_git_str, sizeof(sz_ver_git_str))) { - printf("FW git-hash: %s\n", GIT_VERSION); + printf("FW git-hash: %s\n", px4_git_version); ret = 0; }