quanser.communications.stream.receive_int16_array quanser.communications.stream.receive_uint16s navigation bar

Table of Contents

quanser.communications.stream.receive_uint16

Receives a 16-bit unsigned integer from a stream.

Syntax

        [data, would_block] = stream.receive_uint16
    

Description

This function receives a single 16-bit unsigned integer over a client stream.

If quanser.communications.stream.listen or quanser.communications.stream.connect was called with the non-blocking flag set to false (0), then this function blocks until all the data is read. If the connection has been closed gracefully then it returns an empty array only once there is no more data to receive. Otherwise it returns the 16-bit integer read before the connection closed. Once all the data in the stream buffer is exhausted it will return an empty array to indicate the connection has been closed. If an error occurs, then it issues an error message.

If quanser.communications.stream.listen or quanser.communications.stream.connect was called with the non-blocking flag set to true (1), then this function does not block. If no data is available at all then it returns would_block equal to true. In this case, the poll function may be used with the 'receive' flag to determine when data becomes available. Otherwise it returns the 16-bit integer received.

This operation is not valid on listening streams created using quanser.communications.stream.listen.

Parameters

stream

Stream handle returned by quanser.communications.stream.connect or accept.

Outputs

data

The 16-bit integer received, as an uint16. For blocking streams, if this array is empty then the connection has been closed gracefully. For non-blocking streams, would_block must also be false to indicate closure.

would_block

Whether the function would have blocked. Always false for blocking streams.

Examples

        data = receive_uint16;    % Receive one 16-bit unsigned integer
    

See Also

 

navigation bar