Merge branch 'master' of github.com:berthubert/galmon

pull/107/merge
bert hubert 2021-11-13 13:00:07 +01:00
commit f4256dac8b
7 changed files with 35 additions and 25 deletions

View File

@ -137,7 +137,7 @@ septool: navmon.pb.o septool.o bits.o ext/fmt-6.1.2/src/format.o galileo.o gps.
testrunner: navmon.pb.o testrunner.o ubx.o bits.o ext/fmt-6.1.2/src/format.o galileo.o gps.o beidou.o ephemeris.o sp3.o osen.o navmon.o rinex.o githash.o
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -lprotobuf -lz
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib -lprotobuf -lz -pthread
gndate: gndate.o githash.o ext/fmt-6.1.2/src/format.o navmon.o
$(CXX) -std=gnu++17 $^ -o $@ -L/usr/local/lib

View File

@ -226,7 +226,7 @@ struct GalileoMessage : GPSLikeEphemeris
{
int dw = (int)(wn%64) - (int)(wn0g%64);
if(dw > 31)
dw = 31- dw;
dw = dw - 64;
int delta = dw*7*86400 + tow - getT0g(); // NOT ephemeris age tricks
// 2^-35 2^-51 3600

View File

@ -257,7 +257,8 @@ int main(int argc, char **argv)
res = mc.getURL(url+"svs.json");
j = nlohmann::json::parse(res);
bool first=true;
bool first=true;
bool globalOsnma=false;
for(const auto& sv : j) {
if(!sv.count("gnssid") || !sv.count("fullName") || !sv.count("sigid")) {
cout<<"Skipping "<< sv.count("gnssid") <<", "<< sv.count("fullName") <<", " <<sv.count("sigid") <<endl;
@ -279,7 +280,8 @@ int main(int argc, char **argv)
// cout<<"Skipping "<<fullName<<" in loop: "<<sv.count("healthissue")<<", "<<sv.count("eph-age-m") << ", "<<sv.count("perrecv")<<endl;
continue;
}
for(const auto& recv : sv["perrecv"]) {
if(!recv.count("last-seen-s")) {
cout<<"Missing last-seen-s"<<endl;
@ -289,20 +291,10 @@ int main(int argc, char **argv)
numfresh++;
if((int)recv["last-seen-s"] < 3600)
notseen=false;
}
if(sv.count("osnma") && sv["osnma"]==true)
globalOsnma |= 1;
static int ctr;
bool overriden=false;
/*
if(fullName=="E01@1") {
if(((ctr++) % 130) < 65)
if(sv.count("osnma"))
overriden = true;
cerr<<"Reporting for "<<fullName<<": "<<(overriden || (sv.count("osnma") && (sv["osnma"] != false)))<<endl;
}
*/
auto osnmachange = g_sk.reportState(fullName, "osnma", overriden || (sv.count("osnma") && (sv["osnma"] != false)));
auto healthchange = g_sk.reportState(fullName, "health", sv["healthissue"]!=0);
std::optional<string> tooOldChange;
@ -343,8 +335,6 @@ int main(int argc, char **argv)
*/
ostringstream out;
if(osnmachange)
out<<"OSNMA state change: "<< (*osnmachange) <<" ";
if(healthchange)
out<< *healthchange<<" ";
@ -408,6 +398,17 @@ int main(int argc, char **argv)
cout<<humanTimeNow() <<" " << tweet << endl;
}
}
auto osnmachange = g_sk.reportState("global", "osnma", globalOsnma);
if(osnmachange) {
string tweet= "Galileo OSNMA new state: "+*osnmachange;
cout<<humanTimeNow()<< " " <<tweet<<endl;
if(doTweet) {
sendTweet(tweet);
}
}
cout<<".";
cout.flush();
}

View File

@ -422,6 +422,8 @@ try
if(wtype == 4) {
// 2^-34 2^-46
cout <<" iodnav "<<gm.iodnav <<" af0 "<<gm.af0 <<" af1 "<<gm.af1 <<", scaled: "<<ldexp(1.0*gm.af0, 19-34)<<", "<<ldexp(1.0*gm.af1, 38-46);
cout << " t0g " << gm.t0g <<" a0g " << gm.a0g <<" a1g " << gm.a1g <<" WN0g " << gm.wn0g;
if(tow && oldgm4s.count(nmm.gi().gnsssv()) && oldgm4s[nmm.gi().gnsssv()].iodnav != gm.iodnav) {
auto& oldgm4 = oldgm4s[nmm.gi().gnsssv()];

View File

@ -2632,7 +2632,7 @@ try
for(const auto& ed : rm.d_ephs) {
auto iter = g_svstats.find(ed.id);
// XXX NAVCAST ONLY
if(iter != g_svstats.end() && iter->second.completeIOD() && iter->second.liveIOD().getIOD() == ed.iod && nmm.sourceid()==300)
if(iter != g_svstats.end() && iter->second.completeIOD() && iter->second.liveIOD().getIOD() == ed.iod && nmm.sourceid()==302)
iter->second.rtcmEphDelta = ed;
idb.addValue(ed.id, "rtcm-eph-correction", {
@ -2658,7 +2658,7 @@ try
for(const auto& cd : rm.d_clocks) {
auto iter = g_svstats.find(cd.id);
if(iter != g_svstats.end() && nmm.sourceid()==300) /// XXX wrong
if(iter != g_svstats.end() && nmm.sourceid()==302) /// XXX wrong
iter->second.rtcmClockDelta = cd;
idb.addValue(cd.id, "rtcm-clock-correction", {
@ -2686,7 +2686,7 @@ try
else if(rm.type == 1060 || rm.type == 1243) {
for(const auto& ed : rm.d_ephs) {
auto iter = g_svstats.find(ed.id);
if(iter != g_svstats.end() && iter->second.completeIOD() && iter->second.liveIOD().getIOD() == ed.iod && nmm.sourceid()==300)
if(iter != g_svstats.end() && iter->second.completeIOD() && iter->second.liveIOD().getIOD() == ed.iod && nmm.sourceid()==302)
iter->second.rtcmEphDelta = ed;
idb.addValue(ed.id, "rtcm-eph-correction", {
@ -2754,7 +2754,7 @@ try
for(const auto& cd : rm.d_clocks) {
auto iter = g_svstats.find(cd.id);
if(iter != g_svstats.end() && nmm.sourceid()==300)
if(iter != g_svstats.end() && nmm.sourceid()==302)
iter->second.rtcmClockDelta = cd;
idb.addValue(cd.id, "rtcm-clock-correction", {

View File

@ -133,9 +133,11 @@ try
bool doVERSION{false}, doSTDOUT{false};
CLI::App app(program);
string sourceaddr;
bool quiet{false};
app.add_option("--source", sourceaddr, "Connect to this IP address:port to source SBF (otherwise stdin)");
app.add_option("--destination,-d", destinations, "Send output to this IPv4/v6 address");
app.add_option("--station", g_srcid, "Station id")->required();
app.add_option("--quiet", quiet, "Don't emit noise");
app.add_flag("--version", doVERSION, "show program version and copyright");
app.add_flag("--stdout", doSTDOUT, "Emit output to stdout");
try {
@ -181,7 +183,8 @@ try
for(;;) {
double to=1000;
auto res = getSEPMessage(srcfd, &to);
cerr<<res.first.getID()<<" - " <<res.first.getIDBare() << endl;
if(!quiet)
cerr<<res.first.getID()<<" - " <<res.first.getIDBare() << endl;
if(res.first.getID() == 4023) { // I/NAV
auto str = res.first.getPayload();
struct SEPInav
@ -571,6 +574,7 @@ try
}
else {
if(!quiet)
cerr<<"Unknown message "<<res.first.getID() << " / " <<res.first.getIDBare()<<" ("<<res.first.d_store.size()<<" bytes)"<<endl;
}
}

View File

@ -158,9 +158,12 @@ void ZStdReader::worker()
while(input.pos != input.size) {
output.pos=0;
output.size=outputcapacity;
ZSTD_decompressStream(z, &output, &input);
int res = ZSTD_decompressStream(z, &output, &input);
if(ZSTD_isError(res)) {
cerr<<"Error decompressing ZSTD data"<<endl;
break;
}
int res;
res = writen(d_writepipe, output.dst, output.pos);
if(!res) // we are history
break;