07-25-2005 12:19 PM
07-26-2005 07:02 AM
Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)
Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor
07-26-2005 08:35 AM
LabView is calling the DLL from a Call Function Node.
The DLL is a copy of the below code. Is there anything wrong with this code?
Christopher Lusardi
/********************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
char file [100];
#include "my_header.h"
int create_file ()
{
char Location [100] = "my_files/";
FILE *Fptr;
char box [50];
int numalo = 0;
int numdalo = 0;
int mypid;
int element;
if ( gethostname (box, 50) < 0 )
{
printf ("gethostname failed\n");
return (-1);
}
mypid = (int)getpid ();
sprintf (file,"%s%s_%d",Location,box,mypid);
if ( (Fptr = fopen (file,"w+")) == NULL )
{
printf ("fopen () failed opening file = %s\n",file);
return (-1);
}
else
{
fprinttf (Fptr,"%d\n",Number_of_items);
fprinttf (Fptr,"^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
for (element = 0; element < Number_of_items;element++)
{
if ( vegetable [element] == 1024 )
{
fprintf (Fptr,"%d %d %X %d %d %X %X %X\n",
vegetable [element],
fruit,
filtered_water.tomato [element],
filtered_water.green [element],
filtered_water.bacteria [element],
filtered_water.organic [element],
filtered_water.raw [element],
filtered_water.washed [element]);
}
else
{
fprintf (Fptr,"%d %d %X %d %d %d %X %X\n",
vegetable [element],
fruit,
filtered_water.tomato [element],
filtered_water.green [element],
filtered_water.bacteria [element],
filtered_water.organic [element],
filtered_water.raw [element],
filtered_water.washed [element]);
}
}
}
fclose (Fptr);
return (0);
07-26-2005 08:46 AM
Hi Chistopher,
Where is Number_Of_Items being initialised?
Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)
Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor
07-26-2005 08:58 AM
>Where is Number_Of_Items being initialised?
Number_Of_Items is incremented/decremented based on type of request asked of a service program.
This service routine is a separate program. Many applications, running at the same speed, make the requests.
If a resource is asked for the variable is incremented. If the resource is given up it is decremented.
There are about ~20 * 2 (really copies of the 1st 20) plus the DDL's routines used to accomplish this task,
and a large prototype routine that does the same thing. Each different routine is for a different type of request.
Christopher Lusardi
07-26-2005 09:43 AM
> fprinttf (Fptr,"%d\n",Number_of_items);
> fprinttf (Fptr,"^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
The above code segment is a typo. It should be:
fprintf (Fptr,"%d\n",Number_of_items);
fprintf (Fptr,"^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
Christopher Lusardi
07-26-2005 09:48 AM
Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)
Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor
07-26-2005 10:07 AM
> Where is Number_of_items defined? is it a static?
It is initially defined in a dot h file for the main routine as
int Number_of_items;
and is accessed by including in many files (via another dot h file)
extern int Number_of_items;
It is set to 0 in a file that all users should use at the start of their main routines.
Christopher Lusardi
07-26-2005 01:50 PM
O'kay, I was told that a GUI button was causing the problem. I investigated and was able to duplicate the problem
outside of the LabView environment. This means that the problem is not a DLL problem, and it is not a LabView problem.
Consequently, the problem is easier to solve, and I can do it on my own. I do not even think it is a fclose () problem.
Thank you for your mis-placed time,
Christopher Lusardi
08-16-2005 11:04 AM