AP_Common: Update AP_FWVersion struct to be used with binary parsers
- Add an uint64_t header to allow easy detection of struct - Add an uint16_t version - MSB is for major release, compatibility break - LSB for minor version, no compatibility break - Add pointer size variable to allow decode of pointers - Add vehicle type information - Add board type and subtype to allow hardware identification - Set type of fw_type to uint8_t since enum is declared as int - Organize struct to be packed inside 32bits system Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
This commit is contained in:
parent
75e9550bce
commit
adda695630
@ -3,21 +3,35 @@
|
||||
#include <stdint.h>
|
||||
#include <GCS_MAVLink/GCS_MAVLink.h>
|
||||
|
||||
class AP_FWVersion {
|
||||
class PACKED AP_FWVersion {
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Struct to hold infomation about the software version struct
|
||||
*
|
||||
*/
|
||||
// First 7 MSBs are a start sequence, LSB is a checksum
|
||||
const uint64_t header;
|
||||
// MSB (major version breaks compatibility), LSB (minor version no compatibility break)
|
||||
const uint16_t header_version;
|
||||
// Pointer size to extract pointer values
|
||||
const uint8_t pointer_size;
|
||||
|
||||
const uint8_t reserved; // padding
|
||||
const uint8_t vehicle_type;
|
||||
const uint8_t board_type;
|
||||
const uint16_t board_subtype;
|
||||
const uint8_t major;
|
||||
const uint8_t minor;
|
||||
const uint8_t patch;
|
||||
const FIRMWARE_VERSION_TYPE fw_type;
|
||||
const uint8_t fw_type; /*FIRMWARE_VERSION_TYPE*/
|
||||
const uint32_t os_sw_version;
|
||||
const char *fw_string;
|
||||
const char *fw_hash_str;
|
||||
const char *middleware_name;
|
||||
const char *middleware_hash_str;
|
||||
const char *os_name;
|
||||
const char *os_hash_str;
|
||||
const uint32_t os_sw_version;
|
||||
|
||||
static const AP_FWVersion &get_fwverz() { return fwver; }
|
||||
|
||||
|
@ -21,12 +21,27 @@
|
||||
#endif
|
||||
|
||||
#include <AP_Common/AP_FWVersion.h>
|
||||
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
||||
|
||||
const AP_FWVersion AP_FWVersion::fwver{
|
||||
// Version header struct
|
||||
.header = 0x61706677766572fb, // First 7 MSBs: "apfwver", LSB is the checksum of the previous string: 0xfb
|
||||
.header_version = 0x0100U, // Major and minor version
|
||||
.pointer_size = static_cast<uint8_t>(sizeof(void*)),
|
||||
.reserved = 0,
|
||||
.vehicle_type = static_cast<uint8_t>(APM_BUILD_DIRECTORY),
|
||||
.board_type = static_cast<uint8_t>(CONFIG_HAL_BOARD),
|
||||
.board_subtype = static_cast<uint16_t>(CONFIG_HAL_BOARD_SUBTYPE),
|
||||
.major = FW_MAJOR,
|
||||
.minor = FW_MINOR,
|
||||
.patch = FW_PATCH,
|
||||
.fw_type = FW_TYPE,
|
||||
#ifdef BUILD_DATE_YEAR
|
||||
// encode build date in os_sw_version
|
||||
.os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY,
|
||||
#else
|
||||
.os_sw_version = 0,
|
||||
#endif
|
||||
#ifndef GIT_VERSION
|
||||
.fw_string = THISFIRMWARE,
|
||||
.fw_hash_str = "",
|
||||
@ -43,10 +58,4 @@ const AP_FWVersion AP_FWVersion::fwver{
|
||||
.os_name = nullptr,
|
||||
.os_hash_str = nullptr,
|
||||
#endif
|
||||
#ifdef BUILD_DATE_YEAR
|
||||
// encode build date in os_sw_version
|
||||
.os_sw_version = (BUILD_DATE_YEAR*100*100) + (BUILD_DATE_MONTH*100) + BUILD_DATE_DAY,
|
||||
#else
|
||||
.os_sw_version = 0,
|
||||
#endif
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user