- Driver for the Risoe Temperature controller

- HM is now working
- display code added
This commit is contained in:
cvs
2003-02-14 13:00:28 +00:00
parent ac10723d74
commit 45a07c9ddc
18 changed files with 748 additions and 27 deletions

View File

@@ -32,8 +32,30 @@ int GPIBread(pGPIB self, int devID, void *buffer, int bytesToRead){
return self->read(devID, buffer,bytesToRead);
}
/*--------------------------------------------------------------------*/
char *GPIBreadTillTerm(pGPIB self, int devID, int terminator){
unsigned char buchstabe[2];
Tcl_DString buffer;
char *result = NULL;
int status;
Tcl_DStringInit(&buffer);
buchstabe[1] = '\0';
GPIBread(self,devID,buchstabe,1);
while(buchstabe[0] != (unsigned char)terminator){
Tcl_DStringAppend(&buffer,buchstabe,-1);
status = GPIBread(self,devID,buchstabe,1);
if(status != 1){
Tcl_DStringAppend(&buffer,"GPIB Read Error",-1);
break;
}
}
result = strdup(Tcl_DStringValue(&buffer));
Tcl_DStringFree(&buffer);
return result;
}
/*--------------------------------------------------------------------*/
void GPIBclear(pGPIB self, int devID){
return self->clear(devID);
self->clear(devID);
}
/*--------------------------------------------------------------------*/
void GPIBerrorDescription(pGPIB self, int code, char *buffer, int maxBuf){
@@ -83,8 +105,9 @@ int GPIBAction(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]){
pGPIB self = (pGPIB)pData;
int boardID, devID, tmo, count, eoi, eot, address,
secondaryAddress, status;
secondaryAddress, status, terminator;
char pBuffer[1024];
char *result = NULL;
assert(self != NULL);
@@ -151,11 +174,28 @@ int GPIBAction(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon,pBuffer,eError);
return 0;
}
} else if(strcmp(argv[1],"clear") == 0){
/*
clear command
*/
if(argc < 2){
SCWrite(pCon,"ERROR: insufficient number of arguments to clear",
eError);
return 0;
}
if(Tcl_GetInt(pSics->pTcl,argv[2],&devID) != TCL_OK){
SCWrite(pCon,"ERROR: failed to convert arguments to integer",
eError);
return 0;
}
GPIBclear(self,devID);
SCSendOK(pCon);
return 1;
} else if(strcmp(argv[1],"send") == 0){
/*
send command
*/
if(argc < 2){
if(argc < 4){
SCWrite(pCon,"ERROR: insufficient number of arguments to send",
eError);
return 0;
@@ -165,8 +205,38 @@ int GPIBAction(SConnection *pCon, SicsInterp *pSics, void *pData,
eError);
return 0;
}
Arg2Text(argc-2,argv+2,pBuffer,1023);
status = GPIBsend(self,devID,pBuffer, strlen(pBuffer));
Arg2Text(argc-3,argv+3,pBuffer,1023);
status = GPIBsend(self,devID,pBuffer, (int)strlen(pBuffer));
if(status > 0){
SCSendOK(pCon);
return 1;
} else {
sprintf(pBuffer,"ERROR: error %d on send", status);
SCWrite(pCon,pBuffer,eError);
return 0;
}
} else if(strcmp(argv[1],"sendwithterm") == 0){
/*
send command
*/
if(argc < 5){
SCWrite(pCon,"ERROR: insufficient number of arguments to sendwithterm",
eError);
return 0;
}
if(Tcl_GetInt(pSics->pTcl,argv[2],&devID) != TCL_OK){
SCWrite(pCon,"ERROR: failed to convert arguments to integer",
eError);
return 0;
}
if(Tcl_GetInt(pSics->pTcl,argv[4],&terminator) != TCL_OK){
SCWrite(pCon,"ERROR: failed to convert arguments to integer",
eError);
return 0;
}
strncpy(pBuffer,argv[3], 1024);
pBuffer[strlen(pBuffer)] = (char)terminator;
status = GPIBsend(self,devID,pBuffer, (int)strlen(pBuffer));
if(status > 0){
SCSendOK(pCon);
return 1;
@@ -198,6 +268,34 @@ int GPIBAction(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon,pBuffer,eError);
return 0;
}
} else if(strcmp(argv[1],"readtillterm") == 0){
/*
read command
*/
if(argc < 3){
SCWrite(pCon,"ERROR: insufficient number of arguments to read",
eError);
return 0;
}
if(Tcl_GetInt(pSics->pTcl,argv[2],&devID) != TCL_OK){
SCWrite(pCon,"ERROR: failed to convert arguments to integer",
eError);
return 0;
}
if(Tcl_GetInt(pSics->pTcl,argv[3],&terminator) != TCL_OK){
SCWrite(pCon,"ERROR: failed to convert arguments to integer",
eError);
return 0;
}
result = GPIBreadTillTerm(self,devID,terminator);
if(result != NULL){
SCWrite(pCon,result,eValue);
free(result);
return 1;
} else {
SCWrite(pCon,"ERROR: failed to read at GPIB",eError);
return 0;
}
} else {
SCWrite(pCon,"ERROR: command not recognized",eError);
return 0;