PX4 Firmware
PX4 Autopilot Software http://px4.io
version.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2013-2019 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 /**
35  * @file version.h
36  *
37  * Tools for system version detection.
38  *
39  * @author Anton Babushkin <anton.babushkin@me.com>
40  * @author Beat Küng <beat-kueng@gmx.net>
41  */
42 
43 #pragma once
44 
45 #include <px4_platform_common/px4_config.h>
46 #include <systemlib/px4_macros.h>
47 #include <stdint.h>
48 
50 
51 /**
52  * get the board name as string (including the version if there are multiple)
53  */
54 static inline const char *px4_board_name(void)
55 {
56  return PX4_BOARD_NAME;
57 }
58 
59 /**
60  * get the board sub type
61  */
62 static inline const char *px4_board_sub_type(void)
63 {
64  return board_get_hw_type_name();
65 }
66 
67 /**
68  * get the board HW version
69  */
70 static inline int px4_board_hw_version(void)
71 {
72  return board_get_hw_version();
73 }
74 
75 /**
76  * get the board HW revision
77  */
78 static inline int px4_board_hw_revision(void)
79 {
80  return board_get_hw_revision();
81 }
82 
83 /**
84  * get the build URI (used for crash logging)
85  */
86 const char *px4_build_uri(void);
87 
88 /**
89  * Convert a version tag string to a number
90  * @param tag version tag in one of the following forms:
91  * - vendor: v1.4.0-0.2.0
92  * - dev: v1.4.0-rc3-7-g7e282f57
93  * - rc: v1.4.0-rc4
94  * - beta: v1.4.0-beta1
95  * - release: v1.4.0
96  * - linux: 7.9.3
97  * @return version in the form 0xAABBCCTT (AA: Major, BB: Minor, CC: Patch, TT Type @see FIRMWARE_TYPE)
98  */
99 __EXPORT uint32_t version_tag_to_number(const char *tag);
100 
101 /**
102  * get the PX4 Firmware version
103  * @return version in the form 0xAABBCCTT (AA: Major, BB: Minor, CC: Patch, TT Type @see FIRMWARE_TYPE)
104  */
105 __EXPORT uint32_t px4_firmware_version(void);
106 
107 /**
108  * Convert a version tag string to a vendor version number
109  * @param tag version tag in one of the following forms:
110  * - vendor: v1.4.0-0.2.0
111  * - dev: v1.4.0-rc3-7-g7e282f57
112  * - rc: v1.4.0-rc4
113  * - beta: v1.4.0-beta1
114  * - release: v1.4.0
115  * - linux: 7.9.3
116  * @return version in the form 0xAABBCCTT (AA: Major, BB: Minor, CC: Patch, TT Type @see FIRMWARE_TYPE)
117  */
118 __EXPORT uint32_t version_tag_to_vendor_version_number(const char *tag);
119 
120 /**
121  * get the PX4 Firmware vendor version
122  * @return version in the form 0xAABBCCTT (AA: Major, BB: Minor, CC: Patch, TT Type @see FIRMWARE_TYPE)
123  */
125 
126 /**
127  * get the board version (last 8 bytes should be silicon ID, if any)
128  */
129 __EXPORT uint32_t px4_board_version(void);
130 
131 /**
132  * operating system version
133  * @return version in the form 0xAABBCCTT (AA: Major, BB: Minor, CC: Patch, TT Type @see FIRMWARE_TYPE)
134  */
135 __EXPORT uint32_t px4_os_version(void);
136 
137 /**
138  * Operating system version as human readable string (git tag)
139  * @return string or NULL if not defined
140  */
141 __EXPORT const char *px4_os_version_string(void);
142 
143 /**
144  * name of the operating system
145  * @return human readable string
146  */
147 __EXPORT const char *px4_os_name(void);
148 
149 /**
150  * Toolchain name used to compile PX4
151  */
152 __EXPORT const char *px4_toolchain_name(void);
153 
154 /**
155  * Toolchain version used to compile PX4 (no particular format)
156  */
157 __EXPORT const char *px4_toolchain_version(void);
158 
159 /**
160  * Firmware version as human readable string (git tag)
161  */
162 __EXPORT const char *px4_firmware_version_string(void);
163 
164 /**
165  * get the git branch name (can be empty, for example if HEAD points to a tag)
166  */
167 __EXPORT const char *px4_firmware_git_branch(void);
168 
169 /**
170  * Firmware version in binary form (first part of the git tag)
171  */
173 
174 /**
175  * ECL lib version as human readable string (git tag)
176  */
177 __EXPORT const char *px4_ecl_lib_version_string(void);
178 
179 /**
180  * MAVLink lib version in binary form (first part of the git tag)
181  */
183 
184 /**
185  * Operating system version in binary form (first part of the git tag)
186  * @return this is not available on all OSes and can return 0
187  */
188 __EXPORT uint64_t px4_os_version_binary(void);
189 
191 
__EXPORT uint64_t px4_mavlink_lib_version_binary(void)
MAVLink lib version in binary form (first part of the git tag)
__EXPORT uint32_t version_tag_to_number(const char *tag)
Convert a version tag string to a number.
Definition: version.c:66
static const char * px4_board_sub_type(void)
get the board sub type
Definition: version.h:62
#define __END_DECLS
Definition: visibility.h:59
const char * px4_build_uri(void)
get the build URI (used for crash logging)
Definition: version.c:61
Definition: I2C.hpp:51
A set of useful macros for enhanced runtime and compile time error detection and warning suppression...
__EXPORT uint32_t px4_board_version(void)
get the board version (last 8 bytes should be silicon ID, if any)
Definition: version.c:250
__EXPORT uint64_t px4_firmware_version_binary(void)
Firmware version in binary form (first part of the git tag)
Definition: version.c:343
__EXPORT uint32_t px4_firmware_vendor_version(void)
get the PX4 Firmware vendor version
Definition: version.c:240
__EXPORT const char * px4_ecl_lib_version_string(void)
ECL lib version as human readable string (git tag)
Definition: version.c:348
#define __BEGIN_DECLS
Definition: visibility.h:58
static int px4_board_hw_revision(void)
get the board HW revision
Definition: version.h:78
__EXPORT uint64_t px4_os_version_binary(void)
Operating system version in binary form (first part of the git tag)
Definition: version.c:364
__EXPORT const char * px4_firmware_git_branch(void)
get the git branch name (can be empty, for example if HEAD points to a tag)
Definition: version.c:245
__EXPORT uint32_t px4_firmware_version(void)
get the PX4 Firmware version
Definition: version.c:149
__EXPORT const char * px4_os_version_string(void)
Operating system version as human readable string (git tag)
Definition: version.c:288
static __BEGIN_DECLS const char * px4_board_name(void)
get the board name as string (including the version if there are multiple)
Definition: version.h:54
__EXPORT const char * px4_firmware_version_string(void)
Firmware version as human readable string (git tag)
Definition: version.c:338
__EXPORT const char * px4_toolchain_version(void)
Toolchain version used to compile PX4 (no particular format)
Definition: version.c:329
__EXPORT const char * px4_os_name(void)
name of the operating system
Definition: version.c:297
__EXPORT uint32_t px4_os_version(void)
operating system version
Definition: version.c:259
__EXPORT const char * px4_toolchain_name(void)
Toolchain name used to compile PX4.
Definition: version.c:314
static int px4_board_hw_version(void)
get the board HW version
Definition: version.h:70
__EXPORT uint32_t version_tag_to_vendor_version_number(const char *tag)
Convert a version tag string to a vendor version number.
Definition: version.c:154