gps: Improve the FALSE setting of the ALREADY_COPIED variable

This commit is contained in:
muramura
2023-05-08 07:04:11 +02:00
committed by Beat Küng
parent ddfc2986dc
commit 3c45b184d3
+4 -7
View File
@@ -547,7 +547,7 @@ void GPS::handleInjectDataTopic()
// Reset instance in case we didn't actually want to switch
_orb_inject_data_sub.ChangeInstance(_selected_rtcm_instance);
bool updated = false;
bool updated = already_copied;
// Limit maximum number of GPS injections to 8 since usually
// GPS injections should consist of 1-4 packets (GPS, Glonass, BeiDou, Galileo).
@@ -558,11 +558,9 @@ void GPS::handleInjectDataTopic()
size_t num_injections = 0;
do {
num_injections++;
updated = already_copied || _orb_inject_data_sub.update(&msg);
if (updated) {
num_injections++;
// 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.
@@ -576,8 +574,7 @@ void GPS::handleInjectDataTopic()
}
}
// Reset the flag, it's only used once.
already_copied = false;
updated = _orb_inject_data_sub.update(&msg);
} while (updated && num_injections < max_num_injections);
}