Table of Contents
quanser.communications.stream.receive_singles
Receives an array of 32-bit floating-point numbers from a stream.
[data, would_block] = stream.receive_singles(num_singles)
This function receives data over a client stream. It attempts to receive num_singles 32-bit real numbers from the communication channel.
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 array of 32-bit real numbers 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 array of 32-bit real numbers received.
The BSD socket API has no equivalent function.
This operation is not valid on listening streams created using quanser.communications.stream.listen.
stream
Stream handle returned by quanser.communications.stream.connect or accept.
num_singles
The number of singles to receive.
data
An array of single's containing the 32-bit real numbers received. 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. The array may have fewer than num_singles elements if the stream is non-blocking or the connection was closed and these were the remaining 32-bit real numbers.
would_block
Whether the function would have blocked. Always false for blocking streams.
data = stream.receive_singles(1000); % Receive 1000 32-bit real numbers
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.