2019-08-12 17:15:25 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include "fmt/format.h"
|
|
|
|
#include "fmt/printf.h"
|
|
|
|
#include <fstream>
|
|
|
|
#include <map>
|
|
|
|
#include <bitset>
|
|
|
|
#include <vector>
|
|
|
|
#include <thread>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include "ubx.hh"
|
|
|
|
#include "bits.hh"
|
|
|
|
#include "minivec.hh"
|
|
|
|
#include "navmon.pb.h"
|
|
|
|
#include "ephemeris.hh"
|
|
|
|
#include "gps.hh"
|
2019-08-26 07:58:01 -06:00
|
|
|
#include "glonass.hh"
|
|
|
|
#include "beidou.hh"
|
|
|
|
|
2019-08-12 17:15:25 -06:00
|
|
|
#include <unistd.h>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
static std::string humanTime(time_t t)
|
|
|
|
{
|
2019-08-17 03:05:03 -06:00
|
|
|
struct tm tm={0};
|
2019-08-12 17:15:25 -06:00
|
|
|
gmtime_r(&t, &tm);
|
|
|
|
|
|
|
|
char buffer[80];
|
|
|
|
strftime(buffer, sizeof(buffer), "%a, %d %b %Y %T %z", &tm);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
for(;;) {
|
|
|
|
char bert[4];
|
|
|
|
if(read(0, bert, 4) != 4 || bert[0]!='b' || bert[1]!='e' || bert[2] !='r' || bert[3]!='t') {
|
|
|
|
cerr<<"EOF or bad magic"<<endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t len;
|
|
|
|
if(read(0, &len, 2) != 2)
|
|
|
|
break;
|
|
|
|
len = htons(len);
|
|
|
|
char buffer[len];
|
|
|
|
if(read(0, buffer, len) != len)
|
|
|
|
break;
|
|
|
|
|
|
|
|
NavMonMessage nmm;
|
|
|
|
nmm.ParseFromString(string(buffer, len));
|
|
|
|
cout<<humanTime(nmm.localutcseconds())<<" "<<nmm.localutcnanoseconds()<<" ";
|
|
|
|
cout<<"src "<<nmm.sourceid()<< " ";
|
|
|
|
if(nmm.type() == NavMonMessage::ReceptionDataType) {
|
|
|
|
cout<<"receptiondata for "<<nmm.rd().gnssid()<<","<<nmm.rd().gnsssv()<<endl;
|
|
|
|
}
|
|
|
|
else if(nmm.type() == NavMonMessage::GalileoInavType) {
|
|
|
|
basic_string<uint8_t> inav((uint8_t*)nmm.gi().contents().c_str(), nmm.gi().contents().size());
|
|
|
|
unsigned int wtype = getbitu(&inav[0], 0, 6);
|
|
|
|
cout << "galileo inav for "<<nmm.gi().gnssid()<<","<<nmm.gi().gnsssv()<<" wtype "<< wtype << endl;
|
|
|
|
}
|
|
|
|
else if(nmm.type() == NavMonMessage::GPSInavType) {
|
|
|
|
int sv = nmm.gpsi().gnsssv();
|
2019-08-17 02:30:49 -06:00
|
|
|
auto cond = getCondensedGPSMessage(std::basic_string<uint8_t>((uint8_t*)nmm.gpsi().contents().c_str(), nmm.gpsi().contents().size()));
|
|
|
|
struct GPSState gs;
|
|
|
|
uint8_t page;
|
|
|
|
int frame=parseGPSMessage(cond, gs, &page);
|
2019-08-18 02:56:22 -06:00
|
|
|
cout<<"GPS "<<sv<<": "<<gs.tow<<" ";
|
2019-08-17 03:05:03 -06:00
|
|
|
if(frame == 1) {
|
2019-08-18 02:56:22 -06:00
|
|
|
cout << "gpshealth = "<<(int)gs.gpshealth<<", wn "<<gs.wn;
|
2019-08-17 03:05:03 -06:00
|
|
|
}
|
|
|
|
else if(frame == 2) {
|
2019-08-18 02:56:22 -06:00
|
|
|
cout << "t0e = "<<gs.iods.begin()->second.t0e << " " <<ephAge(gs.tow, gs.iods.begin()->second.t0e);
|
2019-08-17 02:30:49 -06:00
|
|
|
}
|
|
|
|
cout<<"\n";
|
2019-08-12 17:15:25 -06:00
|
|
|
}
|
2019-08-26 07:58:01 -06:00
|
|
|
else if(nmm.type() == NavMonMessage::BeidouInavType) {
|
|
|
|
int sv = nmm.bi().gnsssv();
|
|
|
|
auto cond = getCondensedBeidouMessage(std::basic_string<uint8_t>((uint8_t*)nmm.bi().contents().c_str(), nmm.bi().contents().size()));
|
|
|
|
BeidouMessage bm;
|
|
|
|
uint8_t pageno;
|
|
|
|
int fraid = bm.parse(cond, &pageno);
|
|
|
|
cout<<"BeiDou "<<sv<<": "<<bm.sow<<", FraID "<<fraid<<endl;
|
2019-08-12 17:15:25 -06:00
|
|
|
|
2019-08-26 07:58:01 -06:00
|
|
|
}
|
2019-08-12 17:15:25 -06:00
|
|
|
else if(nmm.type() == NavMonMessage::ObserverPositionType) {
|
|
|
|
cout<<"ECEF"<<endl;
|
|
|
|
// XXX!! this has to deal with source id!
|
|
|
|
}
|
|
|
|
else if(nmm.type() == NavMonMessage::RFDataType) {
|
|
|
|
cout<<"RFdata for "<<nmm.rfd().gnssid()<<","<<nmm.rfd().gnsssv()<<endl;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cout<<"Unknown type "<< (int)nmm.type()<<endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|