mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 20:28:37 +08:00
board_name.c: remove the file and HW_ARCH macro, use px4_board_name() instead
boards define BOARD_NAME, so board_name() is not necessary. HW_ARCH was just a wrapper around board_name(). This patch simplifies to having only one common method px4_board_name().
This commit is contained in:
@@ -34,7 +34,6 @@ px4_add_module(
|
|||||||
MODULE drivers__boards__aerocore
|
MODULE drivers__boards__aerocore
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
../common/board_dma_alloc.c
|
../common/board_dma_alloc.c
|
||||||
aerocore_init.c
|
aerocore_init.c
|
||||||
aerocore_timer_config.c
|
aerocore_timer_config.c
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ px4_add_module(
|
|||||||
MODULE drivers__boards__aerofc-v1
|
MODULE drivers__boards__aerofc-v1
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
aerofc_init.c
|
aerofc_init.c
|
||||||
aerofc_spi.c
|
aerofc_spi.c
|
||||||
aerofc_usb.c
|
aerofc_usb.c
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ px4_add_module(
|
|||||||
MODULE drivers__boards__auav-x21
|
MODULE drivers__boards__auav-x21
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
../common/board_dma_alloc.c
|
../common/board_dma_alloc.c
|
||||||
auav_can.c
|
auav_can.c
|
||||||
auav_init.c
|
auav_init.c
|
||||||
|
|||||||
@@ -100,16 +100,6 @@
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Name: board_name
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* All boards must provide this API to return the board name.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
__EXPORT const char *board_name(void);
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: board_dma_alloc_init
|
* Name: board_dma_alloc_init
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 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 board_name.c
|
|
||||||
*
|
|
||||||
* Provide the board_name interface.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <px4_config.h>
|
|
||||||
#include "board_config.h"
|
|
||||||
#include <lib/version/version.h>
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Definitions
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Name: board_name
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* All boards must provide this API to return the board name.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
__EXPORT const char *board_name()
|
|
||||||
{
|
|
||||||
return BOARD_NAME;
|
|
||||||
}
|
|
||||||
@@ -33,7 +33,6 @@
|
|||||||
px4_add_module(
|
px4_add_module(
|
||||||
MODULE drivers__boards__crazyflie
|
MODULE drivers__boards__crazyflie
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
../common/board_dma_alloc.c
|
../common/board_dma_alloc.c
|
||||||
crazyflie_init.c
|
crazyflie_init.c
|
||||||
crazyflie_usb.c
|
crazyflie_usb.c
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ px4_add_module(
|
|||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_dma_alloc.c
|
../common/board_dma_alloc.c
|
||||||
../common/board_name.c
|
|
||||||
mindpx_can.c
|
mindpx_can.c
|
||||||
mindpx2_init.c
|
mindpx2_init.c
|
||||||
mindpx_timer_config.c
|
mindpx_timer_config.c
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
px4_add_module(
|
px4_add_module(
|
||||||
MODULE drivers__boards__px4-stm32f4discovery
|
MODULE drivers__boards__px4-stm32f4discovery
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
px4discovery_init.c
|
px4discovery_init.c
|
||||||
px4discovery_usb.c
|
px4discovery_usb.c
|
||||||
px4discovery_led.c
|
px4discovery_led.c
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ px4_add_module(
|
|||||||
MODULE drivers__boards__px4fmu-v1
|
MODULE drivers__boards__px4fmu-v1
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
px4fmu_can.c
|
px4fmu_can.c
|
||||||
px4fmu_init.c
|
px4fmu_init.c
|
||||||
px4fmu_timer_config.c
|
px4fmu_timer_config.c
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ px4_add_module(
|
|||||||
MODULE drivers__boards__px4fmu-v2
|
MODULE drivers__boards__px4fmu-v2
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
../common/board_dma_alloc.c
|
../common/board_dma_alloc.c
|
||||||
px4fmu_can.c
|
px4fmu_can.c
|
||||||
px4fmu2_init.c
|
px4fmu2_init.c
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ px4_add_module(
|
|||||||
MODULE drivers__boards__px4fmu-v4
|
MODULE drivers__boards__px4fmu-v4
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
../common/board_dma_alloc.c
|
../common/board_dma_alloc.c
|
||||||
px4fmu_can.c
|
px4fmu_can.c
|
||||||
px4fmu_init.c
|
px4fmu_init.c
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ px4_add_module(
|
|||||||
MODULE drivers__boards__tap-v1
|
MODULE drivers__boards__tap-v1
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
../common/board_name.c
|
|
||||||
../common/board_dma_alloc.c
|
../common/board_dma_alloc.c
|
||||||
tap_init.c
|
tap_init.c
|
||||||
tap_pwr.c
|
tap_pwr.c
|
||||||
|
|||||||
+28
-18
@@ -40,36 +40,46 @@
|
|||||||
* @author Anton Babushkin <anton.babushkin@me.com>
|
* @author Anton Babushkin <anton.babushkin@me.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef VERSION_H_
|
#pragma once
|
||||||
#define VERSION_H_
|
|
||||||
|
|
||||||
/* The preferred method for publishing a board name up is to
|
|
||||||
* provide board_name()
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
__BEGIN_DECLS
|
|
||||||
|
|
||||||
__EXPORT const char *board_name(void);
|
|
||||||
|
|
||||||
__END_DECLS
|
|
||||||
|
|
||||||
#define FREEZE_STR(s) #s
|
#define FREEZE_STR(s) #s
|
||||||
#define STRINGIFY(s) FREEZE_STR(s)
|
#define STRINGIFY(s) FREEZE_STR(s)
|
||||||
#define FW_GIT STRINGIFY(GIT_VERSION)
|
#define FW_GIT STRINGIFY(GIT_VERSION)
|
||||||
#define FW_BUILD_URI STRINGIFY(BUILD_URI)
|
#define FW_BUILD_URI STRINGIFY(BUILD_URI)
|
||||||
|
|
||||||
|
/* The preferred method for publishing a board name is to
|
||||||
|
* define it in board_config.h as BOARD_NAME
|
||||||
|
*/
|
||||||
#if defined(CONFIG_ARCH_BOARD_SITL)
|
#if defined(CONFIG_ARCH_BOARD_SITL)
|
||||||
# define HW_ARCH "SITL"
|
# define BOARD_NAME "SITL"
|
||||||
#elif defined(CONFIG_ARCH_BOARD_EAGLE)
|
#elif defined(CONFIG_ARCH_BOARD_EAGLE)
|
||||||
# define HW_ARCH "EAGLE"
|
# define BOARD_NAME "EAGLE"
|
||||||
#elif defined(CONFIG_ARCH_BOARD_EXCELSIOR)
|
#elif defined(CONFIG_ARCH_BOARD_EXCELSIOR)
|
||||||
# define HW_ARCH "EXCELSIOR"
|
# define BOARD_NAME "EXCELSIOR"
|
||||||
#elif defined(CONFIG_ARCH_BOARD_RPI)
|
#elif defined(CONFIG_ARCH_BOARD_RPI)
|
||||||
# define HW_ARCH "RPI"
|
# define BOARD_NAME "RPI"
|
||||||
#elif defined(CONFIG_ARCH_BOARD_BEBOP)
|
#elif defined(CONFIG_ARCH_BOARD_BEBOP)
|
||||||
# define HW_ARCH "BEBOP"
|
# define BOARD_NAME "BEBOP"
|
||||||
#else
|
#else
|
||||||
#define HW_ARCH (board_name())
|
# include "board_config.h"
|
||||||
|
# ifndef BOARD_NAME
|
||||||
|
# error "board_config.h must define BOARD_NAME"
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* VERSION_H_ */
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the board name as string (including the version if there are multiple)
|
||||||
|
*/
|
||||||
|
static inline const char *px4_board_name(void)
|
||||||
|
{
|
||||||
|
return BOARD_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
#include <px4_sem.h>
|
#include <px4_sem.h>
|
||||||
#include <systemlib/mavlink_log.h>
|
#include <systemlib/mavlink_log.h>
|
||||||
#include <replay/definitions.hpp>
|
#include <replay/definitions.hpp>
|
||||||
|
#include <version/version.h>
|
||||||
|
|
||||||
#ifdef __PX4_DARWIN
|
#ifdef __PX4_DARWIN
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@@ -1361,7 +1362,7 @@ void Logger::write_header()
|
|||||||
void Logger::write_version()
|
void Logger::write_version()
|
||||||
{
|
{
|
||||||
write_info("ver_sw", PX4_GIT_VERSION_STR);
|
write_info("ver_sw", PX4_GIT_VERSION_STR);
|
||||||
write_info("ver_hw", HW_ARCH);
|
write_info("ver_hw", px4_board_name());
|
||||||
write_info("sys_name", "PX4");
|
write_info("sys_name", "PX4");
|
||||||
int32_t utc_offset = 0;
|
int32_t utc_offset = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -874,7 +874,7 @@ int write_version(int fd)
|
|||||||
|
|
||||||
/* fill version message and write it */
|
/* fill version message and write it */
|
||||||
strncpy(log_msg_VER.body.fw_git, px4_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));
|
strncpy(log_msg_VER.body.arch, px4_board_name(), sizeof(log_msg_VER.body.arch));
|
||||||
return write(fd, &log_msg_VER, sizeof(log_msg_VER));
|
return write(fd, &log_msg_VER, sizeof(log_msg_VER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,14 +183,14 @@ int UavcanNode::getHardwareVersion(uavcan::protocol::HardwareVersion &hwver)
|
|||||||
int rv = -1;
|
int rv = -1;
|
||||||
|
|
||||||
if (UavcanNode::instance()) {
|
if (UavcanNode::instance()) {
|
||||||
if (!std::strncmp(HW_ARCH, "PX4FMU_V1", 9)) {
|
if (!std::strncmp(px4_board_name(), "PX4FMU_V1", 9)) {
|
||||||
hwver.major = 1;
|
hwver.major = 1;
|
||||||
|
|
||||||
} else if (!std::strncmp(HW_ARCH, "PX4FMU_V2", 9)) {
|
} else if (!std::strncmp(px4_board_name(), "PX4FMU_V2", 9)) {
|
||||||
hwver.major = 2;
|
hwver.major = 2;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
; // All other values of HW_ARCH resolve to zero
|
; // All other values of px4_board_name() resolve to zero
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t udid[12] = {}; // Someone seems to love magic numbers
|
uint8_t udid[12] = {}; // Someone seems to love magic numbers
|
||||||
|
|||||||
@@ -198,11 +198,12 @@ int ver_main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!strncmp(argv[1], sz_ver_hwcmp_str, sizeof(sz_ver_hwcmp_str))) {
|
if (!strncmp(argv[1], sz_ver_hwcmp_str, sizeof(sz_ver_hwcmp_str))) {
|
||||||
if (argc >= 3 && argv[2] != NULL) {
|
if (argc >= 3 && argv[2] != NULL) {
|
||||||
/* compare 3rd parameter with HW_ARCH string, in case of match, return 0 */
|
/* compare 3rd parameter with px4_board_name() string, in case of match, return 0 */
|
||||||
ret = strncmp(HW_ARCH, argv[2], strlen(HW_ARCH));
|
const char *board_name = px4_board_name();
|
||||||
|
ret = strncmp(board_name, argv[2], strlen(board_name));
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
PX4_INFO("match: %s", HW_ARCH);
|
PX4_INFO("match: %s", board_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -217,7 +218,7 @@ int ver_main(int argc, char *argv[])
|
|||||||
bool show_all = !strncmp(argv[1], sz_ver_all_str, sizeof(sz_ver_all_str));
|
bool show_all = !strncmp(argv[1], sz_ver_all_str, sizeof(sz_ver_all_str));
|
||||||
|
|
||||||
if (show_all || !strncmp(argv[1], sz_ver_hw_str, sizeof(sz_ver_hw_str))) {
|
if (show_all || !strncmp(argv[1], sz_ver_hw_str, sizeof(sz_ver_hw_str))) {
|
||||||
printf("HW arch: %s\n", HW_ARCH);
|
printf("HW arch: %s\n", px4_board_name());
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user