#pragma once #include #include #include #include "bits.hh" #include std::basic_string getCondensedGPSMessage(std::basic_string_view 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 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 int parseGPSMessage(std::basic_string_view cond, T& out, uint8_t* pageptr=0) { using namespace std; int frame = getbitu(&cond[0], 24+19, 3); // 10 * 4 bytes in payload now out.tow = 1.5*(getbitu(&cond[0], 24, 17)*4); // cerr << "Preamble: "< 56 // page 25 -> 63 // 2-10 -> 25 -> 32 ?? } else if(frame == 5) { // this is a caroussel frame // cerr<<"Frame 5, SV: "<