EPICS

Last modified by Sebastian Marsching on 2023/02/27 22:56

EPICS Base

Extracting the upper 32 bits from a 64-bit integer

Sometimes, it is necessary to extract individual bits from a 64-bit integer (e.g. one that is read from a hardware register through the int64in record). This is possible through some calc record magic.

Please note that this depends on some internal casting behavior, so it might not work on all platforms. It has been tested to work successfully with EPICS Base 7.0.6 running x86_64 Linux, but it seems like it does not work with the same version of EPICS running on ARM Linux.

record(int64in, "$(P)$(R)MyRegister") {
  field(FLNK, "$(P)$(R)MyRegister:Low")
}

record(mbbiDirect, "$(P)$(R)MyRegister:Low") {
  field(DTYP, "stream")
  field(INP,  "$(P)$(R)MyRegister MSI")
  field(FLNK, "$(P)$(R)MyRegister:CalcHigh")
}

# This looks a bit strange, but it is a reliable way of extracting the upper
# 32 bits of the 64 bit register. This works, because the value is implicitly
# converted to a double, which preserves the upper 52 bits of the original
# value. From this value, we have to substract the unsigned value of the lower
# 32 bits (if we didn’t do this, we would get an off-by-one error under certain
# circumstances due to rounding), and then we can right-shift by 32 bits (which
# we have to do through division for a floating point number). Finally, we cut
# off any fractional parts that might be left due to rounding.
record(calc, "$(P)$(R)MyRegister:CalcHigh") {
  field(CALC, "FLOOR((A-(B+((B<0)?(2^32):0)))/(2^32))")
  field(INPA, "$(P)$(R)MyRegister MSI")
  field(INPB, "$(P)$(R)MyRegister:Low MSI")
  field(FLNK, "$(P)$(R)MyRegister:High")
}

record(mbbiDirect, "$(P)$(R)MyRegister:High") {
  field(DTYP, "stream")
  field(INP,  "$(P)$(R)MyRegister:CalcHigh MSI")
}

EDM

In addition to the dependencies for MEDM I had to install the following packages:

  • libgif-dev
  • libpng-dev
  • libxtst-dev

Under Ubuntu 14.04 LTS I had to modify the file extensions/configure/os/CONFIG_SITE.linux-x86_64.linux-x86_64 in order to make X11_LIB and MOTIF_LIB to point to /usr/lib/x86_64-linux-gnu. In addition to that I had to modify the file edmMain/Makefile and add the line USR_LDFLAGS_Linux += -Wl,--no-as-needed as described on the EPICS mailing-list.

MEDM

Compiling MEDM on Ubuntu 10.04 LTS (lucid lynx)

If EPICS base is installed in /my/epics/path/base, you should extract the EPICS extensions top directory bundle to /my/epics/path, so that a new directory /my/epics/path/extensions is created. The MEDM source archive should be extracted to /my/epics/path/extensions/src. You should then switch to /my/epics/path/extensions/src/medm3_1_5 and run make.

In addition to a lot of development packages I had already installed, I had to install the following packages:

  • libmotif-dev
  • libxmu-dev
  • libxp-dev
  • libxt-dev
  • x11proto-print-dev

synApps

Compiling synApps on Ubuntu 10.04 LTS (lucid lynx)

In order to compile synApps 5.5 on Ubuntu 10.04 LTS, I had to install the following packages (other packages might be needed as well):

  • flex
  • libusb-dev

In order to compile synApps 5.6 on Ubuntu 10.04 LTS, I had to install the following packages (other packages might be needed as well):

  • re2c
  • libbz2-dev
  • libfreetype6-dev
  • libpng-dev
  • libusb-dev
  • libxext-dev
  • libxml2-dev

StripTool

In addition to the dependencies listed for EDM and MEDM I had to install the following packages:

  • libxpm-dev

Asyn

Codes for Tracing I/O Operations

/* traceMask definitions*/
#define ASYN_TRACE_ERROR     0x0001
#define ASYN_TRACEIO_DEVICE  0x0002
#define ASYN_TRACEIO_FILTER  0x0004
#define ASYN_TRACEIO_DRIVER  0x0008
#define ASYN_TRACE_FLOW      0x0010

/* traceIO mask definitions*/
#define ASYN_TRACEIO_NODATA 0x0000
#define ASYN_TRACEIO_ASCII  0x0001
#define ASYN_TRACEIO_ESCAPE 0x0002
#define ASYN_TRACEIO_HEX    0x0004