Skip to content

Commit

Permalink
gps: use all injection data
Browse files Browse the repository at this point in the history
When we fall back to another link, we are already doing a uORB copy when
checking the data. Therefore, we should further down use/send that data
instead of overwriting it immediately.

Signed-off-by: Julian Oes <julian@oes.ch>
  • Loading branch information
julianoes authored and bkueng committed May 3, 2023
1 parent 2fd3de8 commit 1d4b66f
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/drivers/gps/gps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ void GPS::handleInjectDataTopic()
return;
}

// We don't want to call copy again further down if we have already done a
// copy in the selection process.
bool already_copied = false;
gps_inject_data_s msg;

// If there has not been a valid RTCM message for a while, try to switch to a different RTCM link
Expand All @@ -531,6 +534,8 @@ void GPS::handleInjectDataTopic()
if (_orb_inject_data_sub.ChangeInstance(i)) {
if (_orb_inject_data_sub.copy(&msg)) {
if ((hrt_absolute_time() - msg.timestamp) < 5_s) {
// Remember that we already did a copy on this instance.
already_copied = true;
_selected_rtcm_instance = i;
break;
}
Expand All @@ -554,25 +559,26 @@ void GPS::handleInjectDataTopic()

do {
num_injections++;
updated = _orb_inject_data_sub.updated();

if (updated) {

if (_orb_inject_data_sub.copy(&msg)) {
updated = already_copied || _orb_inject_data_sub.update(&msg);

// Prevent injection of data from self
if (msg.device_id != get_device_id()) {
/* 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;
_last_rtcm_injection_time = hrt_absolute_time();
}
if (updated) {
// Prevent injection of data from self
if (msg.device_id != get_device_id()) {
/* 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;
_last_rtcm_injection_time = hrt_absolute_time();
}
}

// Reset the flag, it's only used once.
already_copied = false;

} while (updated && num_injections < max_num_injections);
}

Expand Down

1 comment on commit 1d4b66f

@DronecodeBot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/uxrce-dds-bridge-multicast-udp-addresses-and-ports/32218/7

Please sign in to comment.