Which SLRT Functions Replace xPC Functions?

조회 수: 5 (최근 30일)
Engenuity
Engenuity 2024년 8월 7일
댓글: Garmit Pant 2024년 8월 12일
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?

채택된 답변

Garmit Pant
Garmit Pant 2024년 8월 8일
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!
  댓글 수: 2
Engenuity
Engenuity 2024년 8월 12일
Thank you...
Garmit Pant
Garmit Pant 2024년 8월 12일
Glad I could be of help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by