I have a text file that actually contains hex values stored by a program. For instance the the file.txt would contain:
4D 45 5A 4E 53 41 54
I need to convert the raw data to understand it, specifically I need to take two bytes and convert them into an integer. This is the approach I took:
First I split the text file to an array based on the spaces. Then I converted the array to a byte array.
beacon = beacon.split()
beaconBytes = [byte.encode('utf-8') for byte in beacon]
Now it looks like this:
[b'4D', b'45', b'5A', b'4E', b'53', b'41', b'54']
Since the data is transmitted in little endian, the first two bytes should translate to 0x454d = 17741.
But why does :
int.from_bytes(beaconBytes[0]+beaconBytes[1], byteorder='little', signed=False)
print 892617780? Where did this huge number come from?