diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3ba6c2ad71..f577df121d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -29,6 +29,7 @@ add_subdirectory(multiple_drones) add_subdirectory(offboard) add_subdirectory(parachute) add_subdirectory(set_actuator) +add_subdirectory(system_info) add_subdirectory(takeoff_and_land) add_subdirectory(terminate) add_subdirectory(transponder) diff --git a/examples/system_info/CMakeLists.txt b/examples/system_info/CMakeLists.txt new file mode 100644 index 0000000000..67df5cfb5a --- /dev/null +++ b/examples/system_info/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.10.2) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +project(system_info) + +add_executable(system_info + system_info.cpp +) + +find_package(MAVSDK REQUIRED) + +target_link_libraries(system_info + MAVSDK::mavsdk +) + +if(NOT MSVC) + add_compile_options(takeoff_and_land PRIVATE -Wall -Wextra) +else() + add_compile_options(takeoff_and_land PRIVATE -WX -W2) +endif() diff --git a/examples/system_info/system_info.cpp b/examples/system_info/system_info.cpp new file mode 100644 index 0000000000..b6b8a77144 --- /dev/null +++ b/examples/system_info/system_info.cpp @@ -0,0 +1,100 @@ +// +// Simple example to demonstrate how to query system info using MAVSDK. +// + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace mavsdk; +using std::chrono::seconds; +using std::this_thread::sleep_for; + +void usage(const std::string& bin_name) +{ + std::cerr << "Usage : " << bin_name << " \n" + << "Connection URL format should be :\n" + << " For TCP : tcp://[server_host][:server_port]\n" + << " For UDP : udp://[bind_host][:bind_port]\n" + << " For Serial : serial:///path/to/serial/dev[:baudrate]\n" + << "For example, to connect to the simulator use URL: udp://:14540\n"; +} + +std::shared_ptr get_system(Mavsdk& mavsdk) +{ + std::cout << "Waiting to discover system...\n"; + auto prom = std::promise>{}; + auto fut = prom.get_future(); + + // We wait for new systems to be discovered, once we find one that has an + // autopilot, we decide to use it. + Mavsdk::NewSystemHandle handle = mavsdk.subscribe_on_new_system([&mavsdk, &prom, &handle]() { + auto system = mavsdk.systems().back(); + + if (system->has_autopilot()) { + std::cout << "Discovered autopilot\n"; + + // Unsubscribe again as we only want to find one system. + mavsdk.unsubscribe_on_new_system(handle); + prom.set_value(system); + } + }); + + // We usually receive heartbeats at 1Hz, therefore we should find a + // system after around 3 seconds max, surely. + if (fut.wait_for(seconds(3)) == std::future_status::timeout) { + std::cerr << "No autopilot found.\n"; + return {}; + } + + // Get discovered system now. + return fut.get(); +} + +int main(int argc, char** argv) +{ + if (argc != 2) { + usage(argv[0]); + return 1; + } + + Mavsdk mavsdk; + ConnectionResult connection_result = mavsdk.add_any_connection(argv[1]); + + if (connection_result != ConnectionResult::Success) { + std::cerr << "Connection failed: " << connection_result << '\n'; + return 1; + } + + auto system = get_system(mavsdk); + if (!system) { + return 1; + } + + auto info = Info{system}; + + // Wait until version/firmware information has been populated from the vehicle + while (info.get_identification().first == Info::Result::InformationNotReceivedYet) { + std::cout << "Waiting for Version information to populate from system." << '\n'; + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + + // Get the system Version struct + const Info::Version& system_version = info.get_version().second; + + // Print out the vehicle version information. + std::cout << system_version << std::endl; + + // Get the system Product struct + const Info::Product& system_product = info.get_product().second; + + // Print out the vehicle product information. + std::cout << system_product << std::endl; + + return 0; +} \ No newline at end of file diff --git a/proto b/proto index 68ac98d4f9..822dc55977 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 68ac98d4f9286ec556b24599e592954441366515 +Subproject commit 822dc55977a3fd9dbd045151d21bdb4721d54455 diff --git a/src/mavsdk/plugins/info/include/plugins/info/info.h b/src/mavsdk/plugins/info/include/plugins/info/info.h index 4100344ab5..a7604eb89f 100644 --- a/src/mavsdk/plugins/info/include/plugins/info/info.h +++ b/src/mavsdk/plugins/info/include/plugins/info/info.h @@ -134,6 +134,27 @@ class Info : public PluginBase { * @brief System version information. */ struct Version { + /** + * @brief These values define the type of firmware/flight software release + */ + enum class FlightSoftwareVersionType { + Unknown, /**< @brief Unknown type. */ + Dev, /**< @brief Development release. */ + Alpha, /**< @brief Alpha release. */ + Beta, /**< @brief Beta release. */ + Rc, /**< @brief Release candidate. */ + Release, /**< @brief Official stable release. */ + }; + + /** + * @brief Stream operator to print information about a `Info::FlightSoftwareVersionType`. + * + * @return A reference to the stream. + */ + friend std::ostream& operator<<( + std::ostream& str, + Info::Version::FlightSoftwareVersionType const& flight_software_version_type); + int32_t flight_sw_major{}; /**< @brief Flight software major version */ int32_t flight_sw_minor{}; /**< @brief Flight software minor version */ int32_t flight_sw_patch{}; /**< @brief Flight software patch version */ @@ -145,6 +166,8 @@ class Info : public PluginBase { int32_t os_sw_patch{}; /**< @brief Operating system software patch version */ std::string flight_sw_git_hash{}; /**< @brief Flight software git hash */ std::string os_sw_git_hash{}; /**< @brief Operating system software git hash */ + FlightSoftwareVersionType + flight_sw_version_type{}; /**< @brief Flight software version type */ }; /** diff --git a/src/mavsdk/plugins/info/info.cpp b/src/mavsdk/plugins/info/info.cpp index 341f66da63..7e4848c2e1 100644 --- a/src/mavsdk/plugins/info/info.cpp +++ b/src/mavsdk/plugins/info/info.cpp @@ -94,6 +94,26 @@ std::ostream& operator<<(std::ostream& str, Info::Product const& product) return str; } +std::ostream& operator<<( + std::ostream& str, Info::Version::FlightSoftwareVersionType const& flight_software_version_type) +{ + switch (flight_software_version_type) { + case Info::Version::FlightSoftwareVersionType::Unknown: + return str << "Unknown"; + case Info::Version::FlightSoftwareVersionType::Dev: + return str << "Dev"; + case Info::Version::FlightSoftwareVersionType::Alpha: + return str << "Alpha"; + case Info::Version::FlightSoftwareVersionType::Beta: + return str << "Beta"; + case Info::Version::FlightSoftwareVersionType::Rc: + return str << "Rc"; + case Info::Version::FlightSoftwareVersionType::Release: + return str << "Release"; + default: + return str << "Unknown"; + } +} bool operator==(const Info::Version& lhs, const Info::Version& rhs) { return (rhs.flight_sw_major == lhs.flight_sw_major) && @@ -105,7 +125,8 @@ bool operator==(const Info::Version& lhs, const Info::Version& rhs) (rhs.os_sw_major == lhs.os_sw_major) && (rhs.os_sw_minor == lhs.os_sw_minor) && (rhs.os_sw_patch == lhs.os_sw_patch) && (rhs.flight_sw_git_hash == lhs.flight_sw_git_hash) && - (rhs.os_sw_git_hash == lhs.os_sw_git_hash); + (rhs.os_sw_git_hash == lhs.os_sw_git_hash) && + (rhs.flight_sw_version_type == lhs.flight_sw_version_type); } std::ostream& operator<<(std::ostream& str, Info::Version const& version) @@ -123,6 +144,7 @@ std::ostream& operator<<(std::ostream& str, Info::Version const& version) str << " os_sw_patch: " << version.os_sw_patch << '\n'; str << " flight_sw_git_hash: " << version.flight_sw_git_hash << '\n'; str << " os_sw_git_hash: " << version.os_sw_git_hash << '\n'; + str << " flight_sw_version_type: " << version.flight_sw_version_type << '\n'; str << '}'; return str; } diff --git a/src/mavsdk/plugins/info/info_impl.cpp b/src/mavsdk/plugins/info/info_impl.cpp index 4adaebf475..45627644b3 100644 --- a/src/mavsdk/plugins/info/info_impl.cpp +++ b/src/mavsdk/plugins/info/info_impl.cpp @@ -106,6 +106,9 @@ void InfoImpl::process_autopilot_version(const mavlink_message_t& message) _version.flight_sw_major = (autopilot_version.flight_sw_version >> (8 * 3)) & 0xFF; _version.flight_sw_minor = (autopilot_version.flight_sw_version >> (8 * 2)) & 0xFF; _version.flight_sw_patch = (autopilot_version.flight_sw_version >> (8 * 1)) & 0xFF; + _version.flight_sw_version_type = + get_flight_software_version_type(static_cast( + (autopilot_version.flight_sw_version >> (8 * 0)) & 0xFF)); // first three bytes of flight_custom_version (little endian) describe vendor version _version.flight_sw_git_hash = swap_and_translate_binary_to_str( @@ -151,6 +154,30 @@ void InfoImpl::process_autopilot_version(const mavlink_message_t& message) _information_received = true; } +Info::Version::FlightSoftwareVersionType +InfoImpl::get_flight_software_version_type(FIRMWARE_VERSION_TYPE firmwareVersionType) +{ + switch (firmwareVersionType) { + case FIRMWARE_VERSION_TYPE_DEV: + return Info::Version::FlightSoftwareVersionType::Dev; + + case FIRMWARE_VERSION_TYPE_ALPHA: + return Info::Version::FlightSoftwareVersionType::Alpha; + + case FIRMWARE_VERSION_TYPE_BETA: + return Info::Version::FlightSoftwareVersionType::Beta; + + case FIRMWARE_VERSION_TYPE_RC: + return Info::Version::FlightSoftwareVersionType::Rc; + + case FIRMWARE_VERSION_TYPE_OFFICIAL: + return Info::Version::FlightSoftwareVersionType::Release; + + default: + return Info::Version::FlightSoftwareVersionType::Unknown; + } +} + void InfoImpl::process_flight_information(const mavlink_message_t& message) { std::lock_guard lock(_mutex); diff --git a/src/mavsdk/plugins/info/info_impl.h b/src/mavsdk/plugins/info/info_impl.h index bf9b7ff542..fe703de5d7 100644 --- a/src/mavsdk/plugins/info/info_impl.h +++ b/src/mavsdk/plugins/info/info_impl.h @@ -38,6 +38,9 @@ class InfoImpl : public PluginImplBase { void process_flight_information(const mavlink_message_t& message); void process_attitude(const mavlink_message_t& message); + Info::Version::FlightSoftwareVersionType + get_flight_software_version_type(FIRMWARE_VERSION_TYPE); + mutable std::mutex _mutex{}; Info::Version _version{}; diff --git a/src/mavsdk_server/src/generated/info/info.pb.cc b/src/mavsdk_server/src/generated/info/info.pb.cc index c1739f44da..12dc8068c5 100644 --- a/src/mavsdk_server/src/generated/info/info.pb.cc +++ b/src/mavsdk_server/src/generated/info/info.pb.cc @@ -196,7 +196,9 @@ PROTOBUF_CONSTEXPR Version::Version( , flight_sw_vendor_patch_(0) , os_sw_major_(0) , os_sw_minor_(0) - , os_sw_patch_(0){} + , os_sw_patch_(0) + , flight_sw_version_type_(0) +{} struct VersionDefaultTypeInternal { PROTOBUF_CONSTEXPR VersionDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -224,7 +226,7 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORIT } // namespace rpc } // namespace mavsdk static ::_pb::Metadata file_level_metadata_info_2finfo_2eproto[15]; -static const ::_pb::EnumDescriptor* file_level_enum_descriptors_info_2finfo_2eproto[1]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_info_2finfo_2eproto[2]; static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_info_2finfo_2eproto = nullptr; const uint32_t TableStruct_info_2finfo_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { @@ -341,6 +343,7 @@ const uint32_t TableStruct_info_2finfo_2eproto::offsets[] PROTOBUF_SECTION_VARIA PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::Version, os_sw_patch_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::Version, flight_sw_git_hash_), PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::Version, os_sw_git_hash_), + PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::Version, flight_sw_version_type_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::mavsdk::rpc::info::InfoResult, _internal_metadata_), ~0u, // no _extensions_ @@ -365,7 +368,7 @@ static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protode { 78, -1, -1, sizeof(::mavsdk::rpc::info::Identification)}, { 86, -1, -1, sizeof(::mavsdk::rpc::info::Product)}, { 96, -1, -1, sizeof(::mavsdk::rpc::info::Version)}, - { 113, -1, -1, sizeof(::mavsdk::rpc::info::InfoResult)}, + { 114, -1, -1, sizeof(::mavsdk::rpc::info::InfoResult)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -411,7 +414,7 @@ const char descriptor_table_protodef_info_2finfo_2eproto[] PROTOBUF_SECTION_VARI "Identification\022\024\n\014hardware_uid\030\001 \001(\t\022\022\n\n" "legacy_uid\030\002 \001(\004\"[\n\007Product\022\021\n\tvendor_id" "\030\001 \001(\005\022\023\n\013vendor_name\030\002 \001(\t\022\022\n\nproduct_i" - "d\030\003 \001(\005\022\024\n\014product_name\030\004 \001(\t\"\247\002\n\007Versio" + "d\030\003 \001(\005\022\024\n\014product_name\030\004 \001(\t\"\207\005\n\007Versio" "n\022\027\n\017flight_sw_major\030\001 \001(\005\022\027\n\017flight_sw_" "minor\030\002 \001(\005\022\027\n\017flight_sw_patch\030\003 \001(\005\022\036\n\026" "flight_sw_vendor_major\030\004 \001(\005\022\036\n\026flight_s" @@ -419,33 +422,42 @@ const char descriptor_table_protodef_info_2finfo_2eproto[] PROTOBUF_SECTION_VARI "_patch\030\006 \001(\005\022\023\n\013os_sw_major\030\007 \001(\005\022\023\n\013os_" "sw_minor\030\010 \001(\005\022\023\n\013os_sw_patch\030\t \001(\005\022\032\n\022f" "light_sw_git_hash\030\n \001(\t\022\026\n\016os_sw_git_has" - "h\030\013 \001(\t\"\305\001\n\nInfoResult\0222\n\006result\030\001 \001(\0162\"" - ".mavsdk.rpc.info.InfoResult.Result\022\022\n\nre" - "sult_str\030\002 \001(\t\"o\n\006Result\022\022\n\016RESULT_UNKNO" - "WN\020\000\022\022\n\016RESULT_SUCCESS\020\001\022\'\n#RESULT_INFOR" - "MATION_NOT_RECEIVED_YET\020\002\022\024\n\020RESULT_NO_S" - "YSTEM\020\0032\235\004\n\013InfoService\022y\n\024GetFlightInfo" - "rmation\022,.mavsdk.rpc.info.GetFlightInfor" - "mationRequest\032-.mavsdk.rpc.info.GetFligh" - "tInformationResponse\"\004\200\265\030\001\022p\n\021GetIdentif" - "ication\022).mavsdk.rpc.info.GetIdentificat" - "ionRequest\032*.mavsdk.rpc.info.GetIdentifi" - "cationResponse\"\004\200\265\030\001\022[\n\nGetProduct\022\".mav" - "sdk.rpc.info.GetProductRequest\032#.mavsdk." - "rpc.info.GetProductResponse\"\004\200\265\030\001\022[\n\nGet" - "Version\022\".mavsdk.rpc.info.GetVersionRequ" - "est\032#.mavsdk.rpc.info.GetVersionResponse" - "\"\004\200\265\030\001\022g\n\016GetSpeedFactor\022&.mavsdk.rpc.in" - "fo.GetSpeedFactorRequest\032\'.mavsdk.rpc.in" - "fo.GetSpeedFactorResponse\"\004\200\265\030\001B\033\n\016io.ma" - "vsdk.infoB\tInfoProtob\006proto3" + "h\030\013 \001(\t\022R\n\026flight_sw_version_type\030\014 \001(\0162" + "2.mavsdk.rpc.info.Version.FlightSoftware" + "VersionType\"\211\002\n\031FlightSoftwareVersionTyp" + "e\022(\n$FLIGHT_SOFTWARE_VERSION_TYPE_UNKNOW" + "N\020\000\022$\n FLIGHT_SOFTWARE_VERSION_TYPE_DEV\020" + "\001\022&\n\"FLIGHT_SOFTWARE_VERSION_TYPE_ALPHA\020" + "\002\022%\n!FLIGHT_SOFTWARE_VERSION_TYPE_BETA\020\003" + "\022#\n\037FLIGHT_SOFTWARE_VERSION_TYPE_RC\020\004\022(\n" + "$FLIGHT_SOFTWARE_VERSION_TYPE_RELEASE\020\005\"" + "\305\001\n\nInfoResult\0222\n\006result\030\001 \001(\0162\".mavsdk." + "rpc.info.InfoResult.Result\022\022\n\nresult_str" + "\030\002 \001(\t\"o\n\006Result\022\022\n\016RESULT_UNKNOWN\020\000\022\022\n\016" + "RESULT_SUCCESS\020\001\022\'\n#RESULT_INFORMATION_N" + "OT_RECEIVED_YET\020\002\022\024\n\020RESULT_NO_SYSTEM\020\0032" + "\235\004\n\013InfoService\022y\n\024GetFlightInformation\022" + ",.mavsdk.rpc.info.GetFlightInformationRe" + "quest\032-.mavsdk.rpc.info.GetFlightInforma" + "tionResponse\"\004\200\265\030\001\022p\n\021GetIdentification\022" + ").mavsdk.rpc.info.GetIdentificationReque" + "st\032*.mavsdk.rpc.info.GetIdentificationRe" + "sponse\"\004\200\265\030\001\022[\n\nGetProduct\022\".mavsdk.rpc." + "info.GetProductRequest\032#.mavsdk.rpc.info" + ".GetProductResponse\"\004\200\265\030\001\022[\n\nGetVersion\022" + "\".mavsdk.rpc.info.GetVersionRequest\032#.ma" + "vsdk.rpc.info.GetVersionResponse\"\004\200\265\030\001\022g" + "\n\016GetSpeedFactor\022&.mavsdk.rpc.info.GetSp" + "eedFactorRequest\032\'.mavsdk.rpc.info.GetSp" + "eedFactorResponse\"\004\200\265\030\001B\033\n\016io.mavsdk.inf" + "oB\tInfoProtob\006proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_info_2finfo_2eproto_deps[1] = { &::descriptor_table_mavsdk_5foptions_2eproto, }; static ::_pbi::once_flag descriptor_table_info_2finfo_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_info_2finfo_2eproto = { - false, false, 2068, descriptor_table_protodef_info_2finfo_2eproto, + false, false, 2420, descriptor_table_protodef_info_2finfo_2eproto, "info/info.proto", &descriptor_table_info_2finfo_2eproto_once, descriptor_table_info_2finfo_2eproto_deps, 1, 15, schemas, file_default_instances, TableStruct_info_2finfo_2eproto::offsets, @@ -461,10 +473,39 @@ PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_in namespace mavsdk { namespace rpc { namespace info { -const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* InfoResult_Result_descriptor() { +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Version_FlightSoftwareVersionType_descriptor() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_info_2finfo_2eproto); return file_level_enum_descriptors_info_2finfo_2eproto[0]; } +bool Version_FlightSoftwareVersionType_IsValid(int value) { + switch (value) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + return true; + default: + return false; + } +} + +#if (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +constexpr Version_FlightSoftwareVersionType Version::FLIGHT_SOFTWARE_VERSION_TYPE_UNKNOWN; +constexpr Version_FlightSoftwareVersionType Version::FLIGHT_SOFTWARE_VERSION_TYPE_DEV; +constexpr Version_FlightSoftwareVersionType Version::FLIGHT_SOFTWARE_VERSION_TYPE_ALPHA; +constexpr Version_FlightSoftwareVersionType Version::FLIGHT_SOFTWARE_VERSION_TYPE_BETA; +constexpr Version_FlightSoftwareVersionType Version::FLIGHT_SOFTWARE_VERSION_TYPE_RC; +constexpr Version_FlightSoftwareVersionType Version::FLIGHT_SOFTWARE_VERSION_TYPE_RELEASE; +constexpr Version_FlightSoftwareVersionType Version::FlightSoftwareVersionType_MIN; +constexpr Version_FlightSoftwareVersionType Version::FlightSoftwareVersionType_MAX; +constexpr int Version::FlightSoftwareVersionType_ARRAYSIZE; +#endif // (__cplusplus < 201703) && (!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912)) +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* InfoResult_Result_descriptor() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_info_2finfo_2eproto); + return file_level_enum_descriptors_info_2finfo_2eproto[1]; +} bool InfoResult_Result_IsValid(int value) { switch (value) { case 0: @@ -2614,8 +2655,8 @@ Version::Version(const Version& from) GetArenaForAllocation()); } ::memcpy(&flight_sw_major_, &from.flight_sw_major_, - static_cast(reinterpret_cast(&os_sw_patch_) - - reinterpret_cast(&flight_sw_major_)) + sizeof(os_sw_patch_)); + static_cast(reinterpret_cast(&flight_sw_version_type_) - + reinterpret_cast(&flight_sw_major_)) + sizeof(flight_sw_version_type_)); // @@protoc_insertion_point(copy_constructor:mavsdk.rpc.info.Version) } @@ -2630,8 +2671,8 @@ os_sw_git_hash_.InitDefault(); #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING ::memset(reinterpret_cast(this) + static_cast( reinterpret_cast(&flight_sw_major_) - reinterpret_cast(this)), - 0, static_cast(reinterpret_cast(&os_sw_patch_) - - reinterpret_cast(&flight_sw_major_)) + sizeof(os_sw_patch_)); + 0, static_cast(reinterpret_cast(&flight_sw_version_type_) - + reinterpret_cast(&flight_sw_major_)) + sizeof(flight_sw_version_type_)); } Version::~Version() { @@ -2662,8 +2703,8 @@ void Version::Clear() { flight_sw_git_hash_.ClearToEmpty(); os_sw_git_hash_.ClearToEmpty(); ::memset(&flight_sw_major_, 0, static_cast( - reinterpret_cast(&os_sw_patch_) - - reinterpret_cast(&flight_sw_major_)) + sizeof(os_sw_patch_)); + reinterpret_cast(&flight_sw_version_type_) - + reinterpret_cast(&flight_sw_major_)) + sizeof(flight_sw_version_type_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -2765,6 +2806,15 @@ const char* Version::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) } else goto handle_unusual; continue; + // .mavsdk.rpc.info.Version.FlightSoftwareVersionType flight_sw_version_type = 12; + case 12: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 96)) { + uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + _internal_set_flight_sw_version_type(static_cast<::mavsdk::rpc::info::Version_FlightSoftwareVersionType>(val)); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -2868,6 +2918,13 @@ uint8_t* Version::_InternalSerialize( 11, this->_internal_os_sw_git_hash(), target); } + // .mavsdk.rpc.info.Version.FlightSoftwareVersionType flight_sw_version_type = 12; + if (this->_internal_flight_sw_version_type() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteEnumToArray( + 12, this->_internal_flight_sw_version_type(), target); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -2943,6 +3000,12 @@ size_t Version::ByteSizeLong() const { total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_os_sw_patch()); } + // .mavsdk.rpc.info.Version.FlightSoftwareVersionType flight_sw_version_type = 12; + if (this->_internal_flight_sw_version_type() != 0) { + total_size += 1 + + ::_pbi::WireFormatLite::EnumSize(this->_internal_flight_sw_version_type()); + } + return MaybeComputeUnknownFieldsSize(total_size, &_cached_size_); } @@ -2998,6 +3061,9 @@ void Version::MergeFrom(const Version& from) { if (from._internal_os_sw_patch() != 0) { _internal_set_os_sw_patch(from._internal_os_sw_patch()); } + if (from._internal_flight_sw_version_type() != 0) { + _internal_set_flight_sw_version_type(from._internal_flight_sw_version_type()); + } _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } @@ -3026,8 +3092,8 @@ void Version::InternalSwap(Version* other) { &other->os_sw_git_hash_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(Version, os_sw_patch_) - + sizeof(Version::os_sw_patch_) + PROTOBUF_FIELD_OFFSET(Version, flight_sw_version_type_) + + sizeof(Version::flight_sw_version_type_) - PROTOBUF_FIELD_OFFSET(Version, flight_sw_major_)>( reinterpret_cast(&flight_sw_major_), reinterpret_cast(&other->flight_sw_major_)); diff --git a/src/mavsdk_server/src/generated/info/info.pb.h b/src/mavsdk_server/src/generated/info/info.pb.h index 0e2fe1d46f..587942188e 100644 --- a/src/mavsdk_server/src/generated/info/info.pb.h +++ b/src/mavsdk_server/src/generated/info/info.pb.h @@ -119,6 +119,35 @@ namespace mavsdk { namespace rpc { namespace info { +enum Version_FlightSoftwareVersionType : int { + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_UNKNOWN = 0, + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_DEV = 1, + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_ALPHA = 2, + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_BETA = 3, + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RC = 4, + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RELEASE = 5, + Version_FlightSoftwareVersionType_Version_FlightSoftwareVersionType_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits::min(), + Version_FlightSoftwareVersionType_Version_FlightSoftwareVersionType_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits::max() +}; +bool Version_FlightSoftwareVersionType_IsValid(int value); +constexpr Version_FlightSoftwareVersionType Version_FlightSoftwareVersionType_FlightSoftwareVersionType_MIN = Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_UNKNOWN; +constexpr Version_FlightSoftwareVersionType Version_FlightSoftwareVersionType_FlightSoftwareVersionType_MAX = Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RELEASE; +constexpr int Version_FlightSoftwareVersionType_FlightSoftwareVersionType_ARRAYSIZE = Version_FlightSoftwareVersionType_FlightSoftwareVersionType_MAX + 1; + +const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* Version_FlightSoftwareVersionType_descriptor(); +template +inline const std::string& Version_FlightSoftwareVersionType_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function Version_FlightSoftwareVersionType_Name."); + return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum( + Version_FlightSoftwareVersionType_descriptor(), enum_t_value); +} +inline bool Version_FlightSoftwareVersionType_Parse( + ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Version_FlightSoftwareVersionType* value) { + return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum( + Version_FlightSoftwareVersionType_descriptor(), name, value); +} enum InfoResult_Result : int { InfoResult_Result_RESULT_UNKNOWN = 0, InfoResult_Result_RESULT_SUCCESS = 1, @@ -2194,6 +2223,44 @@ class Version final : // nested types ---------------------------------------------------- + typedef Version_FlightSoftwareVersionType FlightSoftwareVersionType; + static constexpr FlightSoftwareVersionType FLIGHT_SOFTWARE_VERSION_TYPE_UNKNOWN = + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_UNKNOWN; + static constexpr FlightSoftwareVersionType FLIGHT_SOFTWARE_VERSION_TYPE_DEV = + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_DEV; + static constexpr FlightSoftwareVersionType FLIGHT_SOFTWARE_VERSION_TYPE_ALPHA = + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_ALPHA; + static constexpr FlightSoftwareVersionType FLIGHT_SOFTWARE_VERSION_TYPE_BETA = + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_BETA; + static constexpr FlightSoftwareVersionType FLIGHT_SOFTWARE_VERSION_TYPE_RC = + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RC; + static constexpr FlightSoftwareVersionType FLIGHT_SOFTWARE_VERSION_TYPE_RELEASE = + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RELEASE; + static inline bool FlightSoftwareVersionType_IsValid(int value) { + return Version_FlightSoftwareVersionType_IsValid(value); + } + static constexpr FlightSoftwareVersionType FlightSoftwareVersionType_MIN = + Version_FlightSoftwareVersionType_FlightSoftwareVersionType_MIN; + static constexpr FlightSoftwareVersionType FlightSoftwareVersionType_MAX = + Version_FlightSoftwareVersionType_FlightSoftwareVersionType_MAX; + static constexpr int FlightSoftwareVersionType_ARRAYSIZE = + Version_FlightSoftwareVersionType_FlightSoftwareVersionType_ARRAYSIZE; + static inline const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* + FlightSoftwareVersionType_descriptor() { + return Version_FlightSoftwareVersionType_descriptor(); + } + template + static inline const std::string& FlightSoftwareVersionType_Name(T enum_t_value) { + static_assert(::std::is_same::value || + ::std::is_integral::value, + "Incorrect type passed to function FlightSoftwareVersionType_Name."); + return Version_FlightSoftwareVersionType_Name(enum_t_value); + } + static inline bool FlightSoftwareVersionType_Parse(::PROTOBUF_NAMESPACE_ID::ConstStringParam name, + FlightSoftwareVersionType* value) { + return Version_FlightSoftwareVersionType_Parse(name, value); + } + // accessors ------------------------------------------------------- enum : int { @@ -2208,6 +2275,7 @@ class Version final : kOsSwMajorFieldNumber = 7, kOsSwMinorFieldNumber = 8, kOsSwPatchFieldNumber = 9, + kFlightSwVersionTypeFieldNumber = 12, }; // string flight_sw_git_hash = 10; void clear_flight_sw_git_hash(); @@ -2318,6 +2386,15 @@ class Version final : void _internal_set_os_sw_patch(int32_t value); public: + // .mavsdk.rpc.info.Version.FlightSoftwareVersionType flight_sw_version_type = 12; + void clear_flight_sw_version_type(); + ::mavsdk::rpc::info::Version_FlightSoftwareVersionType flight_sw_version_type() const; + void set_flight_sw_version_type(::mavsdk::rpc::info::Version_FlightSoftwareVersionType value); + private: + ::mavsdk::rpc::info::Version_FlightSoftwareVersionType _internal_flight_sw_version_type() const; + void _internal_set_flight_sw_version_type(::mavsdk::rpc::info::Version_FlightSoftwareVersionType value); + public: + // @@protoc_insertion_point(class_scope:mavsdk.rpc.info.Version) private: class _Internal; @@ -2336,6 +2413,7 @@ class Version final : int32_t os_sw_major_; int32_t os_sw_minor_; int32_t os_sw_patch_; + int flight_sw_version_type_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; friend struct ::TableStruct_info_2finfo_2eproto; }; @@ -3955,6 +4033,26 @@ inline void Version::set_allocated_os_sw_git_hash(std::string* os_sw_git_hash) { // @@protoc_insertion_point(field_set_allocated:mavsdk.rpc.info.Version.os_sw_git_hash) } +// .mavsdk.rpc.info.Version.FlightSoftwareVersionType flight_sw_version_type = 12; +inline void Version::clear_flight_sw_version_type() { + flight_sw_version_type_ = 0; +} +inline ::mavsdk::rpc::info::Version_FlightSoftwareVersionType Version::_internal_flight_sw_version_type() const { + return static_cast< ::mavsdk::rpc::info::Version_FlightSoftwareVersionType >(flight_sw_version_type_); +} +inline ::mavsdk::rpc::info::Version_FlightSoftwareVersionType Version::flight_sw_version_type() const { + // @@protoc_insertion_point(field_get:mavsdk.rpc.info.Version.flight_sw_version_type) + return _internal_flight_sw_version_type(); +} +inline void Version::_internal_set_flight_sw_version_type(::mavsdk::rpc::info::Version_FlightSoftwareVersionType value) { + + flight_sw_version_type_ = value; +} +inline void Version::set_flight_sw_version_type(::mavsdk::rpc::info::Version_FlightSoftwareVersionType value) { + _internal_set_flight_sw_version_type(value); + // @@protoc_insertion_point(field_set:mavsdk.rpc.info.Version.flight_sw_version_type) +} + // ------------------------------------------------------------------- // InfoResult @@ -4069,6 +4167,11 @@ inline void InfoResult::set_allocated_result_str(std::string* result_str) { PROTOBUF_NAMESPACE_OPEN +template <> struct is_proto_enum< ::mavsdk::rpc::info::Version_FlightSoftwareVersionType> : ::std::true_type {}; +template <> +inline const EnumDescriptor* GetEnumDescriptor< ::mavsdk::rpc::info::Version_FlightSoftwareVersionType>() { + return ::mavsdk::rpc::info::Version_FlightSoftwareVersionType_descriptor(); +} template <> struct is_proto_enum< ::mavsdk::rpc::info::InfoResult_Result> : ::std::true_type {}; template <> inline const EnumDescriptor* GetEnumDescriptor< ::mavsdk::rpc::info::InfoResult_Result>() { diff --git a/src/mavsdk_server/src/plugins/info/info_service_impl.h b/src/mavsdk_server/src/plugins/info/info_service_impl.h index 9b6e34afb3..8de8bb38d2 100644 --- a/src/mavsdk_server/src/plugins/info/info_service_impl.h +++ b/src/mavsdk_server/src/plugins/info/info_service_impl.h @@ -120,6 +120,58 @@ class InfoServiceImpl final : public rpc::info::InfoService::Service { return obj; } + static rpc::info::Version::FlightSoftwareVersionType translateToRpcFlightSoftwareVersionType( + const mavsdk::Info::Version::FlightSoftwareVersionType& flight_software_version_type) + { + switch (flight_software_version_type) { + default: + LogErr() << "Unknown flight_software_version_type enum value: " + << static_cast(flight_software_version_type); + // FALLTHROUGH + case mavsdk::Info::Version::FlightSoftwareVersionType::Unknown: + return rpc::info:: + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_UNKNOWN; + case mavsdk::Info::Version::FlightSoftwareVersionType::Dev: + return rpc::info:: + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_DEV; + case mavsdk::Info::Version::FlightSoftwareVersionType::Alpha: + return rpc::info:: + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_ALPHA; + case mavsdk::Info::Version::FlightSoftwareVersionType::Beta: + return rpc::info:: + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_BETA; + case mavsdk::Info::Version::FlightSoftwareVersionType::Rc: + return rpc::info::Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RC; + case mavsdk::Info::Version::FlightSoftwareVersionType::Release: + return rpc::info:: + Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RELEASE; + } + } + + static mavsdk::Info::Version::FlightSoftwareVersionType + translateFromRpcFlightSoftwareVersionType( + const rpc::info::Version::FlightSoftwareVersionType flight_software_version_type) + { + switch (flight_software_version_type) { + default: + LogErr() << "Unknown flight_software_version_type enum value: " + << static_cast(flight_software_version_type); + // FALLTHROUGH + case rpc::info::Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_UNKNOWN: + return mavsdk::Info::Version::FlightSoftwareVersionType::Unknown; + case rpc::info::Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_DEV: + return mavsdk::Info::Version::FlightSoftwareVersionType::Dev; + case rpc::info::Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_ALPHA: + return mavsdk::Info::Version::FlightSoftwareVersionType::Alpha; + case rpc::info::Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_BETA: + return mavsdk::Info::Version::FlightSoftwareVersionType::Beta; + case rpc::info::Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RC: + return mavsdk::Info::Version::FlightSoftwareVersionType::Rc; + case rpc::info::Version_FlightSoftwareVersionType_FLIGHT_SOFTWARE_VERSION_TYPE_RELEASE: + return mavsdk::Info::Version::FlightSoftwareVersionType::Release; + } + } + static std::unique_ptr translateToRpcVersion(const mavsdk::Info::Version& version) { @@ -147,6 +199,9 @@ class InfoServiceImpl final : public rpc::info::InfoService::Service { rpc_obj->set_os_sw_git_hash(version.os_sw_git_hash); + rpc_obj->set_flight_sw_version_type( + translateToRpcFlightSoftwareVersionType(version.flight_sw_version_type)); + return rpc_obj; } @@ -176,6 +231,9 @@ class InfoServiceImpl final : public rpc::info::InfoService::Service { obj.os_sw_git_hash = version.os_sw_git_hash(); + obj.flight_sw_version_type = + translateFromRpcFlightSoftwareVersionType(version.flight_sw_version_type()); + return obj; }