Reverse the order if incoming data

I have a radio IC that provides weather message data and also provides a confidence level of each byte of data received. The problem is that the confidence data comes in a little strange and I'm not sure how to rearrange it.

Response byte #4: conf7[7:6] conf6[5:4] conf5[3:2] conf4[1:0]
Response byte #5: conf3[7:6] conf2[5:4] conf1[3:2] conf0[1:0]
Response byte #6: Data0[7:0]
...
...
...
... byte#13: Data7[7:0]

So taking the incoming data bytes and placing them in a string is simple enough, but how do I take the 2 bytes of confidence data coming in and break them up so that I can correlate the confidence bit with the corresponding data bit i.e...Data0/conf0?

The confidence data represents a char number between 0 and 3 for each confidence bit.

Store the two bytes of confidence data into two byte variables, or an array, then use bitRead() to access the individual bits.

OK, so I2C interface.......

int conf7, conf 6, conf5, conf4, //int to store confidence values

byte confByte0 = Wire.read(); //Response byte #4

conf7 = bitRead(confByte, 3); // read left-most bit of confByte0
conf6 = bitRead(confByte, 2);
conf5 = bitRead(confByte, 1);
conf4 = bitRead(confByte, 0);// read right-most bit of confByte0

Does that look right?

int conf7, conf 6, conf5, conf4, //int to store confidence values

No. The values are not ints. They are single bits, so, if you need to store them individually, they should be stored in byte variables, which are half the size.

conf7 = bitRead(confByte, 3); // read left-most bit of confByte0

No. The leftmost bit is bit 7.

It appears that the "confidence bit" is actually two bits, so, you'll need two bitRead()s and two bitWrite()s to get the data, and store it in the low order bits of the byte,

byte conf[ ] = { };

byte confByte0 = Wire.read(); //Response byte #4 with conf7-conf4 contained

cBit = bitRead(confByte, 7);
bitWrite(conf[7], 1, cBit);
cBit = bitRead(confByte, 6);
bitWrite(conf[7], 0, cBit);

cBit = bitRead(confByte, 5);
bitWrite(conf[6], 1, cBit);
cBit = bitRead(confByte, 4);
bitWrite(conf[6], 0, cBit);

cBit = bitRead(confByte, 3);
bitWrite(conf[5], 1, cBit);
cBit = bitRead(confByte, 2);
bitWrite(conf[5], 0, cBit);

cBit = bitRead(confByte, 1);
bitWrite(conf[4], 1, cBit);
cBit = bitRead(confByte, 0);
bitWrite(conf[4], 0, cBit);

Getting closer?

byte conf[ ] = { };

With 0 initializers, that will be a pretty small array.

Getting closer?

Other than the array size, yes.

The data message has a maximum data length of 268 bytes so I should probably do the following:

byte conf[268] = { };

That's a sizeable chunk of RAM you're using there. Make sure you have that much available. Do you really need to handle the maximum size message?

Well, PaulS suggested that I change the size of the array.
I figured I either need to let the array establish its own size as the message comes in or I need to define the max size.

Is there another approach. This is to collect NOAA Weather Radio messages.

hm so all the values you get are 2 bits ??.
and max 248 bits
you can store 32 bits in a long int, 8 long ints would be enough, or 8 bytes

easy way to store it might just be to do 2 bit shifts left and next add the new reading and repeat it until your variable type is full

PGTBOOS:
8 long ints would be enough, or 8 bytes

Try 32bytes:
8 * uint32_t = 8 * 4 = 32bytes = 256bits

No message could be max of 268 bytes not bits. The confidence bits are 2 bits for each of the max 268 bytes and represent a value of 0 to 3 based on quality.

00=0
01=1
10=2
11=3

You probably want to right-shift (>> move-positions) and mask (& mask-bits) to read the confidence bits.

byte confBits = 0b10000111; // example for examples below

byte tempCB = ( confBits >> 6 ) & 0b11; // tempCB == 0b10 == 2
byte tempCB = ( confBits >> 4 ) & 0b11; // tempCB == 0b00 == 0
byte tempCB = ( confBits >> 2 ) & 0b11; // tempCB == 0b01 == 1
byte tempCB = confBits & 0b11; // tempCB == 0b11 == 3

It's loop-friendly too.