Professional Documents
Culture Documents
Em C Code For IOCs
Em C Code For IOCs
Contents
vxWorks intro
Major differences between vxWorks and Unix/Linux
Using the vxWorks shell
Programming techniques
Contents
vxWorks intro
Major differences between vxWorks and Unix/Linux
Using the vxWorks shell
Programming techniques
Type rmc
vxWorks help
Examples
Calling functions
printf (String: %s, number: %d\n, str, drvXyDebug)
Contents
vxWorks intro
Major differences between vxWorks and Unix/Linux
Using the vxWorks shell
Programming techniques
Wrong
Right
/* internal variable */
int card_count;
/* internal variable */
static int card_count;
/* external variable */
int debug=0;
/* external variable */
int drvXyDebug=0;
Wrong
/* values for one card */
static char* addr;
static int ivec;
Right
/* linked list */
struct drvPriv {
struct drvPriv *next;
char* addr;
int ivec;
} drvPriv;
static drvPriv *first=NULL;
Be paranoid!
Contents
vxWorks intro
Major differences between vxWorks and Unix/Linux
Using the vxWorks shell
Programming techniques
<subRecord.h>
<callback.h>
<taskLib.h>
<semLib.h>
<errno.h>
here
"SynApps"
Contents
vxWorks intro
Major differences between vxWorks and Unix/Linux
Using the vxWorks shell
Programming techniques
record type
DTYP string
<recGbl.h>
<devSup.h>
<alarm.h>
<dbAccess.h>
<waveformRecord.h>
}
return 0;
Contents
vxWorks intro
Major differences between vxWorks and Unix/Linux
Using the vxWorks shell
Programming techniques
C-like syntax
Understands many C functions and statements
Escapes to "real" C-code for special occasions
Using SNL
start
state "cold"
[temp>25.3] /
cooling on
[temp<22] /
cooling off
state "hot"
program coolingswitch
int cooling;
assign cooling to "{DEV}:COOLING";
double temp;
assign temp to "{DEV}:TEMP";
monitor temp;
ss coolingswitch {
state cold {
when (temp>25.3) {
cooling = 1;
pvPut(cooling);
} state hot
}
state hot {
when (temp<22.0) {
cooling = 0;
pvPut(cooling);
} state cold
}
}
especially #include
%
Avoid accessing "global" SNL
variables from within escaped
C code.
program calculator
%%#include <math.h>
%{
void myCalc(
double i1,
double i2,
double* o1,
double* o2)
{
*o1 = sin(i1 + i2);
*o2 = cos(i1 i2);
}
}%
Implementation depends on
"+r" flag
Advanced EPICS Training, Dirk Zimoch 2009
"Abusing" SNL
for calculations
start
idle
[newInput] / myCalc()
double in1;
double in2;
double out1;
double out2;
assign in1 to "{DEV}:INPUT1";
assign in2 to "{DEV}:INPUT2";
assign out1 to "{DEV}:OUTPUT1";
assign out2 to "{DEV}:OUTPUT2";
monitor in1;
monitor in2;
evflag newInput;
sync in1 to newInput;
sync in2 to newInput;
ss calculator {
state idle {
when (efTestAndClear(newInput)) {
myCalc(in1, in2, &out1, &out2);
pvPut(out1);
pvPut(out2);
} state idle
}
}
Contents
vxWorks intro
Major differences between vxWorks and Unix/Linux
Using the vxWorks shell
Programming techniques
Other systems
Embedded Linux on Virtex 4, Cosylab microIOC,
Global module
Commonly used code (device
driver, record type, )
Installed into global driver pool
with make install
Can be used by everyone
Gets version number from CVS tag
CVS location: G/DRV/
Can be loaded with require
Local module
Locally used code (SNL,
sub/genSub functions, )
Installed to IOC boot directory
with swit
No interference with other modules
Does not need version numbers
CVS location: A, X, F, P
Can be loaded with require
"hytec","1"
"hytec","1.4"
"hytec","1.4.2"
"hytec","test"
Using driver.makefile
Configuring driver.makefile
Why overwriting?
Files are not all in the same directory as the Makefile.
Not all files should be used.
Configuring driver.makefile
Why overwriting?
I don't like directory name.
Directory name contains illegal characters like or space.
only alphanumeric plus underscore allowed
Advanced EPICS Training, Dirk Zimoch 2009
Configuring driver.makefile
Configuring driver.makefile
Why overwriting?
Module should be used on other OS than vxWorks.
genSub or SNL code for Linux IOCs
Configuring driver.makefile
Why overwriting?
Module is a lower level driver on that other drivers may depend
For example asyn or ipac
Only important for global modules
Local modules are not installed for use by others
Advanced EPICS Training, Dirk Zimoch 2009
Make targets
make uninstall
Cleanly (!) removes global module from driver pool
make help
Prints some help
Advanced EPICS Training, Dirk Zimoch 2009
Using require
require
"xxx"
require
"xxx","2.1"
Loads version 2.1 of library and dbd file (only for global modules)
xxxLib-2.1, xxxLib-2.1.munch, libxxx-2.1.so, or xxx-2.1.dll
require
"xxx","test"
Location of headers:
$INSTBASE/iocBoot/<EPICS_VERSION>/include