diff --git a/tecsdriv.c b/tecsdriv.c index 42024e95..a15d71a5 100644 --- a/tecsdriv.c +++ b/tecsdriv.c @@ -57,6 +57,7 @@ #include "tecsdriv.h" #include "servlog.h" #include "sicsvar.h" +#include "tecs/coc_util.h" #include "tecs/tecs_cli.h" #include "tecs/str_util.h" #include "tecs/err_handling.h" @@ -85,7 +86,9 @@ int iRet; pEVDriver pD; pTecsDriv pMe; - char *dev; + char *result; + double fNum; + float fVal; self = (pEVControl)pData; assert(self); @@ -97,39 +100,37 @@ return EVControlWrapper(pCon,pSics,pData,argc,argv); } - strtolower(argv[1]); - if (strcmp(argv[1],"device") == 0) - { - if(argc > 2) /* set case */ - { - pD=self->pDriv; assert(pD); - pMe=pD->pPrivate; assert(pMe); - iRet=TeccSetDev(pMe->pData,argv[2]); - if (iRet<0) { - sprintf(pBueffel,"ERROR: %s",ErrMessage); - SCWrite(pCon,pBueffel,eError); - return 0; - } - return 1; - } - else /* get case */ - { - pD=self->pDriv; assert(pD); - pMe=pD->pPrivate; assert(pMe); - dev=TeccGetDev(pMe->pData); - if (dev==NULL) { - sprintf(pBueffel,"ERROR: %s",ErrMessage); - SCWrite(pCon,pBueffel,eError); - return 0; - } - sprintf(pBueffel,"%s.%s = %s\n",self->pName, - argv[1],dev); - SCWrite(pCon,pBueffel,eValue); - return 1; - } - } - else - { + strcpy(pBueffel, " "); + strcat(pBueffel, argv[1]); + strcat(pBueffel, " "); + strtolower(pBueffel); + if ( NULL==strstr(" log send list tolerance access errorhandler interrupt ", pBueffel) + && NULL==strstr(" upperlimit lowerlimit safevalue currentvalue targetvalue ", pBueffel) + ) { + + pD=self->pDriv; assert(pD); + pMe=pD->pPrivate; assert(pMe); + if(argc > 2) { /* set case */ + iRet=TeccSetPar(pMe->pData,argv[1],argv[2]); + if (iRet<0) { + sprintf(pBueffel,"ERROR: %s",ErrMessage); + SCWrite(pCon,pBueffel,eError); + return 0; + } + return 1; + } else { /* get case */ + result=TeccGetPar(pMe->pData,argv[1]); + if (result==NULL) { + sprintf(pBueffel,"ERROR: %s",ErrMessage); + SCWrite(pCon,pBueffel,eError); + return 0; + } + sprintf(pBueffel,"%s.%s = %s\n",self->pName, + argv[1],result); + SCWrite(pCon,pBueffel,eValue); + return 1; + } + } else { return EVControlWrapper(pCon,pSics,pData,argc,argv); } /* not reached */ @@ -148,20 +149,30 @@ assert(pMe); time(&now); - if (now>lastGet) { + if (now!=lastGet) { /* TecsGet was not yet called within this second */ lastGet=now; } else { - SicsWait(1); /* avoid extensive network traffic */ + CocDelay(500); /* wait 0.5 sec. (seems that SICS has nothing else to do then reading temperatures) */ + printf("usleep %d\n", now); } /* get temperature */ iRet = TeccGet(pMe->pData, fPos); - if(iRet < 0 ) - { + if (iRet > 1) { + if (pMe->iLastError==2) { + iRet=TeccWait(pMe->pData); + } else { + pMe->lastError = "configuring controller"; + pMe->iLastError=2; /* fixable */ + return 0; + } + } + if(iRet < 0) { pMe->lastError = ErrMessage; pMe->iLastError=1; /* severe */ return 0; } + pMe->lastError=0; return 1; } /*----------------------------------------------------------------------------*/