initial version of s7plcFW driver
This commit is contained in:
6
MODULE
Normal file
6
MODULE
Normal file
@ -0,0 +1,6 @@
|
||||
# Please change the following email with yours.
|
||||
Email: Damir.Anicic@psi.ch
|
||||
Module-Name: s7plcFW
|
||||
Description: s7plcFW - the same as Dirk's s7plc, but uses FETCH/WRITE instead of SEND/RECEIVE
|
||||
Project-Name:
|
||||
|
10
Makefile
Normal file
10
Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
include /ioc/tools/driver.makefile
|
||||
|
||||
#BUILDCLASSES+=Linux
|
||||
|
||||
DBDS += s7plcFWBase.dbd
|
||||
DBDS_3.14 += s7plcFWCalcout.dbd
|
||||
DBDS_3.14 += s7plcFWReg.dbd
|
||||
|
||||
EPICS_VERSIONS =
|
||||
EPICS_VERSIONS += 3.14.8
|
144
compat3_13.h
Normal file
144
compat3_13.h
Normal file
@ -0,0 +1,144 @@
|
||||
/* EPICS R3.13 compatibility header
|
||||
*
|
||||
* Including this header allows (some) EPICS R3.14 code to be compiled
|
||||
* with EPICS R3.13 for a vxWorks system using a GNU compiler.
|
||||
*
|
||||
* It replaces R3.14 headers
|
||||
* epicsTypes.h
|
||||
* epicsAssert.h
|
||||
* epicsString.h
|
||||
* epicsExport.h
|
||||
* epicsThread.h
|
||||
* epicsTimer.h
|
||||
* epicsMutex.h
|
||||
* epicsEvent.h
|
||||
* cantProceed.h
|
||||
*
|
||||
* It is not complete and only simulates the C interfaces (not C++).
|
||||
* It uses some gcc extensions and might not work with other compilers.
|
||||
* It requires vxWorks.
|
||||
* It might be buggy or produce slightly different behaviour than the
|
||||
* original R3.14 functions.
|
||||
*
|
||||
* Since all functions are simulated as macros, you might not be able to
|
||||
* take the address of a function. Be careful with arguments as they
|
||||
* might be evaluated multiple times.
|
||||
* This won't work: fptr = &epicsTimerStartDelay;
|
||||
* Don't do this (changing arg): epicsTimerStartDelay(*ptimer++, delay);
|
||||
*
|
||||
* You can take the address of
|
||||
* epicsMutexUnlock
|
||||
* epicsMutexDestroy
|
||||
* epicsEventSignal
|
||||
* epicsEventDestroy
|
||||
*
|
||||
* You have been warned.
|
||||
* Dirk Zimoch, March 2005
|
||||
*/
|
||||
|
||||
#ifndef compat3_13_h
|
||||
#define compat3_13_h
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <sysLib.h>
|
||||
#include <selectLib.h>
|
||||
|
||||
/* epicsAssert */
|
||||
#include <assert.h>
|
||||
|
||||
/* epicsString */
|
||||
#define epicsStrDup(s) strcpy(malloc(strlen(s)+1),(s))
|
||||
|
||||
/* epicsExport */
|
||||
#define epicsExportAddress(a,b) extern void avoid_compiler_warning
|
||||
|
||||
/* epicsThread */
|
||||
#include <taskLib.h>
|
||||
#define epicsThreadId void*
|
||||
#define EPICSTHREADFUNC FUNCPTR
|
||||
#define epicsThreadPriorityLow 10
|
||||
#define epicsThreadPriorityMedium 50
|
||||
#define epicsThreadPriorityHigh 90
|
||||
|
||||
#define epicsThreadCreate(name, pri, stack, func, args) \
|
||||
(void*)taskSpawn((name), 255-(pri)*255/99, VX_FP_TASK, (stack), (FUNCPTR)(func), (int)(args), \
|
||||
0,0,0,0,0,0,0,0,0)
|
||||
|
||||
#define epicsThreadSleep(sec) taskDelay((sec)*sysClkRateGet())
|
||||
#define epicsThreadIsSuspended(t) (taskIdVerify((int)(t)) || taskIsSuspended((int)(t)))
|
||||
|
||||
/* epicsTimer */
|
||||
#include <wdLib.h>
|
||||
#define epicsTimerQueueId char*
|
||||
#define epicsTimerQueueAllocate(a,b) NULL
|
||||
typedef void (*epicsTimerCallback) (void* pPrivate);
|
||||
typedef struct epicsTimerForC {WDOG_ID wd; FUNCPTR cb; int p;} *epicsTimerId;
|
||||
|
||||
#define epicsTimerQueueCreateTimer(q, callback, param) __extension__ \
|
||||
({ \
|
||||
epicsTimerId ti = calloc(1,sizeof(struct epicsTimerForC)); \
|
||||
ti->wd = wdCreate(); \
|
||||
ti->cb = (FUNCPTR)(callback); \
|
||||
ti->p = (int)(param); \
|
||||
ti; \
|
||||
})
|
||||
|
||||
#define epicsTimerStartDelay(ti,delay) \
|
||||
(void) wdStart((ti)->wd, (delay)*sysClkRateGet(), (ti)->cb, (ti)->p)
|
||||
|
||||
/* cantProceed */
|
||||
#define callocMustSucceed(n,s,m) __extension__ \
|
||||
({ \
|
||||
void *mem = calloc((n),(s)); \
|
||||
if (!mem) { printErr("FATAL: callocMustSucceed failed in %s line %d %s: \n", \
|
||||
__FILE__, __LINE__, (m), strerror(errno)); taskSuspend(0); } \
|
||||
mem; \
|
||||
})
|
||||
|
||||
/* epicsMutex */
|
||||
#include <semLib.h>
|
||||
#define epicsMutexId SEM_ID
|
||||
|
||||
#define epicsMutexMustCreate() __extension__ \
|
||||
({ \
|
||||
SEM_ID m = semMCreate(SEM_Q_FIFO); \
|
||||
if (!m) { printErr("FATAL: epicsMutexMustCreate failed in %s line %d: %s\n", \
|
||||
__FILE__, __LINE__, strerror(errno)); taskSuspend(0); } \
|
||||
m; \
|
||||
})
|
||||
|
||||
#define epicsMutexMustLock(m) \
|
||||
(semTake(m, WAIT_FOREVER) && \
|
||||
(printErr("FATAL: epicsMutexMustLock failed in %s line %d: %s\n", \
|
||||
__FILE__, __LINE__, strerror(errno)), \
|
||||
taskSuspend(0), ERROR))
|
||||
|
||||
#define epicsMutexUnlock semGive
|
||||
#define epicsMutexDestroy semDelete
|
||||
|
||||
/* epicsEvent */
|
||||
#define epicsEventId SEM_ID
|
||||
#define epicsEventEmpty SEM_EMPTY
|
||||
#define epicsEventFull SEM_FULL
|
||||
|
||||
#define epicsEventMustCreate(state) __extension__ \
|
||||
({ \
|
||||
SEM_ID e = semBCreate(SEM_Q_FIFO, state); \
|
||||
if (!e) { printErr("FATAL: epicsEventMustCreate failed in %s line %d: %s\n", \
|
||||
__FILE__, __LINE__, strerror(errno)); taskSuspend(0); } \
|
||||
e; \
|
||||
})
|
||||
|
||||
#define epicsEventMustWait(e) \
|
||||
(semTake(e, WAIT_FOREVER) && \
|
||||
(printErr("FATAL: epicsEventMustWait failed in %s line %d: %s\n", \
|
||||
__FILE__, __LINE__, strerror(errno)), \
|
||||
taskSuspend(0), ERROR))
|
||||
|
||||
#define epicsEventSignal semGive
|
||||
#define epicsEventWaitWithTimeout(e,t) semTake((e),(t)*sysClkRateGet())
|
||||
#define epicsEventWait(e) semTake((e),WAIT_FOREVER)
|
||||
#define epicsEventTryWait(e) semTake((e),NO_WAIT)
|
||||
#define epicsEventDestroy semDelete
|
||||
|
||||
#endif
|
2516
devS7plcFW.c
Normal file
2516
devS7plcFW.c
Normal file
File diff suppressed because it is too large
Load Diff
1055
drvS7plcFW.c
Normal file
1055
drvS7plcFW.c
Normal file
File diff suppressed because it is too large
Load Diff
78
drvS7plcFW.h
Normal file
78
drvS7plcFW.h
Normal file
@ -0,0 +1,78 @@
|
||||
/* $Author: anicic $ */
|
||||
/* $Date: 2010/09/22 13:44:37 $ */
|
||||
/* $Id: drvS7plcFW.h,v 1.1 2010/09/22 13:44:37 anicic Exp $ */
|
||||
/* $Name: $ */
|
||||
/* $Revision: 1.1 $ */
|
||||
|
||||
#ifndef drvS7plcFW_h
|
||||
#define drvS7plcFW_h
|
||||
|
||||
#include <dbScan.h>
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(a)
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG
|
||||
#define STATIC static
|
||||
#else
|
||||
#define STATIC
|
||||
#endif
|
||||
|
||||
/* driver initialisation define */
|
||||
|
||||
typedef struct s7plcFWStation s7plcFWStation;
|
||||
|
||||
extern int s7plcFWDebug;
|
||||
|
||||
void s7plcFWDebugLog(int level, const char *fmt, ...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
|
||||
s7plcFWStation *s7plcFWOpen(char *name);
|
||||
IOSCANPVT s7plcFWGetFetchScanPvt(s7plcFWStation *station);
|
||||
IOSCANPVT s7plcFWGetWriteScanPvt(s7plcFWStation *station);
|
||||
|
||||
int s7plcFWReadArray(
|
||||
s7plcFWStation *station,
|
||||
unsigned int offset,
|
||||
unsigned int dlen,
|
||||
unsigned int nelem,
|
||||
void* pdata
|
||||
);
|
||||
|
||||
int s7plcFWWriteMaskedArray(
|
||||
s7plcFWStation *station,
|
||||
unsigned int offset,
|
||||
unsigned int dlen,
|
||||
unsigned int nelem,
|
||||
void* pdata,
|
||||
void* pmask
|
||||
);
|
||||
|
||||
#define s7plcFWWriteArray(station, offset, dlen, nelem, pdata) \
|
||||
s7plcFWWriteMaskedArray((station), (offset), (dlen), (nelem), (pdata), NULL)
|
||||
|
||||
#define s7plcFWWriteMasked(station, offset, dlen, pdata, mask) \
|
||||
s7plcFWWriteMaskedArray((station), (offset), (dlen), 1, (pdata), (mask))
|
||||
|
||||
#define s7plcFWWrite(station, offset, dlen, pdata) \
|
||||
s7plcFWWriteMaskedArray((station), (offset), (dlen), 1, (pdata), NULL)
|
||||
|
||||
#define s7plcFWRead(station, offset, dlen, pdata) \
|
||||
s7plcFWReadArray((station), (offset), (dlen), 1, (pdata))
|
||||
|
||||
/************************************************************************/
|
||||
/* * DRV driver error codes */
|
||||
#define M_drvLib (1003<<16U)
|
||||
#define drvError(CODE) (M_drvLib | (CODE))
|
||||
|
||||
#define S_drv_OK 0 /* success */
|
||||
#define S_drv_badParam drvError(1) /*driver: bad parameter*/
|
||||
#define S_drv_noMemory drvError(2) /*driver: no memory*/
|
||||
#define S_drv_noDevice drvError(3) /*driver: device not configured*/
|
||||
#define S_drv_invSigMode drvError(4)/*driver: signal mode conflicts with device config*/
|
||||
#define S_drv_cbackChg drvError(5) /*driver: specified callback differs from previous config*/
|
||||
#define S_drv_alreadyQd drvError(6)/*driver: a read request is already queued for the channel*/
|
||||
#define S_drv_noConn drvError(7) /*driver: connection to plc lost*/
|
||||
|
||||
#endif /* drvS7plcFW_h */
|
1050
s7plcFW.html
Normal file
1050
s7plcFW.html
Normal file
File diff suppressed because it is too large
Load Diff
17
s7plcFWBase.dbd
Normal file
17
s7plcFWBase.dbd
Normal file
@ -0,0 +1,17 @@
|
||||
device(mbboDirect, INST_IO, s7plcFWMbboDirect, "S7plcFW")
|
||||
device(mbbiDirect, INST_IO, s7plcFWMbbiDirect, "S7plcFW")
|
||||
device(bi, INST_IO, s7plcFWBi, "S7plcFW")
|
||||
device(bo, INST_IO, s7plcFWBo, "S7plcFW")
|
||||
device(longin, INST_IO, s7plcFWLongin, "S7plcFW")
|
||||
device(longout, INST_IO, s7plcFWLongout, "S7plcFW")
|
||||
device(mbbo, INST_IO, s7plcFWMbbo, "S7plcFW")
|
||||
device(mbbi, INST_IO, s7plcFWMbbi, "S7plcFW")
|
||||
device(ao, INST_IO, s7plcFWAo, "S7plcFW")
|
||||
device(ai, INST_IO, s7plcFWAi, "S7plcFW")
|
||||
device(stringout, INST_IO, s7plcFWStringout, "S7plcFW")
|
||||
device(stringin, INST_IO, s7plcFWStringin, "S7plcFW")
|
||||
device(waveform, INST_IO, s7plcFWWaveform, "S7plcFW")
|
||||
device(bi, INST_IO, s7plcFWStat, "S7plcFW stat")
|
||||
device(bi, INST_IO, s7plcFWStat2,"S7plcFW stat2")
|
||||
driver(s7plcFW)
|
||||
|
1
s7plcFWCalcout.dbd
Normal file
1
s7plcFWCalcout.dbd
Normal file
@ -0,0 +1 @@
|
||||
device(calcout, INST_IO, s7plcFWCalcout, "S7plcFW")
|
3
s7plcFWReg.dbd
Normal file
3
s7plcFWReg.dbd
Normal file
@ -0,0 +1,3 @@
|
||||
registrar(s7plcFWRegister)
|
||||
variable(s7plcFWDebug, int)
|
||||
|
Reference in New Issue
Block a user