//Serial bufferbyte serIn; // var that will hold the bytes-in read from the serialBufferbyte serInString[9]; // CM11a can send up to 10 bytes (program only handles 3 bytes)int serInIndx = 0; // index of serInString[] in which to insert the next incoming byteint serOutIndx = 0; // index of the outgoing serInString[] array;

CheckX10controller(); // Check CM11a for data or power failure. parseX10SerialString();

}

// Read from X10 controllervoid CheckX10controller() {

if (X10Serial.available() > 0) { incomingByte = X10Serial.read();

switch (incomingByte) {

case ((byte)0xA5): // Polling: This happens the first time you plug the X10 controller in the socket or after a power cut delay(100); // CM11a is slow; don't write too fast, won't work! X10Serial.write((byte)0x9B); // Acknowledge / Clear, This must be cleared or it will not except any other x10 commands delay(60); Serial.println("Power Supply Restored"); break;