Difference between revisions of "Install EIB eibd"

From xPL
Jump to: navigation, search
(Launch the xPL serial port device at startup)
(Install knx)
 
(44 intermediate revisions by one user not shown)
Line 1: Line 1:
The EIB / KNX bus can be accessed via the [https://www.auto.tuwien.ac.at/~mkoegler/index.php/eibd eibd daemon].
+
The EIB / KNX bus can be accessed via the [https://github.com/knxd/knxd/wiki knxd daemon].
The original distribution at [https://www.auto.tuwien.ac.at/~mkoegler/ TU Wien] is no longer maintained.
+
The work has been taken over on [http://sourceforge.net/projects/bcusdk/ SourceForge].
+
  
 
Before all, make sure you have installed an [[install xpl hub|xPL hub]] and a [[Install_BeagleBone#Control_user|control user]].
 
Before all, make sure you have installed an [[install xpl hub|xPL hub]] and a [[Install_BeagleBone#Control_user|control user]].
  
= Install eibd =
+
= Install knx =
  
Note: to my experience, '''this works on x86 machines, but not on armhf boards'''.
+
Install [https://github.com/knxd/knxd knxd]:
 +
apt install knxd
 +
apt install knxd-tools
  
Copy the [https://www.auto.tuwien.ac.at/~mkoegler/index.php/eibdeb PGP public key] to a local file <code>eibPgp.key</code> on your computer.
+
Start the daemon:
Add it to the list of trusted keys:
+
su
+
apt-key add <i>path-to</i>/eibPgp.key
+
 
+
Add the repository to the debian package maintenance system: edit <code>/etc/apt/sources.list</code> and add the lines:
+
## EIB
+
deb http://www.auto.tuwien.ac.at/~mkoegler/debian eib main
+
deb-src http://www.auto.tuwien.ac.at/~mkoegler/debian eib main
+
 
+
Install the package:
+
apt-get update
+
apt-get install bcusdk
+
 
+
On the EIB side, the IP Router should be configured as a bus coupler (address nn.nn.0) and be provided a fixed IP address.
+
In the following description, the address is <code> 192.168.1.204 </code>.
+
 
+
Test it: start the daemon in a terminal window:
+
 
  su control
 
  su control
  eibd -S -D -i -d ipt:192.168.1.204
+
  knxd -b ipt:192.168.1.204
  
Monitor the traffic:
+
List commands:
  groupsocketlisten ip:localhost
+
  knxtool list
  
Pushing on an EIB button should be reported in the last terminal window.
+
Perform a write:
 +
knxtool on ip:localhost 1/1/1
 +
knxtool off ip:localhost 1/1/1
 +
or:
 +
knxtool groupswrite ip:localhost 1/1/1 1
 +
knxtool groupswrite ip:localhost 1/1/1 0
  
In a 3rd terminal window, light-on a bulb:
+
Listen to the KNX telegrams:
  su control
+
  knxtool vbusmonitor1time ip:localhost
groupswrite ip:localhost 1/1/1 1
+
^C
 +
As to my understanding, the <code>busmonitor</code> variants work with filters to be defined
 +
whilst the <code>vbusmonitor</code> variants show all messages.
 +
Also, the <code>groupsocketlisten</code> command allows compatibility with the original <code>eibd</code> daemon.
  
Stop the daemon:
+
Stop the service:
  killall eibd
+
  pkill knxd
 +
ps ax | grep knxd | grep -v grep
  
 
= Install xPL EIB bridge =
 
= Install xPL EIB bridge =
  
::<html>
+
Download the [http://www.dspc.ch/xPL/Downloads/xpl-knxWrite.pl EIB write] and [http://www.dspc.ch/xPL/Downloads/xpl-knxdRead.pl EIB read] scripts:
<a title="By Dsmurat (+) [LGPL (http://www.gnu.org/licenses/lgpl.html)], via Wikimedia Commons" href="http://commons.wikimedia.org/wiki/File%3AUnder_construction_icon-blue.svg"><img width="512" alt="Under construction icon-blue" src="//upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Under_construction_icon-blue.svg/512px-Under_construction_icon-blue.svg.png"/></a>
+
</html>
+
 
+
Download the [http://www.dspc.ch/xPL/Downloads/xpl-eib-eibdWrite.pl eibd write] and [http://www.dspc.ch/xPL/Downloads/xpl-eib-eibdRead.pl eibd read] scripts.
+
 
+
Move the script to xPL scripts directory:
+
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
  mv xpl-eib-eibdWrite.pl $SCRIPTS_BASE_DIR
+
  cd $SCRIPTS_BASE_DIR
  mv xpl-eib-eibdRead.pl $SCRIPTS_BASE_DIR
+
wget http://www.dspc.ch/xPL/Downloads/xpl-knxWrite.pl
  chown control:users $SCRIPTS_BASE_DIR/*.pl
+
  wget http://www.dspc.ch/xPL/Downloads/xpl-knxRead.pl
  chmod 775 $SCRIPTS_BASE_DIR/*.pl
+
  chown control:users *.pl
 +
  chmod 775 *.pl
  
 
= Test xPL EIB writer =
 
= Test xPL EIB writer =
 
The test is shown here on a Linux machine such as a [[install BeagleBone|BeagleBone]].
 
It has to be slightly adapted on Mac OS.
 
  
 
Open a first terminal window (on any machine with xPL installed) and monitor the xPL protocol:
 
Open a first terminal window (on any machine with xPL installed) and monitor the xPL protocol:
Line 68: Line 52:
 
If the <code>eibd</code> daemon isn't running, launch it in a second window:
 
If the <code>eibd</code> daemon isn't running, launch it in a second window:
 
  su control
 
  su control
  eibd -S -D -i -d ipt:192.168.1.204
+
  knxd -u /tmp/eib -b ipt:192.168.1.204
 
+
Then launch the <code>eibd</code> monitor:
+
groupsocketlisten ip:localhost
+
  
 
In another terminal window, start the xPL EIB writer:
 
In another terminal window, start the xPL EIB writer:
 
  su control
 
  su control
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
  $SCRIPTS_BASE_DIR/xpl-eib-eibdWrite.pl -v -n home
+
  $SCRIPTS_BASE_DIR/xpl-knxWrite.pl -v -n home
  
Open yet another terminal and send a message to the EIB bridge:
+
Open yet another terminal and send a message to the EIB tunnelling server:
 
  su control
 
  su control
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
Line 84: Line 65:
  
 
This should turn on EIB device <code>1/1/1</code>.
 
This should turn on EIB device <code>1/1/1</code>.
The <code>groupsocketlisten</code> window should show the <code>eibd</code> write command.
+
The <code>groupsocketlisten</code> window should show the <code>knxd</code> write command.
  
= Launch the xPL EIB writer at startup =
+
If no more testing is wanted, stop the EIB daemon:
 +
pkill knxd
 +
ps ax | grep knxd | grep -v grep
 +
 
 +
= Test xPL EIB reader =
 +
 
 +
Open a first terminal window (on any machine with xPL installed) and monitor the xPL protocol:
 +
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 +
$SCRIPTS_BASE_DIR/xpl-monitor.pl -vf
 +
 
 +
If the <code>eibd</code> daemon isn't running, launch it in a second window:
 +
su control
 +
knxd -u /tmp/eib -b ipt:192.168.1.204
 +
 
 +
Then start the xPL EIB reader:
 +
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 +
knxtool groupsocketlisten ip:localhost | $SCRIPTS_BASE_DIR/xpl-knxRead.pl -v -n home
 +
 
 +
Push on an EIB button or send a message to the EIB tunnelling server in a 3rd terminal window:
 +
su control
 +
knxtool groupswrite ip:localhost 1/1/1 1
 +
knxtool groupswrite ip:localhost 1/1/1 0
 +
 
 +
The EIB activity should appear in the <code>xpl-monitor.pl</code> window.
 +
 
 +
Stop the EIB daemon:
 +
pkill knxd
 +
ps ax | grep knxd | grep -v grep
 +
 
 +
= Launch the xPL EIB interface at startup =
  
 
The EIB writer is to be launched after the xPL hub.
 
The EIB writer is to be launched after the xPL hub.
 +
The EIB reader is launched as a <code>pre-start script</code>.
 +
 +
== Debian with SystemD ==
 +
 +
On Debian with [https://wiki.debian.org/systemd systemd] (such as [https://www.raspbian.org/ Raspbian]
 +
or [https://www.ubuntu.com/ Ubuntu]), the scripts can be defined as services.
 +
 +
Edit <code>/lib/systemd/system/xpl-knxWrite.service</code>:
 +
[Unit]
 +
Description=xPL KNX write
 +
After=xpl-hub.service knxd.service
 +
 +
[Service]
 +
Type=simple
 +
User=control
 +
Group=users
 +
ExecStart=/home/control/Documents/Controls/xpl-knxWrite.pl -n home -w 2
 +
Restart=always
 +
 +
[Install]
 +
WantedBy=multi-user.target
 +
 +
 +
Edit <code>/lib/systemd/system/xpl-knxRead.service</code>:
 +
[Unit]
 +
Description=xPL KNX read
 +
After=xpl-hub.service knxd.service
 +
 +
[Service]
 +
Type=simple
 +
User=control
 +
Group=users
 +
ExecStart=/bin/bash -c '/usr/bin/knxtool groupsocketlisten ip:localhost | /home/control/Documents/Controls/xpl-knxRead.pl -n home'
 +
Restart=always
 +
 +
[Install]
 +
WantedBy=multi-user.target
 +
 +
Activate the services:
 +
su
 +
systemctl enable xpl-knxWrite.service
 +
service xpl-knxWrite start
 +
systemctl enable xpl-knxRead.service
 +
service xpl-knxRead start
  
== Ubuntu ==
+
Reboot and check:
 +
ps aux | grep -v grep | grep -i xpl
 +
ps ax | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///'
 +
systemctl list-units --type=service --state=running | grep -i knx
 +
service xpl-knx* status
  
On Ubuntu, the xPL serial port device emits <code>xpl-eibSerialPort_started</code> at startup.
+
== Ubuntu with Upstart ==
This will be used to state-up the xPL EIB bridge.
+
  
 
Edit <code>/etc/init/xpl-eib.conf</code>:
 
Edit <code>/etc/init/xpl-eib.conf</code>:
 
  ################################################################################
 
  ################################################################################
  # xPL EIB writer, interfaves to a Tapko serial port
+
  # xPL EIB interface to an eibd daemon
 
  #
 
  #
  description "xPL EIB bridge"
+
  description "xPL EIB interface"
 
  version    "1.0"
 
  version    "1.0"
 
  author      "Francois Corthay"
 
  author      "Francois Corthay"
Line 107: Line 164:
 
  #
 
  #
 
  env SCRIPTS_DIR='/home/control/Documents/Controls'
 
  env SCRIPTS_DIR='/home/control/Documents/Controls'
  env SCRIPT_NAME='xpl-eib-Tapko.pl'
+
env EIBD_DIR='/usr/local/bin'
  env PARAMETERS='-n home -s dspc-serPort.eib'
+
  env SCRIPT_NAME='xpl-knxWrite.pl'
 +
  env PARAMETERS='-n home'
 
   
 
   
 
  #-------------------------------------------------------------------------------
 
  #-------------------------------------------------------------------------------
 
  # Start and stop conditions
 
  # Start and stop conditions
 
  #
 
  #
  start on xpl-eibSerialPort_started          
+
  start on xpl-hub_started          
 
  stop on shutdown
 
  stop on shutdown
 
  respawn
 
  respawn
 
  setuid control
 
  setuid control
 
  setgid users
 
  setgid users
 +
 +
#-------------------------------------------------------------------------------
 +
# Start eibd daemon and reader before the writer
 +
#
 +
pre-start script
 +
  $EIBD_DIR/eibd -S -D -i -d ipt:192.168.1.204
 +
  $EIBD_DIR/groupsocketlisten ip:localhost | $SCRIPTS_DIR/xpl-knxRead.pl $PARAMETERS &
 +
end script
 +
 +
#-------------------------------------------------------------------------------
 +
# Stop eib daemon on shutdown
 +
#
 +
pre-stop script
 +
  pkill knxd
 +
end script
 
   
 
   
 
  #-------------------------------------------------------------------------------
 
  #-------------------------------------------------------------------------------
Line 126: Line 199:
 
Start the device and test it:
 
Start the device and test it:
 
  su root
 
  su root
  service xpl-eib status
+
  killall knxd
initctl emit xpl-eibSerialPort_started
+
  service xpl-eib start
  service xpl-eib status
+
 
   
 
   
 +
su control
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  $SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-eib.home -c eib.basic group='1/1/1' data=0x01
 
  $SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-eib.home -c eib.basic group='1/1/1' data=0x01
Line 138: Line 211:
 
  initctl list | grep xpl
 
  initctl list | grep xpl
  
== Mac OS ==
+
[[Category: all]] [[Category: install]] [[Category: xPL]]
 
+
On Mac OS, the xPL EIB bridge starts-up later than the xPL serial port.
+
 
+
Edit <code>/Library/LaunchDaemons/eib.plist</code>:
+
<?xml version="1.0" encoding="UTF-8"?>
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+
<plist version="1.0">
+
  <dict>
+
    <key>Label</key>
+
    <string>xPL EIB bridge</string>
+
    <key>OnDemand</key>
+
    <false/>
+
    <key>UserName</key>
+
    <string>control</string>
+
    <key>ProgramArguments</key>
+
    <array>
+
      <string>/Users/control/Documents/Controls/xpl-eib-Tapko.pl</string>
+
      <string>-n</string>
+
      <string>home</string>
+
      <string>-s</string>
+
      <string>dspc-serPort.eib</string>
+
      <string>-w</string>
+
      <string>30</string>
+
    </array>
+
  </dict>
+
</plist>
+
 
+
Start the device and test it:
+
su root
+
launchctl load /Library/LaunchDaemons/xpl-eib.plist
+
+
SCRIPTS_BASE_DIR=/Users/control/Documents/Controls
+
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-eib.home -c eib.basic group='1/1/1' data=0x01
+
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-eib.home -c eib.basic group='1/1/1' data=0x00
+
 
+
Reboot the Mac and check for the daemons:
+
ps ax | grep -i xpl | grep -v grep
+
launchctl list | grep xPL
+
 
+
[[Category: install]] [[Category: xPL]]
+

Latest revision as of 12:48, 8 January 2022

The EIB / KNX bus can be accessed via the knxd daemon.

Before all, make sure you have installed an xPL hub and a control user.

Install knx

Install knxd:

apt install knxd
apt install knxd-tools

Start the daemon:

su control
knxd -b ipt:192.168.1.204

List commands:

knxtool list

Perform a write:

knxtool on ip:localhost 1/1/1
knxtool off ip:localhost 1/1/1

or:

knxtool groupswrite ip:localhost 1/1/1 1
knxtool groupswrite ip:localhost 1/1/1 0

Listen to the KNX telegrams:

knxtool vbusmonitor1time ip:localhost
^C

As to my understanding, the busmonitor variants work with filters to be defined whilst the vbusmonitor variants show all messages. Also, the groupsocketlisten command allows compatibility with the original eibd daemon.

Stop the service:

pkill knxd
ps ax | grep knxd | grep -v grep

Install xPL EIB bridge

Download the EIB write and EIB read scripts:

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
cd $SCRIPTS_BASE_DIR
wget http://www.dspc.ch/xPL/Downloads/xpl-knxWrite.pl
wget http://www.dspc.ch/xPL/Downloads/xpl-knxRead.pl
chown control:users *.pl
chmod 775 *.pl

Test xPL EIB writer

Open a first terminal window (on any machine with xPL installed) and monitor the xPL protocol:

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-monitor.pl -vf

If the eibd daemon isn't running, launch it in a second window:

su control
knxd -u /tmp/eib -b ipt:192.168.1.204

In another terminal window, start the xPL EIB writer:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-knxWrite.pl -v -n home

Open yet another terminal and send a message to the EIB tunnelling server:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-eib.home -c eib.basic group='1/1/1' data=0x01

This should turn on EIB device 1/1/1. The groupsocketlisten window should show the knxd write command.

If no more testing is wanted, stop the EIB daemon:

pkill knxd
ps ax | grep knxd | grep -v grep

Test xPL EIB reader

Open a first terminal window (on any machine with xPL installed) and monitor the xPL protocol:

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-monitor.pl -vf

If the eibd daemon isn't running, launch it in a second window:

su control
knxd -u /tmp/eib -b ipt:192.168.1.204

Then start the xPL EIB reader:

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
knxtool groupsocketlisten ip:localhost | $SCRIPTS_BASE_DIR/xpl-knxRead.pl -v -n home

Push on an EIB button or send a message to the EIB tunnelling server in a 3rd terminal window:

su control
knxtool groupswrite ip:localhost 1/1/1 1
knxtool groupswrite ip:localhost 1/1/1 0

The EIB activity should appear in the xpl-monitor.pl window.

Stop the EIB daemon:

pkill knxd
ps ax | grep knxd | grep -v grep

Launch the xPL EIB interface at startup

The EIB writer is to be launched after the xPL hub. The EIB reader is launched as a pre-start script.

Debian with SystemD

On Debian with systemd (such as Raspbian or Ubuntu), the scripts can be defined as services.

Edit /lib/systemd/system/xpl-knxWrite.service:

[Unit]
Description=xPL KNX write
After=xpl-hub.service knxd.service

[Service]
Type=simple
User=control
Group=users
ExecStart=/home/control/Documents/Controls/xpl-knxWrite.pl -n home -w 2
Restart=always

[Install]
WantedBy=multi-user.target


Edit /lib/systemd/system/xpl-knxRead.service:

[Unit]
Description=xPL KNX read
After=xpl-hub.service knxd.service

[Service]
Type=simple
User=control
Group=users
ExecStart=/bin/bash -c '/usr/bin/knxtool groupsocketlisten ip:localhost | /home/control/Documents/Controls/xpl-knxRead.pl -n home'
Restart=always

[Install]
WantedBy=multi-user.target

Activate the services:

su
systemctl enable xpl-knxWrite.service
service xpl-knxWrite start
systemctl enable xpl-knxRead.service
service xpl-knxRead start

Reboot and check:

ps aux | grep -v grep | grep -i xpl
ps ax | grep -i xpl | grep -v grep | sed 's/.*\/Controls\///'
systemctl list-units --type=service --state=running | grep -i knx
service xpl-knx* status

Ubuntu with Upstart

Edit /etc/init/xpl-eib.conf:

################################################################################
# xPL EIB interface to an eibd daemon
#
description "xPL EIB interface"
version     "1.0"
author      "Francois Corthay"

#-------------------------------------------------------------------------------
# Configuration variables
#
env SCRIPTS_DIR='/home/control/Documents/Controls'
env EIBD_DIR='/usr/local/bin'
env SCRIPT_NAME='xpl-knxWrite.pl'
env PARAMETERS='-n home'

#-------------------------------------------------------------------------------
# Start and stop conditions
#
start on xpl-hub_started          
stop on shutdown
respawn
setuid control
setgid users

#-------------------------------------------------------------------------------
# Start eibd daemon and reader before the writer
#
pre-start script
  $EIBD_DIR/eibd -S -D -i -d ipt:192.168.1.204
  $EIBD_DIR/groupsocketlisten ip:localhost | $SCRIPTS_DIR/xpl-knxRead.pl $PARAMETERS &
end script

#-------------------------------------------------------------------------------
# Stop eib daemon on shutdown
#
pre-stop script
  pkill knxd
end script

#-------------------------------------------------------------------------------
# Start daemon
#
exec $SCRIPTS_DIR/$SCRIPT_NAME $PARAMETERS

Start the device and test it:

su root
killall knxd
service xpl-eib start

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-eib.home -c eib.basic group='1/1/1' data=0x01
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-eib.home -c eib.basic group='1/1/1' data=0x00

Reboot the PC and check for the daemons:

ps ax | grep -i xpl | grep -v grep
initctl list | grep xpl