Azzera filtri
Azzera filtri

How can I download file log data manually from my Speedgoat target?

95 visualizzazioni (ultimi 30 giorni)
Is there a way to download file logs manually from my Speedgoat target, either with or without MATLAB?
I am looking for a way to transfer, import, and delete the files using basic protocols like FTP or SCP.

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 10 Lug 2024 alle 0:00
Modificato: MathWorks Support Team il 10 Lug 2024 alle 20:24
The recommended way to download and import file logs is by using automatic import, or one of the following interactive methods:
Starting in R2021a, there is a supported workflow to copy file log data from the Speedgoat target computer to a host computer without MATLAB. However, note that eventually, you will need to launch MATLAB to import the data in Simulation Data Inspector (SDI) as you cannot view the raw data anywhere else.

1. Prepare your model for manual file log import

Make sure that you disabled the automatic file log import feature, and that you configured the number of file log runs stored for your real-time application so that it fits your needs:

2. How the file log data is stored on the target computer

After a run stops, log files generated by File Log blocks are stored under the following directory on the target computer file system:
/home/slrt/applications/MODELNAME/logdata
Each run is stored in a separate folder under this directory:
/home/slrt/applications/MODELNAME/logdata/run_1
/home/slrt/applications/MODELNAME/logdata/run_2
<...>
Where every run folder contains two files, one .dat file and one .timestamp file.

3. Download file log data from target computer

Using a third-party file transfer tool of your choice (e.g. PuTTY pscp, FileZilla), log into the Speedgoat target computer. Please note the default is "slrt" for both username and password when logging into the FTP server on the target computer.
You can either download the entire 'applications' folder, or the 'MODELNAME' subfolder for your specific real-time application:
/home/slrt/applications/
/home/slrt/applications/MODELNAME/
Note that downloading just the 'logdata' or 'run_x' folders is not sufficient.
  • PuTTY PSCP example:
Below is an example of how to copy the content of the 'applications' folder from a Speedgoat target computer with IP address 192.168.7.5 at port 22 to the local directory "C:\work\my_logdata\" from the Windows Command Prompt using PuTTY pscp:
"C:\Program Files\PuTTY\pscp.exe" -v -P 22 -pw slrt -r slrt@192.168.7.5:applications C:\work\my_logdata\
  • MATLAB FTP example:
You can also use the FTP functions shipped with basic MATLAB. Below is a code example:
% Create new folder for import - avoid reusing the same local folder
timestamp = char(datetime('now','Format','yyyy-MM-dd_HH-mm-ss'));
mkdir(timestamp);
cd(timestamp);
% Create MATLAB FTP object - use 'ftp' instead of 'sftp' in R2021a and earlier
ftpobj = sftp('192.168.7.5','slrt',"Password",'slrt');
cd(ftpobj,'/home/slrt');
% To inspect the available models inside the 'applications' folder:
% dir(ftpobj,'applications')
% To download the file logs for a single model:
mget(ftpobj,'./applications/MODELNAME/');
% To download the file logs for all models:
mget(ftpobj,'./applications/');
close(ftpobj)

4. Delete runs from the target (optional)

After downloading the data, you can delete single 'run_x' folders or the entire 'logdata' folder from the target computer. The recommended method is using the tg.FileLog.discard function. If MATLAB & Simulink Real-Time is unavailable, you can use FTP tools like FileZilla, PuTTY PSCP, or SSH, ensuring the real-time application is stopped. For example code on deleting a folder using basic file operations, see the following MATLAB Answer:

5. Import, visualize & save file log data in MATLAB

To read the file log data, open MATLAB and use the following two functions:
Importing the file logs into MATLAB will require licenses for MATLAB and Simulink Real-Time. There is no way to read the raw .dat files outside of MATLAB. The only way to import them is going through SDI.
Here is a MATLAB code example to import, view and export the local file log data to a MAT file. It assumes that the 'applications' folder was downloaded from the target into the 'C:\work\my_logdata\' directory on your host computer:
% Change current directory to local location of the 'applications' folder
cd('C:\work\my_logdata\applications');
% See full list of available file log runs
mylist = slrealtime.fileLogList
% Import file logs for model 'MODELNAME'
slrealtime.fileLogImport('MODELNAME');
% Open Simulation Data Inspector to view data (optional)
Simulink.sdi.view
% Access the most recently created run in SDI
runIDs = Simulink.sdi.getAllRunIDs;
runID = runIDs(end);
% Export from SDI to workspace
simDataset = Simulink.sdi.exportRun(runID);
% Export from SDI to MAT file
Simulink.sdi.exportRun(runID,'to','file','filename','filelog.mat');
% Delete run from SDI
Simulink.sdi.deleteRun(runID);
Note: Starting in R2022a, the "slrealtime.fileLogImport" function no longer supports importing file logs from log data obtained in different versions of MATLAB. If you have log data from older versions of MATLAB that you would like to import, please use the following workflow:
  1. Load log data into the old MATLAB version.
  2. Export data to a ".mat" file
  3. Load ".mat" file into the new MATLAB version.

 

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by