diff --git a/ease.c b/ease.c index c0c06a2..c2a2658 100644 --- a/ease.c +++ b/ease.c @@ -839,7 +839,7 @@ static int EaseInit(SConnection * pCon, EaseBase * eab, int argc, return -1; eab->task = FsmStartTask(eab, eab->handler, eab->idle, eab->p.name); - TaskRegister(pServ->pTasker, (TaskFunc) FsmTaskHandler, NULL, FsmKill, + TaskRegisterN(pServ->pTasker,"ease", (TaskFunc) FsmTaskHandler, NULL, FsmKill, eab->task, 0); return 1; } diff --git a/faverage.c b/faverage.c index 070f76c..6d5ccde 100644 --- a/faverage.c +++ b/faverage.c @@ -384,9 +384,7 @@ int MakeFA(SConnection * pCon, SicsInterp * pSics, void *pData, SCWrite(pCon, "ERROR: mbank value not found!", eError); } if (mbank == 1) { - pCom = FindCommand(pSics, "hm2"); - pDum = (pDummy) pCom->pData; - pNew->pHistogram2 = (pHistMem) pDum; + pNew->pHistogram2 = FindHM(pSics,"hm2"); } var1 = FindVariable(pServ->pSics, "lbank"); if (var1) { @@ -395,9 +393,7 @@ int MakeFA(SConnection * pCon, SicsInterp * pSics, void *pData, SCWrite(pCon, "ERROR: lbank value not found!", eError); } if (lbank == 1) { - pCom = FindCommand(pSics, "hm1"); - pDum = (pDummy) pCom->pData; - pNew->pHistogram1 = (pHistMem) pDum; + pNew->pHistogram1 = FindHM(pSics,"hm1"); } var3 = FindVariable(pServ->pSics, "ubank"); if (var3) { @@ -406,9 +402,7 @@ int MakeFA(SConnection * pCon, SicsInterp * pSics, void *pData, SCWrite(pCon, "ERROR: ubank value not found!", eError); } if (ubank == 1) { - pCom = FindCommand(pSics, "hm3"); - pDum = (pDummy) pCom->pData; - pNew->pHistogram3 = (pHistMem) pDum; + pNew->pHistogram3 = FindHM(pSics,"hm3"); } iRet = AddCommand(pSics, argv[1], FocusAverageDo, KillFA, pNew); if (!iRet) { diff --git a/jvlprot.c b/jvlprot.c index c1ecb84..ec74020 100644 --- a/jvlprot.c +++ b/jvlprot.c @@ -151,15 +151,10 @@ static int JVLHandler(Ascon *a) return 1; break; case AsconReading: - if(!validResponse(priv)){ - a->state = AsconWriteStart; - return 1; - } - if(time(NULL) > priv->start + a->timeout){ - a->state = AsconReadDone; - DynStringConcat(a->rdBuffer,"timeout"); - return 1; - } + /* if(!validResponse(priv)){ */ + /* a->state = AsconWriteStart; */ + /* return 1; */ + /* } */ ret = AsconReadChar(a->fd, &chr); if (ret < 0) { /* EINTR means we must retry */ @@ -170,6 +165,10 @@ static int JVLHandler(Ascon *a) *(priv->rdPtr) = (unsigned char)chr; priv->toRead--; priv->rdPtr++; + if(!validResponse(priv)){ + a->state=AsconWriteStart; + return 1; + } if(priv->toRead <= 0){ a->state = AsconReadDone; if(priv->reading){ @@ -190,6 +189,12 @@ static int JVLHandler(Ascon *a) } } } + } else { + if(time(NULL) > priv->start + a->timeout){ + a->state = AsconReadDone; + DynStringConcat(a->rdBuffer,"timeout"); + return 1; + } } return 1; break; diff --git a/make_gen b/make_gen index 397ed1e..1bf035d 100644 --- a/make_gen +++ b/make_gen @@ -14,7 +14,7 @@ OBJ=psi.o buffer.o ruli.o sps.o pimotor.o charbychar.o\ amorstat.o tasinit.o ptasdrive.o tasutil.o tasscan.o swmotor.o \ polterwrite.o ecb.o frame.o el734driv.o el734dc.o ecbdriv.o \ ecbcounter.o el737driv.o sinqhmdriv.o tdchm.o velodorn.o \ - velodornier.o docho.o sanscook.o tecsdriv.o itc4driv.o itc4.o\ + velodornier.o sanscook.o tecsdriv.o itc4driv.o itc4.o\ bruker.o ltc11.o A1931.o eurodriv.o slsmagnet.o \ el755driv.o serial.o scontroller.o t_update.o \ t_rlp.o t_conv.o el737hpdriv.o dornier2.o el734hp.o \ diff --git a/pardef.c b/pardef.c index f434caa..a170420 100644 --- a/pardef.c +++ b/pardef.c @@ -1088,7 +1088,7 @@ void ParOut(char *buf) buf); if (!ctx->obj->logPending) { ctx->obj->logPending = 1; - TaskRegister(pServ->pTasker, ParLog, NULL, NULL, ctx->obj, 0); /* schedule ParLog */ + TaskRegisterN(pServ->pTasker,"parlog", ParLog, NULL, NULL, ctx->obj, 0); /* schedule ParLog */ } break; case PAR_LOG: diff --git a/polterwrite.c b/polterwrite.c index bcf9987..cafd04b 100644 --- a/polterwrite.c +++ b/polterwrite.c @@ -71,7 +71,7 @@ static int Countstartcallback(int iEvent, void *pEventData, void *pUser) self->iEnd = 0; self->tUpdate = time(NULL); self->pCon = (SConnection *) pEventData; - TaskRegister(pServ->pTasker, PoldiTask, NULL, NULL, self, 1); + TaskRegisterN(pServ->pTasker,"POLDIUpdater", PoldiTask, NULL, NULL, self, 1); return 1; } return 1; diff --git a/psi.c b/psi.c index a36a320..e5e5285 100644 --- a/psi.c +++ b/psi.c @@ -311,8 +311,6 @@ static pVelSelDriv CreatePsiVelSelDriv(char *name, char *array, } /*------------------------------------------------------------------*/ -extern pCodri MakeDoChoDriver(char *pHost, int iPort, int iChannel, - int iSingle); extern pCodri MakeCookerDriver(char *pHost, int iPort, int iChannel); /*-------------------------------------------------------------------*/ static pCodri CreatePsiController(SConnection * pCon, int argc, @@ -323,39 +321,7 @@ static pCodri CreatePsiController(SConnection * pCon, int argc, int iPort, iChannel, iRet, iSingle = 0; char pBueffel[512]; - if (strcmp(argv[0], "docho") == 0) { - if (argc < 4) { - SCWrite(pCon, - "ERROR: Insufficient number of arguments to install Dornier Chopper driver", - eError); - return NULL; - } - iRet = Tcl_GetInt(pTcl, argv[2], &iPort); - if (iRet != TCL_OK) { - snprintf(pBueffel,511, "ERROR: expected integer as port number, got %s", - argv[2]); - SCWrite(pCon, pBueffel, eError); - return NULL; - } - iRet = Tcl_GetInt(pTcl, argv[3], &iChannel); - if (iRet != TCL_OK) { - snprintf(pBueffel,511, - "ERROR: expected integer as channel number, got %s", - argv[3]); - SCWrite(pCon, pBueffel, eError); - return NULL; - } - if (argc > 4) { - iRet = Tcl_GetInt(pTcl, argv[4], &iSingle); - if (iRet != TCL_OK) { - snprintf(pBueffel,511, - "ERROR: expected integer as single flag, got %s", argv[4]); - SCWrite(pCon, pBueffel, eError); - return NULL; - } - } - pNew = MakeDoChoDriver(argv[1], iPort, iChannel, iSingle); - } else if (strcmp(argv[0], "sanscook") == 0) { + if (strcmp(argv[0], "sanscook") == 0) { if (argc < 4) { SCWrite(pCon, "ERROR: Insufficient number of arguments to install SANS Cooker driver", diff --git a/sinq.c b/sinq.c index dd3645b..5703f49 100644 --- a/sinq.c +++ b/sinq.c @@ -125,7 +125,7 @@ int SinqFactory(SConnection * pCon, SicsInterp * pSics, for (i = 0; i < MAXLOG; i++) { pNew->lastSinq[i] = -200; } - TaskRegister(pServ->pTasker, SinqTask, NULL, NULL, pNew, 1); + TaskRegisterN(pServ->pTasker,"sinq", SinqTask, NULL, NULL, pNew, 1); return AddCommand(pSics, "sinq", SinqWrapper, KillSinq, pNew); } diff --git a/spss7.c b/spss7.c index a1be7f2..5d67c9a 100644 --- a/spss7.c +++ b/spss7.c @@ -16,8 +16,12 @@ #include #include #include + #define MAXDATA 65552 /* 64KB + 16 Byte for headers */ +#define NOTLOADED -10 +#define NOSWITCHES -20 + /*----------------------- private data structure --------------*/ typedef struct { DevSer *devser; @@ -448,8 +452,7 @@ static char *S7InitSwitchHandler(void *actionData, char *reply, int comerror) /* * Start: read length of the database */ - if(reply == NULL){ - self->sps->switchdblength = 0; + if(reply == NULL && self->sps->switchdblength == NOTLOADED){ MakeFetchMessage(self,self->sps->switchdbnum, 0,2); return self->message; } @@ -457,9 +460,13 @@ static char *S7InitSwitchHandler(void *actionData, char *reply, int comerror) /* * we are reading the database length */ - if(self->sps->switchdblength == 0){ + if(self->sps->switchdblength == NOTLOADED){ memcpy(&dblength, self->replyData+16,2); self->sps->switchdblength = ntohs(dblength); + if(self->sps->switchdblength == 0){ + self->sps->switchdblength = NOSWITCHES; + return NULL; + } MakeFetchMessage(self,self->sps->switchdbnum, 0,ntohs(dblength)); return self->message; @@ -471,7 +478,13 @@ static char *S7InitSwitchHandler(void *actionData, char *reply, int comerror) return NULL; } } - +/*-------------------------------------------------------------------*/ +static void KillS7Action(void *data) +{ + if(data != NULL){ + free(data); + } +} /*===================================================================*/ static int S7UpdateCmd(pSICSOBJ ccmd, SConnection * con, Hdb * cmdNode, Hdb * par[], int nPar) @@ -487,7 +500,7 @@ static int S7UpdateCmd(pSICSOBJ ccmd, SConnection * con, updateAction->sps = self; updateAction->spsNode = ccmd->objectNode; DevQueue(self->devser, updateAction, ProgressPRIO, - S7UpdateHandler, S7ActionMatch, free, NULL); + S7UpdateHandler, S7ActionMatch, KillS7Action, NULL); SCSendOK(con); return 1; } @@ -538,6 +551,7 @@ int MakeSPSS7(SConnection * con, SicsInterp * sics, self->dbnum = atoi(argv[2]); self->switchdbnum = atoi(argv[3]); + self->switchdblength = NOTLOADED; pNew = MakeSICSOBJv(argv[1],"SPS-S7", HIPNONE, usInternal); if(pNew == NULL){ @@ -581,13 +595,13 @@ int MakeSPSS7(SConnection * con, SicsInterp * sics, initSwitchAction->sps = self; initSwitchAction->spsNode = pNew->objectNode; DevQueue(self->devser, initSwitchAction, WritePRIO, - S7InitSwitchHandler, S7ActionMatch, free, NULL); + S7InitSwitchHandler, S7ActionMatch, KillS7Action, NULL); updateAction->sps = self; updateAction->spsNode = pNew->objectNode; DevSchedule(self->devser, updateAction, ReadPRIO, 60., - S7UpdateHandler, S7ActionMatch, free, NULL); + S7UpdateHandler, S7ActionMatch, KillS7Action, NULL); return 1; }