rtiostream_wrapper - Test rtiostream shared library functions in MATLAB - MATLAB (original) (raw)

Test rtiostream shared library functions in MATLAB

Syntax

Description

[streamID](#d126e42637) = rtiostream_wrapper([sharedLib](#d126e42591), 'open') opens an rtiostream communication channel or stream through a shared library.

[[errFlag](#d126e42913),[transmittedDataSize](#d126e42932)] = rtiostream_wrapper([sharedLib](#d126e42591),'send',[streamID](#d126e42637),[data](#d126e42657),[dataSize](#d126e42674))transmits data from a workspace variable through the open communication channel or stream.

[[errFlag](#d126e42913),[receivedData](#d126e42952),[receivedDataSize](#d126e42971)] = rtiostream_wrapper([sharedLib](#d126e42591),'recv',[streamID](#d126e42637),[dataSize](#d126e42674)) receives workspace variable data from the open communication channel or stream.

[streamID](#d126e42637) = rtiostream_wrapper(___,[Name,Value](#namevaluepairarguments)) specifies additional options using one or more name-value pair arguments. These arguments are implementation-dependent, that is, they are specific to the shared library that you use.

[errFlag](#d126e42913) = rtiostream_wrapper([sharedLib](#d126e42591),'close',[streamID](#d126e42637)) closes the rtiostream communication channel or stream.

rtiostream_wrapper([sharedLib](#d126e42591),'unloadlibrary') unloads the shared library, clearing persistent data.

example

Examples

Open Communication Channels

These examples use the supplied TCP/IP and serial communication drivers to open communication channels.

Open rtiostream stationA as a TCP/IP server:

stationA = rtiostream_wrapper('libmwrtiostreamtcpip.dll','open',... '-client', '0',... '-blocking', '0',... '-port', portnumber);

Opens rtiostream StationB as a TCP/IP client:

stationB = rtiostream_wrapper('libmwrtiostreamtcpip.dll','open',... '-client','1',... '-blocking', '0',... '-port', portnumber,... '-hostname','localhost');

If you use the supplied development computer driver for serial communications (as an alternative to the drivers for TCP/IP), specify the bit rate when you open a channel with a specific port. For example, open channel stationA with port COM1 and bit rate of 9600:

stationA = rtiostream_wrapper('libmwrtiostreamserial.dll','open',... '-port','COM1',... '-baud','9600');

Input Arguments

collapse all

Shared library that implements required rtIOStream functions, rtIOStreamOpen, rtIOStreamSend, rtIOStreamRecv, and rtIOStreamClose. Must be on system path. Specify one of these values:

Handle to rtiostream communication stream.

Array that contains data for transmission.

Size of workspace variable data to transmit or receive, in bytes.

Name-Value Arguments

expand all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: '-hostname','localhost'

TCP/IP Communication

expand all

Open rtiostream as TCP/IP server or client:

Port for TCP/IP communication.

Identifier for your development computer, for example,'localhost'.

Call behavior when receiving data:

Default is 0 unless the preprocessor macrodefine VXWORKS exists. In this case, the default is 1.

Waiting period of call that receives data:

Default for client connections is to wait 1 second. Default for server connections is to wait indefinitely.

Serial Communication

expand all

COM port for serial communication.

Bit rate for serial communication port.

Output Arguments

collapse all

If the function opens the communications stream, it returns a handle to the stream. Otherwise, it returns -1.

If the function runs without errors, it returns zero. Otherwise, it returns -1.

Size of data transmitted through communication stream. Can be less thandataSize, the number of bytes specified for transmission.

Array that contains received data.

Number of bytes received from communication stream. Can be less thandataSize, the number of bytes specified for transmission.

Version History

Introduced in R2008b