LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

network access to INI files

Solved!
Go to solution

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?

0 Kudos
Message 11 of 14
(1,396 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 12 of 14
(1,392 Views)
Solution
Accepted by topic author ElectroLund

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!

0 Kudos
Message 13 of 14
(1,361 Views)

@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!

0 Kudos
Message 14 of 14
(1,344 Views)