RCX Tools

RCX Tools [top]

This section of RCX Internals describes the tools I use to communicate with the RCX, with pointers to source code. Note that my tools are designed to be compiled and run under IRIX, although with few or no modifications, I expect they will run under any flavor of Unix. In particular, they should run under Linux and Solaris with no modifications.

Two tools are currently available:

In addition, I have released a small C development environment:

Copyright © 1998, 1999 Kekoa Proudfoot. All rights reserved.

Send [top]

A program to send a message to the RCX and dump the response as hex. Accepts unencoded message bytes on the command line and dumps a decoded response to stdout. Unencoded and decoded messages do not contain the packet header, checksum, and complement bytes.

The program attempts to provide reliable communication with the RCX. It will retry a send up to three times, and it will check the response to see if it was valid. The exit code will be non-zero if the send failed. Note that the RCX does not respond to the set message opcode; this program will always return a non-zero exit code when that opcode is sent.

The program also attempts to encapsulate RCX communication into a few simple routines, making portions of the program reusable for building other tools.

Here is an example where an alive is sent and its response is received.

1% send 10
0000: ef

Here, I download a program to the RCX in three steps. The first step uses set program number to set the current program to 4, which appears as 5 on the display. Next, start task download is used to initiate a transfer of task number 0. Finally, transfer data is used to send a short program that plays two beeps then waits forever. This program makes use of two opcodes, play sound and branch always near. The latter loops back onto itself. To start the program, hit the run key on the RCX. To stop the program, press the run key again.

2% send 91 04
0000: 6e
3% send 25 00 00 00 04 00
0000: da 00
4% send 45 00 00 04 00 51 01 27 81 00
0000: ba 00

Be wary of sequence bit problems. If the opcode you want to send now is the same as the last opcode acknowledged by the RCX, you have to toggle the 0x08 bit for the opcode to be accepted again.


The previous version of this program is available here. It is still somewhat useful, especially if you want to see the raw reply bytes sent by the RCX.

Thanks to Vadim Strizhevsky for pointing out a correction in the above instructions regarding the 0x08 bit being called the 0x80 bit.

Firmdl [top]

A Unix firmware downloader for the RCX, with support for quad-rate downloading.

Quad-rate downloading is a feature that significantly reduces firmware download times. It is implemented on top of a fast serial protocol that has a 2x baud rate with no complements or parity bits. The fast protocol is enabled by a short firmware stub that reconfigures some control registers and tweaks some ROM program state. Once the firmware stub is downloaded and executed, the ROM responds to the fast serial protocol, which the downloader then uses to transfer the actual firmware file. Because the initial firmware stub is small, all but the most trivial programs see a download time improvement when using quad-speed downloading.

The caveat to using quad-speed downloading is its sensitivity to lighting conditions. Getting quad-speed downloading to work right might require some trial and error. In addition to avoiding harsh lighting conditions, it is important to place the RCX around 4-12 inches from the IR tower.

If quad-speed downloading does not work, a --slow switch can be used to revert to single-speed transfers. Run the downloader with --help for more information.

Firmdl is available as a single file or as a collection of individual files. The single file is intended to be easier to transport and compile, but the file collection is typically more reusable and more up-to-date. A subset of the files in the collection implement a general set of routines for communicating with the RCX using the ROM packet formatting conventions; these files might be useful to programmers wanting source code to interface to the RCX using the serial protocol.

firmdl3.c: one file, probably out-of-date
firmdl3.tar.gz: separate files, current versions

Previous versions:

Librcx [top]

Librcx is intended to be a lowest-level driver for the Lego RCX. It provides an interface between your C code and the RCX ROM. The intent is to allow you to easily explore the ROM interface. It is also possible to use this code as a starting point for writing something more sophisticated, along the lines of LegOS.


Version history:

Copyright © 1998 Kekoa Proudfoot. All rights reserved. kekoa@graphics.stanford.edu