Need a response to this. seems to have gotten barried. Thread started 8/28.
This code according to the developers demonstrates the problem.
Dennis Morehart
GE Indutrial Systems
\
The value of "VME_SLOT_Number" is .
\ \ \ #include #include #include #include #include #include #include #include#define VAR_LEN 60
int verbose=0;
// Usage data for use function
#ifdef __USAGE
%C [-v c l] varname [value]
Where:
-v Verbose.
-q quiet
-c Create variable
-f Set flags to DS_PERM (use with -c)
-l looptime Display variable every looptime seconds 0=single pass
#endif
int main(int argc, char **argv)
{
int c;
char varname[VAR_LEN+1];
char value[VAR_LEN+1];
int create=0, quiet = 0;
int looptime=0;
ds_t data_server;
char flag=0;
// Set default values
strcpy (varname, “”);
strcpy (value, “”);
// parse arguments
while( ( c = getopt( argc, argv, “fvqcl:” )) != -1 )
{
switch( c )
{
case ‘v’:
verbose++;
break;
case ‘q’:
quiet++;
break;
case ‘c’:
create=1;
break;
case ‘f’:
flag = DS_PERM;
break;
case ‘l’:
looptime=atoi (optarg);
break;
default :
if (!quiet)
printf ("\nInvalid argument %s\n", optarg);
exit (-1);
}
}
if (argv[optind] == NULL)
{
if (!quiet)
printf ("\nNo variable name given %s\n", argv[1]);
exit (-1);
}
strcpy (varname, argv[optind]);
if (argv[optind+1] != NULL)
strcpy (value, argv[optind+1]);
// Connect to the data server
if ((data_server= ds_register ( )) == -1)
{
if (!quiet)
printf ("\nUnable to open data server. Error:%s \n",strerror(errno));
exit (-1);
}
if (verbose)
printf ("\nConnected to Data server");
if (create) // Create the variable
{
if ((ds_create ( data_server, varname, flag ,0 )) == -1)
{
if (!quiet)
printf ("\nUnable to create data server name %s. Error:%s\n", varname,
strerror(errno));
exit (-1);
}
if (verbose)
printf ("\nCreated variable %s", varname);
}
if (strlen (value)) // Set the variable
{
if ((ds_set( data_server, varname, value, strlen(value))) == -1)
{
if (!quiet)
printf ("\nUnable to set data server name %s. Error: %s\n", varname,
strerror(errno));
exit (-1);
}
if (verbose)
printf ("\nSet Variable %s to %s", varname, value);
}
while (1)
{
if ((ds_get(data_server,varname,value, VAR_LEN )) == -1)
{
if (!quiet)
printf ("\nUnable to get data server name %s. Error: %s\n", varname,
strerror(errno));
exit (-1);
}
if (!quiet)
printf ("\nData Server Variable %s = %s", varname, value);
else
printf ("%s", value);
if (looptime==0)
break;
sleep (looptime);
}
}