fix missing return from ITC4_Config, change SerialError to getRS232Error, adjust Formatting

r2415 | dcl | 2008-04-14 08:37:57 +1000 (Mon, 14 Apr 2008) | 2 lines
This commit is contained in:
Douglas Clowes
2008-04-14 08:37:57 +10:00
parent 895e52bfe9
commit 519bf308fa

View File

@@ -1,10 +1,10 @@
/*--------------------------------------------------------------------------
I T C 4 U T I L
A few utility functions for dealing with a ITC4 temperature controller
within the SINQ setup: host -- TCP/IP -- MAC --- RS-232.
Mark Koennecke, Juli 1997
Copyright:
@@ -55,7 +55,7 @@
char pCommand[80];
char pReply[132];
pITC4 self = NULL;
self = (pITC4)malloc(sizeof(ITC4));
if(self == NULL)
{
@@ -68,7 +68,7 @@
self->fDiv = 10.;
self->fMult = 10.;
self->controller = NULL;
self->controller = (prs232)FindCommandData(pServ->pSics,pRS232,
"RS232 Controller");
if(!self->controller){
@@ -81,7 +81,7 @@
controller do not recognize it. Sighhhhhhh. I had to put it in again
in order to check for ITC-503, but I handle the thing by default as
an ITC4 if I do not get a proper response.
*/
*/
self->i503 = 0;
sprintf(pCommand,"V");
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
@@ -94,8 +94,8 @@
if(strstr(pReply,"ITC503") != NULL)
{
self->i503 = 1;
}
}
if(!self->iReadOnly)
{
/* switch to remote and unlocked operation pg48 */
@@ -103,15 +103,15 @@
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
{
return iRet;
}
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* Set heater and gas flow controls to manual pg51 */
sprintf(pCommand,"A0");
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
@@ -119,13 +119,13 @@
if(iRet != 1)
{
return iRet;
}
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* Set heater sensor pg 52 */
sprintf(pCommand,"H%1.1d",self->iControl);
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
@@ -133,13 +133,13 @@
if(iRet != 1)
{
return ITC4__BADCOM;
}
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* Display on control sensor on front panel pg51 */
sprintf(pCommand,"F%1.1d",self->iControl);
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
@@ -147,7 +147,7 @@
if(iRet != 1)
{
return iRet;
}
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
@@ -161,7 +161,7 @@
if(iRet != 1)
{
return iRet;
}
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
@@ -175,14 +175,14 @@
}
}
return 1;
}
}
/*--------------------------------------------------------------------------*/
void ITC4_Close(pITC4 *pData)
{
}
}
/*--------------------------------------------------------------------------*/
/* Called by ansto/itc4driv.c:ConfigITC4 */
int ITC4_Config(pITC4 *pData, int iTmo, int iRead, int iControl,
int ITC4_Config(pITC4 *pData, int iTmo, int iRead, int iControl,
float fDiv,float fMult)
{
@@ -191,92 +191,92 @@
char pCommand[10];
pITC4 self;
self = *pData;
/* 3 input channels see p52 */
/* BUG ALLOWS iControl=4 */
if (iControl < 1 || iControl > 3) {
return 1;
} else {
/* switch to remote and unlocked operation pg48 */
sprintf(pCommand,"C3");
iRet = transactRS232(self->controller, pCommand,strlen(pCommand), pReply,79);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
self = *pData;
/* Set heater and gas flow controls to manual pg51 */
sprintf(pCommand,"A0");
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* 3 input channels see p52 */
/* BUG ALLOWS iControl=4 */
if (iControl < 1 || iControl > 3) {
return 1;
} else {
/* switch to remote and unlocked operation pg48 */
sprintf(pCommand,"C3");
iRet = transactRS232(self->controller, pCommand,strlen(pCommand), pReply,79);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* Set heater sensor pg 52 */
sprintf(pCommand,"H%1.1d",iControl);
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
return ITC4__BADCOM;
} else if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
} else {
self->iControl = iControl;
}
/* Set heater and gas flow controls to manual pg51 */
sprintf(pCommand,"A0");
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* Display on control sensor on front panel pg51 */
sprintf(pCommand,"F%1.1d",iControl);
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* Set heater sensor pg 52 */
sprintf(pCommand,"H%1.1d",iControl);
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
return ITC4__BADCOM;
} else if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
} else {
self->iControl = iControl;
}
/* Heater Auto, Gas Manual pg51 */
sprintf(pCommand,"A1");
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* reset timeout */
/*iRet = SerialConfig(&self->pData, 10);*/
if(iRet != 1)
{
return iRet;
}
/* Display on control sensor on front panel pg51 */
sprintf(pCommand,"F%1.1d",iControl);
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* Heater Auto, Gas Manual pg51 */
sprintf(pCommand,"A1");
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79);
if(iRet != 1)
{
return iRet;
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
/* reset timeout */
/*iRet = SerialConfig(&self->pData, 10);*/
if(iRet != 1)
{
return iRet;
}
}
}
return 1;
}
}
/* --------------------------------------------------------------------------*/
int ITC4_Send(pITC4 *pData, char *pCommand, char *pReply, int iLen)
{
@@ -290,7 +290,7 @@
strcat(pCommand,"\r");
} */
return transactRS232(self->controller,pCommand,strlen(pCommand),pReply,iLen);
}
}
/*--------------------------------------------------------------------------*/
int ITC4_Read(pITC4 *pData, float *fVal)
{
@@ -309,7 +309,7 @@
if(iRet != 1)
{
return iRet;
}
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
@@ -322,7 +322,7 @@
strcpy(self->pAns,pReply);
return ITC4__BADCOM;
}
iRet = sscanf(&pReply[1],"%f",&fRead);
if(iRet != 1)
{
@@ -333,7 +333,7 @@
*fVal = fRead;
}
else
{
{
*fVal = fRead/self->fDiv;
}
return 1;
@@ -354,7 +354,7 @@
{
return ITC4__READONLY;
}
/* format command */
if(self->i503)
{
@@ -365,20 +365,20 @@
fSet = fVal;
iSet = (int)(fSet*self->fMult);
sprintf(pCommand,"T%5.5d",iSet);
}
}
/* try three times: send, read, test, if OK return, else
resend. This must be done because the ITC4 tends to loose
characters
*/
for(i = 0; i < 3; i++)
{
/* send command */
{
/* send command */
iRet = transactRS232(self->controller,pCommand,strlen(pCommand),pReply,131);
if(iRet != 1)
{
return iRet;
}
}
if(pReply[0] == '?')
{
strcpy(self->pAns,pReply);
@@ -404,14 +404,14 @@
else
{
fDelta = fRead - fSet;
}
}
if(fDelta < 0)
fDelta = -fDelta;
if(fDelta < fPrecision)
{
/* Success, go home */
return 1;
}
}
}
return ITC4__BADSET;
}
@@ -422,7 +422,7 @@
pITC4 self;
self = *pData;
switch(iCode)
{
case ITC4__BADCOM:
@@ -441,9 +441,9 @@
break;
case ITC4__BADSET:
strncpy(pError,"ITC4: Failed three times to write new set value to ITC4",iLen);
break;
break;
default:
SerialError(iCode, pError,iLen);
break;
getRS232Error(iCode, pError,iLen);
break;
}
}