0

I am trying to extract data from a GPS receiver. The way they transmit their information is shown in the following figure.

Bit information

I am trying to get roota. I have word 8 and word 9 in seperate bitsets. How do I combine the relevant bits into one bitset?

I also need to use this scale factor information to get a double precision number. The scale factor information is shown below.

scale factor information

I have tried

std::bitset<32> word8_binary; // is filled with word 8 data.
std::bitset<32> word9_binary; // is filled with word 9 data.

std::bitset<32> roota_binary;

for (int i=13; i>5; i--)
{             
    roota_binary = word8_binary[i] << 32 | word9_binary[i];
} 

But this is not giving me the result I want. I also don't know how to sue the scale factor.

Your help would be much appreciated.

Ariel Baron
  • 331
  • 4
  • 13
  • How is this data received? Each *"word"* is only 30 bits! The message frame of 300 bits would not be byte aligned for the second frame. – sawdust Apr 07 '17 at 23:59

1 Answers1

0

This might not be "c++" enough, but I'd do bit manipulation on the corresponding integers:

ulong roota_binary = (((word8_binary.to_ulong() >> 6) & 0xFF) <<24) +
                     ((word9_binary.to_ulong() >>6) & 0xFFFFFF); 

The >>6 gets rid of the parity bits, the masks isolate the bits you need, and the <<24 puts the high ones on top.

AShelly
  • 34,686
  • 15
  • 91
  • 152