Clear Filters
Clear Filters

Which SLRT Functions Replace xPC Functions?

4 views (last 30 days)
I need to update legacy r2010b MATLAB code that uses xPC functions to r2024a code that uses Simulink Real-Time functions. For example, I have replaced instances of xpctargetping with slrtpingtarget (https://www.mathworks.com/help/releases/R2020a/xpc/api/slrtpingtarget.html).
Are there modern SLRT replacement functions for legacy setxpcenv and xpctarget.fs/xpctarget.ftp functions? Maybe setslrtenv and slrt('target') or slrealtime.fs/ftp? (https://www.mathworks.com/help/slrealtime/api/slrealtime.target.html)
Are these functions only available once connected to target hardware?

Accepted Answer

Garmit Pant
Garmit Pant on 8 Aug 2024
Hello Engenuity,
As of the latest release, R2024a, Simulink Real-Time (SLRT) provides alternative workflows to the legacy xPC functions.
Replacing "setxpcenv"
The "setxpcenv" function is used to set environment properties in xPC Target. In SLRT, the environment properties and parameters can be tuned using the "slrtExplorer" and the "Target" object.
To use the interactive SLRT Explorer, run the following command in the Command Window:
slrtExplorer
The SLRT Explorer provides a UI for viewing connection status and interacting with a real-time application. You can set environment settings like IP address, etc.
The following code snippet demonstrates how to initialize a "Target" object and use object functions:
tg = slrealtime('TargetPC1');
% Connect to the computer
connect(tg);
% Configure the target computer to run the selected real-time application on startup
setStartupApp(tg, 'slrt_ex_osc');
% Set the IP address and netmask on the target computer
setipaddr(tg, '192.168.7.5', '255.255.255.0');
Replacing "xpctarget.fs" and "xpctarget.ftp"
The "xpctarget.fs" function does not have a direct replacement. You cannot manage and manipulate the file system as extensively in SLRT compared to xPC. Instead, SLRT introduces File Logging. This can be achieved by using the "Enable File Log" block in the model. The import method can then be used to import file log data from the target computer.
import(tg.FileLog, 'app_name')
An FTP server connection can be established by using the ftp function. The FTP connection object can be used to upload and download files. You can also create, delete, and navigate to different folders on the server.
ftpobj = ftp("ftp.example.com")
You can further use the various object methods of the "ftp" object to access the files on the server.
For further understanding, kindly refer to the following MathWorks Documentation:
  • This MATLAB Answers post details different methods of Signal Logging using “File Log” and FTP connection for SLRT: MATLAB Answers
  • This resource details the process of configuring the Target Computer settings: Target Computer Settings
I hope you find the above explanation and suggestions useful!

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!