Main Content

rtiostreamtest

Test custom rtiostream interface implementation

Description

rtiostreamtest(connection, parameterOne, parameterTwo, verbosityFlag) runs a test suite to verify your custom rtiostream interface implementation.

rtiostreamtest('tcp', host, port), via TCP/IP communication, connects MATLAB® to the target hardware using the specified host and port.

rtiostreamtest('serial', port, baud), via serial communication, connects MATLAB to the target hardware using the specified port and baud value.

During initialization, the function uses basic rtiostream I/O. The function determines:

  • Byte ordering of data on the target hardware.

  • Granularity of memory address.

  • Size of data types.

  • Whether rtIOStreamRecv blocks, that is, when there is no data whether rtIOStreamRecv waits for data or returns immediately with size received == 0.

  • The size (BUFFER_SIZE) of its internal buffer for receiving or transmitting data through rtiostream. The default is 128 bytes.

In Test 1 (fixed size data exchange), the function:

  • Checks data can be sent and received correctly in different chunk sizes. The chunk sizes for your development computer and target hardware are symmetric.

  • Sends data as a known sequence that it can validate.

  • Performs “host-to-target” tests. Your development computer sends data and your target hardware receives data in successive chunks of 1, 4, and 128 bytes.

  • Performs “target-to-host” tests. Your target hardware sends data and your development computer receives data in successive chunks of 1, 4, and 128 bytes.

In Test 2 (varying size data exchange), the function:

  • Checks that data can be sent and received correctly in different chunk sizes. The chunk sizes for your development computer and target hardware are asymmetric.

  • Sends data as a known sequence that it can validate.

  • Performs “host-to-target” tests:

    • Your development computer sends data in chunks of 128 bytes and your target hardware receives data in chunks of 64 bytes.

    • Your development computer sends data in chunks of 64 bytes and your target hardware receives data in chunks of 128 bytes.

  • Performs “target-to-host” tests:

    • Your target hardware sends data in chunks of 64 bytes and your development computer receives data in chunks of 128 bytes.

    • Your target hardware sends data in chunks of 128 bytes and your development computer receives data in chunks of 64 bytes.

In Test 3 (receive buffer detection), the function determines the data that it can store in between calls to rtIOStreamRecv on the target hardware. The function uses an iterative process:

  1. The development computer transmits a data sequence while the target hardware sleeps. rtIOStreamRecv is not called while the target hardware sleeps.

  2. When the target hardware wakes up, it calls rtIOStreamRecv to receive data from the internal buffer of the driver.

  3. The function determines whether the internal buffer overflowed by checking for errors and checking the received data values.

  4. If there are no overflow errors and the transmitted data is received correctly, the function starts another iteration, performing step 1 with a larger data sequence.

The function reports the size of the last known good buffer.

Examples

Verify Behavior of Custom rtiostream Interface Implementation

The test suite consists of two parts. One part of the test suite is an application that runs on the target hardware. The other part runs in MATLAB.

  1. To create the target application, compile and link these files:

    rtiostreamtest.c, rtiostreamtest.h, and main.c are located in matlabroot/toolbox/coder/rtiostream/src/rtiostreamtest.

  2. Download and run the application on your target hardware.

  3. To run the MATLAB part of the test suite, invoke the rtiostreamtest function. For example:

    rtiostreamtest('tcp','myProcessor','2345')

    The function produces an output like this:

    ### Test suite for rtiostream ###
    Initializing connection with target...
    
    ### Hardware characteristics discovered
    Size of char    : 8 bit
    Size of short   : 16 bit
    Size of int     : 32 bit
    Size of long    : 32 bit
    Size of float   : 32 bit
    Size of double  : 64 bit
    Size of pointer : 64 bit
    Byte ordering   : Little Endian
    
    ### rtiostream characteristics discovered
    Round trip time : 0.25098 ms
    rtIOStreamRecv behavior : non-blocking
    
    ### Test results
    Test 1 (fixed size data exchange): ......... PASS
    Test 2 (varying size data exchange): ......... PASS
    
    ### Test suite for rtiostream finished successfully ###
    

    The function also generates the average bandwidth profile.

Input Arguments

collapse all

Specify transport protocol for communication channel:

  • 'tcp' –– TCP/IP

  • 'serial' –– RS-232 serial

If connection is 'tcp', specify name of target processor. For example, if your development computer is the target processor, you can specify 'localhost'.

If connection is 'serial', specify serial port ID, for example, 'COM1' for COM1, ‘'COM2' for COM2, and so on.

If connection is 'tcp', specify port number of TCP/IP server, an integer value between 256 and 65535.

If connection is 'serial', specify baud value, for example, 9600.

If you specify 'verbose', the function displays messages that contain progress information. You can use the messages to debug runtime failures.

Introduced in R2013a