Sunday, February 9, 2014

UPS for Raspberry Pi

As described in the previous post, I'm using the Raspberry Pi as a server for my calender and addressbook data. It is directly connected to my WLan station, and I want to be able to simply shutdown both devices by simply switching off power. Simply switching off power is not the best idea for a Linux system. That is, the preferred way is to neatly shutdown the system before. Since I do not want to start a terminal application before in order to shutdown the Pi properly, I found a different solution: CW2's Pi USV (USV is german for UPS). It is a battery powered UPS, which comes with a nice software package for Pi's Debian Linux. The UPS and the software shutdown the system when the USB power supply is switched off. This is exactly what I needed.

Installation is rather easy. On you find a short movie demoing the device, along with some PDFs of how to connect the hardware and set up the software (there are english manuals, even though the web page is in german language only).

I have a case for my Pi, and in order to be able to use that case with the UPS, I had to cut three holes as shown in the picture. The installation of the hardware is nicely documented in CW2's manuals.


CW2 UPS comes with nice software, which monitors the power and automatically shutdown the system if the USB power is switched off. The software comes as a Debian package, and the installation sets up everything -- usually you do not need to manually adjust things.

This is how I installed the software on command line (as I have no monitor attached to my Pi, I always connect via ssh):

Download piusvmonitor software on command line via wget:


Install piusvmonitor as super user:

sudo dpkg --install piusvmonitor.deb

After installation, you will find a shell script

in /etc/init.d for starting the piusmonitor automatically. After installation, the software is automatically started. The monitor actually is a service, running in the background.

Configuration and log files are found in


Check functionality:

tail -f /usr/share/piusvmonitor/log.piusv
Sun Feb  9 12:21:38 2014
Now, remove one battery as shown on the demo on This will be shown in the log:
Sun Feb  9 12:21:39 2014
Sun Feb  9 12:21:39 2014
Now, put battery back:
Sun Feb  9 12:21:53 2014
Sun Feb  9 12:21:53 2014
Eventually, try the shutdown by removing the USB power supply:
Sun Feb  9 12:22:02 2014
Sun Feb  9 12:22:02 2014
Sun Feb  9 12:22:12 2014
 PIUSV shutdown
Sun Feb  9 12:22:12 2014
 PIUSV shutdown
Sun Feb  9 12:22:16 2014
Connection to closed by remote host.
Connection to closed.    
The last two lines a due to the ssh connection, of course. After rebooting and reconnecting to the PI, the piusv software is started automatically:
Sun Feb  9 12:22:28 2014
Sun Feb  9 12:28:20 2014
Sun Feb  9 12:28:21 2014


The CW2 UPS is a nice little device, and the software is working great. Unfortunately the common Rasperry Pi case does not really fit. Most of all, it would be nice to have a real connector for the battery package instead of the press-stud connection. The CW2 UPS costs about 30€ and can be ordered irectly from CW2. Additionally, you need batteries, of course. Note that the UPS does not automatically charge the batteries, so there is still some "manual" maintenance necessary.

Sunday, January 12, 2014

Raspberry Pi and ownCloud: Calendar and contact synchronization without Apple or Google

The probably badest news about Mac OS X Maverick is that the synchronization services were removed, thus disabling tools like Missing Sync to work. I used Missing Sync to synchronize calendar and contacts between my MacBook and Android phone. Since I do not want to use Google, I had to find another solution.
My new solution is a combination of the following things:
  • Raspberry Pi
  • ownCloud
  • CalDav- and CardDav-Sync for Android
I have a Raspberry Pi running ownCloud connected to my Airport Extreme via Ethernet cable (as it is directly placed near to the Airport). It has a static IP, so that it is easy to find in my local network. For security reasons it is only available in my local network: I don't need global access to my few contact and calendar data, as it is sufficient to sync the data when I (and my Android and MacBook) are at home. ownCloud is a little cloud solution, providing WebDav, CalDav and CardDav services. These services are used to sync the data similar to Google or Apple.
Why a Raspberry Pi?
For security reasons, I didn't want to use a (virtual) server publicly available on the internet. I simply do not have the time to constantly update a server for fixing security issues. Also, setting up a server in the cloud is not that much different from using Google, is it? Since the server needs to be accessible to the Android device, a static IP address is very convenient. I could have installed ownCloud on my MacBook directly, and assigning the book a static IP address (or reserve a specific DSCP IP address to the MacBook), however with the Pi I can use the server not only for me but also for roommates ;-) And then, for a geek a real local server is simply a must, isn't it?

Setup Raspberry Pi and ownCloud

Installation if this set up was pretty easy:
  1. Buy a Raspberry Pi along with an USB power supply, an SDHC card, and a little case and maybe little cooling elements
  2. Format SDHC card (luckily my MacBook has an SD card slot) via SD Formatter for Mac (
  3. Install Rasbian via Noobs (
    1. follow readme instruction foud in Noobs zip
    2. install Rasbian via Noobs, enable SSH via menu
    3. set up static IP address (e.g., see
    4. while 3.1-3.3 needed the Pi to be connected to a monitor, once the static IP address is configured, the following steps can be applied via ssh.
  4. Install ownCloud (, following the tutorial at (german only).
    Minor adjustment: The SSL configuration file has to have newlines, that is, use this template:
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/apache.pem
    DocumentRoot /var/www

Set up clients

Now, configure ownCloud, that is, set up initial admin user and create a new user via the web interface.
There is not much magic to configuring CalDav and CardDav to the OS X apps (in the apps, select preferences and add your own server using the static IP address and the configured user).
There may be some trouble setting up CardDav. For El Capitan, add a new CardDav account, manual setup, and use the following server address:

For initial import of the calendar entries, export your calendar to a file. This file is then uploaded via drag'n drop to ownCloud and imported there via click (only click once, this might take a while).
The last point has been a little bit tricky, as I had to create a temporary folder manually in order make it work. This is how I did it:
cd /var/www/apps/calendar/
sudo mkdir import_tmp
sudo chown www-data:www-data import_tmp
Android Apps
I'm using the following Android apps now (instead of the Missing Sync software with Fliq Calendar, which I never really liked):
(Thank you Marcus for pointing me to these apps!)

Thursday, October 6, 2011

Latex listings definitions for modeling languages

Seems as if the Latex listings package does not let me go...

After blogging about how to nicely format listing with the Latex listings package, using a Eclipse syntax coloring style, and solving some tiny yet annoying problems with hyphenations of inline listings and labels within listings, I have compiled a couple of language definitions for (Eclipse) modeling languages.

Actually, these definitions are rather small, as they basically contain a list of keywords of a language. Besides the language definition, I usually define a command for quickly writing some inline listing code. I have explained this command in an earlier blog posting.

So, here are the definitions for QVT, ATL, ETL, Xtend, and Xtext.

QVT -- Query, View, Transformations

% relations:  
   checkonly, domain, enforce, extends, implementedby, import, 
  key, overrides, primitive, query, relation, top, 
  transformation, when, where
% operational: 
 Bag, Collection, Dict, OrderedSet, Sequence, Set, Tuple, abstract, 
access, and, any, assert, blackbox, break, case, class, collect, 
collectNested, collectOne, collectselect, collectselectOne, 
composes, compute, configuration, constructor, continue, datatype, 
default, derived, disjuncts, do, elif, else, end, endif, 
enum, except, exists, extends, exception, false, forAll, forEach , 
forOne, from, helper, if, implies, import , in, inherits, init, 
inout, intermediate, invresolve, invresolveIn, invresolveone, 
invresolveoneIn , isUnique, iterate, late, let, library, literal, 
log, main, map, mapping, merges, metamodel, modeltype, new, not, 
null, object, one, or, ordered, out, package, population, primitive, property, 
query, raise, readonly, references, refines, reject, resolve, resolveIn, resolveone, 
resolveoneIn, return, select, selectOne, sortedBy, static, 
switch, tag, then, transformation, true, try, typedef, unlimited, 
uses, var, when, where, while, with, xcollect , xmap, xor, xselect 

ATL -- Atlas Transformation Language


ETL -- Epsilon Transformation Language

   pre, rule, operation, 
  var, transform,to,
  select, selectOne, all,

Xtend 1.0.1


Xtext 1.0.1

 morekeywords={grammar, with, hidden, generate, as, import, returns, current, terminal, enum},

If you need a new language definition for your own Xtext based modeling or programming or domain specific or whatever language, it is very easy to retrieve the tokens of the language. Within the project of your Xtext grammar file, a special ANTLR file containing all the tokens will be generated. You will find that file in


[Updated February 2012] A friend of mine (thank you, Jens!) just sent me a new definition for Xpand:
 % note: first and last guillemot of comments will not appear in comment style, guillemots are not possible in delimiters
 % for use with UTF-8
This definition is a slight modification of the definitions posted in the Eclipse M2T forum (and also at the Rtsys Group Wiki, Uni Kiel) a while ago.

Saturday, July 23, 2011

Pimp your Kindle

I really like the idea of ebooks. These E Inks displays have an astonishing quality: I was very surprised to be even able to read a Din A4 PDF, downsized to fit the 6 inch display of a Kindle---although it is hard to read.

So, as I like the idea, I bought an ebook reader. I decided to buy Amazon's Kindle reader, as there are a lot of ebooks available thanks to Amazon. While I'm still enthusiastic about the really good display, I'm completely disappointed in the Kindle software. Most of all, ebooks are always displayed using justified text. But since hyphenation is not supported, this leads to really ugly layouts. The combination of justified text without hyphenation is a show-stopper!

So, I tried to figure out a solution to that problem. Fortunately, I found a Kindle version of the FBReader (fbkindle), which is not too complicated to be installed on the Kindle. FBReader displays ebooks in epubs format, and it provides hyphenation as known from TeX. Really nice! This blog entry summarizes the necessary steps along with a short presentation of additional tips.


Before explaining the necessary steps to install FBReader, I just want to show you the differences between the original Kindle AZW reader and the FBReader.

Figure 1: Comparison of original Kindle AZW reader (left) and FBKindle epub reader (right)

Figure 1 shows two scans of the Kindle. I have used Melville's Moby Dick (free Amazon vs. Feedbooks version). It is freely available, not only at Amazon but also at some other ebook sites, and besides it is one book I always wanted to read. While some of the differences stem from the information stored in the ebooks themselves, other things are only (missing) features of the reader software. However, in my experience, the example is rather a typical one: I've found much worse (free) ebooks, and also slightly better ones. Let's go into the details:

The first obvious thing is hyphenation. As said above, the Kindle cannot hyphenate, which is a real problem due to the justified text layout used. The worst thing about that is, that it sometimes produces pseudo paragraphs, as you can see in the circle marked with "1a" (and also in the second line of the following chapter). FBReader supports hyphenation (circle marked "1b"). This is a software problem and no missing feature of the ebook. That is: No AZW ebook will support hyphenation, at least not with the current Kindle reader software.

The other differences stem from the ebooks themselves. As the headings demonstrate ("2a" vs. "2b"), the AZW book does not correctly layout the heading. That is, the title of the heading is formatted as plain text. While this is only ugly, I have found free AZW books with footnotes inserted into the plain text without anything indicating the footnote (the free version of Hegel's Logik). An even worse problem is, that some books do not come with no table of contents, and no chapter markers. As indicated with the "3a", the AZW version of Moby Dick does not provide any chapter markers, while the EPUB version does ("3b"). Actually, with out these markers and TOC, an ebook like Moby Dick is not usable at all. Sometime, it is possible to generate TOCs with tools such as Calibre, but, hey guys, I want to read a book, not create and fix it.

While the FBReader provides a much better layout, I really miss one feature the Kindle reader software provides: dictionary integration. This is a really cool feature, and although is is listed as a planned feature for FBReader, is is not implemented yet. At the moment, I'm using my Android's ColorDict to help me out, just as I used to do when reading books printed on paper. Weird! The dictionary coming with Kindle is an english dictionary, and I have installed a free german-english dictionary, as explained below.


Figure 2: Kindle root folder after installing 3rd-party software

Figure 2 shows my Kindle root folder, with some subfolder created by the software described below. It contains a folder with the collections database and some configuration files of the Kindle AZW reader (1), as well as your content (2). All third-party software is installed on the Kindle by first mounting the Kindle to your PC or Mac, and then by copying some installation file into the mounted root folder (0) (sometimes, this folder is referred to as "/mount/us", on MAc OS X, it is the root folder when you mount your Kindle). Then, the Kindle needs to be rebooted, and when starting up, the software is installed automatically (and the installer is removed). The installer usually creates a folder in the Kindle's root folder.

Frankly, I really hate to install hacks on the Kindle. So, please Amazon, improve your Kindle software! The hardware is really cool, but the software is rotten! Meanwhile, here's how to install alternative software. Frankly, this is not the first list, and you will find similar lists on the web. One of the best places is the forum, and a list of hacks can be found there as well.

The quick installation should only serve as a short guide, please read the documentation linked to before installing anything. You may lose warranty when applying the hacks described below, or you may break your Kindle. Use it on your own risk!

"Jailbreak" for Kindle

A small "security" feature built into the original Kindle software prevents arbitrary 3rd-party software to be installed. So, we first need a special piece of software, to work around this issue. This is the "jailbreak". There exists different software versions of the original Kindle software, and they require different software hacks as well. The Kindle (at the time writing this post) comes with version 3.1. Yifan Lu has published a jailbreak for that version:

Yifan Lu's website: Kindle 3.1 Jailbreak
Quick install
  1. Unpack
  2. Copy installer update_jailbreak_*_*_install matching your kindle version into Kindle's root folder (Fig. 2 (0))
  3. Restart Kindle (Home, Menu - Settings, Menu - Restart
See download location.

The ad-base Kindle is not that easy to jailbreak, and frankly: if you choose to save that little money and accept ads, then do not complain about the original software. However, according to Yifan Lu, some non-ad Kindles also come with the new 3.2.1 software, so here's the link on how to jailbreak this version as well (I didn't try it myself): Yifan Lu: Kindle 3.2.1 Jailbreak (also see thread at mobilreader).


In order to be able to start 3rd-party software, you need some launcher software (as there is no command line available by default). Launchpad is a small utility, which enables the user to execute commands after pressing a defined sequence of keys, as demonstrated on this Youtube video.. Launchpad is available via the forum:
Quick install
  1. Download and unpack
  2. Copy installer update_launchpad_*_*_install.bin matching your kindle version into Kindle's root folder (Fig. 2 (0))
  3. Restart Kindle (Home, Menu - Settings, Menu - Restart
See download location.

After successfully installing launchpad, a new subfolder should have been created in your Kindle's root folder, as shown in Figure 2 (3). Inside that folder, you will find the configuration files *.ini with defined key sequences and commands to be executed. Note that you always have to press Shift before the defined key sequences, and that you have to press all keys one after the other and not all at the same time.

FBReader (FBKindle)

Now we are ready to install FBReader, in order to be able to read DRM-free EPUB books on your Kindle. There exist two versions: FBReader by Dzha and FBKindle by Andy Wooden. I have chosen FBKindle , as it runs vis-a-vis with the original Kindle reader software, and one can easily switch between both version using a keyboard shortcut. Both versions are ports of the original C++ FBReader software. Unfortunately, this version has not been updated for quite some time, especially because nice things such as dictionary integration are still missing. Note: There also exists a sourceforge project called FBKindle, unfortunately it does not contain any files yet.

Quick install
  1. Download and copy fbKindle-bin.tar.gz into Kindle's root folder (Fig. 2 (0))
  2. Add the following lines to your launchpad/launchpad.ini file (or create launchpad/fbreader.ini containing these line):
    F R = !/mnt/us/fbKindle/ FBReader &
    U T = !cd /mnt/us; tar zxvf fbKindle-bin.tar.gz; rm fbKindle-bin.tar.gz;echo 101 >/proc/eink_fb/update_display
  3. Restart Kindle (Home, Menu - Settings, Menu - Restart) in order to activate new key sequences

  4. Activate FBKindle installation key-sequence, i.e. quickly press Shift, then U, and then T. This will unpack the FBKindle archive, and install FBReader in a subfolder fbKindle on your Kindle, as shown in Fig. 2 (4)

  5. Now, start FBKindle via Shift, then F, and then R. Actually, you will have to restart FBKindle every time after restarting your Kindle!

See download location,german guide at
Unfortunately, the library management of FBReader/FBKindle is as bad as the the management functions of the original Kindle software. Seriously, I'm wondering how Amazon (or in that case the FBReader programmers) expects user's to install and manage more than 20 books. Anyways, the menu button will activate the FBReader menu, and from there on it should be self explaining (shortcuts are documented on the pages linked to above). The nice thing about FBKindle is, that you can easily switch forth and back between FBReader and the original Kindle software by pressing shift and alt simultaneously.

Free dictionaries for the Kindle software

Back to the original Kindle software. A really nice feature of the Kindle reader is that is comes with integrated dictionary support. Since I usually need english to german translations, I was looking for an english-german dictionary. There exists a lot of free dictionaries, and I found a free solution for the Kindle as well. Michael Sheldon (kudos to Michael) has converted free dictionaries into the mobi-format, which is supported by Kindle.
Quick install
  1. Download dictionary file, e.g.,, and place it inside your documents folder
  2. Select this dictionary as your primary dictionary via menu - Settings, menu - Change Primary Dictionary
Michael Sheldon's blog

Custom Screensaver

Not really necessary, but nice to have: screensaver with your own pictures. I really do not understand why Amazon does not directly support that feature. So, you have to firstly install a 3rd party screensaver hack. Then, you can copy your own pictures into a folder of the screensaver software.
Quick install
  1. Download and unpack
  2. Copy installer update_ss_0.22.N_*_install.bin matching your kindle version into Kindle's root folder (Fig. 2 (0))
  3. Restart Kindle (Home, Menu - Settings, Menu - Restart
  4. Installer should have created a folder linkss, as shown in Figure 2 (5). Copy your images (600x800 pixels) into the created folder linkss/screensavers.
  5. Restart Kindle (Home, Menu - Settings, Menu - Restart) in order to activate new images.
See download location.

Wednesday, May 11, 2011

Fun with Multiple VPN Connections on Mac OS X

Disclaimer: Frankly, I'm neither a Unix nerd nor a network freak. Maybe this is why I prefer using Mac OS X: In most cases things are simply working, or at least some nice graphical interfaces guides me through the network configuration jungle. So, use my tips on your own risk and feel free to write me a comment, if you can explain things better :-)

Virtual private network (VPN) are one of these things making me nervous without a nice GUI. Fortunately, OS X directly supports all the protocols I need (and thank you, Apple, for supporting the Cisco protocol as of OS X version 10.6). Setting up a VPN is as simple as installing a printer. Maybe even simplier ;-)

However, there are always new problems challenges waiting, and one of these challenges is the use of multiple VPNs simultaneously. I have the following situation: I can only connect to some local network, which does not allow any internet connections. For that purpose, I have to use a VPN "T" -- the VPN server "TServer" (names are only for simplify reading) is more or less the only thing accessible from that internal network. So, every connection to the internet runs through this VPN.

Now, I have to connect to a server "S", which only accepts connections from a local network, I call it "FNet". And my VPN server "TServer" is not part of this network "FNet". In order to access this server, I usually start another VPN "F" (with another VPN-server "FServ", virtually placing me (and my machine's IP address) inside the local network "FNet". Unfortunately, I can only connect to "FServ" via the first VPN. So, the question is, how to set up the second VPN?

Fortunately, it is possible to simply connect to two VPNs simultaneously. All you need to do is simply to configure both VPNs in your network settings.
Fig. 1:Simultaneously connect to multiple VPNs
I can then firstly connect to the VPN "T", and when this connection is establish I can use it to connect to the second VPN "F". Figure 1 shows the VPN menu in the system menu bar (OS 10.6, with elder versions, things look a bit different, as explained here).

Well, this is the easy part. The harder part is to tell the applications which VPN to use. This problem is (almost) the same problem as using different network interfaces (e.g., use the Ethernet connection for some tasks, and a WLan connection for others), as the VPNs create virtual network interfaces. So, it's time to start the console... ifconfig prints out the available network interfaces. E.g., my first VPN "T" has created a new interface called ppp0:

ppp0: flags=8051 mtu 1444
 inet --> netmask 0xffff0000

It is not that important to know exactly what you see here. The only important thing is the number which is the IP-address assigned to my machine for VPN "T".

After connecting to the second VPN "F", another interface is available, representing the second VPN:

utun0: flags=8051 mtu 1280
 inet --> netmask 0xffffff00

Within this second VPN, I've got the IP

So, I have two interfaces and two IP addresses, one for each VPN. This information can be used to tell applications to connect via one specific VPN.

In my case, I want to make an SSH connection to the server "S", which is only possible from within "FNet", that is, using the second VPN "F". Fortunately, I can tell ssh to use a certain IP address on my local machine. Let's assume to be the IP address of the server S. This is how to connect to "S" via the second VPN "F":

>ssh -b -l theUser

in which "theUser" the user login for "S". is the IP of my machine within FNet (as F virtually places my machine in FNet). Note that you have to use the IP address rather then the name of the server (maybe some geek can tell me how to "update" the DNS stuff accordingly).

Other applications cannot be configured that easily, in these cases you have to add routing entries to your route table. E.g., instead of using the "-b" option of ssh, I could have added a new route (I found that tip here). To add a route, I need to be a super user, so we have to use sudo:

>sudo add route

Now, I can directly connect to S without the "-b" option:

>ssh -l theUser

Don't forget to delete the route when no longer needed:

>sudo delete route

Thursday, November 18, 2010

Problems with TortoiseSVN and authentication (on WinXP)

Newer versions of TortoiseSVN may produce errors when repositories reside on servers with unknown (untrusted, whatever) certificates. The very same repositories may be checked out and updated using a command line version (or with Mac tools). The error message may be a little too short and doesn't explain very much:
negotiation failed: Secure connection truncated (
In order to fix this, you will have to change the underlying method of subversion/Tortoise for communicating with the server. This has to be specified in the server settings. This is a simple text file, hidden somewhere on your system. The easiest way of locating this file is by opening the Tortoise Settings and edit the "Subversion configuration file" (found under "General"). However, this only opens the "config" file, but what we need is the "server" file -- which luckily can be found in the very same folder as the "config" file. On my german Windows XP installation, its path is C:\Dokumente und Einstellungen\userid\Anwendungsdaten\Subversion\server. In "server" (pay attention to not accidentally add a ".txt" when saving the file), add a new server group in the group section, and set the http-library to "serf" for that group. E.g.,
myserver =

http-library = serf
Now, TortoiseSVN should work with your server.

P.S.: I found the solution at (although I have no debian system, it solved my problem, so thank for the tip, Peter Samuelson) ;-). I adapted the solution for TortoiseSVN, as it fixes the problem with TortoiseSVN, and most TortoiseSVN forums suggest to downgrade to elder TortoiseSVN versions, which didn't worked in my case.

Tuesday, September 21, 2010

Mount Samsung GT-i5800 as an USB Drive

Today I wanted to sync some of my music files with my new GT-i5800. Unfortunately, it didn't worked with MissingSync via Wi-Fi, so I tried USB. Well, how do I mount my GT-i5800 as a USB drive on OS X? By default, USB settings are "Samsung Kies", which I do not need on OS X (and with MissingSync). This setting has to be changed to "Mass storage" before connecting the USB cable!
Settings > About phone > USB settings > (X) Mass storage (default: Samsung Kies)
or in german:
Einstellungen > Telefoninfo > USB-Einstellungen > (X) Massenspeicher
Only after changing this setting, you can connect the GT-i5800 as described in the Missing Sync manual: "pull down the notification window (aka ‘window shade’) and tap USB connected."

Well, and thanks to bTunes ($1.49), my Android device almost feels like an iPod :-D