Table of Contents
quanser.communications.stream Class
The quanser.communications.stream class provides methods to communicate betweeen local and remote systems or devices. It provides a uniform interface for communications such as TCP/IP, UDP, shared memory, serial, SPI, I2C, etc. A communication channel is represented by a "stream", which can be a server, or listening stream, that accepts connections from clients, or a client that connects to a server or device.
To create a listening stream to act as a server, use the static quanser.communications.stream.listen method. The listen function returns an instance of the stream class whose accept method may then be used to accept a connection from a client. When the stream is no longer needed it should be closed using the close method.
To create a stream to act as a client, use the static quanser.communications.stream.connect method. The connect function returns an instance of the stream class whose methods may then be used to send and receive data from the server. When the stream is no longer needed it should be closed using the close method.
The methods of the stream class may be grouped into the following categories:
To build and run scripts involving communications in real-time on Quanser targets, refer to the Basic Procedures for Scripts.
Static Functions
The quanser.communications.stream class has the following static functions:
Creates a stream acting as a client that connects to a server. |
|
Creates a listening stream to act as a server which can receive client connections. |
|
Closes all open streams. |
Configuration Functions
Once the board is open, the configuration functions are used to configure features of the stream, such as getting or setting the byte order or character format.
The following methods of the stream instance may be used to configure the stream:
Gets the character format of the stream. |
|
Sets the character format of the stream. |
|
Sets the byte order used by the stream for multibyte data types. |
State Functions
Once the board is open, the state functions are used to accept a client connection over a listening stream or poll the state of the stream.
The following methods of the stream instance may be used to query the state of the stream:
Accepts a client connection over a listening stream. |
|
Polls the state of the stream. |
Send Functions
The send functions send data over the communication channel. For multi-byte data types, the byte order configured for the stream determines the order in which the bytes of the data type are sent.
Note that the send functions store the data in the stream send buffer and the data is only sent over the communication channel when the buffer is full or the flush method is called.
The send functions are as follows:
Flushes the contents of the stream send buffer to the underlying communication channel. |
|
Sends a 64-bit floating-point number over the stream. |
|
Sends an array of 64-bit floating-point numbers over the stream. |
|
Sends an array of 64-bit floating-point numbers as an atomic unit over the stream. |
|
Sends a 32-bit floating-point number over the stream. |
|
Sends an array of 32-bit floating-point numbers over the stream. |
|
Sends an array of 32-bit floating-point numbers as an atomic unit over the stream. |
|
Sends an 8-bit integer over the stream. |
|
Sends an array of 8-bit integers over the stream. |
|
Sends an array of 8-bit integers as an atomic unit over the stream. |
|
Sends an 8-bit unsigned integer over the stream. |
|
Sends an array of 8-bit unsigned integers over the stream. |
|
Sends an array of 8-bit unsigned integers as an atomic unit over the stream. |
|
Sends a 16-bit integer over the stream. |
|
Sends an array of 16-bit integers over the stream. |
|
Sends an array of 16-bit integers as an atomic unit over the stream. |
|
Sends a 16-bit unsigned integer over the stream. |
|
Sends an array of 16-bit unsigned integers over the stream. |
|
Sends an array of 16-bit unsigned integers as an atomic unit over the stream. |
|
Sends a 32-bit integer over the stream. |
|
Sends an array of 32-bit integers over the stream. |
|
Sends an array of 32-bit integers as an atomic unit over the stream. |
|
Sends a 32-bit unsigned integer over the stream. |
|
Sends an array of 32-bit unsigned integers over the stream. |
|
Sends an array of 32-bit unsigned integers as an atomic unit over the stream. |
|
Sends a 64-bit integer over the stream. |
|
Sends an array of 64-bit integers over the stream. |
|
Sends an array of 64-bit integers as an atomic unit over the stream. |
|
Sends a 64-bit unsigned integer over the stream. |
|
Sends an array of 64-bit unsigned integers over the stream. |
|
Sends an array of 64-bit unsigned integers as an atomic unit over the stream. |
|
Prints formatted text to a stream. |
|
Prints formatted text to a stream as an atomic unit. |
Receive Functions
The receive functions receive data over the communication channel. For multi-byte data types, the byte order configured for the stream determines the order in which the bytes of the data type are received.
The receive functions are as follows:
Receives bytes over the stream and ignores them. |
|
Receives a 64-bit floating-point number over the stream. |
|
Receives an array of 64-bit floating-point numbers over the stream. |
|
Receives an array of 64-bit floating-point numbers as an atomic unit over the stream. |
|
Receives a 32-bit floating-point number over the stream. |
|
Receives an array of 32-bit floating-point numbers over the stream. |
|
Receives an array of 32-bit floating-point numbers as an atomic unit over the stream. |
|
Receives an 8-bit integer over the stream. |
|
Receives an array of 8-bit integers over the stream. |
|
Receives an array of 8-bit integers as an atomic unit over the stream. |
|
Receives an 8-bit unsigned integer over the stream. |
|
Receives an array of 8-bit unsigned integers over the stream. |
|
Receives an array of 8-bit unsigned integers as an atomic unit over the stream. |
|
Receives a 16-bit integer over the stream. |
|
Receives an array of 16-bit integers over the stream. |
|
Receives an array of 16-bit integers as an atomic unit over the stream. |
|
Receives a 16-bit unsigned integer over the stream. |
|
Receives an array of 16-bit unsigned integers over the stream. |
|
Receives an array of 16-bit unsigned integers as an atomic unit over the stream. |
|
Receives a 32-bit integer over the stream. |
|
Receives an array of 32-bit integers over the stream. |
|
Receives an array of 32-bit integers as an atomic unit over the stream. |
|
Receives a 32-bit unsigned integer over the stream. |
|
Receives an array of 32-bit unsigned integers over the stream. |
|
Receives an array of 32-bit unsigned integers as an atomic unit over the stream. |
|
Receives a 64-bit integer over the stream. |
|
Receives an array of 64-bit integers over the stream. |
|
Receives an array of 64-bit integers as an atomic unit over the stream. |
|
Receives a 64-bit unsigned integer over the stream. |
|
Receives an array of 64-bit unsigned integers over the stream. |
|
Receives an array of 64-bit unsigned integers as an atomic unit over the stream. |
|
Scans formatted text from a stream. |
|
Scans formatted text from a stream as an atomic unit. |
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.