Changes for page EPICS
Last modified by Sebastian Marsching on 2023/02/27 22:56
From version 2.1
edited by Sebastian Marsching
on 2023/02/27 22:56
on 2023/02/27 22:56
Change comment:
There is no comment for this version
To version 1.2
edited by Sebastian Marsching
on 2022/04/03 13:57
on 2022/04/03 13:57
Change comment:
Added tag [Network]
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,43 +1,5 @@ 1 1 {{toc/}} 2 2 3 -# EPICS Base 4 - 5 -## Extracting the upper 32 bits from a 64-bit integer 6 - 7 -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. 8 - 9 -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. 10 - 11 - record(int64in, "$(P)$(R)MyRegister") { 12 - field(FLNK, "$(P)$(R)MyRegister:Low") 13 - } 14 - 15 - record(mbbiDirect, "$(P)$(R)MyRegister:Low") { 16 - field(DTYP, "stream") 17 - field(INP, "$(P)$(R)MyRegister MSI") 18 - field(FLNK, "$(P)$(R)MyRegister:CalcHigh") 19 - } 20 - 21 - # This looks a bit strange, but it is a reliable way of extracting the upper 22 - # 32 bits of the 64 bit register. This works, because the value is implicitly 23 - # converted to a double, which preserves the upper 52 bits of the original 24 - # value. From this value, we have to substract the unsigned value of the lower 25 - # 32 bits (if we didn’t do this, we would get an off-by-one error under certain 26 - # circumstances due to rounding), and then we can right-shift by 32 bits (which 27 - # we have to do through division for a floating point number). Finally, we cut 28 - # off any fractional parts that might be left due to rounding. 29 - record(calc, "$(P)$(R)MyRegister:CalcHigh") { 30 - field(CALC, "FLOOR((A-(B+((B<0)?(2^32):0)))/(2^32))") 31 - field(INPA, "$(P)$(R)MyRegister MSI") 32 - field(INPB, "$(P)$(R)MyRegister:Low MSI") 33 - field(FLNK, "$(P)$(R)MyRegister:High") 34 - } 35 - 36 - record(mbbiDirect, "$(P)$(R)MyRegister:High") { 37 - field(DTYP, "stream") 38 - field(INP, "$(P)$(R)MyRegister:CalcHigh MSI") 39 - } 40 - 41 41 # EDM 42 42 43 43 In addition to the dependencies for MEDM I had to install the following packages: ... ... @@ -104,4 +104,6 @@ 104 104 #define ASYN_TRACEIO_ASCII 0x0001 105 105 #define ASYN_TRACEIO_ESCAPE 0x0002 106 106 #define ASYN_TRACEIO_HEX 0x0004 69 + 70 + 107 107 ```