Install Gambas

Remote Management Install

If you want remote login, install ssh and nomachine's nx:

$ sudo apt-get install ssh

I use nx for remote X sessions, but you can also use something else like vnc for example ...
$ mkdir ~/install/nx
$ cd ~/install/nx

$ wget
$ wget
$ wget

$ sudo dpkg -i nxclient_3.3.0-6_i386.deb
$ sudo dpkg -i nxnode_3.3.0-12_i386.deb
$ sudo dpkg -i nxserver_3.3.0-15_i386.deb

$ wget
$ wget
$ wget

$ sudo dpkg -i nxclient_3.3.0-6_x86_64.deb
$ sudo dpkg -i nxnode_3.3.0-12_x86_64.deb
$ sudo dpkg -i nxserver_3.3.0-14_x86_64.deb

You can download clients here.

If you enable Multimedia support while defining a connection you can hear the audio from your server too!

Apache install

If you want to use the web client module, you have to run Apache with the php5 and xmlrpc modules.
Please be aware of the security risks you take, the software is not fully tested.
You can also use lighttpd see below, not tested the security/user auth part, but xmlrpc ajax runs ok.

Install Apache2, PHP, MySQL and XMLRPC support:

$ sudo apt-get install apache2 php5 libapache2-mod-php5 php5-xmlrpc  php5-mysql

Then you need to tweak the apache config file a bit, to be able to have authentication and customlog settings changed:

NOTE: The example below is from default Ubuntu Hardy installation, your file may look a bit different.

$ sudo vi /etc/apache2/sites-available/default

You see this, change the two lines where the arrows point below.

[[NameVirtualHost]] *
<VirtualHost *>
        [[ServerAdmin]] webmaster@localhost

        [[DocumentRoot]] /var/www/
        <Directory />
                Options [[FollowSymLinks]]
                [[AllowOverride]] None
        <Directory /var/www/>
                Options Indexes [[FollowSymLinks]] MultiViews
------>         [[AllowOverride]] All
                Order allow,deny
                allow from all

        [[ScriptAlias]] /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                [[AllowOverride]] None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        [[ErrorLog]] /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        [[LogLevel]] warn

------> [[CustomLog]] /var/log/apache2/access.log combined env=!dontlog
        [[ServerSignature]] On

Next restart Apache to let it read the config file, watch for error messages.

$ sudo /etc/init.d/apache2 restart

lighttpd install

Install base part.

$ sudo aptitude install lighttpd

Install PHP modules.

$ sudo aptitude install php5-cgi php5-mysql php5-xmlrpc

To enable PHP5 in Lighttpd, we must modify /etc/php5/cgi/php.ini and add the line cgi.fix_pathinfo = 1 right at the end of the file:
$ sudo vi /etc/php5/cgi/php.ini

cgi.fix_pathinfo = 1

To enable the fastcgi configuration (which is stored in /etc/lighttpd/conf-available/10-fastcgi.conf), run the following command:

$ sudo lighttpd-enable-mod fastcgi

This creates a symlink /etc/lighttpd/conf-enabled/10-fastcgi.conf which points to /etc/lighttpd/conf-available/10-fastcgi.conf

Tell Lighttpd where to find php- add this to the bottom of /etc/lighttpd/lighttpd.conf

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/bin/php5-cgi",
                     "socket" => "/tmp/php.socket" 

Then reload Lighttpd:

$ sudo /etc/init.d/lighttpd force-reload

Clock synchronisation with ntp

It's important that your domotica server has the right time, you can achieve this by running ntpd on it, this describes how you can get it running.

Install the needed package:

$ sudo apt-get install ntp

Change it's config file to choose nearby ntp servers:

$ sudo vi /etc/ntp.conf

Replace line with server with the following (if you live in the Netherlands):


Restart the daemon:

$ sudo /etc/init.d/ntp restart
* Stopping NTP server ntpd                                              [ OK ]
* Starting NTP server ntpd                                              [ OK ]

Now you can check it with:

ntpq> peers
     remote           refid      st t when poll reach   delay   offset  jitter
 metronoom.dmz.c PPS(0)           2 u   18   64    1   28.042  36694.5   0.001    2 u   17   64    1   30.153  36694.5   0.001     2 u   16   64    1   26.090  36694.6   0.001
 ntp1.trans-ix.n    2 u   15   64    1   25.615  36696.2   0.001

The offset is the difference between your servers clock and the atomclock time.
After a few minutes you will see that the difference is corrected.

ntpq> peers
     remote           refid      st t when poll reach   delay   offset  jitter
 metronoom.dmz.c PPS(0)           2 u   10   64    1   26.920   -0.251   0.001    2 u   25   64    1   30.268    0.648   0.001     2 u   25   64    1   26.651    0.273   0.001
 ntp1.trans-ix.n    2 u   49   64    1   24.986    2.846   0.001

ntpq> exit

Lock serial device names

Do not run the udevadm command on a Raspberry Pi. This will cause a kernel panic and a hard reboot is required.
You can use the usb-devices command on the Raspberry Pi to get the same information, without crashing.

USB Serial devices get a random device name after reboot on Linux, they don't stay the same, which makes it very difficult to find out which is which every time.
By writing udev rules you can lock names to adapters with a certain serial number embedded.
But the adapters using a Prolific PL2303 chip all have the same device id and serial number, so you have a small problem.
What I have done, is lock the usb port to a certain serial device (actually to another symlink)
Here is how I did it.

Plug in all your interfaces, remove one and plug it back in, look up it's device name.

$ dmesg

[ 3041.219431] usb 1-3.2.4: USB disconnect, address 19
[ 3041.222094] pl2303 ttyUSB9: pl2303 converter now disconnected from ttyUSB9
[ 3041.222158] pl2303 1-3.2.4:1.0: device disconnected
[ 3045.257373] usb 1-3.2.4: new full speed USB device using ehci_hcd and address 20
[ 3045.355654] usb 1-3.2.4: configuration #1 chosen from 1 choice
[ 3045.356225] pl2303 1-3.2.4:1.0: pl2303 converter detected
[ 3045.359626] usb 1-3.2.4: pl2303 converter now attached to ttyUSB9

Now find out which device path it has.

$ udevadm info --attribute-walk -p /class/tty/ttyUSB9

  looking at device '/devices/pci0000:00/0000:00:04.1/usb1/1-3/1-3.2/1-3.2.4/1-3.2.4:1.0/ttyUSB9/tty/ttyUSB9':

  looking at parent device '/devices/pci0000:00/0000:00:04.1/usb1/1-3/1-3.2/1-3.2.4/1-3.2.4:1.0/ttyUSB9':

  looking at parent device '/devices/pci0000:00/0000:00:04.1/usb1/1-3/1-3.2/1-3.2.4/1-3.2.4:1.0':
    ATTRS{bAlternateSetting}==" 0" 

Look for the first KERNELS string with a path in it, so KERNELS=="1-3.2.4:1.0" in the above example.

Create or edit the custom udev rules file and add a line for this device.

$ sudo vi /etc/udev/rules.d/100-usbadapter.rules

Let udev reload it's new rules file, if you add rules to same file, udev will be notified, a restart is not needed then.
$ sudo /etc/init.d/udev restart

Now unplug the adapter and put it back in.
Check the creation of the extra symlinked device name.
$ ls -l /dev/ttyUSB*
crw------- 1 root root    188, 0 2011-11-29 10:18 /dev/ttyUSB0
crw------- 1 root root    188, 1 2011-11-29 10:33 /dev/ttyUSB1
crw------- 1 root root    188, 2 2011-11-29 10:16 /dev/ttyUSB2
crw------- 1 root root    188, 3 2011-11-29 10:13 /dev/ttyUSB3
crw------- 1 root root    188, 4 2011-11-29 10:23 /dev/ttyUSB4
crw------- 1 root root    188, 5 2011-11-29 10:23 /dev/ttyUSB5
crw-rw---- 1 root dialout 188, 1 2011-11-29 10:33 /dev/ttyUSBdigitemp
crw-rw---- 1 root dialout 188, 5 2011-11-29 10:30 /dev/ttyUSBled
crw-rw---- 1 root dialout 188, 0 2011-11-29 10:18 /dev/ttyUSBonkyo
crw-rw---- 1 root dialout 188, 2 2011-11-29 10:31 /dev/ttyUSBplugwise
crw-rw---- 1 root dialout 188, 4 2011-11-29 10:23 /dev/ttyUSBspare
crw-rw---- 1 root dialout 188, 3 2011-11-29 10:31 /dev/ttyUSBzwave

Now use the symlinks in your program to address the adapters.
So /dev/ttyUSBled for example. The link between the /dev/ttyUSB and /dev/ttyUSBled device change, but not the link between the physical USB port and the ttyUSBled device.

Another way to do this that makes the USB device port Independent is to assign the symlink by serial number.

Like before, using udevadm, we're going to get device information. However, This time, we're going to look for the ATTRS{serial} line (almost all FTDI have this, as well as other devices such as the Aeon Labs Z-Stick S2)


root@hal:~# udevadm info -a -n /dev/ttyUSB0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0/ttyUSB0/tty/ttyUSB0':

  looking at parent device '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0/ttyUSB0':

  looking at parent device '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0':
    ATTRS{interface}=="USB <-> RS232" 
    ATTRS{bAlternateSetting}==" 0" 

  looking at parent device '/devices/pci0000:00/0000:00:1d.1/usb3/3-2':
    ATTRS{bNumInterfaces}==" 1" 
    ATTRS{idVendor}=="0403"                                                <===  This line is the vendor ID
    ATTRS{idProduct}=="6001"                                               <===  This line is the product ID
    ATTRS{version}==" 1.10" 
    ATTRS{product}=="USB <-> RS232" 
    ATTRS{serial}=="abc123"                                                 <===  This line is the serial number.

 ------------- SNIP -------------------

Once you know the serial number, create a file for the udev rules (/etc/udev/rules.d/99-usb-rs232.rules) and add the following information to it:


SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="abc123", SYMLINK+="dsc" 

When you unplug and plug in your device, it will now still have /dev/ttyUSB0, but also /dev/dsc or whatever you changed the symlink name to.

Note: as of Ubuntu 12.04 with udev version 175 this didn' t work for me, what did work for me was the following:

KERNEL=="ttyUSB[0-9]*", SUBSYSTEMS=="usb", ATTRS{serial}=="abc123", NAME="dsc" 

Related Resources

  • Added by Steviev over 4 years ago

    Interesting link to install VNC on Raspberry pi:

  • Added by OWK over 4 years ago

    Running Apache/PHP on a Raspberry or an other low power server?

    Install and activate PHP Curl with the following steps:

    sudo apt-get install php5-curl

    sudo nano /var/www/iphone/config.php

    Set use_curl="yes"

  • Added by Steviev about 4 years ago

    On Raspberry Pi the Apache config needs to be as below (path for customlog is different):

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    &lt;Directory /&gt;
    Options FollowSymLinks
    AllowOverride None
    &lt;Directory /var/www/&gt;
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    &lt;Directory "/usr/lib/cgi-bin"&gt;
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    ErrorLog ${APACHE_LOG_DIR}/error.log
    1. Possible values include: debug, info, notice, warn, error, crit,
    2. alert, emerg.
      LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined=!dontlog

Updated by: rdnzl, Updated over 3 years ago
Access count: 84821 since 2011-08-25

Attached Files

iconclient.gif (733 Bytes) rdnzl, 08/23/2011 05:13 PM

udev_rules.txt Magnifier - example rules for serial, video and other usb devices (1.12 KB) rdnzl, 08/31/2012 09:50 AM

Also available in: PDF HTML TXT