diff --git a/src/drivers/gps/gps.cpp b/src/drivers/gps/gps.cpp index 9ade4619f9e..01b39443790 100644 --- a/src/drivers/gps/gps.cpp +++ b/src/drivers/gps/gps.cpp @@ -430,15 +430,17 @@ void GPS::handleInjectDataTopic() if (updated) { gps_inject_data_s msg; - _orb_inject_data_sub.copy(&msg); - /* Write the message to the gps device. Note that the message could be fragmented. - * But as we don't write anywhere else to the device during operation, we don't - * need to assemble the message first. - */ - injectData(msg.data, msg.len); + if (_orb_inject_data_sub.copy(&msg)) { - ++_last_rate_rtcm_injection_count; + /* Write the message to the gps device. Note that the message could be fragmented. + * But as we don't write anywhere else to the device during operation, we don't + * need to assemble the message first. + */ + injectData(msg.data, msg.len); + + ++_last_rate_rtcm_injection_count; + } } } while (updated && num_injections < max_num_injections); }