[ introduction | generic protocol | devices ]
This document describes the protocol used on the RS422 bus that connects various devices around the house. It also lists the (known) devices and their supported commands.
The following figure shows the general structure of a packet on the RS422 bus:
The first byte is the length of the packet, inclusive of itself and the checksum byte at the end of the packet. The checksum is the sum (modulo 256) of all the preceeding bytes in the packet.
The LUN is the device logical unit number (abbreviation shamelessly lifted from SCSI terminology). There are two special LUN values: 0x00 is the LUN of the bus-master for a particular bus (typically the PC via RS232/RS422 bridge); 0xff is the broadcast LUN.
Broadcast packets contain the generic protocol described here. Packets directed at a specific LUN are considered to be device-specific. Packets sent to the bus-master LUN are nearly always reply packets, from either the generic or device-specific protocols.
Generic protocol packets have the following structure:
The following table lists the currently supported values for cmd:
| 0x00 | device discovery, used to find new devices |
| 0x01 | device soft reset, used to reset devices on the bus |
| 0x80 | device address assign, used to assign LUN values |
| 0x81 | device ping, used to ping devices |
| 0x82 | device identity, used to retrieve the identity of a device |
| 0x83 | device raw command, used to control a device without a LUN |
To make device programming slightly simpler, any generic command that has the high-bit set requires a device-ID match. That device-ID is contained in the 4 bytes following the command byte.
The device-discover command (0x00) is used to locate new devices (or existing devices without a LUN set). The packet sent has the following structure:
Devices respond after a reasonably variable delay, based on their device-ID). The response sent by a device is similar to that of the device-identify command; in this case the response has the structure:
The soft-reset command (0x01) is used to reset all devices on the bus. This is only good for devices that are still responding to the system, however. The packet sent has the following structure:
The device-address-assign command (0x80) is used to assign LUN values to devices. The packet sent has the following structure:
The device-ID must match the device's own ID. The response sent by a device is largely the same, except that the (first) LUN value will be 0x00 and not 0xff. The response is largely an acknowledgement to ensure that a device's LUN has indeed been changed.
The device-ping command (0x81) is used to test the existence of a device. The packet sent has the following structure:
The device-ID must match the device's own ID. The response sent by a device is largely the same, except that the LUN value will be 0x00 and not 0xff.
The device-identify command (0x82) is used to retrieve the device identity for a device:
The response from a device has the following format:
The device-raw-command command (0x83) is used to control a device that does not have a LUN set:
Various supported devices and IDs:
| 0x80010000 | test unit |
| 0x80020001 | temperature sensor (machine room) |
| 0x80020002 | temperature sensor (utility room) |
| 0x80020003 | temperature sensor (front room) |
| 0x80020004 | temperature sensor (kitchen) |
| 0x80020005 | temperature sensor (outside) |
| 0x80030000 | remote IR remote |
| 0x80040000 | AVR programmer |
| 0x80050001 | pulse sensor (electicity and gas monitoring) |
| 0x80060001 | general I/O device |
| 0x80070001 | 4-character display |
| 0x80080001 | 8-character display |
| 0x80090001 | bus power manager |
| 0x80100001 | 16-character display |
| 0x80110001 | transmitter test device |
| 0x80120001 | train controller device |
| 0x80130001 | train driver device |
| Command | Response | Description |
|---|---|---|
| 00 | reset counter | |
| 01xx | set counter to xx | |
| 02 | enable periodic messages | |
| 03 | disable periodic messages |
| Command | Response | Description |
|---|---|---|
| 00 | set normal operation | |
| 01 | calibrate high (30 ^C) value | |
| 02 | calibrate low (0 ^C) value | |
| 03 | nn03xxxxyy | read temperature and aux counters, originating LUN in nn, temperature count in xxxx, auxillary count in yy |
| 04 | nn04 | set normal operation and acknowledge, originating LUN in nn |
| 05 | nn05 | calibrate high (30 ^C) value and acknowledge, originating LUN in nn |
| 06 | nn06 | calibrate low (0 ^C) value and acknowledge, originating LUN in nn |
| Command | Response | Description |
|---|---|---|
| 00xxyy | transmit RC5 codeset xx (0-31), command yy (0-63) | |
| 01xx | set RC5 transmit frequency constant to xx (default is 6f) | |
| 02 | nn02xx | get RC5 transmit frequency constant, originating LUN in nn, frequency value in xx |
| Command | Response | Description |
|---|---|---|
| 00 | initialise programmer | |
| 01 | shut-down programmer | |
| 03 | nn03xxyy | read aux counters, originating LUN in nn, aux1 count in xx, aux2 count in yy |
| to be completed | ||
| Command | Response | Description |
|---|---|---|
| 00 | clear counters | |
| 01 | nn01xxxxxxyyyyyy | read and clear counters, originating LUN in nn, counter 1 value in xxxxxx and counter 2 value in yyyyyy |
| Command | Response | Description |
|---|---|---|
| 00xx | output xx on the 8-bit port | |
| 01 | nn01xx | read 8-bit port data, originating LUN in nn, data in xx |
| to be completed | ||
| Command | Response | Description |
|---|---|---|
| 00 | clear display | |
| 01aabbcc... | set display text (max. 44 chars) | |
| 02 | enable scrolling | |
| 03 | disable scrolling | |
| 04xx | set scroll speed to xx | |
| 05xx | set display offset to xx |
| Command | Response | Description |
|---|---|---|
| 00 | clear display | |
| 01aabbcc... | set display text (max. 44 chars) | |
| 02 | enable scrolling | |
| 03 | disable scrolling | |
| 04xx | set scroll speed to xx | |
| 05xx | set display offset to xx |
| Command | Response | Description |
|---|---|---|
| 00 | 00ssss | get device status |
| 0101 | 01 | turn on socket A |
| 0102 | 01 | turn off socket A |
| 0103 | 01 | disable socket A cold-start |
| 0104xx | 01 | enable socket A cold-start after (15 * xx) seconds |
| 0201 | 02 | turn on socket B |
| 0202 | 02 | turn off socket B |
| 0203 | 02 | disable socket B cold-start |
| 0204xx | 02 | enable socket B cold-start after (15 * xx) seconds |
| 0301 | power-cycle bus | |
| 0304xx | 03 | enable bus cold-start after xx seconds |
The ATMega8 device that this currently runs on has plenty of internal memory (1k SRAM). The maximum supported message size is around 496 bytes. To get the whole message in, it must be uploaded in 64-byte chunks, which makes the protocol handling a little odd.
| Command | Response | Description |
|---|---|---|
| 00 | clear display | |
| 01nn aabbcc... | set text segment nn (0-7) to text aabbcc.. (max 64 chars at a time) | |
| 02 | enable scrolling | |
| 03 | disable scrolling | |
| 04xx | set scroll speed to xx | |
| 05xx | set display offset to xx | |
| 06xx | set high display offset to xx | |
| 07hhll | roll display to offset hh ll | |
| 08xx | set scroll start offset to xx (0-15) |
This device doesn't respond to any particular commands: it just transmits a general message to the host (about once per second). It will respond correctly to generic commands, to have its LUN set, etc.
This device has (in theory) 4x 8-bit output ports and 4x 8-bit input ports, wired up to various sensors and indicators.
| Command | Response | Description |
|---|---|---|
| 00 | disable input polling | |
| 01 | enable input polling | |
| 02 xx | set polling speed to xx | |
| 03 pp vv | set output port pp to vv | |
| 04 pp vv ww hhll jjkk | timed port output, after hhll ms set port pp to vv, hold for jjkk ms then set to ww | |
| 05 pp | ppvvcc | read input port pp, value returned in vv, changed bits indicated in cc |
| 06 | cancel any in-progress timed port output | |
| 07 pp vv ww mm hhll jjkk | masked timed port output, after hhll ms set port pp bits mm to vv, hold for jjkk ms then set to ww mask mm; unmasked bits are not affected | |
| 08 | aabbccdd vvwwxxyy | read all input ports (reported in aabbccdd), without clearing change bits (reported in vvwwxxyy) |
| 09 | clear all input port change bits | |
| 0a pp vv mm | set output port pp to vv with mask mm |
This device is driven by remote RS422-over-RF (433 MHz), currently an input-only device so needs device-specific generic commands.
| Command | Response | Description |
|---|---|---|
| 00 | all stop | |
| 01 | ahead half for 1.5s | |
| 02 | ahead full for 1.5s | |
| 03 | reverse half for 1.5s | |
| 04 | reverse full for 1.5s |
Last modified 21st August 2007 by Fred Barnes (http://frmb.org/).