Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions ubxtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static char program[]="ubxtool";
bool doDEBUG{false};
bool doLOGFILE{false};
bool doVERSION{false};
bool doSILENT{false};

struct timespec g_gnssutc;
uint16_t g_galwn;
Expand Down Expand Up @@ -239,7 +240,7 @@ UBXMessage sendAndWaitForUBX(int fd, int seconds, basic_string_view<uint8_t> msg
catch(...) {
if(n==1)
throw;
cerr<<"Retransmit"<<endl;
if (!doSILENT) { cerr<<"Retransmit"<<endl; }
}
}
// we actually never get here, but if you remove this line, we get a warning
Expand Down Expand Up @@ -287,7 +288,7 @@ bool sendAndWaitForUBXAckNack(int fd, int seconds, basic_string_view<uint8_t> ms
catch(...) {
if(n==1)
throw;
cerr<<"Retransmit"<<endl;
if (!doSILENT) { cerr<<"Retransmit"<<endl; }
}
}
return false;
Expand Down Expand Up @@ -498,7 +499,7 @@ void readSome(int fd)
if (doDEBUG) { cerr<<humanTimeNow()<<" "<<string((char*)msg.getPayload().c_str(), msg.getPayload().size()) <<endl; }
}
catch(TimeoutError& te) {
cerr<<"Timeout"<<endl;
if (!doSILENT) { cerr<<"Timeout"<<endl; }
}
}

Expand Down Expand Up @@ -615,6 +616,7 @@ int main(int argc, char** argv)
app.add_flag("--survey-reset", doSurveyReset, "Reset the Surveyed-in state");
app.add_flag("--debug", doDEBUG, "Display debug information");
app.add_flag("--logfile", doLOGFILE, "Create logfile");
app.add_flag("--silent", doSILENT, "Supress non essential logging");
app.add_flag("--version", doVERSION, "show program version and copyright");
try {
app.parse(argc, argv);
Expand All @@ -628,14 +630,19 @@ int main(int argc, char** argv)
}

if(! *pn) {
cerr<<"you must provide the --port"<<endl;
cerr<<"Error: you must provide the --port"<<endl;
exit(1);
}

g_baudval = getBaudrate(baudrate);

if(!(doGPS || doGalileo || doGlonass || doBeidou)) {
cerr<<"Enable at least one of --gps, --galileo, --glonass, --beidou"<<endl;
cerr<<"Error: Enable at least one of --gps, --galileo, --glonass, --beidou"<<endl;
return EXIT_FAILURE;
}

if(doDEBUG && doSILENT) {
cerr<<"--silent and --debug are mutually exclusive."<<endl;
return EXIT_FAILURE;
}

Expand All @@ -644,7 +651,7 @@ int main(int argc, char** argv)
for(const auto& s : destinations) {
auto res=resolveName(s, true, true);
if(res.empty()) {
cerr<<"Unable to resolve '"<<s<<"' as destination for data, exiting"<<endl;
cerr<<"Error: Unable to resolve '"<<s<<"' as destination for data, exiting"<<endl;
exit(EXIT_FAILURE);
}
ns.addDestination(s); // ComboAddress(s, 29603));
Expand Down Expand Up @@ -782,7 +789,7 @@ int main(int argc, char** argv)
if (doDEBUG) { cerr<<humanTimeNow()<<" Got ack on GNSS setting"<<endl; }
}
else {
cerr<<humanTimeNow()<<" Got nack on GNSS setting"<<endl;
cerr<<humanTimeNow()<<" Error: Got nack on GNSS setting"<<endl;
exit(-1);
}
}
Expand Down Expand Up @@ -812,7 +819,7 @@ int main(int argc, char** argv)
if (doDEBUG) { cerr<<humanTimeNow()<<" Got ack on F9P GNSS setting"<<endl; }
}
else {
cerr<<humanTimeNow()<<" Got nack on F9P GNSS setting"<<endl;
cerr<<humanTimeNow()<<" Error: Got nack on F9P GNSS setting"<<endl;
exit(-1);
}
/* VALSET
Expand All @@ -826,7 +833,7 @@ int main(int argc, char** argv)
if (doDEBUG) { cerr<<humanTimeNow()<<" Got ack on F9P UART1 setting"<<endl; }
}
else {
cerr<<humanTimeNow()<<" Got nack on F9P UART1 setting"<<endl;
cerr<<humanTimeNow()<<" Error: Got nack on F9P UART1 setting"<<endl;
exit(-1);
}
}
Expand Down Expand Up @@ -862,7 +869,7 @@ int main(int argc, char** argv)
if (doDEBUG) { cerr<<humanTimeNow()<<" Got ack on survey-reset"<<endl; }
}
else {
cerr<<humanTimeNow()<<" Got nack on survey-reset"<<endl;
cerr<<humanTimeNow()<<" Error: Got nack on survey-reset"<<endl;
exit(-1);
}
exit(0);
Expand Down Expand Up @@ -906,7 +913,7 @@ int main(int argc, char** argv)
if (doDEBUG) { cerr<<humanTimeNow()<<" Got ack on survey-in"<<endl; }
}
else {
cerr<<humanTimeNow()<<" Got nack on survey-in"<<endl;
cerr<<humanTimeNow()<<" Error: Got nack on survey-in"<<endl;
exit(-1);
}
}
Expand All @@ -918,7 +925,7 @@ int main(int argc, char** argv)
if (doDEBUG) { cerr<<humanTimeNow()<<" Got ack on SBAS setting"<<endl; }
}
else {
cerr<<humanTimeNow()<<" Got nack on SBAS setting"<<endl;
cerr<<humanTimeNow()<<" Error: Got nack on SBAS setting"<<endl;
exit(-1);
}
}
Expand Down Expand Up @@ -1254,11 +1261,13 @@ int main(int argc, char** argv)
svseen.insert({id.first, id.second, payload[2]});

if(time(0)- lastStat > 30) {
cerr<<humanTimeNow()<<" src "<<g_srcid<< " (fix: "<<g_fixtype<<") currently receiving: ";
for(auto& s : svseen) {
cerr<<get<0>(s)<<","<<get<1>(s)<<"@"<<get<2>(s)<<" ";
if (!doSILENT) {
cerr<<humanTimeNow()<<" src "<<g_srcid<< " (fix: "<<g_fixtype<<") currently receiving: ";
for(auto& s : svseen) {
cerr<<get<0>(s)<<","<<get<1>(s)<<"@"<<get<2>(s)<<" ";
}
cerr<<endl;
}
cerr<<endl;
lastStat = time(0);
svseen.clear();
}
Expand Down