Assembly: Quanser.Communications (in Quanser.Communications.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Sub SetByteOrder ( _ byteOrder As Stream..::.ByteOrder _ ) |
C# |
---|
public void SetByteOrder( Stream..::.ByteOrder byteOrder ) |
Visual C++ |
---|
public: void SetByteOrder( Stream..::.ByteOrder byteOrder ) |
JavaScript |
---|
function setByteOrder(byteOrder); |
Parameters
- byteOrder
- Type: Quanser.Communications..::.Stream..::.ByteOrder
The byte order to use when sending and receiving data over the stream.
Remarks
This method may be used to cause the bytes within shorts, integers, doubles and other data types to be swapped by the Stream object to account for endian differences between the two endpoints of the connection. The Stream object does not detect the endianness of the peer.
Calling this method with the byteOrder argument set to ByteOrder.LittleEndian causes the bytes to be swapped if the underlying platform is big endian. If the underlying platform is little endian then the bytes are not swapped.
Calling this method with the byteOrder argument set to ByteOrder.BigEndian causes the bytes to be swapped if the underlying platform is little endian. If the underlying platform is big endian then the bytes are not swapped.
Calling this method with the byteOrder argument set to ByteOrder.NativeEndian indicates that the bytes should not be swapped and the byte order of the underlying platform will be used. This byte order is the default.
Byte swapping is only necessary when communicating between processors that use a different endianness. For example, Intel processors are little endian (LSB first) while Motorola processors tend to be big endian (MSB first). By default, no byte swapping takes place (NativeEndian byte order).
Note that the SetSwapBytes(Boolean) and SetByteOrder(Stream..::.ByteOrder) methods override each other, so byte swapping will be determined by the last method called.
Examples
C# | Copy Code |
---|---|
stream.SetByteOrder(Stream.ByteOrder.LittleEndian); |
Visual Basic | Copy Code |
---|---|
stream.SetByteOrder(Stream.ByteOrder.LittleEndian) |
Visual C++ | Copy Code |
---|---|
stream->SetByteOrder(Stream::ByteOrder::LittleEndian); |
Exceptions
Exception | Condition |
---|---|
Quanser.Communications..::.StreamException | If the byte order cannot be configured then an exception is thrown. This situation should never occur unless the underlying stream has been closed. |