fix signed bug in gps t0e, make navdump a bit more powerful

pull/1/head
bert hubert 2019-08-17 10:30:49 +02:00
parent ac76ba1d28
commit 26e088e063
2 changed files with 56 additions and 2 deletions

48
gps.hh
View File

@ -1,9 +1,55 @@
#pragma once
#include <string>
#include <map>
#include "bits.hh"
#include <iostream>
std::basic_string<uint8_t> getCondensedGPSMessage(std::basic_string_view<uint8_t> payload);
struct GPSState
{
struct SVIOD
{
std::bitset<32> words;
int gnssid;
uint32_t t0e;
uint32_t e, sqrtA;
int32_t m0, omega0, i0, omega, idot, omegadot, deltan;
int16_t cuc{0}, cus{0}, crc{0}, crs{0}, cic{0}, cis{0};
// 60 seconds
uint16_t t0c; // clock epoch, stored UNSCALED, since it is not in the same place as GPS
// 2^-34 2^-46
int32_t af0 , af1;
// 2^-59
int8_t af2;
uint32_t wn{0}, tow{0};
};
uint8_t gpshealth{0};
uint16_t ai0{0};
int16_t ai1{0}, ai2{0};
int BGDE1E5a{0}, BGDE1E5b{0};
bool disturb1{false}, disturb2{false}, disturb3{false}, disturb4{false}, disturb5{false};
uint16_t wn{0}; // we put the "unrolled" week number here!
uint32_t tow{0}; // "last seen"
//
// 2^-30 2^-50 1 8-bit week
int32_t a0{0}, a1{0}, t0t{0}, wn0t{0};
int32_t a0g{0}, a1g{0}, t0g{0}, wn0g{0};
int8_t dtLS{0}, dtLSF{0};
uint16_t wnLSF{0};
uint8_t dn; // leap second day number
// 1 2^-31 2^-43 2^-55 16 second
int ura, af0, af1, af2, t0c; // GPS parameters that should not be here XXX
std::map<int, SVIOD> iods;
SVIOD& getEph(int i) { return iods[i]; } // XXXX gps adaptor
void checkCompleteAndClean(int iod){}
};
// expects input as 24 bit read to to use messages, returns frame number
template<typename T>
int parseGPSMessage(std::basic_string_view<uint8_t> cond, T& out, uint8_t* pageptr=0)
@ -45,7 +91,7 @@ int parseGPSMessage(std::basic_string_view<uint8_t> cond, T& out, uint8_t* pagep
int iod = getbitu(&cond[0], 2*24, 8);
auto& eph = out.getEph(iod);
eph.words[2]=1;
eph.t0e = getbits(&cond[0], 9*24, 16) * 16.0; // WE SCALE THIS FOR THE USER!!
eph.t0e = getbitu(&cond[0], 9*24, 16) * 16.0; // WE SCALE THIS FOR THE USER!!
// cerr<<"IODe "<<(int)iod<<", t0e "<< eph.t0e << " = "<< 16* eph.t0e <<"s"<<endl;
eph.e= getbitu(&cond[0], 5*24+16, 32);

View File

@ -62,7 +62,15 @@ int main(int argc, char** argv)
}
else if(nmm.type() == NavMonMessage::GPSInavType) {
int sv = nmm.gpsi().gnsssv();
cout<<"GPS "<<sv<<endl;
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);
cout<<"GPS "<<sv<<": ";
if(frame == 2) {
cout << "t0e = "<<gs.iods.begin()->second.t0e;
}
cout<<"\n";
}
else if(nmm.type() == NavMonMessage::ObserverPositionType) {