XPC Target Embedded Filescope Dynamic File Naming
2 次查看(过去 30 天)
显示 更早的评论
I’m having trouble with the dynamic file naming of Filescope Blocks in xPC Embedded Option. I would like the file name of a scope to increment each time the software boots so I can record data from multiple test runs.
I have added '_<%%%>' to the file name (now ‘ins_<%%%>’) and checked ‘auto restart’ and ‘dynamic file naming’ (not that I want to limit the size of each file with ‘auto restart’ but it is the only way to get the ‘dynamic file naming’ box to appear). If I boot the software 3 times I get one file named ins_001.dat with the correct data in it, one file named ins_002.dat that is empty and only 1KB in size, file ins_003.dat is missing.
I have also tried running the software without either 'auto restart' or 'dynamic file namining' checked but that doesn't work.
Any ideas?
1 个评论
Chris Jones
2012-8-16
Unfortunately, I do not have a solution, only emphasis on the issue set forth by James above.
I am having a similar problem, only in my 2009a version, the initial file D_<%%%>.dat isn't even showing up. When I eliminate the '<%%%>', the first file saves with no problem. I do not have a 'dynamic file naming' option in 2009a, but I do not receive an error, the program builds, loads and executes.
Thoughts?
采纳的回答
Kent Schonert
2012-11-29
The dynamic file naming enables additional files to be created when the max file size is reached for a given file. Autorestart is not for logging across power cycles.
Each time the xPC (FreeDOS) starts the application file, new (mostly empty) data files for the scopes are created, replacing the ones from the previous power cycle.
What I did: To address the issue of preserving data between reboots, I modified the autoexec.bat file to backup my data files from the previous power cycle, before it loads the stand alone application. Due to FreeDOS command set limitations, I compiled an .exe that renames the files to include the current day & time. The autoexec calls my .exe to rename the files and then moves it to a data folder. I used the OpenWatcom compiler/IDE to make a compatible 32-bit DOS executable.
Keep in mind that the filenames are limited to 8 characters, not including the extension.
3 个评论
Kent Schonert
2012-12-6
James,
I was logging several file at once as well. My code is below. It is called several times from the autoexec.bat (you can also call from runxpc.bat).
in autoexe.bat I did:
dir > dir1.txt
moved.exe curr.dat c_ .dat
moved.exe inp.dat i_ .dat
moved.exe out.dat o_ .dat
moved.exe batt.dat b_ .dat
dir > dir2.txt
move /Y c_*.dat c:\data
move /Y i_*.dat c:\data
move /Y o_*.dat c:\data
move /Y b_*.dat c:\data
dir data > dir3.txt
The dir commands were put in troubleshooting, and stayed there because the pauses stopped weird behavior.
My c program compiled in OpenWatcom:
//usage: moved.exe orignal_filename.ext new_filename new_filename_extension
//example: moved.exe curr_.dat c_ .dat
// will rename curr_.dat to c_241040.dat on 24th at 10:40 PM
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <ctime>
#include <stdlib.h>
#include <sstream>
#include <string>
using namespace std;
static unsigned get_file_size (const char * file_name)
{
struct stat sb;
if (stat (file_name, & sb) != 0) {
return 0;
}
return sb.st_size;
}
int main(int argc, char* argv[]){
char origFName[12];
char fPrefix[8],extension[8], temp[8];
char newFname[16];
strcpy(origFName,argv[1]);
strcpy(fPrefix,argv[2]);
strcpy(extension,argv[3]);
//bail if this file is basically empty (or if it doesn't exist)
if( get_file_size(origFName) < 1000)
return 0;
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
//rename file name to current "x_MMDDmm.dat"
strcpy(newFname, fPrefix);
strcat(newFname, itoa(now->tm_mday,temp,10));
strcat(newFname, itoa(now->tm_hour,temp,10));
strcat(newFname, itoa(now->tm_min,temp,10));
strcat(newFname, extension);
cout<<"renaming to "<<newFname<<endl;
rename ( origFName, newFname);
return 0;
}
(BTW, OpenWatcom doesn't fully support STL.)
Sorry for not getting back to you sooner. I need to see if I can have the site email me when I get a reply.
Cheers,
-Kent
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Target Computer Setup 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!