36 #include "build_git_version.h" 40 #if !defined(CONFIG_CDCACM_PRODUCTID) 41 # define CONFIG_CDCACM_PRODUCTID 0 44 #if defined(__PX4_LINUX) 45 #include <sys/utsname.h> 68 uint32_t version_number = 0;
71 size_t buffer_counter = 0;
72 size_t dash_count = 0;
73 size_t point_count = 0;
74 char version[3] = {0, 0, 0};
77 for (
size_t i = 0; i < strlen(tag); i++) {
81 }
else if (tag[i] ==
'.') {
85 if (tag[i] ==
'r' && i < strlen(tag) - 1 && tag[i + 1] ==
'c') {
88 }
else if (tag[i] ==
'p') {
91 }
else if (tag[i] ==
't' && i < strlen(tag) - 1 && tag[i + 1] ==
'y') {
94 }
else if (tag[i] ==
't') {
97 }
else if (tag[i] ==
'v' && i > 0) {
103 (dash_count == 2 && point_count == 2) ||
104 (dash_count == 3 && point_count == 4) ||
105 (dash_count == 4 && point_count == 4)) {
109 for (
size_t i = 0; i < strlen(tag); i++) {
110 if (buffer_counter > 2) {
114 if (tag[i] >=
'0' && tag[i] <=
'9') {
115 buffer = (buffer == -1) ? 0 : buffer;
116 buffer = buffer * 10 + (tag[i] -
'0');
120 version[buffer_counter] = buffer;
129 version[buffer_counter] = buffer;
133 if (buffer_counter <= 0) {
134 firmware_type = 0x00;
137 if (buffer_counter == 3 || buffer_counter == 6) {
138 version_number = ((uint8_t)version[0] << 8 * 3) |
139 ((uint8_t)version[1] << 8 * 2) |
140 ((uint8_t)version[2] << 8 * 1) | firmware_type;
146 return version_number;
156 uint32_t version_number = 0;
159 size_t buffer_counter = 0;
160 char version[6] = {0, 0, 0, 0, 0, 0};
161 size_t dash_count = 0;
162 size_t point_count = 0;
165 for (
size_t i = 0; i < strlen(tag); i++) {
169 }
else if (tag[i] ==
'.') {
173 if (tag[i] ==
'r' && i < strlen(tag) - 1 && tag[i + 1] ==
'c') {
176 }
else if (tag[i] ==
'p') {
179 }
else if (tag[i] ==
't' && i < strlen(tag) - 1 && tag[i + 1] ==
'y') {
182 }
else if (tag[i] ==
't') {
185 }
else if (tag[i] ==
'v' && i > 0) {
191 (dash_count == 2 && point_count == 2) ||
192 (dash_count == 3 && point_count == 4) ||
193 (dash_count == 4 && point_count == 4)) {
197 for (
size_t i = 0; i < strlen(tag); i++) {
198 if (buffer_counter > 5) {
202 if (tag[i] >=
'0' && tag[i] <=
'9') {
203 buffer = (buffer == -1) ? 0 : buffer;
204 buffer = buffer * 10 + (tag[i] -
'0');
208 if (buffer_counter + 1 == 4 && tag[i] ==
'-') {
212 version[buffer_counter] = buffer;
220 if (buffer >= 0 && (buffer_counter + 1 == 3 || buffer_counter + 1 == 6)) {
221 version[buffer_counter] = buffer;
225 if (buffer_counter == 6) {
226 version_number = ((uint8_t)version[3] << 8 * 3) |
227 ((uint8_t)version[4] << 8 * 2) |
228 ((uint8_t)version[5] << 8 * 1) | firmware_type;
230 }
else if (buffer_counter == 3) {
231 version_number = firmware_type;
237 return version_number;
247 return PX4_GIT_BRANCH_NAME;
252 #if defined(__PX4_NUTTX) 261 #if defined(__PX4_DARWIN) || defined(__PX4_CYGWIN) || defined(__PX4_QURT) 263 #elif defined(__PX4_LINUX) 266 if (uname(&name) == 0) {
267 char *c = name.release;
270 while (*c && *c !=
'-') {
281 #elif defined(__PX4_NUTTX) 284 # error "px4_os_version not implemented for current OS" 290 #if defined(__PX4_NUTTX) 291 return NUTTX_GIT_VERSION_STR;
299 #if defined(__PX4_DARWIN) 301 #elif defined(__PX4_LINUX) 303 #elif defined(__PX4_QURT) 305 #elif defined(__PX4_NUTTX) 307 #elif defined(__PX4_CYGWIN) 310 # error "px4_os_name not implemented for current OS" 316 #if defined(__clang__) 318 #elif defined(__ICC) || defined(__INTEL_COMPILER) 320 #elif defined(__GNUC__) || defined(__GNUG__) 322 #elif defined(_MSC_VER) 323 return "MS Visual Studio";
340 return PX4_GIT_VERSION_STR;
345 return PX4_GIT_VERSION_BINARY;
350 #ifdef ECL_LIB_GIT_VERSION_STRING 351 return ECL_LIB_GIT_VERSION_STRING;
357 #ifdef MAVLINK_LIB_GIT_VERSION_BINARY 360 return MAVLINK_LIB_GIT_VERSION_BINARY;
366 #ifdef NUTTX_GIT_VERSION_BINARY 367 return NUTTX_GIT_VERSION_BINARY;
__EXPORT uint64_t px4_mavlink_lib_version_binary(void)
MAVLink lib version in binary form (first part of the git tag)
const char * px4_os_name(void)
name of the operating system
uint32_t px4_firmware_version(void)
get the PX4 Firmware version
const char * px4_toolchain_version(void)
Toolchain version used to compile PX4 (no particular format)
const char * px4_firmware_git_branch(void)
get the git branch name (can be empty, for example if HEAD points to a tag)
uint64_t px4_os_version_binary(void)
Operating system version in binary form (first part of the git tag)
const char * px4_toolchain_name(void)
Toolchain name used to compile PX4.
uint32_t version_tag_to_number(const char *tag)
Convert a version tag string to a number.
uint32_t px4_os_version(void)
operating system version
uint64_t px4_firmware_version_binary(void)
Firmware version in binary form (first part of the git tag)
const char * px4_firmware_version_string(void)
Firmware version as human readable string (git tag)
const char * px4_build_uri(void)
get the build URI (used for crash logging)
Tools for system version detection.
uint32_t px4_firmware_vendor_version(void)
get the PX4 Firmware vendor version
uint32_t version_tag_to_vendor_version_number(const char *tag)
Convert a version tag string to a vendor version number.
#define CONFIG_CDCACM_PRODUCTID
const char * px4_os_version_string(void)
Operating system version as human readable string (git tag)
uint32_t px4_board_version(void)
get the board version (last 8 bytes should be silicon ID, if any)
const char * px4_ecl_lib_version_string(void)
ECL lib version as human readable string (git tag)