<div style="text-align:right;font-size:smaller">EpicsTipsAndTricksMultipleIOCs <a href="/edit/Epics/EpicsTipsAndTricksMultipleIOCs">(edit)</a></div>
To have one PC / Computer per IOC/Server seems to be an annoying situation.
Solution would be to be able to have several IOCs running on a PC. But you will be faced by the following Problems
on the client site.
E.g. for MEDM:
<div style="text-align:right;font-size:smaller">EpicsTipsAndTricksCrisAxisAddtionForSeveralEpicsApplications <a href="/edit/Epics/EpicsTipsAndTricksCrisAxisAddtionForSeveralEpicsApplications">(edit)</a></div>
cris-axis addition for several EPICS applications
HOWTO build flex (libfl) for cris-axis crisv32-axis
Since some of the EPICS extensions and modules rely on libfl flex and the standard distribution of AXIS SDK doesn't contain the libfl.a this has to be added:
Prerequisites
Build & Installation
- set some helper variables:
export SRC_DIR=<Source Directory>
export DOWNLOAD_DIR=<Download Directory>
# provided cross compiler and SDK are installed here export ETRAX_DIR=<ETRAX Tools Directory>
- download sources from http://sourceforge.net/projects/flex/ (version 2.5.35) via direct link to
$DOWNLOAD_DIR
- unpack to
$SRC_DIR
mkdir -p ${SRC_DIR:?undefined} &&
cd SRC_DIR &&
tar -jxvf flex-2.5.35.tar.bz
- Source
cris-axis-setup.sh
,defining environment variables, e.g. AXIS_TOP_DIR
, and extending PATH
, needs ETRAX_DIR
to be defined. or just take its main code: oldpwd=$OLDPWD
base=$(pwd)
cd ${ETRAX_DIR:?undefined)/SDK && cd $(ls --color=never -t -1 -d devbo* | head -n 1) && . ./init_env
cd $base
cd ${ETRAX_DIR:?undefined)/ETRAX/compiler && . ./setup.sh
cd $oldpwd
cd $base
unset scriptname base oldpwd epicsDir
- Change to source directory
$SRC_DIR
cd ${SRC_DIR:?undefined}
- Since
configure
automatically sets for cross-compilers 'ac_cv_func_malloc_0_nonnull' and 'ac_cv_func_realloc_0_nonnull' to 'no', (since it cannot check it) those have to be configured by hand:
- cris-axis
-
export myTARGET=cris-axis-linux-gnu
-
make clean
-
./configure --prefix=${AXIS_TOP_DIR:?undefined}/target/${myTARGET:?defined}/usr --host=${myTARGET} --build=i686-pc-linux-gnu ac_cv_func_realloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes
-
make
-
make install
- crisv32-axis
-
export myTARGET=crisv32-axis-linux-gnu
-
make clean
-
./configure --prefix=${AXIS_TOP_DIR:?undefined}/target/${myTARGET:?defined}/usr --host=${myTARGET} --build=i686-pc-linux-gnu ac_cv_func_realloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes
-
make
-
make install
Compact
export SRC_DIR=<Source Directory>
export DOWNLOAD_DIR=<Download Directory>
# provided cross compiler and SDK are installed here
export ETRAX_DIR=<ETRAX Tools Directory>
mkdir -p ${DOWNLOAD_DIR:?undefined} &&
wget http://prdownloads.sourceforge.net/flex/flex-2.5.35.tar.bz2?download
mkdir -p ${SRC_DIR:?undefined} &&
cd SRC_DIR &&
tar -jxvf flex-2.5.35.tar.bz
oldpwd=$OLDPWD
base=$(pwd)
cd ${ETRAX_DIR:?undefined)/SDK && cd $(ls --color=never -t -1 -d devbo* | head -n 1) && . ./init_env
cd $base
cd ${ETRAX_DIR:?undefined)/ETRAX/compiler && . ./setup.sh
cd $oldpwd
cd $base
unset scriptname base oldpwd epicsDir
# crisv-axis
export myTARGET=cris-axis-linux-gnu
cd ${SRC_DIR:?undefined} &&
make clean
./configure --prefix=${AXIS_TOP_DIR:?undefined}/target/${myTARGET:?defined}/usr --host=${myTARGET} --build=i686-pc-linux-gnu ac_cv_func_realloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes &&
make && make install
# crisv32-axis
export myTARGET=crisv32-axis-linux-gnu
cd ${SRC_DIR:?undefined} &&
make clean
./configure --prefix=${AXIS_TOP_DIR:?undefined}/target/${myTARGET:?defined}/usr --host=${myTARGET} --build=i686-pc-linux-gnu ac_cv_func_realloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes &&
make && make install
<div style="text-align:right;font-size:smaller">EpicsTipsAndTricksNewIocCommand <a href="/edit/Epics/EpicsTipsAndTricksNewIocCommand">(edit)</a></div>
new IOC command
The general way how to add a new IOC command, which can be used inside the IOC Shell is described in Chapter 18.3
IOC Shell - IOC Shell Programming of the
IOC Application Developer's Guide (3.14.9).
Here is an example (with the help of
BK) to make the command
dumpTable(mbo, dac, channel, type)
available at the IOC shell.
#include <epicsExport.h>
/* ... */
/***************************************************************************/
static void dumpTable(int mbo, int dac, int channel, short type)
{
/* some function code */
/* ... */
}
/***************************************************************************/
/* Information needed by iocsh */
/* Argument definition */
static const iocshArg dumpTableArg0 = {"mbo number", iocshArgInt};
static const iocshArg dumpTableArg1 = {"dac number", iocshArgInt};
static const iocshArg dumpTableArg2 = {"channel number", iocshArgInt};
static const iocshArg dumpTableArg3 = {"table type", iocshArgInt};
static const iocshArg *dumpTableArgs[] =
{
&dumpTableArg0,
&dumpTableArg1,
&dumpTableArg2,
&dumpTableArg3
};
/* Function definition */
static const iocshFuncDef dumpTableFuncDef = {"dumpTable", 4, dumpTableArgs};
/* Wrapper called by iocsh, selects the argument types that dumpTable needs */
static void dumpTableCallFunc(const iocshArgBuf *args) {
dumpTable(args[0].ival, args[1].ival, args[2].ival, args[3].ival);
}
/* Registration routine, runs at startup */
static void dumpTableRegister(void) {
iocshRegister(&dumpTableFuncDef, dumpTableCallFunc);
}
epicsExportRegistrar(dumpTableRegister);
variable(mySubDebug)
...
registrar(dumpTableRegister)
<div style="text-align:right;font-size:smaller">EpicsTipsAndTricksUseOfMsiWithMultipleTempleateFiles <a href="/edit/Epics/EpicsTipsAndTricksUseOfMsiWithMultipleTempleateFiles">(edit)</a></div>
use of msi with multiple template files
To produce a single db file from multiple template files it is sufficient to include in the Makefile in the app/Db directory the line with the name of the db. This should be a not existing file (because it will be produced). Existing must be the corresponding substitutions file and the template file(s). In case that the substitutions file calls to a multiple template files is necessary to have an independent name from them, otherwise the generated db file will be only based on the same name template file.
Be aware that none of the template files should have the same name as the substitutions file.
Example: To make a db called vulom_1.db use a file vulom_1.substitutions which references for instance vulom.template, vulomreg.template, and vulomreg1.template
vulom_1.substitutions:
file vulom.template {
{ PRE=HAD, NN="0", MM="1"}
}
file vulomreg.template {
{ PRE=HAD, NN="0", MM="1", CC="Del_0", AA="0", LIM="49.5", GAIN="3.3", LLIM="0"}
{ PRE=HAD, NN="0", MM="1", CC="Del_1", AA="1", LIM="49.5", GAIN="3.3", LLIM="0"}
}
file vulomreg1.template {
{ PRE=HAD, NN="0", MM="1", CC="Down_0", AA="7", LIM="15", GAIN="1"}
{ PRE=HAD, NN="0", MM="1", CC="Down_1", AA="8", LIM="15", GAIN="1"}
}
The Makefile should contain a line
DB += vulom_1.db
additional Dependencies
Adding the line in the Makefile
vulom_1_DEPENDS ?= $(shell perl -n -e 'if (/file\s+(\w+.template)/) {print "$$1 \n";}' vulom_1.substitutions )
right after the previous
DB += vulom_1.db
enables EPICS to check for dependencies (q.v.
IOC Application Developer's Guide - 3.14.9 Chapter 4.6.4):
If a <name> substitutions file contains "file" references to other input files, these referenced files should be made
dependencies of the created <name>.db by adding a dependency definition line:
<name>_DEPENDS = <filename1> <filename2> ...
Applications & Use Cases
The idea is to place here some (external) EPICS applications and use cases (or links to them).
- Getting started using Stream Devices
- A well documented introduction of the PANDA group at Bochum, Germany, of using StreamDevice accessing exemplarily an I-7565 USB/CAN Converter
http://panda-wiki.gsi.de/cgi-bin/view/DCS/EPICSstartUsingStreamDev
<div style="text-align:right"><a style="font-size:smaller" href="/edit/Epics/WindowsTricksTips">edit</a></div>
%FOREACH{"item" in="TippsWindowsResizeRawImgFileUsingVirtualBox"}%
Following the recommendation on http://raspberrypi.stackexchange.com/questions/4943/resize-image-file-before-writing-to-sd-card:
- e.g. to resize to 15.5GB, approx. size 15500
set VBOXMANAGE="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"
IF NOT EXIST %VBOXMANAGE% (
echo %VBOXMANAGE% does not exist ... exiting)
)
ELSE (
IF EXIST input.vdi ( %VBOXMANAGE% closemedium disk input.vdi --delete)
IF EXIST output.vdi ( %VBOXMANAGE% closemedium disk output.vdi --delete)
IF EXIST output.img (%VBOXMANAGE% closemedium disk output.img)
REM use without .img
set /p INPUT_NAME="Enter input file name without .img: ";
set OUTPUT_NAME=%INPUT_NAME%_resized
set /p OUTPUT_SIZE="Enter Size (MB) (e.g. 15000): "
ECHO "========================================================================="
%VBOXMANAGE% convertfromraw %INPUT_NAME%.img input.vdi -format VDI --variant Standard
ECHO "========================================================================="
%VBOXMANAGE% createhd --filename output.vdi --size %OUTPUT_SIZE% --format VDI --variant Standard
ECHO "========================================================================="
%VBOXMANAGE% clonehd input.vdi output.vdi --existing
ECHO "========================================================================="
%VBOXMANAGE% clonehd output.vdi output.img --format RAW
copy output.img %OUTPUT_NAME%.img
%VBOXMANAGE% closemedium disk input.vdi --delete
%VBOXMANAGE% closemedium disk output.vdi --delete
%VBOXMANAGE% closemedium disk output.img
)
%NEXT{"item"}%
%FOREACH{"item" in="TipsWindowsHowToCloneASDCard"}%
<div style="text-align:right"><a style="font-size:smaller" href="/edit/Epics/TipsWindowsHowToCloneASDCard">edit</a></div>
Following the help of page https://startingelectronics.org/articles/raspberry-PI/ten-things-raspberry-PI chapter 10.
This video View on YouTube → shows how to clone a SD card in Windows
%NEXT{"item"}%
<div style="text-align:right"><a style="font-size:smaller" href="/edit/Epics/LinuxTricksTips">edit</a></div>
$> stty -F /dev/ttySx -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke 19200
- Output settings:
- -opost
- do not post-process output
- -onlcr
- do not translate newline to carriage return-newline
- Local settings:
- -isig
- do not enable interrupt, quit, and suspend special characters
- -icanon
- do not enable erase, kill, werase, and rprnt special characters
- -iexten
- do not enable non-POSIX special characters
- -echo
- do not echo input characters
- -echoe
- do not echo erase characters as backspace-space-backspace
- -echok
- do not echo a newline after a kill character
- -echoctl
- do not echo control characters in hat notation ('^c')
- -echoke
- kill all line by obeying the
echoctl
and echok
setting
- 19200
- sets the speed to 19200 Bit/s
Summarizing the settings prevent any additional manipulation of input or output.
udev/udevadm
allows to automatically assign (fixed) symbolic links for USB devices connected to the system pointing the current /dev entry point.
- Prerequisites
- you have to have admin rights.
- How to
-
- Links
-
- "Writing udev rules"
- http://reactivated.net/writing_udev_rules.html
- udev
- https://wiki.ubuntuusers.de/udev/
- "Tutorial on how to write basic udev rules in Linux"
- https://linuxconfig.org/tutorial-on-how-to-write-basic-udev-rules-in-linux
Using ssh config files in ~/.ssh/config allows to specify per host / host alias different user/identity to connect with and more necessary options.
Using the features of the config
file of ssh
in ~/.ssh
one can specify host specific ssh options, including varying identities and users.
from: http://www.gelato.unsw.edu.au/archives/git/0611/31044.html
Example:
- connecting to a specific host using a different identity file and user
$> cat ~/.ssh/config
Host private.host.com
User myname
Hostname host.com
IdentityFile ~/.ssh/private-identity
Host public.host.com
User anotherName
Hostname host.com
IdentityFile ~/.ssh/public-identity
Host git.host.com
User git
Hostname host.com
IdentityFile ~/.ssh/git-identity
- allows to replace:
Using dhclient
exit hooks scripts allows to set e.g. the hostname
dynamically
Based on the articles:
and its own origin
dhclient
and its scripting capabilities on enter and exit hooks allows to react on dynamic network environments.
Provided you have root privileges this can be achieved by creating a script file hostname
created in /etc/dhcp/dhclient-exit-hooks.d/
(on Debian), which is sourced by dhclient
after having updated/received its DHCP informations.
#!/bin/sh
# Filename: /etc/dhcp/dhclient-exit-hooks.d/hostname
# Purpose: Used by dhclient-script to set the hostname of the system
# to match the DNS information for the host as provided by
# DHCP.
#
# Do not update hostname for virtual machine IP assignments
if [ "$interface" != "eth0" ] && [ "$interface" != "eth1" ] && [ "$interface" != "wlan0" ]
then
return
fi
if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
then
return
fi
echo dhclient-exit-hooks.d/hostname: Dynamic IP address = $new_ip_address
hostname=$(a=$(host $new_ip_address) || { false; } && { echo -n $a | cut -d ' ' -f 5 | cut -d "." -f 1; true; }) || unset hostname &&
echo ${hostname?} > /etc/hostname &&
hostname $hostname &&
export HOSTNAME=$hostname &&
echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = $hostname
Applying those code lines:
%FOREACH{"file" in="/etc/dhcp/dhclient-exit-hooks.d/hostname"}%
sudo curl -s https://wiki.gsi.de/pub/Epics/TipsLinuxDhclientDynamicHostname/_etc_dhcp_dhclient-exit-hooks.d_hostname -o $file &&
sudo dos2unix $file &&
sudo chmod a+r $file
%NEXT{"file"}%
Local testing at the prompt:
dhclient
Using dhclient
exit hooks scripts allows to set a mount point depending on the network environment, in this example for the HADES setup
Based on the articles:
and its own origin
dhclient
and its scripting capabilities on enter and exit hooks allows to react on dynamic network environments.
Provided you have root privileges this can be achieved by creating a script file mount_var_diskless
created in /etc/dhcp/dhclient-exit-hooks.d/
(on Debian), which is sourced by dhclient
after having updated/received its DHCP informations.
#!/bin/sh
# Filename: /etc/dhcp/dhclient-exit-hooks.d/mount_var_diskless
# Purpose: Used by dhclient-script to set mount HADES's var/diskless filesystem
# from either the local net (preferred) or the GSI network
#
# Do not update hostname for virtual machine IP assignments
if [ "$interface" != "eth0" ] && [ "$interface" != "eth1" ] && [ "$interface" != "wlan0" ]
then
return
fi
if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
then
return
fi
var_diskless_hades=192.168.100.50
var_diskless_gsi=140.181.75.158
var_diskless_path=/var/diskless/dreamplug
var_diskless_mount=/var/diskless/dreamplug
echo dhclient-exit-hooks.d/mount_var_diskless: new domain-name-servers: $new_domain_name_servers
echo "$new_domain_name_servers" | grep -q $var_diskless_hades && var_diskless_addr=$var_diskless_hades || var_diskless_addr=$var_diskless_gsi
#clean up, but only different mounts
grep -v "$var_diskless_addr:$var_diskless_path" /etc/mtab | grep -q "$var_diskless_mount" && umount $var_diskless_mount
#mount
[ -d "$var_diskless_mount" ] || mkdir -p $var_diskless_mount
grep "$var_diskless_addr:$var_diskless_path" /etc/mtab | grep -q "$var_diskless_mount" || mount $var_diskless_addr:$var_diskless_path $var_diskless_mount
echo dhclient-exit-hooks.d/mount_var_diskless: mounted $var_diskless_addr:$var_diskless_path
unset var_diskless_hades
unset var_diskless_gsi
unset var_diskless_path
unset var_diskless_mount
Finally make sure the file is readable:
chmod a+r /etc/dhcp/dhclient-exit-hooks.d/mount_var_diskless
Local testing at the prompt:
dhclient -v
%FOREACH{"item" in="TipsLinuxHadesNetworkAllowClientToConnectViaGateway"}%
To allow clients to connect outside of Hades network:
ip r a default via 192.168.100.90 dev eth0
%NEXT{"item"}%
%FOREACH{"item" in="TipsLinuxHowToCloneASDCard"}%
Following the help of page https://startingelectronics.org/articles/raspberry-PI/ten-things-raspberry-PI chapter 10.
This video View on YouTube → shows how to clone an SD card in Linux using the dd command line application.
The command for copying an SD card to an image file on your computer is:
sudo dd if=/dev/mmcblk0 of=~/raspi.img
The command for copying an SD card image to a new SD card is:
sudo dd if=~/raspi.img of=/dev/mmcblk0
Where:
-
~/raspi.img
is the location and file name of the image file.
-
/dev/mmcblk0
is the SD card device on the Linux system.
%NEXT{"item"}%
%FOREACH{"item" in="TippsLinuxResizeRawImgFile"}%
see: http://www.vk3erw.com/index.php/16-software/33-raspberry-pi-how-to-resize-sd-card-image
%NEXT{"item"}%
%FOREACH{"item" in="TippsLinuxRebootingTheMagicWay"}%
%NEXT{"item"}%
%FOREACH{"item" in="TippsLinuxProcServRemoteKillViaNetcat"}%
ProcServ usually needs a login to its port to execute a "CTRL+X" sequence to kill/restart the current child process.
Thanks to this cmdline it is also able without.
Thanks to J.Michel / M.Traxler, afaik.
Solution
Assuming that procServ is running its telnet session on port 12345 on localhost
echo -en "\x18" | netcat -w1 localhost 12345;
%NEXT{"item"}%
Introduction
The idea is to collect recommended hardware tools in use and experiences
serial ComPorts/ComServer - LAN ⇔ RS232
EXSYS
Experience and Users
- 6030 used by Wuppertal group of CBM as alternative to WuT
- up-to-now good experiences
- less expensive than WuT
Documentation
W&T, WuT, Wiesemann & Theis
Experience and Users
- Used by HADES, EE/KS, CBM
- Observations
- - in connection with network settings, sometimes quiet stubborn → clumsy hardware reset necessary
- - CBM @ COSY: showed in a radioactive environment (cave), (network) connection problems, 1 out of 3 ports operational
- + good remote programming capabilities
- + internal buffer, might overcome latencies
Documentation
<div style="text-align:right"><a style="font-size:smaller" href="/edit/Epics/GitTricksTips">edit</a></div>
How to "Import a CVS repository into a bare git repository"
<div style="text-align:right"><a style="font-size:smaller" href="/edit/Epics/GitTricksTipsImportCvsIntoGitIncludingHistory">edit</a></div>
# External CVSROOT, e.g. scs@lx-pool.gsi.de:/misc/hadesprojects/slowcontrol/cvsroot/
URL_CVSROOT_EXTERNAL=<[User@]external CVSROOT directory>,
CVSROOT_LOCAL=<local CVSROOT directory>
# Git repository path: e.g. "hadesprojects-slowcontrol.git"
GIT_TARGET_DIR=<New Git Repository>,
# CVS Module to import
MODULE=<CVS Module to extract>
[ ! -z "$CVSROOT_LOCAL" ] mkdir -p "$CVSROOT_LOCAL" &&
[ ! -z "$URL_CVSROOT_EXTERNAL" ] && rsync --progress -a "$URL_CVSROOT_EXTERNAL/" $CVSROOT_LOCAL
[ ! -z "$GIT_TARGET_DIR" ] && GIT_TARGET_REPOSITORY=${GIT_TARGET_DIR%%.git}.git && mkdir -p $GIT_TARGET_REPOSITORY &&
cd $GIT_TARGET_REPOSITORY &&
git init --bare &&
[ ! -z "$MODULE" ] && time git cvsimport -i -o cvshead -p xv -v -k -d $CVSROOT_LOCAL -C $GIT_TARGET_REPOSITORY $MODULE >&/tmp/cvsimport.log ||
echo "import of module \'$MODULE\' of CVS repository \'$URL_CVSROOT_EXTERNAL\' into \'$GIT_TARGET_REPOSITORY\' failed"
git submodule
, illustrated in a few command line examples.
These examples require at least version 1.7.
<div style="text-align:right"><a style="font-size:smaller" href="/edit/Epics/GitTricksTipsSubmodule">edit</a></div>
adding a submodule to a git directory
- git submodule add
- git submodule
- git submodule init
retrieving a repository with submodules
- git clone
- git submodule update
converting a repository into projects with submodules
(H.Brand)
- create new branch
- go into sub directory
- git init
- create remote bare repository
- push to (final) remote repository
- delete local sub directory and
- replace by add submodule pointing to remote,
- commit
- checkout and test
- merge new branch into current "master"
<div style="text-align:right"><a style="font-size:smaller" href="/edit/Epics/GitTricksTipsWorkflow">edit</a></div>
Possible Git Workflow
- (https://raw.githubusercontent.com/AnarManafov/GitWorkflow/master/GitWorkflow_fig1.png)
-
--
PeterZumbruch - 11 Jun 2015