EIBD installation and usage

Aug 03 2012
 

As already mentioned in our previous post  introduction to EIB/KNX, the physical connectivity to the bus can be done in different ways, by means of a serial port, a USB port or else via IP network.

EIBD is a software development that presents the users with a unified interface to access the bus. EIBD implements internally the several KNX protocols used in the different physical media used to access the bus. This is a very useful component in the development of client applications to access and control the home automation network.

In this post we will explain how to install and use this software in a Linux Debian computer.

1. EIBD installation:

As a prerequisite, we install the pthsem package, downloading it from www.auto.tuwien.ac.at:

$ apt-get  install build-essential
  
-------------------------------------
$ cd EIBD
$ wget http: //www .auto.tuwien.ac.at/~mkoegler /pth/pthsem_2 .0.8. tar .gz
tar  zxvf pthsem_2.0.8. tar .gz
cd  pthsem-2.0.8/
$ . /configure
make
$ sudo  make  install

Next, we perform the installation of eibd downloading the bcusdk package from sourceforge:

$ tar  -zxvf bcusdk_0.0.5. tar .gz
cd  bcusdk-0.0.5/
export  LD_LIBRARY_PATH= /usr/local/lib
$ . /configure -- enable -onlyeibd -- enable -eibnetiptunnel -- enable -usb -- enable -eibnetipserver -- enable -ft12 
$ sudo ln  -s  /usr/local/lib/libeibclient .so.0 /usr/lib/libeibclient .so.0
sudo ln  -s  /usr/local/lib/libeibclient .so.0  /lib/libeibclient .so.0
$ make
$ make install

When executing  ”./configure”, we must specify by means of switches the bus connectivity interfaces we want to be enabled.

Once installed, we can display the available options with the –help switch:

$ eibd --help
Usage: eibd [OPTION...] URL
eibd -- a communication stack for EIB
(C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
supported URLs are:
ft12: /dev/ttySx
ip:[multicast_addr[:port]]
ipt:router-ip[:dest-port[:src-port[:nat-ip[:data-port]]]]]
iptn:router-ip[:dest-port[:src-port]]
usb:[bus[:device[:config[:interface]]]]
  
ft12 connects over a serial line without any driver with the FT1.2 Protocol to
a BCU 2
  
ip connects with the EIBnet /IP Routing protocol over an EIBnet /IP gateway. The
gateway must be so configured, that it routes the necessary addresses
  
ipt connects with the EIBnet /IP Tunneling protocol over an EIBnet /IP gateway.
The gateway must be so configured, that it routes the necessary addresses
  
iptn connects with the EIBnet /IP Tunneling protocol over an EIBnet /IP gateway
using the NAT mode
  
usb connects over a KNX USB interface
  
   -c, --GroupCache           enable caching of group communication network
                              state
   -d, --daemon[=FILE]        start the programm as daemon, the output will be
                              written to FILE, if the argument present
   -D, --Discovery            enable the EIBnet /IP server to answer discovery
                              and description requests (SEARCH, DESCRIPTION)
   -e, --eibaddr=EIBADDR      set our own EIB-address to EIBADDR (default
                              0.0.1), for drivers, which need an address
   -f, --error=LEVEL          set error level
   -i, --listen-tcp[=PORT]    listen at TCP port PORT (default 6720)
       --no-tunnel-client-queuing   do not assume KNXnet /IP Tunneling bus
                              interface can handle parallel cEMI requests
   -p, --pid- file =FILE        write the PID of the process to FILE
   -R, --Routing              enable EIBnet /IP Routing in the EIBnet /IP server
   -S, --Server[=ip[:port]]   starts the EIBnet /IP server part
   -t, --trace=LEVEL          set trace level
   -T, --Tunnelling           enable EIBnet /IP Tunneling in the EIBnet /IP
                              server
   -u, --listen- local [=FILE]  listen at Unix domain socket FILE (default
                              /tmp/eib )
   -?, --help                 Give this help list
       --usage                Give a short usage message
   -V, --version              Print program version
  
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
$

In the output from “eibd –help” we can see that our eibd server can connect to the bus by means of  BCU2/ft1.2, IP multicast, IP tunneling, IP tunneling in NAT mode, and USB.

Executing eibd connected through EIBnet/IP

First, we execute in another window a TCP/IP packet sniffer to dump the packets transmitted to/from the multicast address used by KNX.

Then we start eibd in IP multicast mode:

$ eibd --trace=5 --listen- local ip:
Layer 2(01FBBC00,5019291E) Open
Layer 0(01FBBD00,5019291E) Open
Creado socket...
Layer 0(01FBBD00,5019291E) Openend
Layer 2(01FBBC00,5019291E) Opened

 

Then, from a third window we execute the demo command “groupswrite” to send a telegram to the bus that writes the value “1″ to the group address  ”2/3/4″:

$ groupswrite local : /tmp/eib 2 /3/4 1

and check the trace being written by eibd. In it, the KNX telegram sent to the bus is displayed:

Layer 2(01FBBC00,50192A09) Send L_Data low from 0.0.1 to 2 /3/4 hops: 07 T_DATA_XXX_REQ A_GroupValue_Write (small) 01 
Layer 0(01FBBD00,50192A09) Send(017): 06 10 05 30 00 11 29 00 BC F0 00 01 13 04 01 00 81
Layer 2(01FBBC00,50192A09) Recv L_Data low from 0.0.1 to 2 /3/4 hops: 07 T_DATA_XXX_REQ A_GroupValue_Write (small) 01

 

The frame starts with a 6-byte header (see the cEMI format description in introduction to EIB/KNX) :

06:   length of header: 6 bytes
10:   protocol version (1.0)
0530: Service Type Descriptor: 0530=ROUTING_INDICATION
0011: Total length: 17 bytes

The header is followed by the message code 0×29 (L_Data.ind) and the additional information length (0×00)

Finally comes the KNX command itself :

BCF0: Control bytes
0001: source address 0 /0/1
1304: destination address 2 /3/4
01:   Data length: 1 byte
0081: APDU (TPCI+APCI+Datos)
Executing eibd connected through BCU2/FT1.2

Although our machines is not equipped with serial ports, we can simulate in software a pair of serial ports connected in “piggyback” using the linux command  ’socat’

$ socat -d -d pty,raw, echo =0 pty,raw, echo =0
2012 /08/01 15:14:40 socat[18599] N PTY is /dev/pts/5
2012 /08/01 15:14:40 socat[18599] N PTY is /dev/pts/6
2012 /08/01 15:14:40 socat[18599] N starting data transfer loop with FDs [3,3] and [5,5]

socat has created serial ports /dev/pts/5 and /dev/pts/6. Anything written to serial port 5 will appear as input in serial port 6, and viceversa (the actual port numbers can change every time socat is run).

Once we have socat running in a window, we execute eibd in another window, asking it to connect to one of the newly created serial ports:

$ eibd --trace=5 --listen-local ft12:/dev/pts/5

In the trace dumped by eibd, we see that an initialization message “10 40 40 16″ is sent. The message is sent over and over because eibd does not receive the expected ACK response (a single byte 0xE5, as specified in the ft1.2 protocol):

$ eibd --trace=5 --listen- local ft12: /dev/pts/5
Layer 2(013813A0,50193A2E) Open
Layer 2(013813A0,50193A2E) Opened
Layer 2(013813A0,50193A2E) OpenL2
Layer 0(01370C00,50193A2E) Send(004): 10 40 40 16
Layer 0(01370C00,50193A2E) Send(004): 10 40 40 16
Layer 0(01370C00,50193A2E) Send(004): 10 40 40 16
Layer 0(01370C00,50193A2F) Send(004): 10 40 40 16
....

We stop the execution of eibd with ^C. Next, we write an small program that listens for incoming messages in the “/dev/pts/6″ serial port, and sends “0xE5″ ACK messages in response (socat ensures that anything written to serial port 6 appears as incoming data in serial port 5).

Executing again eibd, the trace dumped this time is:

$ eibd --trace=5 --listen- local ft12: /dev/pts/5
Layer 2(01C983A0,50193B04) Open
Layer 2(01C983A0,50193B04) Opened
Layer 2(01C983A0,50193B04) OpenL2
Layer 0(01C87C00,50193B04) Send(004): 10 40 40 16
Layer 0(01C87C00,50193B04) Recv(001): E5
Layer 0(01C87C00,50193B04) Send(014): 68 08 08 68 73 A9 1E 12 34 56 78 9A E8 16
Layer 0(01C87C00,50193B04) Recv(001): E5
Layer 0(01C87C00,50193B04) Send(014): 68 08 08 68 53 A9 00 18 34 56 78 0A 20 16
Layer 0(01C87C00,50193B04) Recv(001): E5

This time, the reset message “10 40 40 16″ gets the expected 0xE5 ACK, and eibd sends a couple more initialization messages, encoded in FT1.2/EMI2.

Now, if we execute the “groupswrite” command in another window:

$ groupswrite local:/tmp/eib 2/3/4 1

we can see in the trace being written by eibd a new message, also encoded in FT1.2 format.

Layer 2(01C983A0,50193FFA) Send L_Data low from 0.0.0 to 6 /1/5 hops: 07 T_DATA_XXX_REQ A_GroupValue_Write (small) 01 
Layer 0(01C87C00,50193FFA) Send(016): 68 0A 0A 68 73 11 0C 00 00 31 05 F1 00 81 38 16
Layer 2(01C983A0,50193FFA) Recv L_Data low from 0.0.0 to 6 /1/5 hops: 07 T_DATA_XXX_REQ A_GroupValue_Write (small) 01 
Layer 0(01C87C00,50193FFA) Recv(001): E5
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值