rtiostreamtest - Test custom rtiostream interface implementation - MATLAB (original) (raw)
Test custom rtiostream
interface implementation
Syntax
Description
rtiostreamtest([connection](#mw%5F51bb2875-4a6a-421e-928f-7fb50877e94c), [parameterOne](#mw%5Fdfc2505b-f321-45cd-b28b-5351b97d4dce), [parameterTwo](#mw%5Fba6c2a87-3ea2-46f0-ad29-abe1f02fd64b), [verbosityFlag](#mw%5F99355747-d108-4793-8f60-ed7e0955dac7))
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
andport
.
rtiostreamtest('serial', port, baud)
, via serial communication, connects MATLAB to the target hardware using the specified port
andbaud
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 whetherrtIOStreamRecv
waits for data or returns immediately with size received==
0. - The size (
BUFFER_SIZE
) of its internal buffer for receiving or transmitting data throughrtiostream
. 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:
- The development computer transmits a data sequence while the target hardware sleeps.
rtIOStreamRecv
is not called while the target hardware sleeps. - When the target hardware wakes up, it calls
rtIOStreamRecv
to receive data from the internal buffer of the driver. - The function determines whether the internal buffer overflowed by checking for errors and checking the received data values.
- 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.
- To create the target application, compile and link these files:
[rtiostreamtest.c](https://mdsite.deno.dev/matlab:edit%28fullfile%28matlabroot,'/toolbox/coder/rtiostream/src/rtiostreamtest/rtiostreamtest.c'%29%29)
[rtiostreamtest.h](https://mdsite.deno.dev/matlab:edit%28fullfile%28matlabroot,'/toolbox/coder/rtiostream/src/rtiostreamtest/rtiostreamtest.h'%29%29)
[rtiostream.h](https://mdsite.deno.dev/matlab:edit%28fullfile%28matlabroot,'/toolbox/coder/rtiostream/src/rtiostream.h'%29%29)
- The
rtiostream
implementation under investigation, for example,[rtiostream_tcpip.c](https://mdsite.deno.dev/matlab:edit%28fullfile%28matlabroot,'/toolbox/coder/rtiostream/src/rtiostreamtcpip/rtiostream%5Ftcpip.c'%29%29)
. [main.c](https://mdsite.deno.dev/matlab:edit%28fullfile%28matlabroot,'/toolbox/coder/rtiostream/src/rtiostreamtest/main.c'%29%29)
rtiostreamtest.c
,rtiostreamtest.h
, andmain.c
are located in matlabroot/toolbox/coder/rtiostream/src/rtiostreamtest.
- Download and run the application on your target hardware.
- 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
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.
Version History
Introduced in R2013a