Talking to devices connected to a PC
Archived post from 2010, recovered from my old blog. The technology described here is probably out of date. Original at the Internet Archive.
One of my assumption regarding intelligent home is that μHomeServer (see this post), a heart of the system, was written in Java. I am not going to argue with anyone and one could implement it in any other language. Anyway it has to be able to talk to devices connected to a PC in order to exchange commands, notifications and messages.
I also assume that only μNet Controller module is connected directly to a serial port (or USB-RS232 converter if PC does not have any) and it acts as a proxy between PC and other devices. I can see several ways to make a Java program talk to all those devices
Dedicated kernel driver
I think the best solution would be to write a Linux kernel driver that would handle μNet protocol and expose input and output streams via sockets or file streams. Java application could work directly on those streams without even knowing about serial ports and other low level stuff. The driver could handle collision detection and retransmissions. Actually μNet Controller would be as simple as an RS-232-RS485 converter in that case. However writing a kernel driver requires knowledge I am missing right now.
Direct access to serial port
There are two libraries allowing Java applications access serial ports directly:
It is quite easy to use each of them. However because of an unpredictable Garbage Collector it is not possible to achieve sub-millisecond accuracy required for handling collision detection and retransmissions in software. That would have to be implemented in μNet Controller.
Each of them comes with a pre-compiled system libraries for different operating systems. They have to be accessible by Java program. I am thinking about licence issues that may arise here.
Note that Javacomm does not support Windows platform.
Serial-network proxy
Ser2net is my recent finding. I have not tested it yet. It looks like it connects a serial port to a socket so you can talk to a device like it was a network service. No additional modules, libraries or dependencies. Of course we’re missing some low level controls so the protocol has to be handled in μNet Controller. A serial port could be even accessed remotely.