07-03-2013 09:35 AM
In my project, that is the case. Though I have four PCs that run the same application, they don't share data between them. They only all share the same target file server, on which to store the DUT log files.
Your typedef technique is new to me. I don't suppose there's a sample project I could learn from?
07-03-2013 10:36 AM
It's something along this line: define a structure that includes all data pertaining to your tests:
typedef struct { char name[16]; char sn[16]; int result; int options; } DUTData;
Then you can save data on disk this way:
int SaveDUTData (DUTData x) { FILE *fH = NULL; fH = fopen ("myFile.dat", "rb+"); if (errno) goto Error; fwrite ((char *)&x, sizeof (DUTData), 1, fH); if (errno) goto Error; Error: if (errno) { // strcpy (msg, "General I/O error in SaveDUTData."); } if (fH) fclose (fH); return errno; }
Similarly, you can retrieve data with the following:
int RestDUTData (DUTData x) { FILE *fH = NULL; fH = fopen ("myFile.dat", "rb"); if (errno) goto Error; fread ((char *)&x, sizeof (DUTData), 1, fH); if (errno) goto Error; Error: if (errno) { // strcpy (msg, "General I/O error in RestDUTData."); } if (fH) fclose (fH); return errno; }
This is just a rude code skeleton, proper error checking is missing and adaptations are needed to access networked disks. Nevertheless, it gives you the idea I was speaking about.
07-09-2013 02:48 PM
I solved my issue by editing the CVI INI library slightly.
1) I copied the "inifile.c" and "inifile.h" locally into my project.
2) I then changed the temp filename that is used in the CreateAndOpenTemporaryFile() call inside the Ini_WriteToFile function. I made this unique to each of my test stations by simply using its serial number. Becareful not to exceed the 5-character limit.
3) Then, I did some better house-keeping in my INI calls in the parent program. For instance, I wasn't dumping the INI buffer after each write to my file with a Ini_Dispose().
So far, so good. I'm not seeing any errors at all now!
07-10-2013 10:50 AM
@RobertoBozzolo wrote:
define a structure that includes all data pertaining to your tests:
typedef struct { char name[16]; char sn[16]; int result; int options; } DUTData;Then you can save data on disk this way:
int SaveDUTData (DUTData x) { FILE *fH = NULL; fH = fopen ("myFile.dat", "rb+"); if (errno) goto Error; fwrite ((char *)&x, sizeof (DUTData), 1, fH); if (errno) goto Error; Error: if (errno) { // strcpy (msg, "General I/O error in SaveDUTData."); } if (fH) fclose (fH); return errno; }
Similarly, you can retrieve data with the following:
int RestDUTData (DUTData x) { FILE *fH = NULL; fH = fopen ("myFile.dat", "rb"); if (errno) goto Error; fread ((char *)&x, sizeof (DUTData), 1, fH); if (errno) goto Error; Error: if (errno) { // strcpy (msg, "General I/O error in RestDUTData."); } if (fH) fclose (fH); return errno; }
Incidentally, I love your struct method! It preserves the order in reading and writing binary files, which is critical. I have corrupted many binary files by not writing and reading in the exact order. Thanks!