@@ -191,6 +191,8 @@ std::string InfoImpl::translate_binary_to_str(uint8_t* binary, unsigned binary_l
191
191
192
192
std::pair<Info::Result, Info::Identification> InfoImpl::get_identification () const
193
193
{
194
+ wait_for_information ();
195
+
194
196
std::lock_guard<std::mutex> lock (_mutex);
195
197
return std::make_pair<>(
196
198
(_information_received ? Info::Result::Success : Info::Result::InformationNotReceivedYet),
@@ -199,23 +201,30 @@ std::pair<Info::Result, Info::Identification> InfoImpl::get_identification() con
199
201
200
202
std::pair<Info::Result, Info::Version> InfoImpl::get_version () const
201
203
{
204
+ wait_for_information ();
205
+
202
206
std::lock_guard<std::mutex> lock (_mutex);
207
+
203
208
return std::make_pair<>(
204
209
(_information_received ? Info::Result::Success : Info::Result::InformationNotReceivedYet),
205
210
_version);
206
211
}
207
212
208
213
std::pair<Info::Result, Info::Product> InfoImpl::get_product () const
209
214
{
215
+ wait_for_information ();
210
216
std::lock_guard<std::mutex> lock (_mutex);
217
+
211
218
return std::make_pair<>(
212
219
(_information_received ? Info::Result::Success : Info::Result::InformationNotReceivedYet),
213
220
_product);
214
221
}
215
222
216
223
std::pair<Info::Result, Info::FlightInfo> InfoImpl::get_flight_information () const
217
224
{
225
+ wait_for_information ();
218
226
std::lock_guard<std::mutex> lock (_mutex);
227
+
219
228
return std::make_pair<>(
220
229
(_flight_information_received ? Info::Result::Success :
221
230
Info::Result::InformationNotReceivedYet),
@@ -281,4 +290,15 @@ std::pair<Info::Result, double> InfoImpl::get_speed_factor() const
281
290
return std::make_pair<>(Info::Result::Success, speed_factor);
282
291
}
283
292
293
+ void InfoImpl::wait_for_information () const
294
+ {
295
+ // Wait 1.5 seconds max
296
+ for (unsigned i = 0 ; i < 150 ; ++i) {
297
+ if (_information_received) {
298
+ break ;
299
+ }
300
+ std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
301
+ }
302
+ }
303
+
284
304
} // namespace mavsdk
0 commit comments