For a specified communication standard RTCM SC104 3.1, I need to split data across bytes as a pair of 12 bit data segments. So for a given message I need to place the message type number on the first byte and half of the second byte. Then I need to start an ID integer on the half of second byte and continue to the third byte. This sort of pattern continues to the end of the message shaving down other integers in 20bit, 5bit, and other sizes essentially cutting of the 0's that would normally fill out the MSB end of the integer values.
I have not seen a clear definition but I assume it must go out in network byte order so before copying bits I would have to reverse my integers in memory. I am still quite new to cpp and am wondering how do I get to the individual bytes making up an integer in memory? If I can access the bytes then I could use bitwise or to split the bits from 2 bytes onto one for the message.
Here's the start of building a message before adding the data:
//build message 1002 gps 00111110 1010
char buf1002[BUFFERSIZE];
buf1002[0] = 0x3E; //00111110
buf1002[1] = 0xA0; //10100000
//ref station id 12 bits of 16
//ex unsigned short m = 1100;
//m would be byte2 00000100 byte1 01001100
//buf1002[1] would be 10100100
//buf1002[2] would be 01001100
//reverse bit order for network after building?
The reference station will be from an unsigned short, so a 2 byte integer. So how do I go about reading a single byte from it? Do I start with a memory location pointer? If so then what?
Any help would be greatly appreciated.