Stačí si přečíst MSDN, resp komentář k BitConverteru: As it seems that BitConverter can't be set to work for working with big-endian devices (as is common in embedded systems), I wrote my own simple class to make it.
http://snipplr.com/view/15179/adapt-syst...
The System.BitConverter class allows you to convert between bytes (in an array) and numerical types (int, uint, etc). However, it doesn't seem to let you set the endianness (which byte is most significant, e.g. in an int/Int32, there are four bytes, so which way do you read them?). It seems to operate such that the methods always return values appropriate to little endian (host order) systems (most significant byte is on the right). Since, in embedded systems, it is often necessary to interact with big-endian systems, I created this class to provide the functionality for either endianness. You simply set the endianness in the class, then all methods will return endian-aware values.
|