Skip to content

Commit a1d767c

Browse files
committed
also dedup gps (on request)
1 parent 4161613 commit a1d767c

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

navmerge.cc

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ set<int> g_bsset;
5555
// this means each Galileo message will only get set once
5656
map<tuple<uint32_t, std::string, uint32_t, std::string, int16_t>, time_t> g_seen;
5757

58-
bool g_inavdedup{false};
58+
bool g_inavdedup{false}, g_gpsdedup{false};
5959

6060
/* Goal: do a number of TCP operations that have a combined timeout.
6161
maybe some helper:
@@ -134,20 +134,36 @@ void recvSession(ComboAddress upstream)
134134
continue;
135135

136136
if(g_inavdedup) {
137-
if(nmm.type() == NavMonMessage::GalileoInavType) {
138-
std::lock_guard<std::mutex> mut(g_mut);
139-
decltype(g_seen)::key_type tup(nmm.gi().gnsssv(),
137+
if(nmm.type() == NavMonMessage::GalileoInavType) {
138+
std::lock_guard<std::mutex> mut(g_mut);
139+
decltype(g_seen)::key_type tup(nmm.gi().gnsssv(),
140140
nmm.gi().contents(),
141141
nmm.gi().sigid(),
142142
nmm.gi().reserved1(),
143143
nmm.gi().has_ssp() ? nmm.gi().ssp() : -1);
144-
145-
if(!g_seen.count(tup))
146-
g_buffer.insert({{nmm.localutcseconds(), nmm.localutcnanoseconds()}, part});
147-
g_seen[tup]=time(0);
148-
}
149-
}
150-
else {
144+
145+
if(!g_seen.count(tup))
146+
g_buffer.insert({{nmm.localutcseconds(), nmm.localutcnanoseconds()}, part});
147+
g_seen[tup]=time(0);
148+
}
149+
}
150+
151+
if(g_gpsdedup) {
152+
if(nmm.type() == NavMonMessage::GPSInavType) {
153+
std::lock_guard<std::mutex> mut(g_mut);
154+
decltype(g_seen)::key_type tup(nmm.gpsi().gnsssv(),
155+
nmm.gpsi().contents(),
156+
nmm.gpsi().sigid(),
157+
"",
158+
0);
159+
160+
if(!g_seen.count(tup))
161+
g_buffer.insert({{nmm.localutcseconds(), nmm.localutcnanoseconds()}, part});
162+
g_seen[tup]=time(0);
163+
}
164+
}
165+
166+
if(!g_gpsdedup && !g_inavdedup) {
151167
std::lock_guard<std::mutex> mut(g_mut);
152168
g_buffer.insert({{nmm.localutcseconds(), nmm.localutcnanoseconds()}, part});
153169
}
@@ -187,7 +203,8 @@ int main(int argc, char** argv)
187203
app.add_option("--destination,-d", destinations, "Send output to this IPv4/v6 address");
188204
app.add_option("--drop-stations", badstations, "Drop these station numbers");
189205
app.add_option("--listener,-l", listeners, "Make data available on this IPv4/v6 address");
190-
app.add_flag("--inavdedup", g_inavdedup, "Only pass on Galileo I/NAV, and dedeup");
206+
app.add_flag("--inavdedup", g_inavdedup, "Only pass on Galileo I/NAV, and dedeup");
207+
app.add_flag("--gpsdedup", g_gpsdedup, "Only pass on GPS, and dedeup");
191208
app.add_flag("--version", doVERSION, "show program version and copyright");
192209
app.add_flag("--stdout", doSTDOUT, "Emit output to stdout");
193210

0 commit comments

Comments
 (0)