An Unheroic Story: Connecting Java to C-Control

After the end of the year parties I had some time to continue my web 3.0 project. In a very incremental way I want to connect my Conrad C-Control V1.1 which features a temperature, humidity, and air pressure sensor to the pachube service.

After looking at several alternatives to implement the connection from the C-Control to the Internet I decided to use the serial port of the C-Control, connect it with my PC and run a Java application to send the XML-data to pachube.

Of course there have been some technical alternatives (Perl, C++) but I decided to build on Java as I would learn most how easy I could integrate the old embedded technology with the current Internet standard.

First I installed the newest Eclipse IDE Version: 3.4.1 Build id: M20080911-1700 from This turned out to be easy even though I had already the Eclipse CDT for C/C++ development. I just have two instances of Eclipse in separated sub-folders: one for Java and one for C.

The I started browsing for data streams in Java to read input from the PC serial port. Boy, I was shocked. There is NO serial or parallel interface support in standard Java. The only Sun support is an outdated and officially not supported Sun Java Library called Java Communication 3.0 API. For Windows one has to relay on the open source development from So first I registered as a Sun developer to acquire the Sun comm API 2.0.3. Therefore, the Sun download tool was installed on my PC. After that I struggled quite a while to find the place in Eclipse to add the library to my project. It took me even longer to find the promised example for using the serial port interface…

The I googled for the rxtx windows support and had look to find Eclipse plug-ins: The the real unheroic story begin to start. I was not able to direct the rxtx windows dlls to the Sun Comm API. After reading dozens of bug reports, howtos, and news I went to bed ;-(

Next day I found a pretty simple solution: Do not use the Sun Comm API at all; instead use the .jar-file from rxtx. After importing the sample java file Eclipse was happy to compile the executable. But this didn’t mean that things worked out already. The input stream from the serial port captured by Java had very strange characters (NULL and others) though the Windows Terminal Software did not have these problems.

After another couples of hours in bug reports and news postings, some testing here and there I found a bug in the „official sample“ file. The readBuffer size did not fit well the characters really read from the port. Quite annoying…

Overall it took me about ten hours to display the serial port input stream on the PC screen. The code to do this has 195 lines. In Perl this would be a small exercise of 10 minutes at most. Stream in C++ would have been much easier also.  My first conclusion: Java is not ready yet for embedded world at all! The code is here:

The next story will be the XML-Output in eeml-format for the pachube web service.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert