#include "beidou.hh" #include "bits.hh" #include using namespace std; // with immense gratitude to https://stackoverflow.com/questions/24612436/how-to-check-a-bch15-11-1-code-checksum-for-bds-beidou-satellite-system static int checkbds(int bits) { static int const at[15] = {1, 2, 4, 8, 3, 6, 12, 11, 5, 10, 7, 14, 15, 13, 9}; int s, i, j; for(i = 1; i <= 2; i++) { s = 0; for(j = 0; j < 15; j++) { if(bits & (1< getCondensedBeidouMessage(std::basic_string_view payload) { // payload consists of 32 bit words where we have to ignore the first 2 bits of every word int chunk = getbitu(&payload[0], 17, 15); // cout <<"w0 checkbds(chunk0): "<(buffer, 28); } // the BeiDou ICD lists bits from bit 1 // In addition, they count the parity bits which we strip out // this function converts their bit numbers to ours // the first word has 4 parity bits, the rest has 8 int beidouBitconv(int their) { int wordcount = their/30; if(!wordcount) return their - 1; return their - (1 + 4 + (wordcount -1)*8); } bool processBeidouAlmanac(const BeidouMessage& bm, struct BeidouAlmanacEntry& bae) { bae.alma = bm.alma; int pageno = bm.alma.pageno; if(bm.fraid == 5 && pageno >= 11 && pageno <= 23) { /* cout<<" AmEpID "<< bm.alma.AmEpID; cout << " AmID "<