Archive for the 'Development' Category


Last week I got the PicoLCD. There is an open source driver for using it with the LCDProc deamon. The LCDproc provides a service which allows applications to show some information on the display.
LCDproc provides an easy to use protocol for showing your own information on the display see the LCDproc Developer’s Guide. I wrote a small python script which shows the currently playing song of a running Music Player Daemon (mpd). Since the PicoLCD provides a few buttons I added some basic control buttons (play, pause, stop, next, previous).
I have different ideas to improve this scripts but I left it this ways, because now it is quite simple and should give a good starting point for every one interested in doing something similar with LCDProc.

You can get the source code from the following page:

Sync ReadOnly (syncro)

I have put together a small description of how to use my syncro script and uploaded the script including the config file to the web server. I have mentioned this script before (Ubuntu on Alix (aufs))

You can find the description and the download here:

Ubuntu on Alix (aufs)

I did some further work on getting Ubuntu on the Alix. I have tested the basic kernel on my second Alix board (2c3). It works so far without problems.
In addition I did some research how to improve the installation. First I thought I would like to have the root file system read only. This manly to reduce the write access to the flash disc. For this I would have to create a ram disc and map several directories to this ram disc since some directories need to be writable. After some research and looking at the Voyage Linux distribution I found an other solution. On the next version of Voyage Linux they will use aufs. I did some tests with aufs and I think this could be the solution I use. I took the script from Voyage Linux and did some small changes to the script for mapping some directories for writing to a memfs. The script used by Voyage Linux is quite nice it will sync back the changes at shutdown and this way no log information get lost on normal shutdown.
I will post the change script later, since I need to do some changes until I think it fits all my needs.

Ubunut on Alix 3c3

Today I got Ubuntu 8.10 Server Edition working on my Alix 3c3. It was actually quite easy to get done. There are only a few things you need to now and it will not work with the default kernel.

To get Ubuntu installed on the flash card I used qemu on my Linux machine. I used the Qemu Launcher application to configure the virtual machine for installation. For the install disk I directly used the flash disc. In my case this was /dev/sdb. It is necessary to launch the Qemu Launcher with super user privileges to get access to this device.
It is possible to start the qemu from the console as well. Here is the command to start the qemu as it was generated from the Qemu Launcher:

/usr/bin/qemu -boot c -m 256 -hda '/dev/sdb' -cdrom '/home/mweb/Desktop/ubuntu-8.10-rc-server-i386.iso' -net nic,vlan=0 -net user,vlan=0 -localtime

Generic Config file:

Within this it is easily possible to install the complete Ubuntu system as you would like to have it. After the installation we need to at least boot once into this system and install our custom kernel, since the default ubuntu kernel will not work on the Alix board. Do all other customization steps here to save you work on the Alix board it self. We should also change the grub config that it uses the device for the root directory instead of the UUID of the device. For some reason I dont know yet it does not work with the UUID.

I used the current stable kernel but it might work with a newer kernels as well. I added two different config files to this post. The config_basic is the basic file I used it should work on other Alix boards as well but this is not tested yet, I will do this later. The config_alix3c3 has additional support for the sound card that is built into the Alix 3c3 board.

To create the kernel just extract the downloaded kernel and copy the config file into the kernel directory. Rename the config file to .config and now you are ready to build the debian package of the kernel. Just call it with make-kpkg. If you need more information about how to build a kernel on Ubuntu use google since there are enough resource out there that just explain this.

$ fakeroot make-kpkg kernel_image kernel-headers

This will build the kernel and headers package for this kernel. Copy it to the Alix and install it with dpkg.

Known Problems/Missing Features

  • Grub can’t find the flash disc (Instead of the UUID of the hard dsic enter the device name and it will work)
  • AppArmor does not work. This is because the kernel module is not build for our custom kernel. I just removed apparmor-utils since i don’t need it for my use case.
  • Read-Only file system. The current installation needs to have a writable root file system. Since we use a flash disc this is not the best solution. I would like to mount it ro and have a ram disk for the tmp files similar to Voyage linux.

Basic Kernel config
Alix 3c3 Kernel config

Updates on PAN

I did work on the PAN connection for the Nokia N810. As I described earlier ( Bluetooth PAN) I used maemo-pan on the Nokia and the setup as described in the mentioned tutorial on the Ubuntu desktop. It worked but I needed to set the desktop address of the computer within the Nokia by hand. Additionally the connection setup took quite some time since I always started the dhcp server new for each connection and it only worked for one PAN connection at a time.

I made two improvements to the old setup. First I added some functionality to the maemo-pan that it lets the user select the device to connect to. The second improvement I made on the Ubuntu desktop. Instead of starting the dhcp server on the newly create interface I create a bridge interface and add the new created interface to the bridged interfaces. This way I only need to start the dhcp server once for the bridge interface. This way it supports more then one PAN connection at once and it runs much more stable than before.

I wrote a small tutorial how to setup a Bluetooth PAN on Ubuntu with a bridge interface.

For the maemo-pan I sent a patch to the project.

Additional note the problem I got with Bluetooth on Ubuntu 8.04 beta is now with the release of Ubuntu 8.04 resolved. The pand binary is available again.

maemo’s scratchbox under Ubuntu Hardy Heron

Today I tried to install the maemo 4 sdk on my Ubuntu Hardy Heron. The first part installing the scratchbox worked with almost no problems. But the installation of the SDK it self did not work that easy. The first error I got was the following:

Inconsistency detected by rtld.c: 1192: dl_main: Assertion ‘(void *) ph->p_vaddr == _rtld_local._dl_sysinfo_dso’ failed!

Lucky me I found a solution from Michael R. Head. It is important to set both values. The first helped me to get into the scratchbox but without setting the mmap_min_addr I could not fully install the applications in the ARMEL target. After I set the second parameter it worked without any further problems.

Execute the following two lines that are described in the solution from Michael R. Head and the installation will work.

echo 0 | sudo tee /proc/sys/vm/vdso_enabled

echo 4096 | sudo tee /proc/sys/vm/mmap_min_addr

Bluetooth PAN

Today I managed to get the personal area networking (PAN) working with a Nokia N810 and a Ubuntu Linux system. However it took me quite a while to figure out everything to get it working.

The first problem I had was that the Nokia N810 does not support the PAN Bluetooth profile by default only dial-up networking (DUN) is supported. The recently released maemo-pan application adds support for PAN to the N810.
The problem I got with maemo-pan is that I could not register my computer as a phone and because of this the maemo-pan application did not find my workstation. After reading the source code I figured out that I just need to set the appropriate value in GConf to get it connecting. It is necessary that the two devices are paired before that they can connect without any further authentication.
With the following call to the gconftool-2 it is possible to set the HW-Address of the Bluetooth adapter of the desktop. This needs to be called on the N810.

gconftool-2 -s /system/osso/connectivity/BT/preferred --t string "XX"

Replace the ‘XX’ above with the hardware address of the desktop. To check that the configuration is set correctly you can call the gconftool-2 with the following parameters:

gconftool-2 -g /system/osso/connectivity/BT/preferred

The next problem I encountered was that I used Ubuntu 8.04beta. Where I figured out that there are some problems with the bluez-utils. Actually the pand executable is missing. I installed the bluez-utils from the PPA from Elliot Murphy. In this package the pand binaries are available and working.

I followed the howto Bluetooth PAND debian etch which did work almost. It did work to get a connection but I got the following error message in the syslog after some data where transmitted.

NETDEV WATCHDOG: bnep0: transmit timed out

If this happens I need to restart the connection and everything will work again, for a small amount of data. Since I tested these within VMWare I thought I might just try it on a real machine. Surprisingly it just worked without any problem. This is yet an other example if you get any problem with a USB device within VMWare just try the device on a real machine since it is possible that it might work without problems. It might work better if I would use VMWare 6 and no more VMWare 5.5 since there where some improvements within the USB support.

What is still missing now is a tool on the N810 to select the Bluetooth partner to connect to that offers PAN. This way it would not be necessary to select the PAN device as a phone or set it by hand as the device to connect to. I will see if I get the time to do that.

.net PDFViewer Component

Today I wanted to Integrate a PDFViewer component into my own .net (C++/CLI) application. In the beginning I hoped to find an opensource component for this. There are several opensource library’s for creating PDF’s with .net but none of them provided a PDFViewer component. There are several commercial solutions available but since they usually provided much more than I needed I was not really interested. On Linux or with other GUI toolkits (GTK, QT4 or Java) there are opensource alternatives available for the viewer but not for .net.

After a while I found a description that it is possible to integrate the Adobe Reader via ActiveX. Armin sent me a short C# example how to do it. Sadly I could not find the necessary dll’s. After some search for this dll’s I found the documentation page of Adobe where they provide examples for the usage of the Adobe Reader within a C# application. After compiling this application I found the needed dll’s in the output directories of this project and then I could set up my application just fine.

The only problem with the examples where that they where unnecessary complicated. I reduced the example to a minimum needed and created a small example application. The example including a short description can be found in the enterpriselab wiki:

Some more interesting links I found during my research:

getopt vs. optparse

Last week I was getting the MessageBroker started for the DustBot project. I needed some code for logging, and starting the server. Since I wanted to have a simple way to specify command line parameters for the MessageBroker I thought about writing some getopt code to do this. This was the time I stumbled upon Poco. Poco is a C++ library that helps to build networking application. One such module provides easy networking to C++. In addition it also provides some helper classes to easily set up a deamon application including parsing the command line parameters.

To parse the command line parameters with Poco was much easier then with getopt and was done very quickly. At this point I thought why do I not have something like this in Python? After a quick search I found optparse a Python module that helps to parse the command line parameters in a much easier way then getopt. To check if it works as easy as it looked like I integrated it into the regexplace script I posted earlier (Change of multiple files). The new version is uploaded to the wiki and can be downloaded from here.
If you need to parse command line parameters with python I recommend the optparse module. Since it really works well and is much easier to use then getopt.

Managed C++ vs. C++/CLI vs. C++

When I started my latest project where I needed some basic C libraries to access the Hardware. I thought I will use a Windows Forms Application with C++. I hoped this offers me writing normal C++ code and still use the new UI code from MS. In addition it would possible to port the application since the underlying C library is platform independent and C++ if correctly separated from the UI code should compile as well.

To bad it was not as easy as I hoped it will. The next time I might just chose an MFC Application where I can write native C++ code and I don’t have to bother with some magic C++ addition.

I had quite a hard time to figure out how I need to structure my application that it will work in managed mode. After some googeling I figured out that there are two different things: Managed C++ and C++/CLI. Managed C++ was the old addition from MS. With Visual Studio 2005 they added C++/CLI which is an ECMA standard and has a similar scope as Managed C++. The keywords of C++/CLI are no more marked with two underlines in front as it was with Managed C++. At the end I found an overview that explained me the strange keywords that I found in the new generated code.

The following links give a good overview about the differences between the C++ and C++/CLI:

The result of all this is that my application will not be portable at all since all the code is infected with CLI code. It would have been possible to separate the C++ code from the CLI code in such a way that it could be reused on an other platform but since it is only a prototype and it just has to work on windows. I will leave that for an other time. To separate C++ code from C++/CLI code it is necessary to write some glue code since CLI does not support all features from C++.

Next Page »