Difference between revisions of "Install central"

From xPL
Jump to: navigation, search
m (Install xPL central device)
(Launch the xPL central device at startup)
Line 55: Line 55:
 
= Launch the xPL central device at startup =
 
= Launch the xPL central device at startup =
  
The xPL serial port device is to be launched after the xPL hub.
+
The xPL central device is to be launched after the xPL hub.
 
+
If the serial port equipment needs an initialisation command,
+
the xPL device controlling the equipment trough the xPL serial port needs to be launched after the xPL serial port.
+
 
+
The following example shows the installation of an xPL serial port device
+
connected to a  [http://www.tapko.de/sim-knx.html Tapko EIB/KNX to RS232 converter].
+
  
 
== Ubuntu ==
 
== Ubuntu ==
  
On Ubuntu, the xPL serial port device starts-up once <code>xpl-hub_started</code> has been emitted.
+
On Ubuntu, the xPL central device starts-up once <code>xpl-hub_started</code> has been emitted.
Once launched, it emits <code>xpl-eibSerialPort_started</code> for the next xPL device to control the serial port equipment.
+
  
Edit <code>/etc/init/xpl-eibSerialPort.conf</code>:
+
Edit <code>/etc/init/xpl-central.conf</code>:
 
  ################################################################################
 
  ################################################################################
  # xPL serial port for Tapko EIB/KNX to RS232 bridge
+
  # xPL central message parser
 
  #
 
  #
  description "xPL EIB bridge serial port"
+
  description "xPL central message parser"
 
  version    "1.0"
 
  version    "1.0"
 
  author      "Francois Corthay"
 
  author      "Francois Corthay"
Line 80: Line 73:
 
  #
 
  #
 
  env SCRIPTS_DIR='/home/control/Documents/Controls'
 
  env SCRIPTS_DIR='/home/control/Documents/Controls'
  env SCRIPT_NAME='xpl-serial_port.pl'
+
  env SCRIPT_NAME='xpl-central.pl'
  env PARAMETERS='-n eib -e \\x0A\\x0D /dev/ttyO1 baudrate 9600 databits 8 parity none stopbits 1 handshake none'
+
  env PARAMETERS='-n home'
 
   
 
   
 
  #-------------------------------------------------------------------------------
 
  #-------------------------------------------------------------------------------
Line 90: Line 83:
 
  respawn
 
  respawn
 
  setuid control
 
  setuid control
  setgid dialout
+
  setgid users
+
#-------------------------------------------------------------------------------
+
# Startup signalling
+
#
+
post-start script
+
  sudo initctl emit xpl-eibSerialPort_started
+
end script
+
 
   
 
   
 
  #-------------------------------------------------------------------------------
 
  #-------------------------------------------------------------------------------
Line 106: Line 92:
 
Start the device and test it:
 
Start the device and test it:
 
  su root
 
  su root
  service xpl-eibSerialPort start
+
  service xpl-central start
  service xpl-eibSerialPort status
+
  service xpl-central status
 
   
 
   
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
 
  SCRIPTS_BASE_DIR=/home/control/Documents/Controls
Line 116: Line 102:
 
== Mac OS ==
 
== Mac OS ==
  
On Mac OS, the xPL serial port device starts-up later than the hub.
+
On Mac OS, the xPL central device starts-up later than the hub.
  
Edit <code>/Library/LaunchDaemons/xpl-eibSerialPort.plist</code>:
+
Edit <code>/Library/LaunchDaemons/xpl-central.plist</code>:
 
  <?xml version="1.0" encoding="UTF-8"?>
 
  <?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">
 
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Line 124: Line 110:
 
   <dict>
 
   <dict>
 
     <key>Label</key>
 
     <key>Label</key>
     <string>xPL EIB bridge serial port</string>
+
     <string>xPL central message parser</string>
 
     <key>OnDemand</key>
 
     <key>OnDemand</key>
 
     <false/>
 
     <false/>
Line 131: Line 117:
 
     <key>ProgramArguments</key>
 
     <key>ProgramArguments</key>
 
     <array>
 
     <array>
       <string>/Users/control/Documents/Controls/xpl-serial_port.pl</string>
+
       <string>/Users/control/Documents/Controls/xpl-central.pl</string>
 
       <string>-n</string>
 
       <string>-n</string>
       <string>eib</string>
+
       <string>lounge</string>
 
       <string>-w</string>
 
       <string>-w</string>
 
       <string>25</string>
 
       <string>25</string>
       <string>-e</string>
+
       <string>-a</string>
       <string>\x0A\x0D</string>
+
       <string>/Users/control/Documents/Controls/centralActions.xml</string>
      <string>/dev/tty.PL2303-0020131D</string>
+
      <string>baudrate</string>
+
      <string>9600</string>
+
      <string>databits</string>
+
      <string>8</string>
+
      <string>parity</string>
+
      <string>none</string>
+
      <string>stopbits</string>
+
      <string>1</string>
+
      <string>handshake</string>
+
      <string>none</string>
+
 
     </array>
 
     </array>
 
   </dict>
 
   </dict>
Line 155: Line 130:
 
Start the device and test it:
 
Start the device and test it:
 
  su root
 
  su root
  launchctl load /Library/LaunchDaemons/xpl-eibSerialPort.plist
+
  launchctl load /Library/LaunchDaemons/xpl-central.plist
 
   
 
   
 
  SCRIPTS_BASE_DIR=/Users/control/Documents/Controls
 
  SCRIPTS_BASE_DIR=/Users/control/Documents/Controls

Revision as of 17:24, 30 March 2014

The central xPL device can be compared to a central station. It monitors all xPL messages and can trigger other messages based on a set of rules stored in an XML file.

Before all,make sure you have installed an xPL hub.

Install xPL central device

Install XML::Simple:

su
perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' 2> /dev/null | grep -i XML
perl -MCPAN -e "install 'XML::Simple'"
exit

If XML::SAX::Expat doesn't install properly and blocks the installation of XML::Simple, try:

su
apt-get install libxml-sax-expat-incremental-perl
ln -s /usr/share/perl5/XML/SAX/ParserDetails.ini /usr/local/share/perl/5.14.2/XML/SAX/ParserDetails.ini
perl -MCPAN -e "install 'XML::Simple'"
exit

Download the xPL central device script.

Move the script to xPL scripts directory:

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
mv xpl-central.pl $SCRIPTS_BASE_DIR
chown control:users $SCRIPTS_BASE_DIR/*.pl
chmod 775 $SCRIPTS_BASE_DIR/*.pl

Test xPL central device

Under construction icon-blue


Test it on a BeagleBone:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-central.pl -h
$SCRIPTS_BASE_DIR/xpl-central.pl -v -n test

Open a 2nd 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

The monitor should echo the serial port incoming messages.

Open another terminal and send a message to the serial port:

su control
SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.test -c serPort.basic command='hello world'

Launch the xPL central device at startup

The xPL central device is to be launched after the xPL hub.

Ubuntu

On Ubuntu, the xPL central device starts-up once xpl-hub_started has been emitted.

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

################################################################################
# xPL central message parser
#
description "xPL central message parser"
version     "1.0"
author      "Francois Corthay"

#-------------------------------------------------------------------------------
# Configuration variables
#
env SCRIPTS_DIR='/home/control/Documents/Controls'
env SCRIPT_NAME='xpl-central.pl'
env PARAMETERS='-n home'

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

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

Start the device and test it:

su root
service xpl-central start
service xpl-central status

SCRIPTS_BASE_DIR=/home/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.eib -c serPort.basic command='gci'
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.eib -c serPort.basic command='dts \$15'
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.eib -c serPort.basic command='tds (1/1/1) 1'

Mac OS

On Mac OS, the xPL central device starts-up later than the hub.

Edit /Library/LaunchDaemons/xpl-central.plist:

<?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 central message parser</string>
    <key>OnDemand</key>
    <false/>
    <key>UserName</key>
    <string>control</string>
    <key>ProgramArguments</key>
    <array>
      <string>/Users/control/Documents/Controls/xpl-central.pl</string>
      <string>-n</string>
      <string>lounge</string>
      <string>-w</string>
      <string>25</string>
      <string>-a</string>
      <string>/Users/control/Documents/Controls/centralActions.xml</string>
    </array>
  </dict>
</plist>

Start the device and test it:

su root
launchctl load /Library/LaunchDaemons/xpl-central.plist

SCRIPTS_BASE_DIR=/Users/control/Documents/Controls
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.eib -c serPort.basic command='gci'
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.eib -c serPort.basic command='dts \$15'
$SCRIPTS_BASE_DIR/xpl-send.pl -v -t cmnd -d dspc-serPort.eib -c serPort.basic command='tds (1/1/1) 1'