feat(version): report OS version on Windows and QuRT

Replace the previous unconditional 0 with a meaningful value
derived from each toolchain's compile-time macro:
- Windows uses _WIN32_WINNT (0xMMmm) -> major.minor.
- QuRT uses __HEXAGON_ARCH__ (e.g. 66) -> 6.6, falling back to
  0 if the macro is absent.

Both go through version_tag_to_number for parity with the Linux,
Darwin, Cygwin, and NuttX branches.

Signed-off-by: Nuno Marques <n.marques21@hotmail.com>
This commit is contained in:
Nuno Marques
2026-04-27 16:47:08 -07:00
parent 34228cc7af
commit ef01bd5b7d
+22 -3
View File
@@ -35,6 +35,7 @@
#include "build_git_version.h"
#include <stdio.h>
#include <string.h>
#if !defined(CONFIG_CDCACM_PRODUCTID)
@@ -300,9 +301,7 @@ uint32_t px4_board_version(void)
uint32_t px4_os_version(void)
{
#if defined(__PX4_QURT) || defined(__PX4_WINDOWS)
return 0;
#elif defined(__PX4_LINUX) || defined(__PX4_DARWIN) || defined(__PX4_CYGWIN)
#if defined(__PX4_LINUX) || defined(__PX4_DARWIN) || defined(__PX4_CYGWIN)
struct utsname name;
if (uname(&name) == 0) {
@@ -320,6 +319,26 @@ uint32_t px4_os_version(void)
return 0;
}
#elif defined(__PX4_WINDOWS)
// _WIN32_WINNT is the targeted Windows version, encoded as 0xMMmm
// (e.g. 0x0A00 → Windows 10.0). It is set by the toolchain.
char buf[16];
snprintf(buf, sizeof(buf), "%d.%d.0",
(_WIN32_WINNT >> 8) & 0xFF,
_WIN32_WINNT & 0xFF);
return version_tag_to_number(buf);
#elif defined(__PX4_QURT)
// Hexagon clang sets __HEXAGON_ARCH__ to the DSP architecture revision
// (e.g. 66 for hexagonv66), which we map to a major.minor pair.
#ifdef __HEXAGON_ARCH__
char buf[16];
snprintf(buf, sizeof(buf), "%d.%d.0",
__HEXAGON_ARCH__ / 10,
__HEXAGON_ARCH__ % 10);
return version_tag_to_number(buf);
#else
return 0;
#endif
#elif defined(__PX4_NUTTX)
return version_tag_to_number(NUTTX_GIT_TAG_STR);
#else