Remove superfluous trailing white space from C files
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
|
||||
L A K E S H O R E 3 4 0 U T I L
|
||||
|
||||
|
||||
A few utility functions for dealing with a LAKESHORE340 temperature controller
|
||||
within the SINQ setup: host -- TCP/IP -- MAC --- RS-232.
|
||||
|
||||
|
||||
Mark Koennecke, Juli 1997
|
||||
Mark Lesha, January 2006 (based on ITC4 code)
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
printf("Busy or bad response received!\n");
|
||||
return LAKESHORE340__BADREAD;
|
||||
}
|
||||
|
||||
|
||||
int LAKESHORE340_ConfigureAndQueryGen(pLAKESHORE340 self, char *command,
|
||||
char *configandqueryparameters, char *configonlyparameters,char *diagnosis)
|
||||
/* Issue a command to the Lakeshore 340, if this works, */
|
||||
@@ -138,14 +138,14 @@
|
||||
printf("Response was good.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int LAKESHORE340_ConfigureAndQuery(pLAKESHORE340 self, char *command,
|
||||
char *parameters, char *diagnosis)
|
||||
/* Use for config/query transactions that don't require index parameters in the query. */
|
||||
{
|
||||
return LAKESHORE340_ConfigureAndQueryGen(self,command,"",parameters,diagnosis);
|
||||
}
|
||||
|
||||
|
||||
int LAKESHORE340_SetControl(pLAKESHORE340 self, int iControl)
|
||||
{
|
||||
/* Attempt to set the sensor used for temperature control. */
|
||||
@@ -162,23 +162,23 @@
|
||||
else
|
||||
return LAKESHORE340__BADPAR;
|
||||
}
|
||||
|
||||
|
||||
int LAKESHORE340_Setup(pLAKESHORE340 self, int iControl) /* Operations common to both Open and Config functions */
|
||||
{
|
||||
int iRet;
|
||||
char pCommand[20];
|
||||
char pReply[132];
|
||||
|
||||
|
||||
/* MJL enable RS232 debugging mode. */
|
||||
//setRS232Debug(self->controller,1);
|
||||
//printf("***RS232 debug mode enabled for LAKESHORE340***\n");fflush(stdout);
|
||||
|
||||
|
||||
/* Setup the comms port (the baudrate etc. are probably just academic since */
|
||||
/* they must be correct if we have established comms, but the termination */
|
||||
/* character setting is relevant - use just \r. */
|
||||
if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"COMM","3,5,2","bad comms setup"))!=1)
|
||||
return iRet;
|
||||
|
||||
|
||||
/* Reset the controller to power-on state. */
|
||||
sprintf(pCommand,"*RST");
|
||||
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||
@@ -197,12 +197,12 @@
|
||||
/* Basically this just makes sure comms is up. */
|
||||
if ((iRet=LAKESHORE340_Check_Status(self))!=1)
|
||||
return iRet;
|
||||
|
||||
|
||||
/* Check the POST status, it should be 0 and not 1. */
|
||||
sprintf(pCommand,"*TST?");
|
||||
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
||||
return iRet;
|
||||
return iRet;
|
||||
if (strcmp(pReply,"0")!=0)
|
||||
{
|
||||
if (strcmp(pReply,"1")==0)
|
||||
@@ -216,7 +216,7 @@
|
||||
return LAKESHORE340__BADREAD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check that the controller is a gen-new-wine Lakeshore 340 */
|
||||
/* There's also the *REV command to check the firmware revision, but */
|
||||
/* that would be going too far ;) */
|
||||
@@ -229,7 +229,7 @@
|
||||
strcpy(self->pAns,pReply);
|
||||
return LAKESHORE340__NOLAKESHORE340;
|
||||
}
|
||||
|
||||
|
||||
/* Switch to remote operation - but leave the keypad unlocked */
|
||||
if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"MODE","2",""))!=1)
|
||||
return iRet;
|
||||
@@ -243,7 +243,7 @@
|
||||
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||
if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1)
|
||||
return iRet;
|
||||
|
||||
|
||||
/* Set up the front panel display on the Lakeshore 340. */
|
||||
/* Set 2 output fields, which we will use to display the set temp */
|
||||
/* and the actual temp at the controlling sensor selected. */
|
||||
@@ -251,7 +251,7 @@
|
||||
/* matches exactly and we can use LAKESHORE340_ConfigureAndQuery ;) */
|
||||
if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"DISPLAY","4,060,1",""))!=1)
|
||||
return iRet;
|
||||
|
||||
|
||||
/* Set up the 4 fields on the front panel display to show both sensor temps. */
|
||||
if ((iRet=LAKESHORE340_ConfigureAndQueryGen(self,"DISPFLD","1","A,1",""))!=1)
|
||||
return iRet;
|
||||
@@ -261,7 +261,7 @@
|
||||
return iRet;
|
||||
if ((iRet=LAKESHORE340_ConfigureAndQueryGen(self,"DISPFLD","4","D,1",""))!=1)
|
||||
return iRet;
|
||||
|
||||
|
||||
/* Set the sensor used for controlling temperature. */
|
||||
/* Sets sensor A when iControl==1 and sensor B when iControl==2. */
|
||||
if ((LAKESHORE340_SetControl(self,iControl))!=1)
|
||||
@@ -275,18 +275,18 @@
|
||||
|
||||
/* Don't bother setting the controller's date & time
|
||||
(not easy to code and probably wouldn't be useful). */
|
||||
|
||||
|
||||
/* Check the LAKESHORE340 operating status one last time */
|
||||
if ((iRet=LAKESHORE340_Check_Status(self))!=1)
|
||||
return iRet;
|
||||
|
||||
|
||||
return 1; /* Success */
|
||||
}
|
||||
|
||||
int LAKESHORE340_Open(pLAKESHORE340 *pData, char *pRS232, int iSensor, int iCTRL, int iMode)
|
||||
{
|
||||
pLAKESHORE340 self = NULL;
|
||||
|
||||
|
||||
self = (pLAKESHORE340)malloc(sizeof(LAKESHORE340));
|
||||
if(self == NULL)
|
||||
{
|
||||
@@ -296,14 +296,14 @@
|
||||
self->iControl = iCTRL;
|
||||
self->iRead = iSensor;
|
||||
self->iReadOnly = iMode;
|
||||
|
||||
|
||||
/* The LAKESHORE340 doesn't require divisors or multipliers
|
||||
and they are always forced to 1.0 */
|
||||
self->fDiv = 1.0;
|
||||
self->fMult = 1.0;
|
||||
|
||||
|
||||
self->controller = NULL;
|
||||
|
||||
|
||||
self->controller = (prs232)FindCommandData(pServ->pSics,pRS232,
|
||||
"RS232 Controller");
|
||||
if(!self->controller){
|
||||
@@ -315,35 +315,35 @@
|
||||
return LAKESHORE340_Setup(self, self->iControl);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void LAKESHORE340_Close(pLAKESHORE340 *pData)
|
||||
{
|
||||
pLAKESHORE340 self;
|
||||
|
||||
|
||||
self = *pData;
|
||||
if (!self)
|
||||
return; // Just in case
|
||||
|
||||
|
||||
/* Try to turn off the heater as a precaution. */
|
||||
LAKESHORE340_ConfigureAndQuery(self,"RANGE","0","");
|
||||
|
||||
|
||||
/* switch off remote operation */
|
||||
/* Not sure if this is really necessary but do it just in case */
|
||||
LAKESHORE340_ConfigureAndQuery(self,"MODE","1","");
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int LAKESHORE340_Config(pLAKESHORE340 *pData, int iTmo, int iRead, int iControl,
|
||||
int LAKESHORE340_Config(pLAKESHORE340 *pData, int iTmo, int iRead, int iControl,
|
||||
float fDiv,float fMult)
|
||||
{
|
||||
pLAKESHORE340 self;
|
||||
|
||||
|
||||
self = *pData;
|
||||
|
||||
|
||||
return LAKESHORE340_Setup(self, iControl);
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int LAKESHORE340_Send(pLAKESHORE340 *pData, char *pCommand, char *pReply, int iLen)
|
||||
{
|
||||
@@ -351,7 +351,7 @@
|
||||
pLAKESHORE340 self;
|
||||
|
||||
self = *pData;
|
||||
|
||||
|
||||
/* Send command direct to the LAKESHORE340 */
|
||||
/* Because the LAKESHORE340 only provides a response for query commands (those
|
||||
ending in a '?'), just perform a write for others and not a full transaction. */
|
||||
@@ -371,7 +371,7 @@
|
||||
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||
iRet=transactRS232(self->controller,pCommand,commandlen,pReply,iLen);
|
||||
}
|
||||
|
||||
|
||||
/* Check the LAKESHORE340 operating status after issuing the command, if it was successful */
|
||||
if (iRet>=1)
|
||||
iRet=LAKESHORE340_Check_Status(self);
|
||||
@@ -409,19 +409,19 @@
|
||||
default:
|
||||
return LAKESHORE340__BADPAR; // But shouldn't happen
|
||||
}
|
||||
|
||||
|
||||
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
||||
return iRet;
|
||||
|
||||
|
||||
iRet = sscanf(pReply,"%g",&fRead); // KRDG returns free-format exponentiated value
|
||||
if(iRet != 1) // Not a number, probably an error response
|
||||
{
|
||||
return LAKESHORE340__BADREAD;
|
||||
}
|
||||
|
||||
|
||||
*fVal = fRead;
|
||||
|
||||
|
||||
/* Check the LAKESHORE340 operating status after the read, and return */
|
||||
iRet=LAKESHORE340_Check_Status(self);
|
||||
return iRet;
|
||||
@@ -441,25 +441,25 @@
|
||||
{
|
||||
return LAKESHORE340__READONLY;
|
||||
}
|
||||
|
||||
|
||||
/* Note we are using control loop #1 only for temperature control. */
|
||||
sprintf(pCommand,"SETP 1,%1.1f",fVal);
|
||||
sprintf(pCommandRead,"SETP? 1"); // To read back and check the set value
|
||||
|
||||
|
||||
/* try three times: send, read, test, if OK return, else resend. */
|
||||
/* MJL doesn't think this is necessary... left over from itc4 */
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
{
|
||||
/* send SETP command, we don't get any response so use writeRS232 */
|
||||
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||
if ((iRet=writeRS232(self->controller,pCommand,strlen(pCommand)))!=1)
|
||||
return iRet;
|
||||
return iRet;
|
||||
/* read the set value again using the SETP? command */
|
||||
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||
if ((iRet=transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131))<=0)
|
||||
return iRet;
|
||||
printf("SETP: Response %d characters: '%s'\n",iRet,pReply);
|
||||
if(pReply[0] == '-'&&strlen(pReply)>7)
|
||||
if(pReply[0] == '-'&&strlen(pReply)>7)
|
||||
{
|
||||
strcpy(self->pAns,pReply);
|
||||
return LAKESHORE340__BADCOM;
|
||||
@@ -500,7 +500,7 @@
|
||||
pLAKESHORE340 self;
|
||||
|
||||
self = *pData;
|
||||
|
||||
|
||||
switch(iCode)
|
||||
{
|
||||
case LAKESHORE340__BADCOM:
|
||||
@@ -530,6 +530,6 @@
|
||||
break;
|
||||
default:
|
||||
getRS232Error(iCode, pError,iLen);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user