I'm working with a G30 using Netmf SDK 4.3.
My desktop team used a MemoryStream and BinaryWriter to serialize some data. So I thought I'd use a memory stream and Binary Reader to deserialize it on the G30. I'm having an issue and I think it has to do with endian configurations and perhaps the specifics of the netmf binary reader implementation.
Lets say my serialized data looks like this:
first byte : 0x01
second byte: 0x00
And I know that this data is meant to represent a decimal 1. This makes sense to me because the binary write uses little endian encoding to write a UInt16 so the LSB is before the MSB. The bytes themselves seem to be big endian.
On my G30 I get these two bytes into an array called rawData. Then I run this function:
public static void deserialize()
using (var stream = new MemoryStream(rawData))
using (var reader = new BinaryReader(stream))
Uint16 deserializedValue = reader.ReadUInt16();
The problem I'm facing is that after this executes I will have deserializedValue = 256 decimal. Which would make sense if the data were taken as MSB first: 0x0100 is indeed 256 in big endian notation.
Am I mixing up my endians? Shouldn't it just work if both the writer and reader use the same endian encoding?
Does the G30 just treat it this way? Causing me to have to flip the bytes around on the desktop (keeping the G30 code smaller would be better)