Main Content

Import File Log Data Manually from Speedgoat Target Computer

This example shows how to import file logs manually from a Speedgoat™ target computer by using MATLAB® functions or system commands. These approaches demonstrate importing the logs without using the import(tg.FileLog) function or Simulink® Real-Time™ Explorer UI in MATLAB. After you import the file logs to the development computer, import the logs into the Simulation Data Inspector to view the data in MATLAB.

File Log Data Storage on Target Computer

In the file system on the target computer, Simulink Real-Time stores log files that are generated by File Log blocks in folders for each real-time application. For example, log files for the slrt_ex_osc application are within:

/home/slrt/applications/slrt_ex_osc/logdata

Each run has a folder, for example:

/home/slrt/applications/slrt_ex_osc/logdata/run_1
/home/slrt/applications/slrt_ex_osc/logdata/run_2

Each run folder contains a DAT file and a TIMESTAMP file, for example:

/home/slrt/applications/slrt_ex_osc/logdata/run_1/tid001.dat
/home/slrt/applications/slrt_ex_osc/logdata/run_1/2023-06-13_16-10-53.timestamp

Note that by default file logs are automatically imported by the development computer and (if auto import is disabled) by default only one file log run is retained on target computer. You can change these setting by changing the default setting for the AutoImportFileLog and FileLogMaxRuns options of the start(tg) function.

Import File Log Data from Target Computer

By using a third-party file transfer tool (for example, PuTTY or FileZilla), log into the target computer. The default username and password are slrt for login to the FTP server on the target computer.

You can either import the entire applications folder or import the real-time application slrt_ex_osc subfolder, for example:

/home/slrt/applications/
/home/slrt/applications/slrt_ex_osc/

Note that just importing the logdata folder or run_x folders is not sufficient.

After importing the data, you can delete single runs or the entire logdata folder from the target computer file system using FTP.

Import by Using PuTTY PSCP

This example shows how to copy the content of the applications folder from a 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 by using the PuTTY pscp utility:

"C:\Program Files\PuTTY\pscp.exe" -v -P 22 -pw slrt -r slrt@192.168.7.5:applications C:\work\my_logdata\

Import by Using MATLAB FTP

This example shows how to copy the content of the applications folder from a target computer with IP address 192.168.7.5 at port 22 to the local directory C:\work\my_logdata\ in MATLAB by using an FTP object:

1. Create MATLAB FTP object. In R2021a and earlier, use ftp instead of sftp. In the Command Window, type:

ftpobj = sftp('192.168.7.5','slrt',"Password",'slrt');
cd(ftpobj,'/home/slrt');

2. Inspect the available apps inside the applications folder. In the Command Window, type:

dir(ftpobj,'applications')

3. To import the file logs for a single model (for example, slrt_ex_osc), in the Command Window, type:

mget(ftpobj,'./applications/slrt_ex_osc/');

4. To import the file logs for all apps, in the Command Window, type:

mget(ftpobj,'./applications/');
close(ftpobj)

Import, Visualize, and Save File Log Data in MATLAB

To read the file log data, open MATLAB and use these functions:

These steps use MATLAB and Simulink Real-Time. It is not possible to read the raw DAT files outside of MATLAB. The only way to import these files is by using the Simulation Data Inspector.

This code example shows how to import, view, and export the local file log data to a MAT file. This code assumes that the applications folder was imported from the target computer into the development computer C:\work\my_logdata\ folder.

1. Change current directory to local location of the applications folder.

cd('C:\work\my_logdata\applications');

2. View a full list of available file log runs.

mylist = slrealtime.fileLogList

3. Import file logs for real-time application slrt_ex_osc.

slrealtime.fileLogImport('slrt_ex_osc');

4. Open the Simulation Data Inspector to view data (optional).

Simulink.sdi.view

5. Access the most recently created run in the Simulation Data Inspector.

runIDs = Simulink.sdi.getAllRunIDs;
runID = runIDs(end);

6. Export from the Simulation Data Inspector to workspace.

simDataset = Simulink.sdi.exportRun(runID);

7. Export from the Simulation Data Inspector to MAT file.

Simulink.sdi.exportRun(runID,'to','file','filename','filelog.mat');

In R2022a and later releases, the slrealtime.fileLogImport function does not support importing file logs from log data obtained in different versions of MATLAB. If you have log data from older versions of MATLAB to import, use these steps:

  • Load log data into the MATLAB release in which it was created.

  • Export data to a MAT file.

  • Load the MAT file into the current MATLAB release.