I've found myself recently fiddling with Modbus over IP in which data is stored and transferred in 16bit registers. To encode data types bigger than 16 bits (such as 32-bit floats, for example) the usual way is to split the 32bit value in two consecutive 16bit registers (a pair). Some implementors of the standard chose to put the most significant 16 bits in the first address of the pair, while some others chose to put them in the second. These two approaches are sometimes referred as Big Endian and Little Endian respectively.
At first I was a bit mislead by this wording, because CS textbooks usually state that endianess has to do with Byte Order. This is also reflected in the way some library functions treat endianess: for instance the struct.unpack library of Python unpacks little-endian and big-endian values by swapping the byte order.
However for this particular application (i.e. Modbus) endianess is indeed referring to the order of the consecutive 16bit registers (aka word order).
So what is the correct definition of endianess? Does it apply strictly to byte order or to any other size of the chunks into which values are split?
Thanks, Bye, Marco
The packing of non-16 bit integer data was never defined by the original standard, and so you will find that different manufacturers have implemented packing in different ways, including how 4-byte floating point numbers are packed, and including what floating point format (IEEE-754 or other) is used. If you are attempting to code a general purpose solution you are going to have to provide user settable, or model number, options. If you are just doing a one-off solution, you have found it.