Porting EtherIP to EPICS 3.14 Usage at SPEAR IOC Software Porting Notes

Download Report

Transcript Porting EtherIP to EPICS 3.14 Usage at SPEAR IOC Software Porting Notes

Stanford Linear Accelerator Center
Porting EtherIP to EPICS 3.14
Usage at SPEAR
• IOC Software
• Porting Notes
3.13/3.14 Sharing
•
•
Stephanie Allison
EPICS Meeting
June, 2003
1
EtherIP at SPEAR
AB ControlLogix Crates
AB Remote IO
Accelerator MPS
IOC
E
N
E
T
P
L
C
C
N
E
T
3 RIO Crates,
3 PanelViews
ControlNet
PC/
RSLogix
EtherNet
Beamline MPS
E
N
E
T
P
L
C
C
N
E
T
Beamline
RIO Crates
ControlNet
WEB
Kicker Control
(Future)
E
N
E
T
PLC/
FlexLogix
3 Kickers
EtherIP IOC Software
Host
Tester
IOC
Events, Mutexs
Scan Threads,
iocsh
PLC 1 Thread
Data Structs
.
.
.
TCP/IP
Time
PLC n Thread
Stephanie Allison
EPICS Meeting
June, 2003
ENET 1 Module
.
.
.
ENET n Module
3
Port from VxWorks to OSI
•
•
•
•
•
•
•
Kay Kasemir supportive – nice collaboration
Most work in driver – not device support
Test on Unix first, then checkout on RTEMS
Timing and semaphores most work
Existing diagnostics great help, web interface useful
Function registration for iocsh
C++ considerations
Stephanie Allison
EPICS Meeting
June, 2003
4
Port from VxWorks to OSI
(cont)
•
•
•
•
Not much work for sockets – add
TCP_NODELAY option
On RTEMS, may need to increase packet
limit (max_interrupt_work) from 20 to 40
“connectWithTimeout” is needed in osiSock!
Change documentation a little
Stephanie Allison
EPICS Meeting
June, 2003
5
Share Source for 3.13/3.14?
•
•
•
•
•
Use EPICS_VERSION and EPICS_REVISION, mostly
in include files to set other macros (code more
readable)
Setup macros to make 3.13 look like 3.14
Maintain both config and configure directories with
the package
Maintain both Makefile (3.14) and Makefile.Vx (3.13)
Change Makefile to build 3.14 if EPICS_HOST_ARCH
is set, otherwise 3.13
Stephanie Allison
EPICS Meeting
June, 2003
6
#if EPICS_VERSION >= 3 && EPICS_REVISION >= 14
#include
#include
#include
#include
"epicsMutex.h"
"epicsEvent.h"
"epicsThread.h"
"epicsTime.h"
/* For timing */
#define EIP_TIME_CONVERSION
#define EIP_MIN_DELAY
#define EIP_MIN_TIMEOUT
#define EIP_MIN_CONN_TIMEOUT
#define EIP_SHORT_TIMEOUT
#define EIP_MEDIUM_TIMEOUT
#define EIP_LONG_TIMEOUT
#define EIP_TIME_GET(A)
#define EIP_TIME_DIFF(A,B)
#define EIP_TIME_ADD(A,B)
1.0 /* sec/sec */
0.02 /* second */
0.1 /* second */
1.0 /* second */
1.0 /* second */
2.0 /* second */
5.0 /* second */
epicsTimeGetCurrent(&(A))
epicsTimeDiffInSeconds(&(A),&(B))
epicsTimeAddSeconds(&(A),(B))
/* For event and mutex */
#define EIP_SEMOPTS
epicsEventFull
#define epicsMutexLockWithTimeout(A,B) epicsMutexLock(A)
#else /* begin 3.13 settings */
#include <taskLib.h>
#include "devLib.h"
#define S_db_noMemory
S_dev_noMemory
/* For timing */
#define EIP_TIME_CONVERSION sysClkRateGet()
/* tick/sec */
#define EIP_MIN_DELAY
0
/* ticks */
#define EIP_MIN_TIMEOUT
10
/* ticks */
#define EIP_MIN_CONN_TIMEOUT 100
/* ticks */
#define EIP_SHORT_TIMEOUT
EIP_TIME_CONVERSION
/* ticks in 1 sec
#define EIP_MEDIUM_TIMEOUT (2*EIP_TIME_CONVERSION) /* ticks in 2 sec
#define EIP_LONG_TIMEOUT
(5*EIP_TIME_CONVERSION) /* ticks in 5 sec
#define epicsTimeStamp
ULONG
/* all times in ticks
#define EIP_TIME_GET(A)
(A=tickGet())
/* current time in ticks
#define EIP_TIME_DIFF(A,B) ((double)(A)-(double)(B)) /* time diff
#define EIP_TIME_ADD(A,B) (A+=(ULONG)(B))
/* time add
*/
*/
*/
*/
*/
*/
*/
/* For event and mutex */
#define epicsMutexId
SEM_ID
#define epicsMutexLockStatus
int
#define epicsMutexLockOK
OK
#define epicsEventId
SEM_ID
#define epicsEventWaitStatus
int
#define epicsEventWaitOK
OK
/* semaphore options (mutex) */
#define EIP_SEMOPTS (SEM_Q_PRIORITY|SEM_DELETE_SAFE|SEM_INVERSION_SAFE)
#define epicsMutexCreate()
semMCreate(EIP_SEMOPTS)
#define epicsMutexDestroy
semDelete
#define epicsMutexUnlock
semGive
#define epicsMutexLock(A)
semTake(A,WAIT_FOREVER)
#define epicsMutexLockWithTimeout(A,B) semTake(A,B)
#define epicsMutexTryLock(A)
semTake(A,NO_WAIT)
#define epicsEventCreate
semMCreate
#define epicsEventDestroy
semDelete
#define epicsEventWaitWithTimeout
semTake
#define epicsEventSignal
semGive
/* For threads */
#define epicsThreadSleep(A)
#define epicsThreadId
#endif /* end 3.13 settings */
taskDelay((int)A)
int