Recent Changes - Search:




Mega Plan



Before starting to write C code for the robot, you must download and install the Gumstix buildroot and the Brainstem libraries. See the Development section for more details.


Running C programs on the Gumstix requires they be compiled elsewhere, and then the executable is transfered to the Gumstix. Source code is compiled with a compiler that is designed for embedded architecture. The best compiler is the ARM C compiler provided in the Gumstix buildroot.

Communicating with the Brainstem over I2C

The C Brainstem libraries are one of many ways you can communicate to the Brainstem. It is fast, stable, and works well with the serial ports and I2C. Attach:gmuBrainstem.c Include this file in your makefile to access the Brainstem.

Building projects for the Gumstix is almost the same as building projects to run on your local machine. See the Brainstem for details on how to build a project on your local machine. The only difference is the value of the CC and ARCH variables. There are two ways to compile your C code:

  1. Run "make CC=arm-linux-gcc ARCH=ARM" or if you are on a Mac, "make CC=arm-linux-gcc ARCH=ARM PLATFORM=Linux"
  2. Add CC=arm-linux-gcc, ARCH=ARM, and PLATFORM=Linux to the makefile and call make.

Communicating with the CMUCam2 over Serial

The following file contains source and binaries for an initial library to communicate with the CMUCam2 over serial: Attach:cmucamlibc.tar.gz The library processes each command and returns a struct with all associated information including reply code, T/S/H packets, etc.. To use the library,

  • Include cmucamlib.h in your source file.
  • Link against cmucamlib.o.
  • Run cmucam2_init("/dev/ttyS2", 1) with proper serial port and 0/1 to disable/enable debugging output
  • Run struct cmucam2_retval cret = cmucam2_run_command("command") [see cmucamtest.c]
  • Look at cret.ret_type to see what type of output was returned (ack, nck, t packet, s packet, string), and use the corresponding variable in the struct to access the data (cret.STR,, cret.S.Rmean)
  • Run cmucam2_print_retval(cret) to view the entire cret struct contents
  • Run cmucam2_uninit() when done.
  • NOTE: the library ONLY supports poll mode, so always start your program with cmucam2_run_command("rs"); cmucam2_run_command("pm 1");

To-Do List

  • Init function should accept baudrate
  • Add error checking on serial port attribute sets
  • Run "rs" and "pm 1" on init
  • Add timeout into reading from serial port and report errors as possible
    • Timeout when running rs/pm 1 from init means:
      • Serial cable not connected
      • Serial port set wrong
      • Baud rate set wrong
      • Camera not turned on
  • Catch "pm 0" / track to make sure poll mode was enabled before other commands are running
    • Add support for non-poll mode? -- much easier just to require poll mode
      • Can't use current "read until :" logic
      • Send \r and check for : before sending any commands
      • Need some sort of mechanism to interrupt current command and send \r
Edit - History - Print - Recent Changes - Search
Page last modified on June 18, 2005, at 02:21 PM