(taken directly from the X10 FAQ) SECTION 4: PROGRAMMING DETAILS FOR CP290 HOME CONTROL INTERFACE ================================================================ Reference: X10 CP290 Home Control Interface Programming Guide for Advanced Programmers The CP290 Home Control Interface communicates with the host computer via a simplified RS-232 interface. Serial communication takes place at 600 baud, eight data bits, no parity, and one stop bit. The reference recommends a pause of one millisecond between transmitted bytes, although in many applications this seems not to be required. This probably depends on the efficiency of the serial communications software used to send data to the interface. The serial connector on the CP290 is a five pin DIN connector. As seen from the back of the interface, the pinouts are as follows: 5 - no connection * * 1 - no connection 4 - data to computer * * 2 - data from computer * 3 - signal ground There are eight possible commands that the computer can send to the CP290. Each command starts with 16 hex FF bytes (each 0xff, or eight ones) for synchronization purposes. These are followed by the command code 0-7 and then a variable number of bytes as required by the syntax of each command. The interface requires a checksum of data bytes that follow the command code (see details for each command for exceptions) as the last byte in a command. The interface responds to each command with 6 hex FF bytes (each 0xFF, or eight ones) for synchronization purposes. This is followed by a status byte, and depending on the command, other information. The interface generates a checksum for all bytes following the status byte and sends it as the last byte in a reply to a command. COMMAND 0 - SET INTERFACE BASE HOUSE CODE The CP290 maintains a value called the base house code, which defaults to house code A on power up. This is equivalent to setting the house code on other X10 controllers; the eight buttons on the CP290 control units 1-8 on or off for the base house code. Note that setting the base house code with this command will clear all data in the interface. Command syntax (computer to interface): bytes 0-15: 1111 1111 - synchronization 16: 0000 0000 - command 0 17: HHHH 0000 - base house code to set where HHHH = 0000 - house code M 0001 E 0010 C 0011 K 0100 O 0101 G 0110 A 0111 I 1000 N 1001 F 1010 D 1011 L 1100 P 1101 H 1110 B 1111 J Return (interface to computer): bytes 0-5: 1111 1111- synchronization 6: 0000 000X - interface status where X = 0 - interface has lost all memory 1 - interface is OK COMMAND 1 - SEND DIRECT COMMAND It is possible to send X10 commands from the computer onto the power line via the CP290. This is not particularly fast. Command Syntax (computer to interface): bytes 0-15: 1111 1111 - synchronization 16: 0000 0001 - command 1 17: LLLL FFFF - dimming level and function 18: HHHH 0000 - house code for this command 19: UUUU UUUU - unit codes bitmapped 9-16 20: VVVV VVVV - unit codes bitmapped 1-8 21: CCCC CCCC - checksum where LLLL = 1111 - dimmest (not quite full off) ... - intermediate brightness values 0000 - brightest (not quite full on) FFFF = 0000 - units off (*) 0001 - lights on, not appliances (*) 0010 - turn on 0011 - turn off 0100 - if light off, turn on full; in any case, dim to full off. Responds as 0011 (*) 0101 - if light off, turn on full; else brighten to full; then dim LLLL (LLLL+1?) steps. Responds as 0100. 0110 - if light off, turn on full; else brighten by LLLL+1 steps. Responds as 0101. (*) 0111 - no obvious effect. Responds as 0110. 1000 - no obvious effect. 1001 - no obvious effect. 1010 - no obvious effect. 1011 - no obvious effect. 1100 - no obvious effect. Responds as 1011. 1101 - no obvious effect. Responds as 1100. 1110 - no obvious effect. Responds as 1101. 1111 - no obvious effect. Responds as 1110. where (*) indicates behavior undocumented in the reference HHHH - as for Command 0 UUUU UUUU - units bitmapped as 9 10 11 12 13 14 15 16 VVVV VVVV - units bitmapped as 1 2 3 4 5 6 7 8 CCCC CCCC - sum of bytes 17-20 Return (interface to computer): bytes 0-5: 1111 1111 - synchronization 6: 0000 000X - interface status (pause while X10 command is sent onto power line) 7-12: 1111 1111 - synchronization 13: 0000 000X - interface status 14: HHHH FFFF - house code and function 15: UUUU UUUU - unit codes bitmapped 9-16 16: VVVV VVVV - unit codes bitmapped 1-8 17: HHHH 0000 - base house code 18: CCCC CCCC - sum of bytes 14-17 where all values are as explained above; response function codes are same as command function codes except as noted COMMAND 2: SET INTERFACE CLOCK This command sets the internal clock in the CP290. Command syntax (computer to interface): bytes 0-15: 1111 1111 - synchronization 16: 0000 0010 - command 2 17: 00mm mmmm - minutes 0-59 18: 000h hhhh - hours 0-23 19: 0ddd dddd - bitmapped day of week Sun - Mon 20: CCCC CCCC - sum of bytes 17-19 where ddd dddd is day of week bitmapped as Sun Sat Fri Thu Wed Tue Mon Return (interface to computer): bytes 0-5: 1111 1111 - synchronization 6: 0000 000X - interface status COMMAND 3a: SEND TIMER EVENT TO INTERFACE This command sends a timer event to the interface. The computer can then be disconnected and the event will be sent over the power line as X10 commands at the appropriate time. Events are stored eight bytes per event in locations 0-1023 in the 2K RAM inside the interface. Command syntax (computer to interface): bytes 0-15: 1111 1111 - synchronization 16: 0000 0011 - command 3 17: AAAA AAAA - LSB of event address 18: 0000 00AA - MSB of event address 19: NNNN MMMM - mode 20: 0ddd dddd - bitmapped days Sun - Mon 21: 000h hhhh - hour 0-23 22: 00mm mmmm - minute 0-59 23: VVVV VVVV - bitmapped unit codes 1-8 24: UUUU UUUU - bitmapped unit codes 9-16 25: HHHH 0000 - house code for this event 26: LLLL FFFF - level and function 27: CCCC CCCC - sum of bytes 19-26 where 0000 00AA AAAA AAAA (bytes 18 and 17) = 0000 0000 0000 0000 for event 0 0000 0000 0000 0100 for event 1 0000 0000 0000 1000 for event 2 .... (increases by 8 for each event) 0011 1111 1111 1100 for event 127 MMMM = 0000 - clear 0001 - ? 0010 - tomorrow only then clear 0011 - ? 0100 - today only then clear 0101 - ? 0110 - ? 0111 - ? 1000 - at exact time 1001 - at approximate time 1010 - ? 1011 - ? 1100 - ? 1101 - ? 1110 - ? 1111 - ? NNNN = MMMM - program event NNNN = MMMM = 0000 - clear event NNNN not = 0000; MMMM = 0000 - store event but put it on hold (will not take place) Actually, setting for NNNN and MMMM is a bit vague. The reference indicates that NNNN = 0 and MMMM is function code as shown above. The software provided with the CP290 uses NNNN = MMMM except when "freezing" an event (deactivating it, but not erasing it). Frozen events also have UUUU UUUU = VVVV VVVV = 0. It's not clear how a frozen event knows what units it is to control. Not clearing the unit mask confuses the standard CP290 software... Return (interface to computer): bytes 0-5: 1111 1111 - synchronization 6: 0000 000X - interface status COMMAND 3b: SEND "GRAPHICS DATA" TO INTERFACE In the 2K RAM of the interface, locations 1024 through 1535 are accessible from the external computer, but are not used for events or any other purpose by the interface. In the CP290 these are referred to as the locations for graphics data. For each of 256 possible units, the memory locations could be used to indicate (under control of an external program) the on/off condition of a unit, or the type of unit it is (possibly an index to a graphics icon). This command writes data from the computer two bytes at a time to these memory locations in the interface. Command syntax (computer to interface): bytes 0-15: 1111 1111 - synchronization 16: 0000 0011 - command 3 17: AAAA AAA0 - LSB of data address 18: 0000 0AAA - MSB of data address 19: GGGG GGGG - data byte 0 20: GGGG GGGG - data byte 1 21: CCCC CCCC - sum of bytes 19 and 20 where 0000 0AAA AAAA AAAA(bytes 18 and 17) = 0000 0100 0000 0000 for data pair 0 0000 0100 0000 0010 for data pair 1 ... (increases by 2 for each subsequent data pair) GGGG GGGG - can be anything relevant to the external program, since this data is not used by the interface Return (interface to computer): bytes 0-5: 1111 1111 - synchronization 6: 0000 000X - interface status COMMAND 4: GET CLOCK TIME AND BASE HOUSE CODE FROM INTERFACE This command reads the time from the internal interface clock and also gets the current base house code. It is an innocuous way of testing for the presence of the interface, and to see if it has lost its memory since the last time events were downloaded to it. If there is no reply to this command after several seconds, the computer could assume that the interface was not (properly) connected. Command syntax (computer to interface): bytes 0-15: 1111 1111 - synchronization 16: 0000 0100 - command 4 Return (interface to computer): bytes 0-5: 1111 1111 6: 0000 000X - interface status 7: 00mm mmmm - minute (0-59) 8: 000h hhhh - hour (0-23) 9: 0ddd dddd - bitmapped days Sun - Mon 10: HHHH 0000 - base house code 11: CCCC CCCC - sum of bytes 7-10 COMMAND 5: GET TIMER EVENTS FROM INTERFACE This command requests the interface to send to the computer the events that it has stored in its memory. Command syntax (computer to interface): bytes 0-15: 1111 1111 - synchronization 16: 0000 0101 - command 5 Return (interface to computer): bytes 0-5: 1111 1111 6: 0000 000X - interface status for( event = 0 ; event < 128 ; event = event+1 ) { if( event is not erased ) { 7: NNNN MMMM - mode 8: 0ddd dddd - bitmapped days Sun - Mon 9: 000h hhhh - hour 0-23 10: 00mm mmmm - minute 0-59 11: VVVV VVVV - bitmapped unit codes 1-8 12: UUUU UUUU - bitmapped unit codes 9-16 13: HHHH 0000 - house code for this event 14: LLLL FFFF - level and function } else 7: 1111 1111 - indicates event in that location is erased } last byte: CCCC CCCC - sum of all bytes for valid events starting with byte 7; does not include the 1111 1111 for locations where event has been erased COMMAND 6: GET "GRAPHICS DATA" FROM INTERFACE This command requests the interface to send the "graphics data" that it has stored in its memory. See COMMAND 3b above. Graphics data is not used in any way by the interface. Command syntax (computer to interface): bytes 0-15: 1111 1111 - synchronization 16: 0000 0110 - command 6 Return (interface to computer): bytes 0-5: 1111 1111 6: 0000 000X- status for( unit = 0 ; unit < 256 ; unit = unit+1 ) { if( graphics data for unit has been stored ) { 7: GGGG GGGG 8: GGGG GGGG } else 7: 1111 1111 } last byte: CCCC CCCC - sum of all data pairs for all units starting with byte 7; excludes the single 1111 1111s in cases where data for that unit has not been stored COMMAND 7: DIAGNOSTIC This command tells the interface to run a self-check on its hardware and firmware. Pin 4 on the interface goes low for 10 seconds; this may generate extraneous characters that are detected by the attached computer. At the end of this time, the interface sends its status if it can. Note that this command will scramble or clear any data stored in the interface. Command syntax (computer to interface): bytes 0-15: 1111 1111 16: 0000 0111 - command 7 Return (interface to computer): bytes ?: extraneous characters for 10 seconds 0-5: 1111 1111 - synchronization 6: 0000 000T - test status where 0000 000T = 0 - interface is OK 1 - interface has a fault KEYBOARD COMMANDS If X10 commands are sent using the keys on the top of the CP290, the interface will send a report to the computer so it can keep track of the status of units. Report (interface to computer): 0-5: 1111 1111 - synchronization 6: 0000 000X - interface status 7: HHHH FFFF - house code and function 8: UUUU UUUU - unit codes bitmapped 9-16 9: VVVV VVVV - unit codes bitmapped 1-8 10: HHHH 0000 - base house code 11: CCCC CCCC - sum of bytes 14-17 where FFFF is the function return code described for Command 1 (SEND COMMAND DIRECT) TIMED EVENTS When the CP-290 sends X10 commands in accordance with an event programmed into it, it will send a report to the computer so the computer can keep track of the status of units. This report is in the same format as the report for keyboard commands described above.