11-25-2009 11:09 PM
errChk(Ini_GetStringIntoBuffer (IniTextHandle, g_sOperatorID, "OperatorID",
g_sOperatorID2, BUF_LEN));
if (error == 0) {
error = ToolErr_MissingItem; // defined in toolbox.h
goto Error;
}
okay when I step through , the error value give me 1, which mean that the string is found.
which when I got to my log file , the string is not there or step through the this line.
which string the check is currently for ? is this for the second parameter or the 4th parameter?
because the section is pull, but the fourth parameter is not there, it gives ""
11-25-2009 11:48 PM
The second parameter (Section Name) is passed to the function. The fourth is returned from the function.
Ini_GetStringIntoBuffer does nothing on Section Name string. If "OperatorID" item item is found in section Section name, its value is returned in g_sOperatorID2. If the item is an empty string (i.e. OperatorID ="") the string will be empty, otherwise it will show the chacters to the right of the equal sign. That's how IniFIle instrument works.
While stepping through the code, is there antything in g_sOperatorID2?
How is defined your LOG_FILE function?
11-26-2009 12:06 AM
right nothing is in that parameter at all, so its suppose to return a error, but instead it saids 1, when i go to the file it just saids ""
do you know y is that?
11-26-2009 12:25 AM
11-26-2009 12:33 AM
11-26-2009 12:38 AM
this is my logic before the boresight command function call, where im getting the operator id at first
int Calculate_Off_Set_Centroid_Point( double dSameXpositionValue,
double dSameYpositionValue,
FRAMEDETAILS FrameSize)
{
int iHalfOfFrameWidth=0;
int iHalfOfFrameHeight=0;
int iMultiplier=0;
int iBufSize=1000;
int iStatus =SUCCESS;
int error = 0;
unsigned int uiNameSize;
double dOffSetXposition=0;
double dOffSetYposition=0;
char sUsername[1000]={0};
char szStringk[1000] = "";
char *sErrorMsg1=0;
char sDirectoryPathName[BUF_LEN_FOR_DIRECTORY];
IniText IniTextFileHandle=0; //Handle for the text file.
char sIniFilePathName[BUF_LEN_FOR_DIRECTORY];
GetProjectDir(sDirectoryPathName);
MakePathname(sDirectoryPathName,KEY_TEXT_FILE,sIniFilePathName);
//Verify if there is enough memory
nullChk(IniTextFileHandle=Ini_New( 0 ));
//Verify if file is on disk
error=FileExists(sIniFilePathName,0);
if(error<VI_SUCCESS)
{
//Terminate DAS3000.exe
Terminate_Executable();
return FAILURE;
}
errChk(Ini_ReadFromFile (IniTextFileHandle,sIniFilePathName));
//Conversion from pixels to degrees
Conversion_Number(&iMultiplier);
//Manipulation to get half of the frame
iHalfOfFrameWidth= FrameSize.WidthCoordinate/2;
iHalfOfFrameHeight= FrameSize.HeightCoordinate/2;
//Math Expression:centroid value - centroid center
//= offset value. (x=width,y=height)
//These two expression below are calculating the x and y centroid offset.
//Converting pixels to degrees
dOffSetXposition=dSameXpositionValue-iHalfOfFrameWidth;
dOffSetXposition=dOffSetXposition*iMultiplier;
dOffSetYposition=dSameYpositionValue-iHalfOfFrameHeight;
dOffSetYposition=dOffSetYposition*iMultiplier;
//Gets the current user name
iStatus = GetCurrentUser (sUsername, iBufSize, &uiNameSize);
sprintf(szStringk,"Current User: %s",sUsername);
texLogPdel(szStringk);
LOG_FILE(szStringk);
// Get operator ID
if((texGetTPC ("OperatorID" ,g_sOperatorID,40))== FALSE)
{
//Try again
if( (texGetTPC ("OperatorID",g_sOperatorID, 40)) == FALSE )
{
sprintf( szStringk,
"texGetTPC error - Skr Serial "
"Number cannot be retrieved '%s'",
g_sOperatorID );
LOG_FILE( szStringk );
strcpy( g_sOperatorID, "Unknown");
LOG_FILE(g_sOperatorID);
}
}
// Get UUT serial number
if((texGetTPC ("UUTMSN" ,g_sSkrSerialNumberk,40))== FALSE)
{
//Try Again
if( (texGetTPC (UUT_MSN,g_sSkrSerialNumberk, 40)) == FALSE )
{
sprintf( szStringk,
"texGetTPC error - Skr Serial "
"Number cannot be retrieved '%s'",
g_sSkrSerialNumberk );
LOG_FILE( szStringk );
strcpy( g_sSkrSerialNumberk, "Unknown");
}
}
sprintf(g_sXoffset,"%f", dOffSetXposition);
sprintf(g_sYoffset,"%f", dOffSetYposition);
//Storing the operator Id and seeker serial number in a text file
//along with x and y offset position
errChk(Ini_PutString(IniTextFileHandle, g_sOperatorID, "OperatorID",
g_sOperatorID1));
errChk(Ini_PutString(IniTextFileHandle, g_sSkrSerialNumberk,X_OFFSET_POS,
g_sXoffset));
errChk(Ini_PutString(IniTextFileHandle, g_sSkrSerialNumberk,Y_OFFSET_POS,
g_sYoffset));
Ini_WriteToFile(IniTextFileHandle, sIniFilePathName);
Error:
if(IniTextFileHandle)
{
//Cleaning memory
Ini_Dispose (IniTextFileHandle);
}
if(error < VI_SUCCESS)
{
sErrorMsg1 = GetGeneralErrorString (error);
MessagePopup ("ERROR", sErrorMsg1);
Terminate_Executable();
}
return error;
}
11-26-2009 12:52 AM
i think I found the problem, the logic suppose to be this way instead
errChk(Ini_GetStringIntoBuffer (IniTextHandle, g_sSkrSerialNumberk, "OperatorID",
g_sOperatorID, BUF_LEN));
11-26-2009 12:53 AM
11-26-2009 12:55 AM
so i just posted my logic of both the functions im using, I had to change my logic , because it was wrong in the first place, now let me step through
int Boresight_Command(double *dAZposX,double *dELposY)
{
int error=0;
char *sErrorMsg1=0;
char sAZposX[BUF_LEN]={0};
char sELposY[BUF_LEN]={0};
char sCrtCommand[BUF_LEN]={0};
char sDirPath[BUF_LEN_FOR_DIRECTORY];
IniText IniTextHandle=0; // Handle for the text file.
char sPathName[BUF_LEN_FOR_DIRECTORY];
GetProjectDir(sDirPath);
MakePathname(sDirPath,KEY_TEXT_FILE,sPathName);
//Verify if there is enough memory
nullChk(IniTextHandle=Ini_New (0));
//Verify if file exist on disk
error=FileExists(sPathName,0);
if(error<=VI_SUCCESS)
{
Terminate_Executable();
return FAILURE;
}
errChk(Ini_ReadFromFile (IniTextHandle,sPathName));
errChk(Ini_GetStringIntoBuffer (IniTextHandle, g_sSkrSerialNumberk, "OperatorID",
g_sOperatorID, BUF_LEN));
if(error == 0)
{
error = ToolErr_MissingItem; // defined in toolbox.h
goto Error;
}
LOG_FILE(g_sOperatorID1);
errChk(Ini_GetDouble(IniTextHandle,g_sSkrSerialNumberk,X_OFFSET_POS,
dAZposX));
errChk(Ini_GetDouble(IniTextHandle,g_sSkrSerialNumberk,Y_OFFSET_POS,
dELposY));
Fmt(sAZposX,"%f",*dAZposX);
sprintf(sCrtCommand,"SERVO, WRITE, 098000034, %s",sAZposX);
Send_SERVO_Command(sCrtCommand);
Fmt(sELposY,"%f",*dELposY);
sprintf(sCrtCommand,"SERVO, WRITE, 098000038, %s",sELposY);
Send_SERVO_Command(sCrtCommand);
Error:
if(IniTextHandle)
{
//Cleaning memory
Ini_Dispose (IniTextHandle);
}
if(error < VI_SUCCESS)
{
sErrorMsg1 = GetGeneralErrorString (error);
MessagePopup ("ERROR", sErrorMsg1);
Terminate_Executable();
}
return error;
}
11-26-2009 01:02 AM
now when I step through it, my ini file look like this
[Unknown]
OperatorID = "Unknown"
X_BORESIGHT = "-639.940000"
Y_BORESIGHT = "-479.860000"
question if my ini file was like this below for the operator tag, dont ,y check suppose to fail according to this check
errChk(Ini_GetStringIntoBuffer (IniTextHandle, g_sSkrSerialNumberk, "OperatorID",
g_sOperatorID, BUF_LEN));
if(error == 0)
{
error = ToolErr_MissingItem; // defined in toolbox.h
goto Error;
}
[Unknown]
OperatorID = ""
X_BORESIGHT = "-639.940000"
Y_BORESIGHT = "-479.860000"