Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
sinqdev
sicspsi
Commits
54bc47bd
Commit
54bc47bd
authored
Jun 14, 2018
by
koennecke
Browse files
Added a setswitch command to the SPS S7 code
Fixed priority in epicsadapter
parent
058d8c78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
4 deletions
+49
-4
epicsadapter.c
epicsadapter.c
+1
-1
spss7.c
spss7.c
+48
-3
No files found.
epicsadapter.c
View file @
54bc47bd
...
...
@@ -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
;
...
...
spss7.c
View file @
54bc47bd
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment