This may be a bit of a weird question, however I have made a program which communicates with another program (the other program was not made by me). I need to send 'distances' to the other program, however I am having trouble understanding how the program is interpreting these distances.
I have intercepted a device which successfully sends distances to the program. Below is an example of a distance being sent. I think the program reads in a distance as a ushort. Hopefully there'll be simple thing I am missing as I cannot seem to be able to convert my distances to the same format.
For example: Distance to be sent is 74. The bytes sent are [0, 74]. This as a ushort is 18944.
My initial thinking was the distance is converted ushort. Then the bytes of the ushort is sent to the program. However this doesn't seem to be the case.
It's Endianness that is the cause of the error:
74 (int16) == [0, 74]
- first high, then low bytes74 (int16) == [74, 0]
- first low, then high bytesAnd that's why the reciever gets
Try checking Little/Big Endian (i.e. order of the bytes):