I am very much a newbie to binary interpretation and want to make sure I understand the data I am looking at. In particular I am looking at 2 bytes in little-endian:
This is a timestamp and it shows me the following value in the object tree:
In the converter it shows:
The "correct" value for me is the unassigned i32le value of 1599082994 which corresponds to a utc timestamp of Wednesday, September 2, 2020 9:43:14 PM.
I guess I have two main questions:
How do I tell Kaitai Struct to parse the bytes as i32le so in the object tree it shows 1599082994 opposed to the i16le value of 4594?
How can you convert the bytes f2 11 into a 32 bit unassigned value. When I try to run the following basic c# program it I cannot covert those bytes into a 32 bit unassigned value but does successfully convert them into a 16 bit unassigned value.
Or I guess secret question 3 and am I looking at this all wrong?
static void Main(string[] args)
{
var hexString = "f211";
var bytes = StringToByteArray(hexString);
var val1 = BitConverter.ToUInt16(bytes);//works
var val2 = BitConverter.ToUInt32(bytes);//error
}
public static byte[] StringToByteArray(String hex)
{
int NumberChars = hex.Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
return bytes;
}
Nevermind the question, we were getting bad documentation that was causing some confusion.