The RCX UNIX/Linux C Programming EnvironmentIn a UNIX/Linux environment simple commands to a command interpreter perform compilation and execution of c programs on the UNIX/Linux platform. Furthermore, in the DAIMI UNIX/Linux environment as e.g. on the UNIX/Linux machines in the building Zuse ( Studenterhallen), commands are also available to cross-compile c programs for the RCX and download the cross-compiled program to run on the RCX.
UNIX/Linux Command IntrepeterIn Tanenbaums Modern Operating Systems, chapter 1, p. 41-42, the UNIX/Linux command interpreter, called the shell, is described together with a few example commands. Useful commands is a list of the most common commands. The command man gives detailed information about a command, e.g. man cp.
Compilation and execution of c programs in UNIX/LinuxTo compile a c program in the UNIX/Linux environment use the commandThis will use the gcc compiler to compile a c program with the file name prog.c into an executable file with the name prog. To execute this program simply write the command or depending on the UNIX/Linux shell used. To obtain detailed warnings use gcc -Wall prog.c -o prog. Use gcc -S prog.c to obtain a file prog.s with a list of an assembly program compiled from the c program.
Cross-compilation of c programs for execution on the RCXCross-compilation of c programs to the Hitachi H300 microcontroller embedded inside the RCX can take place on a UNIX/Linux machine by means of a Makefile described in the RCX Manual. The Makefile contains a path to the cross-compiler, Hitachi assembler and linker in the DAIMI UNIX/Linux environment.To perform the compilation of e.g. a c program saved as TestTemplate.c, copy the Makefile to your current directory and compile as follows: The compilation of the c program results in a binary program in the S-record format saved in the file TestTemplate.srec.
Download of compiled c programs for execution on the RCXDownload of the cross-compiled program is performed through wireless infrared communication by means of an IR Tower, either a serial IR Tower er an USB IR Tower.
Download is performed as follows: Place the RCX in front of the IR Tower, turn on the RCX (the red OnOff button) and run a download program in the UNIX/Linux command interpreter: The download program for the serial Tower is RCX_Download described in the RCX Manual. The download program for the USB Tower is firmdl. Before the download programs can be used a path to a compiled version of the download programs should be included as either in the tcsh shell or in the bash shell. The default name of the RS232 port used has been set to /dev/ttyS0 in the download program RCX_Download. If the port used has the name /dev/ttyS1 either use the download program RCX_Download-ttyS1 or use the RCX_IR environment variable to override the default name. If the USB Tower gives permission problems, try unplugging the Tower for half a second. Last update: 22-01-06 |