From ec1814da34280c6957cd028748e52abe55dd67bb Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Wed, 21 Dec 2022 15:51:42 +0000 Subject: [PATCH] AP_ExternalAHRS: add get_name function for reporting --- libraries/AP_ExternalAHRS/AP_ExternalAHRS.cpp | 9 +++++++++ libraries/AP_ExternalAHRS/AP_ExternalAHRS.h | 3 +++ libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.cpp | 6 ++++++ libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.h | 3 +++ libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h | 3 +++ 5 files changed, 24 insertions(+) diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS.cpp b/libraries/AP_ExternalAHRS/AP_ExternalAHRS.cpp index 44edc6505db..32eee83b6c9 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS.cpp +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS.cpp @@ -213,6 +213,15 @@ void AP_ExternalAHRS::update(void) } } +// Get model/type name +const char* AP_ExternalAHRS::get_name() const +{ + if (backend) { + return backend->get_name(); + } + return nullptr; +} + namespace AP { AP_ExternalAHRS &externalAHRS() diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS.h b/libraries/AP_ExternalAHRS/AP_ExternalAHRS.h index 41664c37c21..037b5200818 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS.h +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS.h @@ -55,6 +55,9 @@ public: return rate.get(); } + // Get model/type name + const char* get_name() const; + // get serial port number, -1 for not enabled int8_t get_port(void) const; diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.cpp b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.cpp index f7512608a97..7ccdce7db54 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.cpp +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.cpp @@ -440,6 +440,12 @@ int8_t AP_ExternalAHRS_LORD::get_port(void) const return port_num; }; +// Get model/type name +const char* AP_ExternalAHRS_LORD::get_name() const +{ + return "LORD"; +} + bool AP_ExternalAHRS_LORD::healthy(void) const { uint32_t now = AP_HAL::millis(); diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.h b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.h index 6695437d492..846a15fd1c7 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.h +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_LORD.h @@ -35,6 +35,9 @@ public: // get serial port number, -1 for not enabled int8_t get_port(void) const override; + // Get model/type name + const char* get_name() const override; + // accessors for AP_AHRS bool healthy(void) const override; bool initialised(void) const override; diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h index 1d0204e0d1b..15a8f353bd4 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h @@ -29,6 +29,9 @@ public: // get serial port number, -1 for not enabled virtual int8_t get_port(void) const { return -1; } + // Get model/type name + virtual const char* get_name() const = 0; + // accessors for AP_AHRS virtual bool healthy(void) const = 0; virtual bool initialised(void) const = 0;