Fixed general bugs.
r2139 | mle | 2007-08-23 15:08:52 +1000 (Thu, 23 Aug 2007) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
a85720686b
commit
e76c3922f0
@@ -66,7 +66,7 @@
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
sprintf(pCommand,"BUSY?");
|
sprintf(pCommand,"BUSY?");
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
||||||
{
|
{
|
||||||
printf("Comms error!\n");
|
printf("Comms error!\n");
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
else
|
else
|
||||||
sprintf(pCommand,"%s %s",command,configonlyparameters);
|
sprintf(pCommand,"%s %s",command,configonlyparameters);
|
||||||
printf("Issuing command: '%s'...\n",pCommand);
|
printf("Issuing command: '%s'...\n",pCommand);
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=writeRS232(self->controller,pCommand,strlen(pCommand)))!=1)
|
if ((iRet=writeRS232(self->controller,pCommand,strlen(pCommand)))!=1)
|
||||||
return iRet;
|
return iRet;
|
||||||
/* Issue the query corresponding to the command, */
|
/* Issue the query corresponding to the command, */
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
else
|
else
|
||||||
sprintf(pCommand,"%s?",command);
|
sprintf(pCommand,"%s?",command);
|
||||||
printf("Issuing query: '%s'...\n",pCommand);
|
printf("Issuing query: '%s'...\n",pCommand);
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
||||||
{
|
{
|
||||||
printf("transactRS232 error! Code=%d.\n",iRet);
|
printf("transactRS232 error! Code=%d.\n",iRet);
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
|
|
||||||
/* Reset the controller to power-on state. */
|
/* Reset the controller to power-on state. */
|
||||||
sprintf(pCommand,"*RST");
|
sprintf(pCommand,"*RST");
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1)
|
if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1)
|
||||||
return iRet;
|
return iRet;
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
/* just in case we want to use the internal status flags later on. */
|
/* just in case we want to use the internal status flags later on. */
|
||||||
/* Actually, we do *RST above, probably this isn't necessary. */
|
/* Actually, we do *RST above, probably this isn't necessary. */
|
||||||
sprintf(pCommand,"*CLS");
|
sprintf(pCommand,"*CLS");
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1)
|
if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1)
|
||||||
return iRet;
|
return iRet;
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
|
|
||||||
/* Check the POST status, it should be 0 and not 1. */
|
/* Check the POST status, it should be 0 and not 1. */
|
||||||
sprintf(pCommand,"*TST?");
|
sprintf(pCommand,"*TST?");
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
||||||
return iRet;
|
return iRet;
|
||||||
if (strcmp(pReply,"0")!=0)
|
if (strcmp(pReply,"0")!=0)
|
||||||
@@ -220,7 +220,7 @@
|
|||||||
/* There's also the *REV command to check the firmware revision, but */
|
/* There's also the *REV command to check the firmware revision, but */
|
||||||
/* that would be going too far ;) */
|
/* that would be going too far ;) */
|
||||||
sprintf(pCommand,"*IDN?",command);
|
sprintf(pCommand,"*IDN?",command);
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
||||||
return iRet;
|
return iRet;
|
||||||
if (strncmp(pReply,"LSCI,MODEL340",13)!=0)
|
if (strncmp(pReply,"LSCI,MODEL340",13)!=0)
|
||||||
@@ -239,7 +239,7 @@
|
|||||||
|
|
||||||
/* Clear any alarms. */
|
/* Clear any alarms. */
|
||||||
sprintf(pCommand,"ALMRST");
|
sprintf(pCommand,"ALMRST");
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1)
|
if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1)
|
||||||
return iRet;
|
return iRet;
|
||||||
|
|
||||||
@@ -359,13 +359,13 @@
|
|||||||
&&(pCommand[i+1]==' '||pCommand[i+1]=='\0')); // any '? ' pattern or trailing '?' will do.
|
&&(pCommand[i+1]==' '||pCommand[i+1]=='\0')); // any '? ' pattern or trailing '?' will do.
|
||||||
if (!isquery) // LAKESHORE340 does not send any response.
|
if (!isquery) // LAKESHORE340 does not send any response.
|
||||||
{
|
{
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
iRet=writeRS232(self->controller,pCommand,commandlen);
|
iRet=writeRS232(self->controller,pCommand,commandlen);
|
||||||
*pReply='\0';
|
*pReply='\0';
|
||||||
}
|
}
|
||||||
else // LAKESHORE340 will send a response.
|
else // LAKESHORE340 will send a response.
|
||||||
{
|
{
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
iRet=transactRS232(self->controller,pCommand,commandlen,pReply,iLen);
|
iRet=transactRS232(self->controller,pCommand,commandlen,pReply,iLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@
|
|||||||
return LAKESHORE340__BADPAR; // But shouldn't happen
|
return LAKESHORE340__BADPAR; // But shouldn't happen
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
|
||||||
return iRet;
|
return iRet;
|
||||||
|
|
||||||
@@ -448,11 +448,11 @@
|
|||||||
for(i = 0; i < 3; i++)
|
for(i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
/* send SETP command, we don't get any response so use writeRS232 */
|
/* send SETP command, we don't get any response so use writeRS232 */
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=writeRS232(self->controller,pCommand,strlen(pCommand)))!=1)
|
if ((iRet=writeRS232(self->controller,pCommand,strlen(pCommand)))!=1)
|
||||||
return iRet;
|
return iRet;
|
||||||
/* read the set value again using the SETP? command */
|
/* read the set value again using the SETP? command */
|
||||||
usleep(50000); // Required to meet Lakeshore340 spec.
|
usleep(100000); // Required to meet Lakeshore340 spec.
|
||||||
if ((iRet=transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131))<=0)
|
if ((iRet=transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131))<=0)
|
||||||
return iRet;
|
return iRet;
|
||||||
printf("SETP: Response %d characters: '%s'\n",iRet,pReply);
|
printf("SETP: Response %d characters: '%s'\n",iRet,pReply);
|
||||||
|
|||||||
@@ -47,29 +47,51 @@
|
|||||||
#include <modriv.h>
|
#include <modriv.h>
|
||||||
#include <rs232controller.h>
|
#include <rs232controller.h>
|
||||||
#include "lh45util.h"
|
#include "lh45util.h"
|
||||||
|
#include <serialsinq.h>
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// Because the Julabo LH45 may return non-printing characters such as DC1 and DC3
|
||||||
|
// at the beginning of its responses, we provide a functin to strip them off.
|
||||||
|
char *ReplyStart(char *pReply)
|
||||||
|
{
|
||||||
|
while(*pReply<0x20&&*pReply!='\0') // chuck out any and all control characters, CR, LF etc.
|
||||||
|
pReply++;
|
||||||
|
return pReply;
|
||||||
|
}
|
||||||
|
|
||||||
int LH45_Check_Status(pLH45 self) /* Can be called to check for correct operation of the LH45 */
|
int LH45_Check_Status(pLH45 self) /* Can be called to check for correct operation of the LH45 */
|
||||||
{
|
{
|
||||||
int iRet;
|
int iRet;
|
||||||
char pCommand[20];
|
char pCommand[20];
|
||||||
char pReply[132];
|
char pReply[132],*pReplyStart;
|
||||||
|
|
||||||
/* Check the status. It should read '03 REMOTE START' or possibly '03 REMOTE START,DEGASING'. */
|
/* Check the status. It should read '03 REMOTE START' or possibly '03 REMOTE START,DEGASING'. */
|
||||||
/* If there is any LH45 overload or other fault condition it will be detected here. */
|
/* If there is any LH45 overload or other fault condition it will be detected here. */
|
||||||
// printf("Checking LH45 status...");fflush(stdout);
|
// printf("Checking LH45 status...");fflush(stdout);
|
||||||
sprintf(pCommand,"status");
|
printf("Getting STATUS \n");fflush(stdout);
|
||||||
|
sprintf(pCommand,"STATUS");
|
||||||
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
|
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
|
||||||
pReply,79);
|
pReply,79);
|
||||||
|
pReplyStart=ReplyStart(pReply);
|
||||||
|
usleep(500000);
|
||||||
|
/home/mrt/workspace
|
||||||
if(iRet <= 0)
|
if(iRet <= 0)
|
||||||
{
|
{
|
||||||
//transactRS232(self->controller,"\nDEBUG: RS232 transaction bad.\n",28,pReply,79);
|
//transactRS232(self->co/home/mrt/workspacentroller,"\nDEBUG: RS232 transaction bad.\n",28,pReply,79);
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
if (strncmp(pReply,"03 REMOTE START",15)!=0)
|
printf("Status is: '%s'\n",pReplyStart);fflush(stdout);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for(i=0;i<strlen(pReply);i++)
|
||||||
|
printf("0x%02x ",((unsigned char *)pReply)[i]);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
if (strncmp(pReplyStart,"03 REMOTE START",15)!=0)
|
||||||
{
|
{
|
||||||
//transactRS232(self->controller,"\nDEBUG: RS232 response bad\n",27,pReply,79);
|
//transactRS232(self->controller,"\nDEBUG: RS232 response bad\n",27,pReply,79);
|
||||||
//transactRS232(self->controller,pReply,strlen(pReply),pReply,79);
|
//transactRS232(self->controller,pReply,strlen(pReply),pReply,79);
|
||||||
strcpy(self->pAns,pReply);
|
strcpy(self->pAns,pReplyStart);
|
||||||
return LH45__FAULT;
|
return LH45__FAULT;
|
||||||
}
|
}
|
||||||
//transactRS232(self->controller,"\nDEBUG: Status reply is good!\n",30,pReply,79);
|
//transactRS232(self->controller,"\nDEBUG: Status reply is good!\n",30,pReply,79);
|
||||||
@@ -86,13 +108,14 @@
|
|||||||
//setRS232Debug(self->controller,1);
|
//setRS232Debug(self->controller,1);
|
||||||
//printf("***RS232 debug mode enabled for LH45***\n");fflush(stdout);
|
//printf("***RS232 debug mode enabled for LH45***\n");fflush(stdout);
|
||||||
|
|
||||||
/* switch to remote operation */
|
/* switch to remote operation - although don't want it to initialise */
|
||||||
/* NOTE: The Julabo does not provide any response for 'out' commands,
|
/* NOTE: The Julabo does not provide any response for 'out' commands,
|
||||||
so we just use writeRS232 not transactRS232 for these */
|
so we just use writeRS232 not transactRS232 for these */
|
||||||
//printf("Issuing out_mode_05 1 command...");fflush(stdout);
|
//printf("Issuing out_mode_05 0 command...");fflush(stdout);
|
||||||
sprintf(pCommand,"out_mode_05 1");
|
sprintf(pCommand,"OUT_MODE_05 0");
|
||||||
iRet = writeRS232(self->controller, pCommand,strlen(pCommand));
|
iRet = writeRS232(self->controller, pCommand,strlen(pCommand));
|
||||||
//printf("Response: '%s'\n",pReply);fflush(stdout);
|
usleep(500000);
|
||||||
|
printf("OUT_MODE_05 1 is completed \n");fflush(stdout);
|
||||||
if(iRet != 1)
|
if(iRet != 1)
|
||||||
{
|
{
|
||||||
return iRet;
|
return iRet;
|
||||||
@@ -110,8 +133,10 @@
|
|||||||
/* Set heater sensor */
|
/* Set heater sensor */
|
||||||
/* For the LH45 there is a choice of internal or external sensor control,
|
/* For the LH45 there is a choice of internal or external sensor control,
|
||||||
set internal when iControl==1 and external when iControl==2 */
|
set internal when iControl==1 and external when iControl==2 */
|
||||||
sprintf(pCommand,"out_mode_04 %1.1d",self->iControl - 1);
|
sprintf(pCommand,"OUT_MODE_04 %d",self->iControl - 1);
|
||||||
iRet = writeRS232(self->controller, pCommand,strlen(pCommand));
|
iRet = writeRS232(self->controller, pCommand,strlen(pCommand));
|
||||||
|
usleep(500000);
|
||||||
|
printf("OUT_MODE_04 Response is completed \n");fflush(stdout);
|
||||||
if(iRet != 1)
|
if(iRet != 1)
|
||||||
{
|
{
|
||||||
return LH45__BADCOM;
|
return LH45__BADCOM;
|
||||||
@@ -167,6 +192,7 @@
|
|||||||
|
|
||||||
if(!self->iReadOnly)
|
if(!self->iReadOnly)
|
||||||
return LH45_Setup(self, self->iControl);
|
return LH45_Setup(self, self->iControl);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
void LH45_Close(pLH45 *pData)
|
void LH45_Close(pLH45 *pData)
|
||||||
@@ -182,8 +208,9 @@
|
|||||||
|
|
||||||
/* switch off remote operation */
|
/* switch off remote operation */
|
||||||
/* Not sure if this is really necessary but do it just in case */
|
/* Not sure if this is really necessary but do it just in case */
|
||||||
sprintf(pCommand,"out_mode_05 0");
|
sprintf(pCommand,"OUT_MODE_05 0");
|
||||||
iRet = writeRS232(self->controller, pCommand,strlen(pCommand));
|
iRet = writeRS232(self->controller, pCommand,strlen(pCommand));
|
||||||
|
usleep(500000);
|
||||||
/* Don't bother checking the status but record any error reply */
|
/* Don't bother checking the status but record any error reply */
|
||||||
/* if(pReply[0] == '-') // Probably an error response
|
/* if(pReply[0] == '-') // Probably an error response
|
||||||
strcpy(self->pAns,pReply); */
|
strcpy(self->pAns,pReply); */
|
||||||
@@ -207,6 +234,7 @@
|
|||||||
pLH45 self;
|
pLH45 self;
|
||||||
|
|
||||||
self = *pData;
|
self = *pData;
|
||||||
|
char *pReplyStart;
|
||||||
|
|
||||||
/* make sure, that there is a \r at the end of the command */
|
/* make sure, that there is a \r at the end of the command */
|
||||||
/* if(strchr(pCommand,(int)'\r') == NULL)
|
/* if(strchr(pCommand,(int)'\r') == NULL)
|
||||||
@@ -218,13 +246,22 @@
|
|||||||
/* Because the Julabo LH45 only provides a response for the 'version', 'status'
|
/* Because the Julabo LH45 only provides a response for the 'version', 'status'
|
||||||
and 'in' commands and not for the 'out' commands, just perform a write
|
and 'in' commands and not for the 'out' commands, just perform a write
|
||||||
for those and not a full transaction. */
|
for those and not a full transaction. */
|
||||||
if (strncmp(pCommand,"out",3)==0) // 'out' command; LH45 does not send any response.
|
if (strncasecmp(pCommand,"OUT",3)==0) // 'OUT' command; LH45 does not send any response.
|
||||||
{
|
{
|
||||||
iRet=writeRS232(self->controller,pCommand,strlen(pCommand));
|
iRet=writeRS232(self->controller,pCommand,strlen(pCommand));
|
||||||
|
usleep(500000);
|
||||||
*pReply='\0';
|
*pReply='\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,iLen);
|
iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,iLen);
|
||||||
|
pReplyStart=ReplyStart(pReply);
|
||||||
|
// In this case we need to actually shift the buffer content since it is passed in from outside
|
||||||
|
char *ptoReply=pReply;
|
||||||
|
do {
|
||||||
|
*ptoReply++=*pReplyStart;
|
||||||
|
} while(*pReplyStart++);
|
||||||
|
}
|
||||||
if(iRet <= 0)
|
if(iRet <= 0)
|
||||||
return iRet;
|
return iRet;
|
||||||
|
|
||||||
@@ -235,7 +272,7 @@
|
|||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
int LH45_Read(pLH45 *pData, float *fVal)
|
int LH45_Read(pLH45 *pData, float *fVal)
|
||||||
{
|
{
|
||||||
char pCommand[20], pReply[132];
|
char pCommand[20], pReply[132], *pReplyStart;
|
||||||
int iRet;
|
int iRet;
|
||||||
float fRead = -9999999.;
|
float fRead = -9999999.;
|
||||||
pLH45 self;
|
pLH45 self;
|
||||||
@@ -247,13 +284,13 @@
|
|||||||
switch(self->iRead)
|
switch(self->iRead)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
sprintf(pCommand,"in_pv_00");
|
sprintf(pCommand,"IN_PV_00");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sprintf(pCommand,"in_pv_02");
|
sprintf(pCommand,"IN_PV_02");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
sprintf(pCommand,"in_pv_03");
|
sprintf(pCommand,"IN_PV_03");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return LH45__BADPAR; // But shouldn't happen
|
return LH45__BADPAR; // But shouldn't happen
|
||||||
@@ -261,23 +298,24 @@
|
|||||||
|
|
||||||
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
|
iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
|
||||||
pReply,79);
|
pReply,79);
|
||||||
|
pReplyStart=ReplyStart(pReply);
|
||||||
|
usleep(500000);
|
||||||
|
|
||||||
if(iRet <= 0)
|
if(iRet <= 0)
|
||||||
{
|
{
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
if(pReply[0] == '-'&&strlen(pReply)>7) // Not a number (-XXX.X\r), probably an error response
|
|
||||||
|
//sprintf(self->pAns,"The read value is '%s'\n and the command is: '%s' \n",pReply,pCommand);
|
||||||
|
//return LH45__FAULT;
|
||||||
|
if(pReplyStart == '-'&&strlen(pReplyStart)>7) // Not a number (-XXX.X\r), probably an error response
|
||||||
{
|
{
|
||||||
strcpy(self->pAns,pReply);
|
strcpy(self->pAns,pReplyStart);
|
||||||
return LH45__BADCOM;
|
return LH45__BADCOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
iRet = sscanf(pReply,"%f",&fRead);
|
iRet = sscanf(pReplyStart,"%f",&fRead);
|
||||||
if(iRet != 1)
|
if (iRet == 1)
|
||||||
{
|
|
||||||
return LH45__BADREAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
*fVal = fRead;
|
*fVal = fRead;
|
||||||
|
|
||||||
/* Check the LH45 operating status after the read, and return */
|
/* Check the LH45 operating status after the read, and return */
|
||||||
@@ -287,7 +325,7 @@
|
|||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
int LH45_Set(pLH45 *pData, float fVal)
|
int LH45_Set(pLH45 *pData, float fVal)
|
||||||
{
|
{
|
||||||
char pCommand[20], pCommandRead[20], pReply[132];
|
char pCommand[20], pCommandRead[20], pReply[132], *pReplyStart;;
|
||||||
int iRet, i;
|
int iRet, i;
|
||||||
const float fPrecision = 0.1;
|
const float fPrecision = 0.1;
|
||||||
float fDelta, fRead;
|
float fDelta, fRead;
|
||||||
@@ -300,14 +338,15 @@
|
|||||||
return LH45__READONLY;
|
return LH45__READONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(pCommand,"out_sp_00 %1.1f",fVal);
|
sprintf(pCommand,"OUT_SP_00 %1.1f",fVal);
|
||||||
sprintf(pCommandRead,"in_sp_00"); // To read back and check the set value
|
sprintf(pCommandRead,"IN_SP_00"); // To read back and check the set value
|
||||||
|
|
||||||
/* try three times: send, read, test, if OK return, else resend. */
|
/* try three times: send, read, test, if OK return, else resend. */
|
||||||
for(i = 0; i < 3; i++)
|
for(i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
/* send command, since it's an 'out' we don't get any response, so use writeRS232 */
|
/* send command, since it's an 'out' we don't get any response, so use writeRS232 */
|
||||||
iRet = writeRS232(self->controller,pCommand,strlen(pCommand));
|
iRet = writeRS232(self->controller,pCommand,strlen(pCommand));
|
||||||
|
usleep(500000);
|
||||||
//writeRS232(self->controller,pReply,strlen(pReply)); // MJL DEBUG
|
//writeRS232(self->controller,pReply,strlen(pReply)); // MJL DEBUG
|
||||||
if(iRet != 1)
|
if(iRet != 1)
|
||||||
{
|
{
|
||||||
@@ -318,20 +357,23 @@
|
|||||||
strcpy(self->pAns,pReply);
|
strcpy(self->pAns,pReply);
|
||||||
return LH45__BADCOM;
|
return LH45__BADCOM;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
/* read the set value again using the 'in' command */
|
/* read the set value again using the 'in' command */
|
||||||
iRet = transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131);
|
iRet = transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131);
|
||||||
|
pReplyStart=ReplyStart(pReply);
|
||||||
|
usleep(500000);
|
||||||
//writeRS232(self->controller,pReply,strlen(pReply)); // MJL DEBUG
|
//writeRS232(self->controller,pReply,strlen(pReply)); // MJL DEBUG
|
||||||
if(iRet <= 0)
|
if(iRet <= 0)
|
||||||
{
|
{
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
if(pReply[0] == '-'&&strlen(pReply)>7) // Not a number (-XXX.X\r), probably an error response
|
if(pReplyStart == '-'&&strlen(pReplyStart)>7) // Not a number (-XXX.X\r), probably an error response
|
||||||
{
|
{
|
||||||
strcpy(self->pAns,pReply);
|
strcpy(self->pAns,pReplyStart);
|
||||||
return LH45__BADCOM;
|
return LH45__BADCOM;
|
||||||
}
|
}
|
||||||
/* Convert the value read back. */
|
/* Convert the value read back. */
|
||||||
iRet=sscanf(pReply,"%f",&fRead);
|
iRet=sscanf(pReplyStart,"%f",&fRead);
|
||||||
if(iRet != 1)
|
if(iRet != 1)
|
||||||
{
|
{
|
||||||
return LH45__BADREAD;
|
return LH45__BADREAD;
|
||||||
@@ -341,6 +383,11 @@
|
|||||||
if(fDelta < 0)
|
if(fDelta < 0)
|
||||||
fDelta = -fDelta;
|
fDelta = -fDelta;
|
||||||
if(fDelta < fPrecision)
|
if(fDelta < fPrecision)
|
||||||
|
{
|
||||||
|
sprintf(pCommand,"OUT_MODE_05 1");
|
||||||
|
iRet = writeRS232(self->controller, pCommand,strlen(pCommand));
|
||||||
|
usleep(500000);
|
||||||
|
if(iRet == 1)
|
||||||
{
|
{
|
||||||
/* Success, but check the LH45 operating status afterwards, and return */
|
/* Success, but check the LH45 operating status afterwards, and return */
|
||||||
/* Don't bother to repeat the write if we get an error here as it would indicate
|
/* Don't bother to repeat the write if we get an error here as it would indicate
|
||||||
@@ -349,6 +396,7 @@
|
|||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return LH45__BADSET;
|
return LH45__BADSET;
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*--------------------------------------------------------------------------
|
/*---------------------------------------------------------------------
|
||||||
L H 4 5 D R I V
|
L H 4 5 D R I V
|
||||||
|
|
||||||
This file contains the implementation of a driver for the Julabo
|
This file contains the implementation of a driver for the Julabo
|
||||||
@@ -191,7 +191,6 @@
|
|||||||
static int LH45Close(pEVDriver self)
|
static int LH45Close(pEVDriver self)
|
||||||
{
|
{
|
||||||
pLH45Driv pMe = NULL;
|
pLH45Driv pMe = NULL;
|
||||||
int iRet;
|
|
||||||
|
|
||||||
assert(self);
|
assert(self);
|
||||||
pMe = (pLH45Driv )self->pPrivate;
|
pMe = (pLH45Driv )self->pPrivate;
|
||||||
@@ -253,12 +252,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
static int LH45Halt(pEVDriver *self)
|
// static int LH45Halt(pEVDriver *self)
|
||||||
{
|
// {
|
||||||
assert(self);
|
// assert(self);
|
||||||
|
//
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
void KillLH45(void *pData)
|
void KillLH45(void *pData)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user