From f3d95891ad1c2969fe68fe2e72502be0f3b6965c Mon Sep 17 00:00:00 2001 From: zolliker Date: Wed, 20 Oct 2021 17:06:55 +0200 Subject: [PATCH] avoid multiple running drive tasks for the same object --- devexec.c | 2 ++ event.h | 1 + interface.c | 15 +++++++++++++++ interface.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/devexec.c b/devexec.c index 261cb8a1..3746f5c6 100644 --- a/devexec.c +++ b/devexec.c @@ -279,6 +279,8 @@ int StartDevice(pExeList self, char *name, pObjectDescriptor pDes, return 0; } + EndDriveTask(pData); /* BEGIN experimental: stop pending drive task for this objects immediately */ + SetDevexecStatus(self,DEVDONE); if(self->waitID < 0 && level == RUNDRIVE){ self->waitID = GetTaskGroupID(pServ->pTasker); diff --git a/event.h b/event.h index 4e6556e9..55484539 100644 --- a/event.h +++ b/event.h @@ -70,6 +70,7 @@ typedef struct { #define TOKENRELEASE 303 #define COMLOG 304 #define CRONFUNC 305 +#define ENDDRIVETASK 306 #line 131 "event.w" diff --git a/interface.c b/interface.c index c0a7a129..de9febc6 100644 --- a/interface.c +++ b/interface.c @@ -224,9 +224,23 @@ static void DriveTaskSignal(void *data, int iSignal, void *pSigData) taskData->pDriv->Halt(taskData->obj); SCSetInterrupt(taskData->pCon,*interrupt); } + } else if (iSignal == ENDDRIVETASK) { + if (taskData->obj == pSigData) { + taskData->pDriv = NULL; /* tell DriveTaskFunc to quit */ + } } } /*--------------------------------------------------------------------------*/ +void EndDriveTask(void *obj) { + /* End a drive task for obj. + Originally in SICS, it was not possible to run an object already running + this was relaxed in SEA, but with the downside, that several drive tasks + for the same object may be running, removed only when the run succeds. + This is called in StartDevice, before creating a new drive task. + */ + TaskSignal(pServ->pTasker, ENDDRIVETASK, obj); +} +/*--------------------------------------------------------------------------*/ static int DriveTaskFunc(void *data) { DriveTaskData *taskData = (DriveTaskData *)data; @@ -234,6 +248,7 @@ static int DriveTaskFunc(void *data) assert(taskData != NULL); + if (!taskData->pDriv) return 0; status = taskData->pDriv->CheckStatus(taskData->obj,taskData->pCon); if(status == HWBusy){ diff --git a/interface.h b/interface.h index db99c1f0..f4be4da6 100644 --- a/interface.h +++ b/interface.h @@ -48,6 +48,8 @@ float *fPos); long StartDriveTask(void *self, SConnection *pCon, char *name, float fTarget); + void EndDriveTask(void *data); + /* end a drive task replaced by a new one with the same object*/ #line 438 "interface.w"