Skip to Main Content Skip to Search
Product Documentation

rtiostream_wrapper - Test rtiostream shared library methods

Syntax

STATION_ID = rtiostream_wrapper(SHARED_LIB,'open')
STATION_ID = rtiostream_wrapper(SHARED_LIB,'open',p1, v1, p2, v2, ...)
[RES,SIZE_SENT] = rtiostream_wrapper(SHARED_LIB,'send',ID, DATA, SIZE)
[RES, DATA_RECVD, SIZE_RECVD] = rtiostream_wrapper(SHARED_LIB,'recv',ID, SIZE)
RES = rtiostream_wrapper(SHARED_LIB,'close',ID)
rtiostream_wrapper(SHARED_LIB, 'unloadlibrary')

Description

rtiostream_wrapper enables you to access the methods of an rtiostream shared library from MATLAB code, for testing purposes.

STATION_ID = rtiostream_wrapper(SHARED_LIB,'open') opens an rtiostream communication channel through a shared library, and returns a handle to the channel.

STATION_ID = rtiostream_wrapper(SHARED_LIB,'open',p1, v1, p2, v2, ...) opens an rtiostream communication channel through a shared library. p1, v1, ... are additional parameter value pairs used when opening an rtiostream communication channel through a shared library. These arguments are implementation dependent, that is, they are specific to the shared library being called.

[RES,SIZE_SENT] = rtiostream_wrapper(SHARED_LIB,'send',ID, DATA, SIZE) sends DATA into the communication channel with handle ID, and attempts to send SIZE bytes.

[RES, DATA_RECVD, SIZE_RECVD] = rtiostream_wrapper(SHARED_LIB,'recv',ID, SIZE) receives up to SIZE bytes of DATA from the communication channel with handle ID.

RES = rtiostream_wrapper(SHARED_LIB,'close',ID) closes the communication channel with handle ID.

rtiostream_wrapper(SHARED_LIB, 'unloadlibrary') unloads the SHARED_LIB, clearing any persistent data.

Input Arguments

SHARED_LIB

Name of shared library that implements the required rtIOStream functions rtIOStreamOpen, rtIOStreamSend, rtIOStreamRecv and rtIOStreamClose. Must be on system path.

Shared library can be:

  • libTCPIP — For TCP/IP communication. Value depends on your operating system. See rtwdemo_rtiostream.

  • 'libmwrtiostreamserial.dll' — For serial communication, Windows only.

open

Opens communication channel

send

Sends data into communication channel with handle ID

ID

Communication channel handle

DATA

Data to be sent

SIZE

Size of requested data in bytes

recv

Receives data from communication channel with handle ID

close

Closes communication channel with handle ID

unloadlibrary

Unloads SHARED_LIB

Name-Value Pair Arguments

p1, v1, ... are optional comma-separated pairs of Name,Value arguments, where Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (''). You can specify several name-value pair arguments in any order as Name1,Value1,…,NameN,ValueN

'-client'

  • 0 — Opens as TCP/IP server

  • 1 — Opens as TCP/IP client

Shared library must be libTcpip.

'-port'

Port number for TCP/IP or COM port string for serial communication. If port is for serial communication, you must also specify bit rate using -baud.

Shared library must be either libTcpip or 'libmwrtiostreamserial.dll'.

'-hostname'

Identifier for host computer, for example, 'localhost'.

Shared library must be libTcpip.

'-baud'

Bit rate for serial communication port.

Shared library must be 'libmwrtiostreamserial.dll'.

Output Arguments

STATION_ID

Handle to communication channel. If attempt is unsuccessful, value is -1.

RES

Error flag:

  • -1 — Error occurred

  • 0 — No error

SIZE_SENT

Number of bytes accepted by communication channel. May be less than SIZE, that is, the requested number of bytes to send.

DATA_RECVD

Data received

SIZE_RECVD

Number of bytes actually received from channel. May be less than SIZE, that is, the requested number of bytes to send.

Examples

The following examples open communication channels using supplied TCP/IP and serial communication drivers.

The following command opens rtiostream channel stationA as a TCP/IP server:

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

The following command opens the rtiostream channel StationB as a TCP/IP client:

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

If you use the supplied host-side driver for serial communications (as an alternative to the drivers for TCP/IP), you must specify the bit rate when you open a channel with a specific port. Specify the option '-baud' with a value for the bit rate. For example, the following command opens COM1 with a bit rate of 9600:

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

See Also

rtIOStreamClose | rtIOStreamOpen | rtIOStreamRecv | rtIOStreamSend

How To

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS