見出し画像

RaspberryPiとUbuntuでEPICSはじめました#6 StreamDevice(インストール編)

この記事は、EPICS(Experimental Physics and Industrial Control System)の初学用にまとめた記事です。

RaspberryPi上でEPICSを動かしてGPIO制御ができるとことまで確認しました。
今回は、StreamDeviceを使用してみたいと考えています。

StreamDeviceとは?

StreamDeviceとは、「バイトストリーム」で動作するシステムをEPICSでサポートするシステムです。なぜ必要なのか?デフォルトのままではダメなのか?

「バイトストリーム」とは何か?「バイト単位のデータ」を意味しますが、制御機器の多くは人間にわかりやすくする為、ASCII文字列で扱うケースが多くこれらの制御をし易くする仕組みです。バイナリデータを扱うことも可能なので必ずしも文字列だけではないです。

必要なパッケージは?

まず実現方法は、StreamDeviceが必要になります。合わせてAsynも必須と最初から情報を提示しているサイトが多いですが、初学としてはここは一歩ずつ進みます。まずStreamDeviceをインストールしてみましょう。

StreamDeviceとは、epicsで使うデバイスの通信IFでバイトストリームの転送が可能です。

インストールするパッケージ

以降の手順では次のファイルのインストールを行いますが、試行錯誤の課程を記述しています。パッケージのインストールが目的の方は読み飛ばしてインストールを行うだけで良いかと思います。StreamDevice, Asyn, Sequencer, re2c,(pcre),clac,sscanとビルド用のm4, libtool, autoconfをインストールします。

今回使うパッケージのバージョンの組み合わせは私はRaspberryPi上のUbuntuでビルド確認しましたが他の環境でもほぼ同じではないでしょうか。

Ubuntu 20.04 LTS 
EPICS : 7.0.4
StreamDevice :  masterブランチ committed 4747bb5 on 29 May
Asyn : R4-38
Sequencer : 2.2.8
re2c : 1.3
pcre : 8.44 は今回は使わない。
sCalcout: R3-6-1
scan : R2-10

git clone https://github.com/paulscherrerinstitute/StreamDevice.git

wget https://epics.anl.gov/download/modules/asyn4-38.tar.gz
wget http://www-csr.bessy.de/control/SoftDist/sequencer/releases/seq-2.2.8.tar.gz
wget https://github.com/skvadrik/re2c/archive/1.3.zip
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.zip
wget https://github.com/epics-modules/calc/archive/R3-6-1.tar.gz
wget https://epics.anl.gov/bcda/synApps/tar/sscan_R2-10.tar.gz

sudo apt install m4
sudo apt install libtool
sudo apt install autoconf

インストール手順

マニュアル読まない派ですが、何度も失敗するので手順を確かめてからやってみます。

1. Prerequisites
Configuration
 mkdir top
 cd top
 makeBaseApp.pl -t support
 最初にディレクトリを作成してからmakeBaseApp.plを実行すると書いてある。

Support for asynDriver
 You most probably want asynDriver support included, 
 asynDriverのサポートが必要なのでインストールしましょう。

Support for sCalcout record
 The sCalcout record is part of synApps. If streamDevice should be built with support for this record, you have to install the calc module from SynApps first. Add references to the RELEASE file as shown here:
 sCalcoutレコードはsynAppsに含まれていて必要ならばインストールするって書いてあります。取り敢えずミニマムでインストールしたいのでなしとします。
って書いた後にそのまま入れてしまっていたので入れています。^^;
が、実際のアプリを作るとst.cmd実行時にエラーが多発するため、コメントアウトしましたのでStreamDeviceから外しています。

Support for regular expression matching
 If you want to enable regular expression matching, you need the PCRE package.
 正規表現マッチングが必要ならPCREパッケージが必要らしいのですが、よく分からないのでなしにします。

2. Build the StreamDevice Library
Unpack the StreamDevice package in the <top> directory of your application build area. (You might probably have done this already.) Go to the newly created StreamDevice directory and run make (or gmake). This will create and install the stream library and the stream.dbd file.
 StreamDeviceパッケージを先ほどのディレクトリに解凍する。そこでmakeするとstream.dbdが作られるとあります。

一応書かれている通りにやってみよう!
Configuration
ディレクトリ作成してmakeBaseApp.plですね。

# まずディレクト作成してmakeBaseApp.plです
epics@ubuntu:/opt/epics$ mkdir stream
epics@ubuntu:/opt/epics$ cd stream
epics@ubuntu:/opt/epics/stream$ makeBaseApp.pl -t support
Name the application(s) to be created.
Names given will have "App" appended to them.
Application names? 

Support for asynDriver
次にAsynですね。

R4-38をダウンロードしてインストールします。
ダウンロード用のディレクトを作成して/opt/epics/tmp
そこからインストールします。


# ダウンロード用ディレクトリを作成
epics@ubuntu:/opt/epics$ mkdir tmp

# ダウンロード
epics@ubuntu:/opt/epics$ cd tmp
epics@ubuntu:/opt/epics/tmp$ wget https://epics.anl.gov/download/modules/asyn4-38.tar.gz
...

# 展開する
epics@ubuntu:/opt/epics/tmp$ cd ..
epics@ubuntu:/opt/epics$ gzip -dc ./tmp/asyn4-38.tar.gz | tar xvf -
...
epics@ubuntu:/opt/epics$ cd asyn4-38

EPICS_BASEを修正して、asynをmakeします。

epics@ubuntu:/opt/epics/asyn4-38$ vi configure/RELEASE

修正箇所
# EPICS_BASE=/corvette/usr/local/epics-devel/base-7.0.3.1
EPICS_BASE=/opt/epics/base

でいきなりmakeはエラーになります。まあ当たり前なんですけど念のためやってみた。

epics@ubuntu:/opt/epics/asyn4-38$ make
...
make[3]: *** No rule to make target 'ipSNCServer.o', needed by 'libtestIPServerSupport.a'.  Stop.
make[3]: Leaving directory '/opt/epics/asyn4-38/testIPServerApp/src/O.linux-arm'
make[2]: *** [/opt/epics/base/configure/RULES_ARCHS:58: install.linux-arm] Error 2
make[2]: Leaving directory '/opt/epics/asyn4-38/testIPServerApp/src'
make[1]: *** [/opt/epics/base/configure/RULES_DIRS:85: src.install] Error 2
make[1]: Leaving directory '/opt/epics/asyn4-38/testIPServerApp'
make: *** [/opt/epics/base/configure/RULES_DIRS:85: testIPServerApp.install] Error 2
epics@ubuntu:/opt/epics/asyn4-38$ 

IPServerがないと言われます。これはSequencerが必要ということですね。
結局SequencerとAsynとStreamDeviceは一蓮托生のモジュールようです。

なので次はSequencerをインストールします。

re2cの記載があるがとりあえず前に前進あるのみ。結論から言うと先にイントールすることをお勧めします。

epics@ubuntu:/opt/epics$ /opt/epics/tmp
epics@ubuntu:/opt/epics/tmp$ wget http://www-csr.bessy.de/control/SoftDist/sequencer/releases/seq-2.2.8.tar.gz
...
epics@ubuntu:/opt/epics/tmp$ cd ..
epics@ubuntu:/opt/epics$ gzip -dc ./tmp/seq-2.2.8.tar.gz | tar xvf -
...
epics@ubuntu:/opt/epics$ ls
asyn4-38  base  base-7.0.4  seq-2.2.8  stream  tmp​

いつも通りにconfigure/RELASEのEPICS_BASEを修正します。


epics@ubuntu:/opt/epics/seq-2.2.8$ vi configure/RELEASE

修正箇所
# EPICS_BASE=/home/franksen/src/epics-base/3-14-12-5
EPICS_BASE=/opt/epics/base

epics@ubuntu:/opt/epics/seq-2.2.8$ make
...

make[3]: re2c: Command not found

あーって感じですね。re2cが必要な箇所が見つかりました。
さて・・・今までいくつエラーになっているか。。。とりあえず前に進みましょう。re2cは先ほどのHPに書かれていましたので辿ると。

epics@ubuntu:/opt/epics/seq-2.2.8$ cd ..
epics@ubuntu:/opt/epics$ cd tmp
epics@ubuntu:/opt/epics/tmp$ wget https://github.com/skvadrik/re2c/archive/1.3.zip
...

epics@ubuntu:/opt/epics/tmp$ cd ..
epics@ubuntu:/opt/epics$ unzip ./tmp/1.3.zip

configureがないのでautoreconfを実行・・・がない!のでまたインストールです。

epics@ubuntu:/opt/epics/re2c-1.3$ sudo apt install autoconf

さあ来た道を戻ります。まずre2cのビルドですが、Makefile.am、 Makefile.inになっているのでautoreconf が必要です。

epics@ubuntu:/opt/epics/re2c-1.3$ autoreconf -i -W all
aclocal: warning: couldn't open directory 'm4': No such file or directory
configure.ac:17: installing './compile'
configure.ac:2: installing './install-sh'
configure.ac:2: installing './missing'
Makefile.am:385: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:385:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:385:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:385:   If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:385:   its definition is in aclocal's search path.
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
autoreconf: automake failed with exit status: 1

m4とlibtoolが必要なのでと言われましたインストールします。

epics@ubuntu:/opt/epics/re2c-1.3$ sudo apt install m4
Reading package lists... Done
Building dependency tree       
Reading state information... Done
m4 is already the newest version (1.4.18-4).
m4 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

epics@ubuntu:/opt/epics/re2c-1.3$ sudo apt install libtool
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
 libltdl-dev
Suggested packages:
 libtool-doc gfortran | fortran95-compiler gcj-jdk
The following NEW packages will be installed:
 libltdl-dev libtool
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 323 kB of archives.
After this operation, 2177 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ports.ubuntu.com/ubuntu-ports focal/main arm64 libltdl-dev arm64 2.4.6-14 [162 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports focal/main arm64 libtool all 2.4.6-14 [161 kB]
Fetched 323 kB in 2s (146 kB/s)
Selecting previously unselected package libltdl-dev:arm64.
(Reading database ... 104179 files and directories currently installed.)
Preparing to unpack .../libltdl-dev_2.4.6-14_arm64.deb ...
Unpacking libltdl-dev:arm64 (2.4.6-14) ...
Selecting previously unselected package libtool.
Preparing to unpack .../libtool_2.4.6-14_all.deb ...
Unpacking libtool (2.4.6-14) ...
Setting up libtool (2.4.6-14) ...
Setting up libltdl-dev:arm64 (2.4.6-14) ...
Processing triggers for man-db (2.9.1-1) ...​

もう一度実行するとm4だけワーニングが残りましたが完了しているようです。

epics@ubuntu:/opt/epics/re2c-1.3$ autoreconf -i -W all
aclocal: warning: couldn't open directory 'm4': No such file or directory
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:135: installing './config.guess'
configure.ac:135: installing './config.sub'

epics@ubuntu:/opt/epics/re2c-1.3$ ./configure
...
epics@ubuntu:/opt/epics/re2c-1.3$ make
...

makeが済んだらmake installですが、sudoが必要です。

# うっかりmake installとやると怒られますので要注意。
epics@ubuntu:/opt/epics/re2c-1.3$ make install
make  install-am
make[1]: Entering directory '/opt/epics/re2c-1.3'
Reconfigure to rebuild docs: ./configure --enable-docs
make[2]: Entering directory '/opt/epics/re2c-1.3'
/usr/bin/mkdir -p '/usr/local/bin'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c re2c '/usr/local/bin'
libtool: install: /usr/bin/install -c re2c /usr/local/bin/re2c
/usr/bin/install: cannot create regular file '/usr/local/bin/re2c': Permission denied
make[2]: *** [Makefile:1464: install-binPROGRAMS] Error 1
make[2]: Leaving directory '/opt/epics/re2c-1.3'
make[1]: *** [Makefile:3242: install-am] Error 2
make[1]: Leaving directory '/opt/epics/re2c-1.3'
make: *** [Makefile:3236: install] Error 2

# sudoをつけるとinstallできます。
epics@ubuntu:/opt/epics/re2c-1.3$ sudo make install
make  install-am
make[1]: Entering directory '/opt/epics/re2c-1.3'
Reconfigure to rebuild docs: ./configure --enable-docs
make[2]: Entering directory '/opt/epics/re2c-1.3'
/usr/bin/mkdir -p '/usr/local/bin'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c re2c '/usr/local/bin'
libtool: install: /usr/bin/install -c re2c /usr/local/bin/re2c
/usr/bin/mkdir -p '/usr/local/share/re2c/stdlib'
/usr/bin/install -c -m 644 include/unicode_categories.re '/usr/local/share/re2c/stdlib'
/usr/bin/mkdir -p '/usr/local/share/man/man1'
/usr/bin/install -c -m 644 doc/re2c.1 '/usr/local/share/man/man1'
make[2]: Leaving directory '/opt/epics/re2c-1.3'
make[1]: Leaving directory '/opt/epics/re2c-1.3'

re2cのインストールが完了しましたのでSequencerに戻ります。

epics@ubuntu:/opt/epics/re2c-1.3$ cd ..
epics@ubuntu:/opt/epics$ cd seq-2.2.8
epics@ubuntu:/opt/epics/seq-2.2.8$ make

Sequencerのmakeが無事通ったら、一つ前のasynをmakeします。

epics@ubuntu:/opt/epics/seq-2.2.8$ cd ..
epics@ubuntu:/opt/epics$ cd asyn4-38
epics@ubuntu:/opt/epics/asyn4-38$ make
...
make[3]: *** No rule to make target 'ipSNCServer.o', needed by 'libtestIPServerSupport.a'.  Stop.
make[3]: Leaving directory '/opt/epics/asyn4-38/testIPServerApp/src/O.linux-arm'
make[2]: *** [/opt/epics/base/configure/RULES_ARCHS:58: install.linux-arm] Error 2
make[2]: Leaving directory '/opt/epics/asyn4-38/testIPServerApp/src'
make[1]: *** [/opt/epics/base/configure/RULES_DIRS:85: src.install] Error 2
make[1]: Leaving directory '/opt/epics/asyn4-38/testIPServerApp'
make: *** [/opt/epics/base/configure/RULES_DIRS:85: testIPServerApp.install] Error 2

エラー内容に何も変化がありませんね?Makefileを確認するとどうやらSequencerのディレクトリ名が違うようです。2箇所修正が必要なようです。

SUPPORT=/opt/epics
 SUPPORTは、Sequencer等のサポートツールのインストール先です。
 他の記事はmodules以下に配置しているのが多いですが、私は/opt/epics配下に置いていますのでこの記述です。

SNCSEQ=$(SUPPORT)/seq-2.2.8
 SNCSEQは、Sequencerのインストール先です。

epics@ubuntu:/opt/epics/asyn4-38$ vi configure/RELEASE

さ修正箇所
# SUPPORT=/corvette/home/epics/devel
SUPPORT=/opt/epics

 #SEQ is required for testIPServer
# SNCSEQ=$(SUPPORT)/seq-2-2-5
SNCSEQ=$(SUPPORT)/seq-2.2.8

#EPICS_BASE 3.14.6 or later is required
# EPICS_BASE=/corvette/usr/local/epics-devel/base-7.0.3.1
EPICS_BASE=/opt/epics/base

やっとStreamDeviceに戻ってきました。いえ手順では次は・・・

Support for sCalcout record

scalcoutは、文字列計算出力、またはEPICSベースのCalcountから派生したscalcountレコードが扱える云々です。まあインストールが目的なので取り敢えず入れましょう。

しかしここにはインストール手順がないのでStreamDeviceに戻ってHPを読み直すと、

Support for sCalcout record
The sCalcout record is part of synApps. If streamDevice should be built with support for this record, you have to install at least the calc module from SynApps first. Add references to the RELEASE file as shown here:

sCalcoutレコードは、synAppsの一部です。streamDeviceはこのレコードをサポートするように構築する場合は、最初にSynAppsから少なくともcalcモジュールのインストールが必要です。追加したらRELEASEファイルに参照を追加する。と記述があります。

ここかな?

calcのR3-6-1を入れてみます。

epics@ubuntu:/opt/epics/stream-2.8$ cd ..
epics@ubuntu:/opt/epics$ cd tmp
epics@ubuntu:/opt/epics/tmp$ wget https://github.com/epics-modules/calc/archive/R3-6-1.tar.gz
...
epics@ubuntu:/opt/epics$ gzip -dc ./tmp/R3-6-1.tar.gz | tar xvf -
...

Makefileファイルを編集してmake、ですがエラーになります。
SSCANも必要なようなので入れます。

sscanのダウンロード、解凍、RELEASE修正、makeですね。
RELEASEの修正箇所は3箇所もう説明不要かもですがいつものアレです。
SUPPORT=/opt/epics
SNCSEQ=$(SUPPORT)/seq-2.2.8
EPICS_BASE=/opt/epics/base

epics@ubuntu:/opt/epics$ cd tmp
epics@ubuntu:/opt/epics/tmp$ wget https://epics.anl.gov/bcda/synApps/tar/sscan_R2-10.tar.gz
epics@ubuntu:/opt/epics/tmp$ cd ..
epics@ubuntu:/opt/epics$ gzip -dc ./tmp/sscan_R2-10.tar.gz | tar xvf -
epics@ubuntu:/opt/epics$ cd sscan-2-10
epics@ubuntu:/opt/epics/sscan-2-10$ vi configure/RELEASE



修正箇所
# SUPPORT=/home/oxygen/MOONEY/epics/synAppsSVN/support
SUPPORT=/opt/epics
-include $(TOP)/../configure/SUPPORT.$(EPICS_HOST_ARCH)^M
^M
#If using the sequencer, point SNCSEQ at its top directory:^M
# SNCSEQ=$(SUPPORT)/seq-2-2-0-2
SNCSEQ=$(SUPPORT)/seq-2.2.8
^M
# EPICS_BASE usually appears last so other apps can override stuff:^M
# EPICS_BASE=/APSshare/epics/base-3.14.12.3
EPICS_BASE=/opt/epics/base
-include $(TOP)/../configure/EPICS_BASE.$(EPICS_HOST_ARCH)^M

epics@ubuntu:/opt/epics/sscan-2-10$ make
...
piler/gcc -I../../../include/os/Linux -I../../../include      -I/opt/epics/seq-2.2.8/include -I/opt/epics/base/include/compiler/gcc -I/opt/epics/base/include/os/Linux -I/opt/epics/base/include        -c ../recDynLink.c
../recDynLink.c:46:15: error: expected ‘;’ before ‘long’
  46 | epicsShareFunc long epicsShareAPI dbNameToAddr(const char *pname,struct dbAddr *);
     |               ^~~~~
     |               ;
../recDynLink.c:46:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dbNameToAddr’
  46 | epicsShareFunc long epicsShareAPI dbNameToAddr(const char *pname,struct dbAddr *);
     |                                   ^~~~~~~~~~~~
../recDynLink.c: In functionrecDynLinkAddInput’:
../recDynLink.c:200:28: warning: implicit declaration of functiondbNameToAddr’ [-Wimplicit-function-declaration]
 200 |  if (options&rdlDBONLY  && dbNameToAddr(pvname,&dbaddr)) return(-1);
     |  
make[3]: *** [/opt/epics/base/configure/RULES_BUILD:241: recDynLink.o] Error 1
make[3]: Leaving directory '/opt/epics/sscan-2-10/sscanApp/src/O.linux-arm'
make[2]: *** [/opt/epics/base/configure/RULES_ARCHS:58: install.linux-arm] Error 2
make[2]: Leaving directory '/opt/epics/sscan-2-10/sscanApp/src'
make[1]: *** [/opt/epics/base/configure/RULES_DIRS:85: src.install] Error 2
make[1]: Leaving directory '/opt/epics/sscan-2-10/sscanApp'
make: *** [/opt/epics/base/configure/RULES_DIRS:85: sscanApp.install] Error 2

あれ?/optepics/base側で/recDynLink.c:46:15: error: expected ‘;’ before ‘long’と怒られます。recDynLink.cのdbAccessDefs.hのincludeがコメントアウトされていて、なぜかdbNameToAddr()が追加されているので、定義をコメントアウトしてincludeを有効にします。(それで良いのかは置いといて/^^;/)
格言:ビルドは通ったものの勝ち(喉元過ぎれば・・・的なやつです。後で火傷していたことを思い出すなんてことも、あるとか、ないとか)

epics@ubuntu:/opt/epics/sscan-2-10$ vi sscanApp/src/recDynLink.c

45行目
修正前
/* #include <dbAccessDefs.h> */
epicsShareFunc long epicsShareAPI dbNameToAddr(const char *pname,struct dbAddr *); 

修正後
#include <dbAccessDefs.h>
//epicsShareFunc long epicsShareAPI dbNameToAddr(const char *pname,struct dbAddr *); 

epics@ubuntu:/opt/epics/sscan-2-10$ make
...

無事ビルドできました。scalcに戻ります。configure/RELEASEの修正箇所は4箇所です。それではscalcのmake
SUPPORT=/opt/epics
SSCAN=$(SUPPORT)/sscan-2-10
SNCSEQ=$(SUPPORT)/seq-2.2.8
EPICS_BASE=/opt/epics/base

epics@ubuntu:/opt/epics$ cd calc-R3-6-1

epics@ubuntu:/opt/epics/calc-R3-6-1$ vi configure/RELEASE


修正箇所
#SUPPORT=/home/oxygen/MOONEY/epics/synAppsSVN/support
SUPPORT=/opt/epics
-include $(TOP)/../configure/SUPPORT.$(EPICS_HOST_ARCH)^M
^M
# Need SSCAN module only to build the swait record (recDynLink library)^M
# If you comment this definition out, the module will just decline to^M
# build the swait record.^M
#SSCAN=$(SUPPORT)/sscan-2-9
SSCAN=$(SUPPORT)/sscan-2-10
^M
# Need SNCSEQ module only to build editSseq.st.  If you comment this^M
# definition out, the module will just decline to build editSseq.st.^M
#SNCSEQ=$(SUPPORT)/seq-2-1-16
SNCSEQ=$(SUPPORT)/seq-2.2.8
^M
# EPICS_BASE usually appears last so other apps can override stuff:^M
#EPICS_BASE=/home/oxygen/MOONEY/epics/bazaar/base-3.14
EPICS_BASE=/opt/epics/base
-include $(TOP)/../configure/EPICS_BASE.$(EPICS_HOST_ARCH)^M


epics@ubuntu:/opt/epics/calc-R3-6-1$ make
...
../sseqRecord.c:536:42: error: ‘struct pv_link’ has no member named ‘precord’


make[3]: *** [/opt/epics/base/configure/RULES_BUILD:241: sseqRecord.o] Error 1
make[3]: Leaving directory '/opt/epics/calc-R3-6-1/calcApp/src/O.linux-arm'
make[2]: *** [/opt/epics/base/configure/RULES_ARCHS:58: install.linux-arm] Error 2
make[2]: Leaving directory '/opt/epics/calc-R3-6-1/calcApp/src'
make[1]: *** [/opt/epics/base/configure/RULES_DIRS:85: src.install] Error 2
make[1]: Leaving directory '/opt/epics/calc-R3-6-1/calcApp'
make: *** [/opt/epics/base/configure/RULES_DIRS:85: calcApp.install] Error 2

エラーになりました。

epics@ubuntu:/opt/epics/calc-R3-6-1$ vi calcApp/src/sseqRecord.c

# エラー発生箇所
pR = (sseqRecord *)(plink->value.pv_link.precord);

‘struct pv_link’ has no member named ‘precord’
precordがpv_linkのメンバーにいないというエラーですね。
/opt/epics/base/include/link.cをみると確かに。これはVerの不一致のようです。
epicsを最新にしたせいかなーって後悔もありますが、開発者目指す方は前のめりで前進あるのみです。(研究者とかもっと別の世界目指している方はここで引き返すのも手です)

epics@ubuntu:/opt/epics/calc-R3-6-1$ vi /opt/epics/base/include/link.h

# pv_linkのメンバーにいない!
struct pv_link {
   ELLNODE     backlinknode;
   char        *pvname;        /* pvname link points to */
   void        *pvt;           /* CA or DB private */
   LINKCVT     getCvt;         /* input conversion function */
   short       pvlMask;        /* Options mask */
   short       lastGetdbrType; /* last dbrType for DB or CA get */
};
...

# 一つ上のvalueにもいない
/* union of possible address structures */
union value {
   char                *constantStr;   /*constant string*/
   struct macro_link   macro_link;     /* link containing macro substitution*/
   struct json_link    json;           /* JSON-encoded link */
   struct pv_link      pv_link;        /* link to process variable*/
   struct vmeio        vmeio;          /* vme io point */
   struct camacio      camacio;        /* camac io point */
   struct rfio         rfio;           /* CEBAF RF buffer interface */
   struct abio         abio;           /* allen-bradley io point */
   struct gpibio       gpibio;
   struct bitbusio     bitbusio;
   struct instio       instio;         /* instrument io link */
   struct bbgpibio     bbgpibio;       /* bitbus to gpib io link */
   struct vxiio        vxiio;          /* vxi io */
};
struct lset;
struct link {
   struct dbCommon *precord;   /* Pointer to record owning link */
   short type;
   short flags;
   struct lset *lset;
   char *text;             /* Raw link text */
   union value value;
};

さて、上記コードを眺めているとlink->precordならば同等のようです。
置き換えてみましょう。

epics@ubuntu:/opt/epics/calc-R3-6-1$ vi calcApp/src/sseqRecord.c

536行目
変更箇所
// pR = (sseqRecord *)(plink->value.pv_link.precord);
pR = (sseqRecord *)(plink->precord);
pcb = (struct callbackSeq *) (pR->dpvt);

epics@ubuntu:/opt/epics/calc-R3-6-1$ make​

makeできましたのでOKです。

格言:ビルドは通ったものの勝ち第二弾

Support for regular expression matching

pcreはインストールしないのですが、何か?くらいは知っておきましょう。
PCRE(Perl Compatible Regular Expressions) 
Perl互換の正規表現のようです、Perl5互換の正規表現を実装するためのパッケージ必要ならば入れましょう。今はここを読み飛ばして2. Build the StreamDevice Library へ進みましょう。

pcreをダウンロード、./INSTALLにconfigureを行うと記述があります、

今回は使いませんが、手順だけ記載しておきます。
今回はスルーしてください。unzip, configure, make, make installです。

epics@ubuntu:/opt/epics$ cd tmp
epics@ubuntu:/opt/epics/tmp$ wget https://ftp.pcre.org/pub/pcre/pcre-8.44.zip
...
epics@ubuntu:/opt/epics/tmp$ cd ..
epics@ubuntu:/opt/epics$ unzip ./tmp/pcre-8.44.zip
...
epics@ubuntu:/opt/epics$ cd pcre-8.44
epics@ubuntu:/opt/epics/pcre-8.44$ autoreconf -i -W all
...
epics@ubuntu:/opt/epics/pcre-8.44$ ./configure
...
epics@ubuntu:/opt/epics/pcre-8.44$ make
...
epics@ubuntu:/opt/epics/pcre-8.44$ sudo make install
...

完了したらstreamのディレクトリ定義の修正を行ってmakeです。

PCRE=$(SUPPORT)/pcre-8.44
 先ほどのディレクトリ名に変更します。

epics@ubuntu:/opt/epics/pcre-8.44$ cd ..
epics@ubuntu:/opt/epics$ ls
asyn4-38  base  base-7.0.4  pcre-8.44  re2c-1.3  seq-2.2.8  stream-2.8  tmp
epics@ubuntu:/opt/epics$ cd stream-2.8
epics@ubuntu:/opt/epics/stream-2.8$ vi configure/RELEASE

修正箇所
 #PCRE =$(SUPPORT)/pcre-7-2
PCRE=$(SUPPORT)/pcre-8.44

make完了したら使えます。

2. Build the StreamDevice Library

streamのダウンロードしていつものアレしてmakeですね。MakefileのTOPを触る手順がありますが、ディレクトリを移動しなければこのままmakeできます。
[訂正]MakefileのTOPは修正が必要でしたごめんなさい。
MakefileのTOPを触らないとASYNがうまく取り込めないようでepicsを動かした時にcannot find a bus namedと怒られて動かない。行き当たりばったりで作業するとこうなる反面教師になれれば幸せ。

epics@ubuntu:/opt/epics/base/app/bs/iocBoot/iocbs$ sudo ./st.cmd...
############################################################################
## EPICS R7.0.4
## Rev. 2020-07-05T10:04+0000
############################################################################
2020/07/08 00:06:06.241320 _main_ Cannot find a bus named 'web' for 'web:str'
2020/07/08 00:06:06.241934 _main_ web:str: Can't attach to bus web 0
2020/07/08 00:06:06.242093 _main_ web:str: Record initialization failed## EPICS R7.0.4

上記エラーを出さないためにも下記が必要。
epics@ubuntu:/opt/epics/stream/StreamDevice$ vi src/Makefile
epics@ubuntu:/opt/epics/stream/StreamDevice$ vi streamApp/Makefile
修正箇所
# TOP = ../..
TOP = ..
epics@ubuntu:/opt/epics/stream/StreamDevice$ vi Makefile
修正箇所
# TOP = ..
TOP = .

後、いつものやつの修正するのは4箇所ですね。
ASYN=$(SUPPORT)/asyn4-38
#CALC =$(SUPPORT)/calc-R3-6-1
  [訂正] 最初はCALC上手くいくと思っていたのですがst.cmd実行時にエラーが出るので外しました。

こんな感じでエラーになる。
epics@ubuntu:/opt/epics/base/app/bs/iocBoot/iocbs$ sudo ./st.cmd
...
Declaration of recordtype(scalcout) preceeded full definition.
Error at or before "}" in file "dbd/iocbs.dbd" line 6149
iocbs_registerRecordDeviceDriver pdbbase
registerRecordDeviceDriver failed aai
registerRecordDeviceDriver failed aao
registerRecordDeviceDriver failed ai
registerRecordDeviceDriver failed ao
...

#PCRE =$(SUPPORT)/pcre-7-2
 PCREはここではあえてコメントアウトしましょう。
EPICS_BASE=/opt/epics/base

# makeBaseApp.plは完了しているので・・・
epics@ubuntu:/opt/epics$ cd /opt/epics/stream
epics@ubuntu:/opt/epics/stream$ ls
Makefile  configure

# gitから取得します。wgetで取得するとinclude/StreamVersion.hが空っぽになるので
#../StreamVersion.c:31:5: error: expected ‘,’ or ‘;’ before ‘STREAM_DEV’
  31 |     STREAM_DEV
# が出てるのでgitをお勧め。
epics@ubuntu:/opt/epics/stream$ git clone https://github.com/paulscherrerinstitute/StreamDevice.git
...
epics@ubuntu:/opt/epics/stream$ cd StreamDevice
epics@ubuntu:/opt/epics/stream/StreamDevice$ vi configure/RELEASE

修正箇所
# ASYN=$(SUPPORT)/asyn4-36
ASYN=$(SUPPORT)/asyn4-38
# CALC=$(SUPPORT)/calc-3-7
CALC=$(SUPPORT)/calc-R3-6-1
# PCRE=$(SUPPORT)/pcre-7-2


# EPICS_BASE usually appears last so other apps can override stuff:
#EPICS_BASE=/usr/local/epics/base-7.0.3
EPICS_BASE=/opt/epics/base


epics@ubuntu:/opt/epics/StreamDevice$ make

できたかどうか確認してみましょう。stream.dbdがあれば成功ですね。

epics@ubuntu:/opt/epics/stream/StreamDevice$ ls ../dbd
stream-base.dbd  stream.dbd  streamApp.dbd

一つ上の階層に出力されているのがミソです。
[訂正]も嘘です。涙、上でMakefileのTOPを修正したのでここにはディレクトは作成されません。正しくは・・・。

epics@ubuntu:/opt/epics/stream/StreamDevice$ ls ..
Makefile  StreamDevice  configure
epics@ubuntu:/opt/epics/stream/StreamDevice$ ls dbd
stream-base.dbd  stream-scalcout.dbd  stream.dbd  streamApp.dbd

これでStremDeviceが使えるはずです。まだこの時点では動作確認していないので使用される方はご自身の判断でご利用ください。



この記事が気に入ったらサポートをしてみませんか?