dcf77 for Linux
Last modified: Mon Mar 15 02:37:33 CET 2004 Index

This is the homepage of dcf77, a small program which decodes the signal of a DCF77-clock attached to the parallel-port sold by "Conrad Elektronik". DCF77 is a broadcasting-system for radio-time in Germany. The program just gets the data out of the clock and writes it on demand into the linux-internal system-clock and the RTC. You have to compile RTC-support into the Kernel to get dcf77 work.

Download Get the source-codes: dcf77-0.1-source.tar.gz.

Compilation Just compile it with your favourite compiler (gcc, egcs or pgcc, or what ever you want). The program does not rely on any libraries besides of libc6. After compiling you should copy the executable to /usr/sbin or somewhere else in your $PATH.

gcc -O2 dcf77.c -o dcf77

Notice #1: You have to optimize at least with -O2, because the program uses inline functions. Notice #2: You must be root to execute the program, because the program needs realtime access to the parallel-port. Notice #3: On my machine the software only works when there is no printer connected to the clock or when the printer which is connected is online. When the printer is connected but offline the clock is not detected.

Compatibility Development was done on Intel (Debian GNU/Linux 2.1); I do not beleive that the code works on other architechtures, because it expects an IBM-compatible parallel port. The software has been intensively tested on an Cyrix 6x86 PR233, a Pentium II 233 and a Pentium 133 without any problems. My clock does its job perfectly for more than a year. There do exist some problems with SMP machines, but that are bugs in the Linux-Kernel. You should get the newest kernel, and everything should work fine.

Pros and cons of the clock The clock is a very cheap piece of hardware. It cannot be used for exact timekeeping. The clock saves time in half seconds, but my program only looks on whole seconds, because I do not know how to set the Linux-clock more exact. And you should notice something else: Different dcf77-clocks have slightly different times, it is not clear which one is right. (Try it: compare several radio-alarm-clocks with your conrad-dcf77-device and the clock of the teletext of the TV: all show slightly different times.) This software is only designed to replace a broken RTC-clock. That is the purpose I use the clock for. Notice: You shouldn't be so smart to put dcf77 into your crontab. This will only provoke problems over problems, because the chance of getting a time difference of one second between two dcf77-calls is 50%. Some userspace daemons like cron itself get irritated when the clock is changed by hand. Because of that you should use dcf77 as seldom as possible. When you have a broken RTC (like me) one dcf77-call in your init-scripts should be enough. When Linux is running the RTC has no more influence on Linux timekeeping, so Linux timekeeping will stay nearly perfect.

Features My programs searches automatically for the clock on all three possible parallel ports. When a clock is found the time is read and printed onto the screen. The difference to the Linux-time is printed out too. When specifing the command-line-switch "-s", both the system-time and the RTC time are set to the dcf77-time. The RTC-time is set with the /dev/rtc-interface. Because of that you need to compile support for this into the kernel.

 © 2000-2004 by Lennart Poettering mzqps77 (at) 0pointer (at) de

$Id: index.latte 123 2004-03-15 01:37:30Z lennart $