stream_set_character_format stream_shutdown navigation bar

Table of Contents

stream_set_swap_bytes

Enables or disables swapping of bytes within data types.

Syntax

stream_set_swap_bytes(stream, swap)
stream_set_swap_bytes(stream)           % Turn on byte swapping.
    

Description

Determines whether the functions that send and receive int16's, int32's, int64's, floats or doubles, or arrays of them, swap the bytes in the individual values. 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. Whether byte swapping is necessary may be determined simply by sending 0x1234 as an int16 and seeing if it arrives as the same number or as 0x3421.

This operation is not valid on listening streams created using stream_listen.

Parameters

stream

Stream handle returned by stream_connect or stream_accept.

swap

Set to true to swap bytes. Set to false to leave byte order as is. If this argument is not specified it defaults to true.

Outputs

This function has no outputs.

Examples

stream_set_swap_bytes(stream, true);    % Turn on byte swapping
    

See Also

 

navigation bar