Try to get data saved from a file scope with Microsoft .Net Framework functions, but just recieve zeros

1 view (last 30 days)
Hey everybody,
I've added a filescope to my target application using the functions of Microsoft .Net Framework and of cause added a filesystem object, fileinfo Object and so on, as code below shows. After the copytohost advice I get a new file with cryptic text at the root-path, but after converting the data with Matlab there are only zeros, where datavalues should be. Can anyone help me to get the real datavalues?
mem = XPCTargetPC1.FileSystem
drvinfo = mem.GetDrives
directory = mem.CreateDirectory("C:\ExpData")
mem.SetCurrentDirectory("C:\ExpData")
sysinfo = directory.GetFileSystemInfos
files = directory.GetFiles
fscope_sig = fscope.Signals
ftime_sig = fscope_sig.Add(app_time)
ftet_sig = fscope_sig.Add(app_tet)
freal_sig = fscope_sig.Add(aout_real)
If files(0).Exists Then
files(0).CopyToHost("root\Data.txt")
End If

Answers (1)

Shiva Arun Kumar
Shiva Arun Kumar on 15 Feb 2012
Hi Svenja,
The commands to read the data from a file created using the File Scope ,from within MATLAB, are:
file=xpctarget.fs;
h=file.fopen('d.txt');
data=file.fread(h);
file.fclose(h);
file = readxpcfile(data);
(In this case the data is being read directly from the target file system. Similar fopen/fread commands can also be used on files that have been copied onto the host computer)
The data can also be read from with .NET: Ex:
xPCFileScopeSignal fscsig = fscsigs["Unit Delay"];
xPCDataFileScSignalObject fscDObj = fscsig.FileScopeSignalDataObject;
double[] scData = fscDObj.GetData();
Since you are adding the scope to the application after it has been downloaded onto the target, please be sure to start the scope before starting the application.
Hope this helps, Shiva

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!