I know in general what offsets are, but I have a question regarding offsets on the following array. Let's say I have a uint8 array:
const myArray uint8[]=
{
0xCB, 0xF8, 0xFA, 0xFB, 0xCA, 0xAC, 0x24, 0x53, 0x64, 0x4F, 0x1E, 0xA2,
0xF9, 0x78, 0xCA, 0x63, 0xB8, 0x7F, 0xFC, 0xFB, 0xD8, 0xFA, 0xFB, 0x8F,
0x67, 0xC1, 0xFD, 0xF8, 0xC2, 0xF8, 0xFF, 0xF9, 0xFA, 0xE4, 0xFA, 0xF9,
0xFB, 0xFE, 0xE4, 0xFA, 0xCA, 0xCF, 0x94, 0xD5, 0xD6, 0xCA, 0xA2, 0xA2,
....
....
....
....
}
Now I have description which says:
--------------------------------------------------
| Offset in myArray | meaning | size (Byte) |
--------------------------------------------------
| 0x00 | Version | 1 |
-------------------------------------------------
| 0x01 | Timestamp | 15 |
------------------------------------------------
| 0x10 | Info1 | 8 |
------------------------------------------------
| 0x18 | Info2 | 2 |
------------------------------------------------
Does this in myArray mean:
For offset 0x00: It's the element with index 0 of myArray, so 0xCB
For offset 0x01: It's the element with index 1..9,so 0xF8, 0xFA, 0xFB, 0xCA, 0xAC, 0x24, 0x53, 0x64, 0x4F
etc.
Or do I interpret it wrong?
Your elements have a given size, as described by your size column. So basically what this tells you is:
Version starts at offset 0x00 (aka, position 0) and has a size of 1, so its the first element: 0xCB
Timestamp starts at offset 0x01 (aka, position 1) and has a size of 15, so its the combined elements: [0xF8, 0xFA, 0xFB, 0xCA, 0xAC, 0x24, 0x53, 0x64, 0x4F, 0x1E, 0xA2, 0xF9, 0x78, 0xCA, 0x63]
Info1 starts at offset 0x10 (aka, position 16) and has a size of 8, so its the combined elements: [0xB8, 0x7F, 0xFC, 0xFB, 0xD8, 0xFA, 0xFB, 0x8F]
Info2 starts at offset 0x18 (aka, position 24) and has a size of 2, so its the combined elements: [0x67, 0xC1]
And so it goes...
One thing that you seem to be getting wrong in your analysis, as others have pointed out is that the offsets are in base 16 (hexadecimal). So 0x10 is 1 * 16 + 0 = 16.
How to interpret each byte sequence as a proper type is up to you.
Does this make sense?