Commit 54bc47bd authored by koennecke's avatar koennecke
Browse files

Added a setswitch command to the SPS S7 code

Fixed priority in epicsadapter
parent 058d8c78
......@@ -115,7 +115,7 @@ static int makeEPICSContext(void *message, void *userData)
epicsTaskID = TaskRegisterN(pServ->pTasker,
"epics",
EpicsTask,
NULL,NULL,NULL,TASK_PRIO_MED
NULL,NULL,NULL,TASK_PRIO_LOW
);
}
return MPCONTINUE;
......
......@@ -15,6 +15,10 @@
* Updated to use long names to avoid collisions
*
* Mark Koennecke, May 2017
*
* Updated to write switches directly. Not how it should be ... but ...
*
* Mark Koennecke, June 2018
*/
#include <sics.h>
#include <sicsobj.h>
......@@ -445,9 +449,6 @@ static void InitializeSwitches(pS7Action self)
switches = GetHipadabaNode(self->spsNode,"switches");
assert(switches != NULL);
/*
* TODO: Add write callbacks to switches
*/
node = switches->child;
while(node != NULL){
AppendHipadabaCallback(node,
......@@ -522,6 +523,42 @@ static int S7UpdateCmd(pSICSOBJ ccmd, SConnection * con,
SCSendOK(con);
return 1;
}
/*-------------------------------------------------------------------------*/
static int S7SetSwitchCmd(pSICSOBJ ccmd, SConnection * con,
Hdb * cmdNode, Hdb * par[], int nPar)
{
pSPSS7 self = (pSPSS7)ccmd->pPrivate;
unsigned int offset, size;
unsigned char value;
pS7Action writeAction = NULL;
if(nPar < 3) {
SCWrite(con,"ERROR: not enough parameters for setswitch: offset, size, value required",
eError);
return 0;
}
offset = par[0]->value.v.intValue;
size = par[1]->value.v.intValue;
value = par[2]->value.v.intValue;
writeAction = calloc(1,sizeof(S7Action));
if(writeAction == NULL){
SCWrite(con, "ERROR: out of memory in S7WriteCallback", eError);
return 0;
}
writeAction->sps = self;
writeAction->pCon = con;
writeAction->spsNode = ccmd->objectNode;
MakeWriteMessage(writeAction,offset,size*2,&value);
DevQueue(self->devser, writeAction, WritePRIO,
S7WriteHandler, S7ActionMatch, free, NULL);
SCSendOK(con);
return 1;
}
/*---------------------------------------------------------------------*/
static void KillSPSS7(void *data)
{
......@@ -543,6 +580,7 @@ int MakeSPSS7(SConnection * con, SicsInterp * sics,
char *devArgs[3];
pS7Action initAction = NULL, updateAction = NULL,
initSwitchAction = NULL;
pHdb child = NULL;
int status;
......@@ -604,6 +642,13 @@ int MakeSPSS7(SConnection * con, SicsInterp * sics,
AddSICSHdbPar(pNew->objectNode,
"update", usSpy, MakeSICSFunc(S7UpdateCmd));
child = AddSICSHdbPar(pNew->objectNode,
"setswitch", usUser, MakeSICSFunc(S7SetSwitchCmd));
AddSICSHdbPar(child, "offset", usUser, MakeHdbInt(2));
AddSICSHdbPar(child, "size", usUser, MakeHdbInt(1));
AddSICSHdbPar(child, "value", usUser, MakeHdbInt(0));
AddHipadabaChild(pNew->objectNode,
MakeSICSROPar("init",MakeHdbInt(0)),NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment