mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-31 13:08:34 -04:00
AP_Servo_Telem: add getter for telem struct
This commit is contained in:
parent
decfeeeaf5
commit
9c8e353ada
@ -152,6 +152,23 @@ void AP_Servo_Telem::write_log()
|
||||
}
|
||||
#endif // HAL_LOGGING_ENABLED
|
||||
|
||||
// Fill in telem structure if telem is available, return false if not
|
||||
bool AP_Servo_Telem::get_telem(const uint8_t servo_index, TelemetryData& telem) const volatile
|
||||
{
|
||||
// Check for valid index
|
||||
if (servo_index >= ARRAY_SIZE(_telem_data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if data has ever been received for the servo index provided
|
||||
if ((active_mask & (1U << servo_index)) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
telem = *const_cast<TelemetryData*>(&_telem_data[servo_index]);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the AP_Servo_Telem singleton
|
||||
AP_Servo_Telem *AP_Servo_Telem::get_singleton()
|
||||
{
|
||||
|
@ -70,6 +70,9 @@ public:
|
||||
// callback to update the data in the frontend, should be called by the driver when new data is available
|
||||
void update_telem_data(const uint8_t servo_index, const TelemetryData& new_data);
|
||||
|
||||
// Fill in telem structure if telem is available, return false if not
|
||||
bool get_telem(const uint8_t servo_index, TelemetryData& telem) const volatile;
|
||||
|
||||
private:
|
||||
|
||||
// Log telem of each servo
|
||||
|
Loading…
Reference in New Issue
Block a user