serial
Class SerialX10

java.lang.Object
  |
  +--serial.SerialX10

public class SerialX10
extends Object

The SerialX10 class is designed to control the X10 control devices, which in turn control the X10 modules which govern current from electrical outlets to various devices. Of primary use in the room are the "lamp" modules, which handle enough current to run a halogen lamp, and can even dim the light level to one of 16 settings. The modules are referred to by Housecode and Module numbers. The Housecode is actually a letter setting on the module, ranging from A-P, but in the SerialX10 class it is a byte from 0-15 (0-->A). The module number ranges from 1-16 on the modules themselves, but in the SerialX10 class it is a byte from 0-15 (1-->0). Thus Housecode C, Module 4 can be turned on by calling x10inst.turnOn(2,3); The usage of this class is intended as follows:

The origin of the X10 packet encoding method is unknown. The original x10a.c serial server (found in /hci/metaglue/old-stuff/src/serial2/old/old-serial-servers/old/x10/old) contains a complex encoding scheme. I have no idea where Chris Barnhart got that scheme. It has been greatly simplified here.


Constructor Summary
SerialX10()
           
 
Method Summary
 void close()
          Closes the port.
 void dim(byte housecode, byte module, byte dimth)
          Sends a "DIM" command to the specified module If it is off, it will turn it on full-way, then dim it down to the proper position (that is a limitation of the X10 API).
 void fadeOff(byte housecode, byte module)
          Sends a fade off command to the module.
 void fadeOn(byte housecode, byte module)
          Fades it on.
static void main(String[] args)
          Used for standalone debugging and hardware tests.
 void open(String in_device)
           
 void turnOff(byte housecode, byte module)
          Sends a directly "OFF" command to the specified module
 void turnOn(byte housecode, byte module)
          Sends an "ON" command to the specified module
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialX10

public SerialX10()
Method Detail

open

public void open(String in_device)
          throws javax.comm.NoSuchPortException,
                 javax.comm.PortInUseException,
                 IOException
Parameters:
in_device - the name of the serial device to speak to. (e.g. "/dev/ttyrg")

turnOn

public void turnOn(byte housecode,
                   byte module)
            throws IOException
Sends an "ON" command to the specified module
Parameters:
housecode - (0-15)
module - (0-15)

fadeOn

public void fadeOn(byte housecode,
                   byte module)
            throws IOException
Fades it on. That this is much different that turnOn is debatable. fadeOff does in fact work as specified.
Parameters:
housecode - (0-15)
module - (0-15)

turnOff

public void turnOff(byte housecode,
                    byte module)
             throws IOException
Sends a directly "OFF" command to the specified module
Parameters:
housecode - (0-15)
module - (0-15)

fadeOff

public void fadeOff(byte housecode,
                    byte module)
             throws IOException
Sends a fade off command to the module. Only use this if the device is known to be on, because otherwise, it will turn it on all the way, then fade it off.
Parameters:
housecode - (0-15)
module - (0-15)

dim

public void dim(byte housecode,
                byte module,
                byte dimth)
         throws IOException
Sends a "DIM" command to the specified module If it is off, it will turn it on full-way, then dim it down to the proper position (that is a limitation of the X10 API).
Parameters:
housecode - (0-15)
module - (0-15)
dimth - (0-15) 0 is dark, 15 is bright

close

public void close()
           throws IOException
Closes the port.

main

public static void main(String[] args)
Used for standalone debugging and hardware tests.