Time Tracking with RFID on BORM ERP

Before I discovered what my Bifferboard really is, I almost disposed it, but now It found a new purpose. It’s a networked rfid Terminal for time tracking on our BORM ERP. I use a simple python script on the device because it’s easier to experiment on a device where I would rather not compile too much every time trying something. In fact, this is my first python project appart from looking through some scripts and changing a few lines here and there.

Serial RFID

First thing was reading from the towitech RFID reader. It has a TTL serial interface, and python has good support for serial. But the data comes in binary, which is not as easy as ascii, not too bad though. Conversion is done like this : “rfidtag += “%02X” % ord(serin)”. I described in a former blog post how to prepare the serial console of the biffboard.

MS SQL Server

Turns out there is good support for Microsoft SQL Server in Linux. There is a package for commandline query in the debian repository as well as a library for python. Both work flawlessly. Reverse engineering the structure of the database was a bit more fun, as the queries involved are not the same on every database system. But the procedure is well documented on the internet. For figuring out what I have to do exactly, I resorted to WireShark for analyzing what queries are sent to the DB server when I log my times with the regular desktop client. Sure, I could have gone one story lower and ask one of the developers of the BORM ERP, but reverse engineering was more fun. When I was done, I asked Markus for verification.

APT Repository

As the ppa’s on launchpad still don’t build packages for debian, I finally investigated how to run my own apt repository. I wanted apt to resolve all dependencies, downloads and updates for me on the bifferboard. Out of the several options I cose reprepro according to this description. To use it, add the following lines to your /etc/apt/sources.list :

deb     http://apt.ulrichard.ch  squeeze main contrib non-free
deb-src http://apt.ulrichard.ch  squeeze main contrib non-free

The packages are signed, but I have yet to prepare a keyring package for automatic verification.

Feedback -> BlinkM (i2c)

Only reading the RFID tag and writing to the database was somehow not enough. I needed some sort of feedback if it worked. First Idea was to use the LED that’s hardwired on the bifferboard. But it’s in the middle of the device and not visible from the outside. The second Idea was to use a piezo buzzer, but at 3.3V you could hear almost nothing and the maximum frequency that I could generate with the script to drive the internal LED was about 20Hz. So, time to solder and use the JTAG pins as GPIO for I2C. I had a BlinkM laying around which seems to be perfect for the job. The only bad thing is that it doesn’t fit into the case any longer.

To get the exact commands, I looked at the sources of the Arduino library for the BlinkM. I can directly communicate from the commandline using i2cset. Although it works, the behavior is not always as expected. For the moment I call this commandline utility from the python script. There seem to be i2c libraries for python, but I didn’t succeed with one of them so far.

Loading the i2c kernel modules on each boot

The page on how to use i2c on the bifferboard shows what to do during testing. It was good for testing only though, because after the next reboot, I had to execute
all the modprobes again. So this page describes what to do, so that the modules are loaded on every boot. But these instructions don’t seem to be well suited for inclusion in a deb package, as it involves editing files already on the system. I would much prefer an approach such as used with cron. Where one can put a packagename.cron.d file into the debian folder.  Also this page talks about installing modues that belong to the package.
But the modules that I want to load don’t belong to my package. They beolng to packages that my packages depends on or came with the kernel or rootfs.

Nevertheless, I ended up using dh_installmodules to put a file in /etc/modprobe.d/ . But from what I saw so far, that’s only for providing the
options. The modules are still not loaded. So, for the moment I hacked the modprobes into the daemon start-stop script which is also called at boot time and from cron. Not nice, but it works until I find a good solution.

Running Python script as a daemon

Daemonizing a python script looks really easy on the python daemon page, but combining it with python configglue didn’d seem so straightforward.

This page also gives a good description of how to run a python script as a daemon. Looks like that’s enough already, and I don’t need python-daemon.

Source

I want to opensource it, but first I have to check, if I’m allowed to do so. It’s probably ok, as all the knowlege used about BORM ERP was gathered through reverse engineering.

Update 6. Feb 2013:

I received the ok to publish the code a long time ago, but forgot to list it here. So here it is:

https://github.com/ulrichard/rfidtime


Posted

in

, , ,

by

Comments

3 responses to “Time Tracking with RFID on BORM ERP”

  1. emma dcosta Avatar
    emma dcosta

    Thanks for sharing this wonderful information regarding time tracking application. We had been looking for a efficient time tracking solution and started using (advertisement removed) time tracking software which had been a completely hassle free experience.

  2. ulrichard Avatar
    ulrichard

    Hi Emma,
    nice that you find my post interesting.
    But this is really not the right place to advertise for a commercial legacy software package.
    Rgds
    Richard

  3. […] than a year ago, I blogged here about using RFID to track presence times in the BORM ERP system. I used the system a lot since then. But the BlinkM was really limited as the only immediate […]

Leave a Reply

Your email address will not be published. Required fields are marked *