Index: trunk/code/behaviors/target_practice/targetBot/main.c
===================================================================
--- trunk/code/behaviors/target_practice/targetBot/main.c	(nonexistent)
+++ trunk/code/behaviors/target_practice/targetBot/main.c	(revision 1484)
@@ -0,0 +1,76 @@
+#include <dragonfly_lib.h>
+#include <encoders.h>
+
+int main(void)
+{
+
+	int maxBOM, rangeVal;
+
+	dragonfly_init(ALL_ON);
+	encoders_init();
+	
+	orbs_set_color(GREEN, RED);
+	delay_ms(500);
+	orbs_set_color(RED, GREEN);
+	delay_ms(500);
+	orbs_set_color(GREEN, GREEN);
+
+	while (1) {
+		
+		bom_refresh(BOM_ALL);
+		delay_ms(100);
+		maxBOM = bom_get_max();
+		usb_puti(maxBOM);
+		usb_putc('\n');
+		if (maxBOM == 4) {
+			motors_off();
+			break;
+		}
+
+		motor_l_set(BACKWARD, 175);
+		motor_r_set(FORWARD, 175);
+
+	}
+
+	while (1) {
+
+		rangeVal = range_read_distance(IR2);
+		usb_puti(rangeVal);
+		usb_putc('\n');
+		if (rangeVal < 500 && rangeVal > 20) {
+			motors_off();
+			orbs_set_color(RED, RED);
+			break;
+		}
+
+		motor_l_set(FORWARD, 175);
+		motor_r_set(FORWARD, 175);
+
+	}
+
+	button2_wait();
+
+	motor_l_set(FORWARD, 175);
+	motor_r_set(FORWARD, 175);
+
+	while (1) {
+		if (encoder_get_x(LEFT) > 500) {
+			motors_off();
+			break;
+		}
+	}
+
+	while (1) {
+
+		orbs_set_color(BLUE, GREEN);
+		delay_ms(500);
+		orbs_set_color(GREEN, BLUE);
+		delay_ms(500);
+
+	}
+
+	while (1); /* END HERE */
+
+	return 0;
+}
+
Index: trunk/code/behaviors/target_practice/targetBot/Makefile
===================================================================
--- trunk/code/behaviors/target_practice/targetBot/Makefile	(nonexistent)
+++ trunk/code/behaviors/target_practice/targetBot/Makefile	(revision 1484)
@@ -0,0 +1,520 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../../..
+endif
+
+# Target file name (without extension).
+TARGET = template
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
+
+#
+###################################
+
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging,
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+#if you want your code to work on the Firefly++ and not Firefly+
+#then add the -DFFPP line to CDEFS
+CDEFS =
+#-DFFPP
+
+# MCU name
+MCU = atmega128
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard *.c)
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC =
+
+# Optimization level, can be [0, 1, 2, 3, s].
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG =
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS += -DF_CPU=$(F_CPU)UL
+CDEFS += -DFFP
+# for wireless library
+ifdef USE_WIRELESS
+	CDEFS += -DROBOT
+endif
+
+# Place -I, -L options here
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
+
+#---------------- Compiler Options ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS =
+# CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(CSTANDARD)
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+#PRINTF_LIB =
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB =
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+MATH_LIB = -lm
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+ifdef USE_WIRELESS
+	LDFLAGS += -lwireless
+endif
+LDFLAGS += -ldragonfly
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = avrisp
+
+# programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#don't check for device signature
+AVRDUDE_FLAGS += -F
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+	@echo
+	@echo $(MSG_BEGIN)
+
+end:
+	@echo $(MSG_END)
+	@echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+	@$(CC) --version
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set
+#     a breakpoint at main().
+gdb-config:
+	@$(REMOVE) $(GDBINIT_FILE)
+	@echo define reset >> $(GDBINIT_FILE)
+	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+	@echo end >> $(GDBINIT_FILE)
+	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
+	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+	@echo load  >> $(GDBINIT_FILE)
+endif
+	@echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+	@$(WINSHELL) /c pause
+
+else
+	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+	@echo
+	@echo $(MSG_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+	@echo
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+	@echo
+	@echo $(MSG_FLASH) $@
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+	@echo
+	@echo $(MSG_EEPROM) $@
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+	@echo
+	@echo $(MSG_EXTENDED_LISTING) $@
+	$(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+	@echo
+	@echo $(MSG_SYMBOL_TABLE) $@
+	$(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+	@echo
+	@echo $(MSG_LINKING) $@
+	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+	@echo
+	@echo $(MSG_COMPILING) $<
+	$(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+	@echo
+	@echo $(MSG_ASSEMBLING) $<
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+	@echo
+	@echo $(MSG_CLEANING)
+	$(REMOVE) $(TARGET).hex
+	$(REMOVE) $(TARGET).eep
+	$(REMOVE) $(TARGET).cof
+	$(REMOVE) $(TARGET).elf
+	$(REMOVE) $(TARGET).map
+	$(REMOVE) $(TARGET).sym
+	$(REMOVE) $(TARGET).lss
+	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LST)
+	$(REMOVE) $(SRC:.c=.s)
+	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVEDIR) .dep
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
Index: trunk/code/behaviors/target_practice/beaconBot/main.c
===================================================================
--- trunk/code/behaviors/target_practice/beaconBot/main.c	(nonexistent)
+++ trunk/code/behaviors/target_practice/beaconBot/main.c	(revision 1484)
@@ -0,0 +1,24 @@
+#include <dragonfly_lib.h>
+
+int main(void)
+{
+
+	/* initialize components, set wireless channel */
+	dragonfly_init(ALL_ON);
+
+	bom_on();
+	
+	while (1) {
+
+		orbs_set_color(GREEN, BLUE);
+
+		delay_ms(1000);
+
+		orbs_set_color(BLUE, GREEN);
+
+		delay_ms(1000);
+
+	}
+
+	return 0;
+}
Index: trunk/code/behaviors/target_practice/beaconBot/Makefile
===================================================================
--- trunk/code/behaviors/target_practice/beaconBot/Makefile	(nonexistent)
+++ trunk/code/behaviors/target_practice/beaconBot/Makefile	(revision 1484)
@@ -0,0 +1,520 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../../..
+endif
+
+# Target file name (without extension).
+TARGET = template
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
+
+#
+###################################
+
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging,
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+#if you want your code to work on the Firefly++ and not Firefly+
+#then add the -DFFPP line to CDEFS
+CDEFS =
+#-DFFPP
+
+# MCU name
+MCU = atmega128
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard *.c)
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC =
+
+# Optimization level, can be [0, 1, 2, 3, s].
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG =
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS += -DF_CPU=$(F_CPU)UL
+CDEFS += -DFFP
+# for wireless library
+ifdef USE_WIRELESS
+	CDEFS += -DROBOT
+endif
+
+# Place -I, -L options here
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
+
+#---------------- Compiler Options ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS =
+# CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(CSTANDARD)
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+#PRINTF_LIB =
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB =
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+MATH_LIB = -lm
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+ifdef USE_WIRELESS
+	LDFLAGS += -lwireless
+endif
+LDFLAGS += -ldragonfly
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = avrisp
+
+# programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#don't check for device signature
+AVRDUDE_FLAGS += -F
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+	@echo
+	@echo $(MSG_BEGIN)
+
+end:
+	@echo $(MSG_END)
+	@echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+	@$(CC) --version
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set
+#     a breakpoint at main().
+gdb-config:
+	@$(REMOVE) $(GDBINIT_FILE)
+	@echo define reset >> $(GDBINIT_FILE)
+	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+	@echo end >> $(GDBINIT_FILE)
+	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
+	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+	@echo load  >> $(GDBINIT_FILE)
+endif
+	@echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+	@$(WINSHELL) /c pause
+
+else
+	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+	@echo
+	@echo $(MSG_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+	@echo
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+	@echo
+	@echo $(MSG_FLASH) $@
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+	@echo
+	@echo $(MSG_EEPROM) $@
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+	@echo
+	@echo $(MSG_EXTENDED_LISTING) $@
+	$(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+	@echo
+	@echo $(MSG_SYMBOL_TABLE) $@
+	$(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+	@echo
+	@echo $(MSG_LINKING) $@
+	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+	@echo
+	@echo $(MSG_COMPILING) $<
+	$(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+	@echo
+	@echo $(MSG_ASSEMBLING) $<
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+	@echo
+	@echo $(MSG_CLEANING)
+	$(REMOVE) $(TARGET).hex
+	$(REMOVE) $(TARGET).eep
+	$(REMOVE) $(TARGET).cof
+	$(REMOVE) $(TARGET).elf
+	$(REMOVE) $(TARGET).map
+	$(REMOVE) $(TARGET).sym
+	$(REMOVE) $(TARGET).lss
+	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LST)
+	$(REMOVE) $(SRC:.c=.s)
+	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVEDIR) .dep
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
Index: trunk/code/behaviors/hunter_prey/abenico/main.c
===================================================================
--- trunk/code/behaviors/hunter_prey/abenico/main.c	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/abenico/main.c	(revision 1484)
@@ -0,0 +1,208 @@
+#include <dragonfly_lib.h>
+#include <wireless.h>
+#include <wl_basic.h>
+#include "smart_run_around_fsm.h"
+#include "hunter_prey.h"
+
+#define CHAN 0xC
+#define ACK_PAUSE 5000
+
+#define ROBOT_HUNTER 0
+#define ROBOT_PREY 1
+#define ROBOT_TAGGED 2
+#define ROBOT_IDLE 3
+
+void packet_receive(unsigned char* packet, int length);
+
+volatile uint8_t robotState; // current state
+volatile uint8_t tagger;    // id of tagging robot
+uint8_t id; // my robot's id
+
+void test_bom(void) {
+  int i;
+  int val;
+
+  while(1) {
+    bom_refresh(BOM_ALL);
+
+    for(i=0; i<16; i++) {
+      val = bom_get(i);
+      usb_puti(val);
+      usb_putc(' ');
+    }
+
+    usb_puts("| ");
+
+    usb_puti(range_read_distance (IR1));
+    usb_putc(' ');
+    usb_puti(range_read_distance (IR2));
+    usb_putc(' ');
+    usb_puti(range_read_distance (IR3));
+    usb_putc(' ');
+    usb_puti(range_read_distance (IR4));
+    usb_putc(' ');
+    usb_puti(range_read_distance (IR5));
+
+    usb_putc('\n');
+    delay_ms(500);
+  }
+
+}
+
+void chase(uint8_t angle) {
+
+  int omega = angle - 4;
+
+  if(angle > 15)
+    return;
+
+  if(omega >  8)
+    omega = omega - 16;
+
+  omega *= 255/8;
+
+/*   usb_puti(omega); */
+/*   usb_putc('\n'); */
+
+  move(140, omega);
+
+}
+
+int main(void) {
+
+  int frontRange;   // reading of front rangefinder
+  uint8_t angle;    // result of bom_get_max()
+  unsigned char *packet;  // packet to send
+  int length;	// length of received packet
+  
+  //intialize the robot and wireless
+  dragonfly_init(ALL_ON);
+
+  //  test_bom();
+
+  id = get_robotid();
+  packet[1] = id;
+  usb_puts("hello, I am robot ");
+  usb_puti(id);
+  usb_putc('\n');
+
+  usb_puts("wireless.\n");
+
+  wl_basic_init_default();
+
+  usb_puts("run around.\n");
+
+  run_around_init();
+
+  usb_puts("channel");
+
+  //use a specific channel to avoid interfering with other tasks
+  wl_set_channel(CHAN);
+  usb_puti(CHAN);
+
+  usb_puts("\norb set");
+
+  // initially in hunter state
+  robotState = ROBOT_HUNTER;
+
+  //if button 2 is held, you are prey
+  if(button2_read()) {
+    robotState = ROBOT_PREY;
+    bom_on();
+  }
+
+
+  while(1) {
+
+    if(robotState==ROBOT_TAGGED) {
+      usb_puts("tagged, waiting to send ACK\n");
+      orb_set_color(YELLOW);
+      //delay_ms(TAG_PAUSE);
+      move(0,0);
+      usb_puts("sending ACK to ");
+      usb_puti(tagger);
+      usb_putc('\n');
+      packet[0] = HUNTER_PREY_ACTION_ACK;
+      packet[1] = tagger;
+      wl_basic_send_global_packet (42, &packet, 2);
+      usb_puts("sent\n");
+      robotState = ROBOT_HUNTER; //no longer prey
+    }
+
+    else if(robotState == ROBOT_PREY) {
+	orb_set_color(GREEN);
+      run_around_FSM();
+    }
+
+    else if (robotState == ROBOT_IDLE) {
+	orb_set_color(BLUE);
+	move(0,0);
+	delay_ms(ACK_PAUSE);
+	robotState = ROBOT_HUNTER;
+    }
+
+    else { //ROBOT_HUNTER
+	orb_set_color(RED);
+      bom_refresh(BOM_ALL);
+      delay_ms(100);
+
+      frontRange = range_read_distance (IR2);
+
+      //BUG: when get_max_bom is called, the rangefinder seems to stop
+      //working
+      angle = bom_get_max();
+      chase(angle);
+
+      usb_puti(frontRange);
+      usb_putc('\n');
+
+      if ((hunter_prey_tagged(angle, frontRange) && rtc_get() >= 1) || button1_read()) {
+	    usb_puts("TAG!\n");
+	    packet[0] = HUNTER_PREY_ACTION_TAG;
+	    packet[1] = id;
+	    wl_basic_send_global_packet (42, &packet, 2);
+	    wl_do();
+	    rtc_reset();
+	}
+    }
+
+    packet = wl_basic_do_default(&length);
+    if (packet)
+	packet_receive(packet, length);
+  }
+  
+  return 0;
+}
+
+void packet_receive(unsigned char* packet, int length)
+{
+
+  if(length>=2){
+    if(packet[0] == HUNTER_PREY_ACTION_TAG) {
+	usb_puts("received a tag packet\n");
+      if(robotState == ROBOT_PREY) {
+	  usb_puts("it was for me\n");
+	robotState = ROBOT_TAGGED;
+	bom_off();
+	tagger = packet[1];
+      }
+      else {
+	usb_puts("tagged, but I'm not it!\n");
+      }
+    }
+    else if(packet[0] == HUNTER_PREY_ACTION_ACK) {
+      robotState = ROBOT_IDLE;
+    }
+    usb_puts("got '");
+    usb_putc(packet[0]);
+    usb_puti(packet[1]);
+    usb_puts("'\n");
+  }
+  else {
+    usb_puts(" length=");
+    usb_puti(length);
+    usb_putc('\n');
+  }
+}
+
+#define HP_BUF_IDX_ACTION 0
Index: trunk/code/behaviors/hunter_prey/abenico/smart_run_around_fsm.c
===================================================================
--- trunk/code/behaviors/hunter_prey/abenico/smart_run_around_fsm.c	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/abenico/smart_run_around_fsm.c	(revision 1484)
@@ -0,0 +1,109 @@
+#include <dragonfly_lib.h>
+#include "smart_run_around_fsm.h"
+
+void run_around_init(void)
+{
+  //range_init();
+  //orb_init();
+ 
+  state = SRA_FORWARD;  // start out moving forward
+  // initialize rangefinder values to 0
+  d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0;
+}
+
+/* evaluate rangefinder input and update state
+ * call this function as often as possible to avoid collisions
+ */
+void run_around_FSM(void)
+{
+    /* TODO: find a better way to handle rangefinder input
+     * robot should deal with -1s (obstacles too close or too far to detect)
+     * in a way that keeps it from crashing or driving in circles
+     */
+    // do not update distances when rangefinders return -1
+    // otherwise update distances with new rangefinder values
+    int16_t temp;
+
+    temp = range_read_distance(IR1);
+    d1 = (temp == -1) ? d1 : temp;
+
+    temp = range_read_distance(IR2);
+    d2 = (temp == -1) ? d2 : temp;
+
+    temp = range_read_distance(IR3);
+    d3 = (temp == -1) ? d3 : temp;
+
+    temp = range_read_distance(IR4);
+    d4 = (temp == -1) ? d4 : temp;
+
+    temp = range_read_distance(IR5);
+    d5 = (temp == -1) ? d5 : temp;
+
+    // update state based on rangefinder input
+    if (d2 < IR2_DANGER)    // avoid frontal collision by turning in place
+	state = SRA_SPIN;
+    /* nowhere to turn, so don't
+     * will probably need to turn around soon, but not yet
+     */
+    else if (d1 < IR13_DANGER && d3 < IR13_DANGER)
+	state = SRA_FORWARD;
+    // avoid left-side collision by turning right
+    else if (d1 < IR13_DANGER || d5 < IR45_DANGER)
+	state = SRA_RIGHT;
+    // avoid right-side collision by turning left
+    else if (d3 < IR13_DANGER || d4 < IR45_DANGER)
+	state = SRA_LEFT;
+    else if (d2 < IR2_INTEREST)	// should turn to avoid obstacle up ahead
+    {
+	if (d3 >= d1)	// more room on right
+	    state = SRA_RIGHT;
+	else	// more room on left
+	    state = SRA_LEFT;
+    }
+    else    // no obstacles close by, so keep going straight
+	state = SRA_FORWARD;
+
+    /* Debugging via USB output */
+/*     usb_puts("IR1: "); */
+/*     usb_puti(d1); */
+/*     usb_puts(" IR2: "); */
+/*     usb_puti(d2); */
+/*     usb_puts(" IR3: "); */
+/*     usb_puti(d3); */
+/*     usb_puts(" IR4: "); */
+/*     usb_puti(d4); */
+/*     usb_puts(" IR5: "); */
+/*     usb_puti(d5); */
+/*     usb_puts("\n\r"); */
+
+    evaluate_state();	// take action on updated state
+}
+
+// behave according to current state
+// TODO: adjust speeds after testing
+void evaluate_state(void)
+{
+    switch (state)
+    {
+	case SRA_FORWARD:
+	    //orb_set_color(GREEN);
+	    move(220, 0);	// drive straight forward
+	    break;
+	case SRA_LEFT:
+	    //orbs_set_color(GREEN, YELLOW);  // green on left side
+	    move(HALF_SPD, NRML_TURN);	// drive forward and to the left
+	    break;
+	case SRA_RIGHT:
+	    //orbs_set_color(YELLOW, GREEN);  // green on right side
+	    move(HALF_SPD, -NRML_TURN);	// drive forward and to the right
+	    break;
+	case SRA_SPIN:
+	    //orb_set_color(RED);
+	    move(0, NRML_TURN);	// spin CCW without traveling
+	    break;
+	default:    // should never reach this
+	    //orb_set_color(PURPLE);
+	    move(0, 0);	// stop completely
+    }
+}
+
Index: trunk/code/behaviors/hunter_prey/abenico/hunter_prey.c
===================================================================
--- trunk/code/behaviors/hunter_prey/abenico/hunter_prey.c	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/abenico/hunter_prey.c	(revision 1484)
@@ -0,0 +1,43 @@
+#include "hunter_prey.h"
+#include <dragonfly_lib.h>
+
+#define TAG_TIME 3
+#define TAG_RANGE 200
+
+/**** This file should not be edited! ****/
+
+
+/*
+ * The criteria for tagging are the following:
+ *   * The max bom is betweed 1 and 7
+ *   * The front rangefinder reads less than TAG_RANGE
+ *   * -1 values from the rangefinder are ignored
+ *   * These conditions are met across TAG_TIME calls to this function
+ */
+
+uint8_t hunter_prey_tagged(int max_bom, int frontRange) {
+
+  static int onTarget = 0;
+
+  if(max_bom < 7 && max_bom > 1 && frontRange > 0 && frontRange < TAG_RANGE) {
+    if(onTarget == 0) {
+      onTarget = TAG_TIME;
+      usb_puts("On target!\n");
+    }
+    else {
+      if(--onTarget <= 0) {
+	onTarget = 0;
+	usb_puts("TAG!\n");
+	return 1;
+      }
+    }
+  }
+  else{
+    //don't reset onTarget because the robot got too close
+    if(frontRange > 0)
+      onTarget = 0;
+  }
+
+  return 0;
+
+}
Index: trunk/code/behaviors/hunter_prey/abenico/hunter_prey.h
===================================================================
--- trunk/code/behaviors/hunter_prey/abenico/hunter_prey.h	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/abenico/hunter_prey.h	(revision 1484)
@@ -0,0 +1,17 @@
+#ifndef _HUNTER_PREY_H
+#define _HUNTER_PREY_H
+
+#include <inttypes.h>
+
+/*
+ * The packet structure is 2 bytes
+ * byte 0 is the action, which is one of the values below
+ * byte 1 is the robot id
+ */
+
+#define HUNTER_PREY_ACTION_TAG 'T'
+#define HUNTER_PREY_ACTION_ACK 'A'
+
+uint8_t hunter_prey_tagged(int max_bom, int front_rangefinder);
+
+#endif
Index: trunk/code/behaviors/hunter_prey/abenico/Makefile
===================================================================
--- trunk/code/behaviors/hunter_prey/abenico/Makefile	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/abenico/Makefile	(revision 1484)
@@ -0,0 +1,520 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../../..
+endif
+
+# Target file name (without extension).
+TARGET = main
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
+
+#
+###################################
+
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging,
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+#if you want your code to work on the Firefly++ and not Firefly+
+#then add the -DFFPP line to CDEFS
+CDEFS =
+#-DFFPP
+
+# MCU name
+MCU = atmega128
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard *.c)
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC =
+
+# Optimization level, can be [0, 1, 2, 3, s].
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG =
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS += -DF_CPU=$(F_CPU)UL
+CDEFS += -DFFP
+# for wireless library
+ifdef USE_WIRELESS
+	CDEFS += -DROBOT
+endif
+
+# Place -I, -L options here
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
+
+#---------------- Compiler Options ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS =
+# CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(CSTANDARD)
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+#PRINTF_LIB =
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB =
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+MATH_LIB = -lm
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+ifdef USE_WIRELESS
+	LDFLAGS += -lwireless
+endif
+LDFLAGS += -ldragonfly
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = avrisp
+
+# programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#don't check for device signature
+AVRDUDE_FLAGS += -F
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+	@echo
+	@echo $(MSG_BEGIN)
+
+end:
+	@echo $(MSG_END)
+	@echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+	@$(CC) --version
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set
+#     a breakpoint at main().
+gdb-config:
+	@$(REMOVE) $(GDBINIT_FILE)
+	@echo define reset >> $(GDBINIT_FILE)
+	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+	@echo end >> $(GDBINIT_FILE)
+	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
+	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+	@echo load  >> $(GDBINIT_FILE)
+endif
+	@echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+	@$(WINSHELL) /c pause
+
+else
+	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+	@echo
+	@echo $(MSG_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+	@echo
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+	@echo
+	@echo $(MSG_FLASH) $@
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+	@echo
+	@echo $(MSG_EEPROM) $@
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+	@echo
+	@echo $(MSG_EXTENDED_LISTING) $@
+	$(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+	@echo
+	@echo $(MSG_SYMBOL_TABLE) $@
+	$(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+	@echo
+	@echo $(MSG_LINKING) $@
+	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+	@echo
+	@echo $(MSG_COMPILING) $<
+	$(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+	@echo
+	@echo $(MSG_ASSEMBLING) $<
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+	@echo
+	@echo $(MSG_CLEANING)
+	$(REMOVE) $(TARGET).hex
+	$(REMOVE) $(TARGET).eep
+	$(REMOVE) $(TARGET).cof
+	$(REMOVE) $(TARGET).elf
+	$(REMOVE) $(TARGET).map
+	$(REMOVE) $(TARGET).sym
+	$(REMOVE) $(TARGET).lss
+	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LST)
+	$(REMOVE) $(SRC:.c=.s)
+	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVEDIR) .dep
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
Index: trunk/code/behaviors/hunter_prey/abenico/smart_run_around_fsm.h
===================================================================
--- trunk/code/behaviors/hunter_prey/abenico/smart_run_around_fsm.h	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/abenico/smart_run_around_fsm.h	(revision 1484)
@@ -0,0 +1,40 @@
+// smart_run_around_fsm.h
+// required to run Smart Run Around functions
+// declare functions and global variables
+
+#ifndef _RUN_AROUND_FSM_H_
+#define _RUN_AROUND_FSM_H_
+
+// states (robot shall never move in reverse)
+// these constants may be changed (but can't overlap) without effect
+#define SRA_FORWARD 0   // drive straight forward
+#define SRA_LEFT 1	// drive forward and to the left
+#define SRA_RIGHT 2	// drive forward and to the right
+#define SRA_SPIN 3	// turn without traveling (last resort if otherwise stuck)
+
+/* conditions on rangefinders (in mm) informing state changes
+ * distances are 50 greater than in real life, cannot be smaller than 100
+ * naming format: SENSOR_URGENCY
+ * changing these constants affects robot operation
+ */
+#define IR2_DANGER 150	// 10 cm: dangerously close to front
+#define IR13_DANGER 200 // 15 cm: dangerously close to sides (looking ahead)
+#define IR2_INTEREST 300    // 25 cm: notably close to front
+#define IR45_DANGER 150	// dangerously close to side (looking sideways)
+
+uint8_t state;	// current state of FSM: SRA_FORWARD, SRA_LEFT, SRA_RIGHT, SRA_SPIN
+int16_t d1, d2, d3, d4, d5; // values returned by rangefinders
+
+// initialize rangefinders and global variables
+void run_around_init(void);
+
+/* evaluate rangefinder input and update state
+ * call this function as often as possible to avoid collisions
+ */
+void run_around_FSM(void);
+
+// behave according to current state
+void evaluate_state(void);
+
+#endif
+
Index: trunk/code/behaviors/hunter_prey/ref/main.c
===================================================================
--- trunk/code/behaviors/hunter_prey/ref/main.c	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/ref/main.c	(revision 1484)
@@ -0,0 +1,152 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include "../../libwireless/lib/wl_basic.h"
+#include "../../libwireless/lib/wireless.h"
+#include "../hunter_prey.h"
+
+#define TYPE 42	// packet type for wireless communication
+
+#define NUM_BOTS 17
+#define TOTAL_GAME_TIME 600*5 //in 100 ms intervals
+
+void packet_receive(char type, int source, unsigned char* packet, int length);
+
+volatile unsigned int preyTime[20];
+volatile int preyBot=-1;
+
+void waitKey(void) {
+  unsigned char buf[10];
+
+  //read from stdin
+   while(read(0, buf, 10)==10) {
+     printf("!");
+     fflush(stdout);
+   }
+
+  while(getchar()==-1);
+}
+
+void print_stats(void) {
+
+  int i=0;
+
+  for(i=0;i<NUM_BOTS;i++) {
+    printf("%5d ", preyTime[i]);
+  }
+
+  printf("\n");
+
+}
+
+int main(int argc, char *argv[])
+{
+    char send_buffer[2];    // holds data to send
+    int data_length;	// length of data received
+    unsigned char *packet_data;	// data received
+    int ret;
+    int i;
+    int winner, maxTime=0;
+
+    unsigned int channel = 0xF;
+
+    struct timespec delay, rem;
+
+    delay.tv_sec = 0;
+    delay.tv_nsec = 100000000;
+
+
+    if(argc > 1) {
+      channel = atoi(argv[1]);
+    }
+
+    printf("using wireless channel %d\n", channel);
+
+    wl_set_com_port("/dev/ttyUSB0");
+    // set up wireless
+    ret = wl_basic_init(&packet_receive);
+
+    if(ret) {
+      printf("ERROR: wl_basic_init failed. %d\n", ret);
+      return ret;
+    }
+    //wl_set_channel(channel);
+
+    for(i=0;i<NUM_BOTS;i++) {
+      preyTime[i]=0;
+    }
+
+    ret = 0;    
+    i=0;
+
+    printf("ready\n");
+
+    //TODO: use rtc to make this more accurate
+    while(i < TOTAL_GAME_TIME) {
+      wl_do();
+
+      if(ret==0) {
+	ret = nanosleep(&delay, &rem);
+      }
+      else {
+	ret = nanosleep(&rem, &rem);
+      }
+
+      //update counts when we have waited at least enough time
+      if(ret == 0 && preyBot >= 0) {
+	preyTime[preyBot]++;
+
+	if(i==0) { //time starts on the first real tag
+	  printf("\nThe race is on!\n");
+	}
+	i++;
+      }
+
+      if((TOTAL_GAME_TIME - i)%600 == 0) {
+	printf("%d minutes remaining!\n", (TOTAL_GAME_TIME - i)/600);
+      }
+
+      if(i%10==0) {
+	print_stats();
+	if( TOTAL_GAME_TIME - i <= 100)
+	  printf("%d...\n", (TOTAL_GAME_TIME - i)/10);
+      }
+    }
+
+
+    for(i=1;i<NUM_BOTS;i++) {
+      if(preyTime[i] > maxTime) {
+	maxTime = preyTime[i];
+	winner = i;
+      }
+    }
+
+    printf("\n\GAME OVER!n\nAAAAAAAAAAND the winner is\nBOT %d!!!!\n", winner);
+
+    return 0;
+}
+
+void packet_receive(char type, int source, unsigned char* packet, int length)
+{
+
+  if(type==42 && length>=2){
+    if(packet[0] == HUNTER_PREY_ACTION_TAG) {
+      //TODO: check tag
+
+    }
+    else if(packet[0] == HUNTER_PREY_ACTION_ACK) {
+
+      preyBot = packet[1];
+      printf("bot %d is prey!\n", preyBot);
+
+    }
+    else {
+      printf("got invalid packet! %c%d\n", packet[0], packet[1]);
+    }
+  }
+  else {
+    printf("got unknown packet! type=%d, length=%d\n", type, length);
+  }
+}
+
Index: trunk/code/behaviors/hunter_prey/ref/Makefile
===================================================================
--- trunk/code/behaviors/hunter_prey/ref/Makefile	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/ref/Makefile	(revision 1484)
@@ -0,0 +1,11 @@
+CC = gcc
+CFLAGS = -Wall -g
+
+all: ref
+
+ref: *.c ../../libwireless/lib/*.c 
+	$(CC) $(CFLAGS) *.c -L../../libwireless/lib -o ref -DWL_DEBUG -lwireless -lpthread -ggdb
+
+clean:
+	rm -f *.o ref ../lib/*.o
+
Index: trunk/code/behaviors/hunter_prey/testbench/main.c
===================================================================
--- trunk/code/behaviors/hunter_prey/testbench/main.c	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/testbench/main.c	(revision 1484)
@@ -0,0 +1,291 @@
+/* testbench for Lab 2 first checkpoint
+ * determine whether robot under test complies with communication standard
+ * to be conducted using XBee USB dongle
+ */
+
+/* The tests shall be as follows
+ * 1. Receive a TAG, send an ACK
+ * - Robot passes if it sends a tag and changes to prey state
+ * 2. Send a TAG, receive an ACK
+ * - Pass if sends ACK, changes to wait state, then hunter state
+ * 3. Receive TAG, send slightly delayed (< 1s) ACK
+ * - Pass if sends one and only one TAG packet (and changes state appropriately)
+ * 4. Receive TAG, do not send ACK
+ * - Pass if sends one and only one TAG packet (and does not change state)
+ * 5. Receive TAG, send ACK to incorrect robot
+ * - Pass if goes to wait state, then back to hunter state
+ * 6. Simulate TAG from robot A to B, ACK from B to A
+ * - Pass if ignores TAG, goes to wait then hunter in response to ACK
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "../../libwireless/lib/wl_basic.h"
+#include "../../libwireless/lib/wireless.h"
+#include "hunter_prey.h"
+#include <time.h>
+
+#define TYPE 42	// packet type for wireless communication
+#define ROBOTID 255 // make up a robot id because the PC doesn't have one
+
+
+void waitKey() {
+  unsigned char buf[10];
+
+  //read from stdin
+   while(read(0, buf, 10)==10) {
+     printf("!");
+     fflush(stdout);
+   }
+
+  while(getchar()==-1);
+}
+
+int main(int argc, char *argv[])
+{
+    char send_buffer[2];    // holds data to send
+    int data_length;	// length of data received
+    unsigned char *packet_data;	// data received
+    int ret;
+
+    unsigned int channel = 0xF;
+
+    struct timespec delay8, rem;
+
+    if(argc > 1) {
+      channel = atoi(argv[1]);
+    }
+
+    printf("using wireless channel %d\n", channel);
+
+    delay8.tv_sec = 2;
+    delay8.tv_nsec = 800000000;
+
+    wl_set_com_port("/dev/ttyUSB0");
+    // set up wireless
+    ret = wl_basic_init_default();
+
+    if(ret) {
+      printf("ERROR: wl_basic_init_default returned %d\n", ret);
+      return ret;
+    }
+
+    ret = wl_set_channel(channel);
+
+    if(ret) {
+      printf("ERROR: set channel failed! %d\n", ret);
+      return ret;
+    }
+
+    printf("Testing communications\n\n");
+
+    // Receive TAG, send ACK
+    printf("Receive TAG, send ACK... ");
+    fflush(stdout);
+    // Wait until we receive a packet
+    while (!(packet_data = wl_basic_do_default(&data_length)));
+
+    printf("got packet, validating and sending ack...");
+    fflush(stdout);
+
+    if (data_length > 2)
+    {
+	printf("Excessive TAG packet length... ");
+	fflush(stdout);
+    }
+
+    if (data_length >= 2 && packet_data[0] == HUNTER_PREY_ACTION_TAG)
+    {
+	// send back an ACK
+	send_buffer[0] = HUNTER_PREY_ACTION_ACK;
+	send_buffer[1] = packet_data[1];
+	printf("sending ack intended for robot %d\n", packet_data[1]);
+	fflush(stdout);
+	wl_basic_send_global_packet(TYPE, send_buffer, 2);
+
+	printf("PASSED\n");
+    }
+    else
+	printf("FAILED\n");
+
+    printf("robot should be prey\nPress enter to continue...\n");
+    waitKey();
+
+    // Send a TAG, receive an ACK
+    printf("Send TAG, wait for ACK... ");
+    fflush(stdout);
+
+    send_buffer[0] = HUNTER_PREY_ACTION_TAG;
+    send_buffer[1] = ROBOTID;
+    // robot number stays the same
+    wl_basic_send_global_packet(TYPE, send_buffer, 2);
+
+    // Wait for an ACK
+    ret = nanosleep(&delay8, &rem);  // wait for 800 ms before sending ACK
+
+    while(ret) {
+      //      printf("nanosleep not done, needs to wait %ld more\n", rem.tv_nsec);
+      ret = nanosleep(&rem, &rem);
+    }
+
+    data_length = -1;
+    packet_data = wl_basic_do_default(&data_length);
+
+    // Check ACK for presence and correctness
+    if (!packet_data || data_length < 2 ||
+	    packet_data[0] != HUNTER_PREY_ACTION_ACK ||
+        packet_data[1] != ROBOTID) {
+      printf("FAILED, packet=%p, len=%d\n", packet_data, data_length);
+      if(data_length >= 2) {
+	printf("\tpacket = [%c, %d]\n",packet_data[0], packet_data[1]);
+      }
+    }
+    else
+	printf("PASSED\n");
+
+    printf("Robot should be Hunter\nPress enter to continue...\n");
+
+    waitKey();
+
+    // Receive a TAG, send a delayed ACK
+    printf("Receive a TAG, send a delayed ACK... ");
+    fflush(stdout);
+
+    while (!(packet_data = wl_basic_do_default(&data_length)));
+
+    if (data_length >= 2 && packet_data[0] == HUNTER_PREY_ACTION_TAG)
+    {
+        printf("got TAG, waiting...");
+	fflush(stdout);
+	// wait before sending ACK back
+	//usleep(900000);
+        delay8.tv_sec = 0;
+        ret = nanosleep(&delay8, &rem);  // wait for 800 ms before sending ACK
+
+	while(ret) {
+	  printf(".");
+	  fflush(stdout);//      printf("nanosleep not done, needs to wait %ld more\n", rem.tv_nsec);
+	  ret = nanosleep(&rem, &rem);
+	}
+
+
+	if (wl_basic_do_default(&data_length))
+	    printf("FAILED, got another TAG too soon\n");
+	else
+	{
+	    // send packet
+	    send_buffer[0] = HUNTER_PREY_ACTION_ACK;
+	    send_buffer[1] = packet_data[1];
+	    wl_basic_send_global_packet(TYPE, send_buffer, 2);
+
+	    printf("PASSED\n");
+	}
+    }
+
+    else
+	printf("FAILED\n");
+
+
+    printf("robot should be prey.\n Press Enter...\n");
+    waitKey();
+
+    printf("sending courtesy tag...");
+    fflush(stdout);
+    send_buffer[0] = HUNTER_PREY_ACTION_TAG;
+    send_buffer[1] = ROBOTID;
+    // robot number stays the same
+    wl_basic_send_global_packet(TYPE, send_buffer, 2);
+    printf("done.\nwaiting for ack...");
+    fflush(stdout);
+
+    while (!(packet_data = wl_basic_do_default(&data_length)));
+
+    if (!packet_data || data_length < 2 ||
+	    packet_data[0] != HUNTER_PREY_ACTION_ACK ||
+	    packet_data[1] != ROBOTID)
+      printf("FAILED, packet=%p, len=%d\n", packet_data, data_length);
+    else
+	printf("done\n");
+
+
+    // Receive a TAG, never send an ACK
+    printf("Receive TAG, never send ACK... ");
+    fflush(stdout);
+
+    while (!(packet_data = wl_basic_do_default(&data_length)));
+
+    if (data_length >= 2 && packet_data[0] == HUNTER_PREY_ACTION_TAG)
+    {
+
+        printf("got TAG, monitoring for 5 seconds\n");
+	fflush(stdout);
+	delay8.tv_sec = 5;
+	delay8.tv_nsec = 0;
+
+	ret = nanosleep(&delay8, &rem);  // wait for 5 secs
+	while(ret) {
+	  //      printf("nanosleep not done, needs to wait %ld more\n", rem.tv_nsec);
+	  ret = nanosleep(&rem, &rem);
+	}
+
+	if (wl_basic_do_default(&data_length))
+	    printf("FAILED, robot is spamming\n");
+	else
+	    printf("PASSED\n");
+    }
+
+    else
+	printf("FAILED\n");
+
+    printf("robot should be hunter.\nPress enter...\n");
+
+    waitKey();
+
+    // Receive TAG, send ACK to incorrect robot
+    printf("Receive TAG, send ACK to incorrect robot... ");
+    fflush(stdout);
+
+    // Wait until we receive a packet
+    while (!(packet_data = wl_basic_do_default(&data_length)));
+
+    if (data_length >= 2 && packet_data[0] == HUNTER_PREY_ACTION_TAG)
+    {
+	// send back an ACK
+	send_buffer[0] = HUNTER_PREY_ACTION_ACK;
+	send_buffer[1] = packet_data[1] + 1;
+	wl_basic_send_global_packet(TYPE, send_buffer, 2);
+
+	printf("PASSED\n");
+    }
+    else
+	printf("FAILED\n");
+
+
+    printf("robot should wait and then still be hunter.\nPress Enter...\n");
+    waitKey();
+
+    // Simulate TAG from robot A to B, ACK from robot B to A
+    printf("Send TAG from robot A to B, ACK from B to A... ");
+    fflush(stdout);
+
+    // TAG
+    send_buffer[0] = HUNTER_PREY_ACTION_TAG;
+    send_buffer[1] = packet_data[1] - 1;    // robot other than testee
+    wl_basic_send_global_packet(TYPE, send_buffer, 2);
+
+    // ACK
+    send_buffer[0] = HUNTER_PREY_ACTION_ACK;
+    // send_buffer[1] stays the same
+    wl_basic_send_global_packet(TYPE, send_buffer, 2);
+
+    if (wl_basic_do_default(&data_length))
+	printf("FAILED\n");
+    else
+	printf("PASSED\n");
+
+    printf("robot should be waiting\n");
+
+    return 0;
+}
+
Index: trunk/code/behaviors/hunter_prey/testbench/Makefile
===================================================================
--- trunk/code/behaviors/hunter_prey/testbench/Makefile	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/testbench/Makefile	(revision 1484)
@@ -0,0 +1,11 @@
+CC = gcc
+CFLAGS = -Wall -g
+
+all: testbench
+
+testbench: *.c ../../libwireless/lib/*.c 
+	$(CC) $(CFLAGS) *.c -L../../libwireless/lib -o testbench -DWL_DEBUG -lwireless -lpthread -ggdb
+
+clean:
+	rm -f *.o testbench ../lib/*.o
+
Index: trunk/code/behaviors/hunter_prey/testbench/.dep/main.o.d
===================================================================
Index: trunk/code/behaviors/hunter_prey/testbench/hunter_prey.h
===================================================================
--- trunk/code/behaviors/hunter_prey/testbench/hunter_prey.h	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/testbench/hunter_prey.h	(revision 1484)
@@ -0,0 +1,17 @@
+#ifndef _HUNTER_PREY_H
+#define _HUNTER_PREY_H
+
+#include <inttypes.h>
+
+/*
+ * The packet structure is 2 bytes
+ * byte 0 is the action, which is one of the values below
+ * byte 1 is the robot id
+ */
+
+#define HUNTER_PREY_ACTION_TAG 'T'
+#define HUNTER_PREY_ACTION_ACK 'A'
+
+uint8_t hunter_prey_tagged(int max_bom, int front_rangefinder);
+
+#endif
Index: trunk/code/behaviors/hunter_prey/main.c
===================================================================
--- trunk/code/behaviors/hunter_prey/main.c	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/main.c	(revision 1484)
@@ -0,0 +1,258 @@
+#include <dragonfly_lib.h>
+#include <wireless.h>
+#include <wl_basic.h>
+#include "smart_run_around_fsm.h"
+#include "hunter_prey.h"
+
+#define CHAN 0xC
+#define TAG_PAUSE 2000
+
+#define ROBOT_HUNTER 0
+#define ROBOT_PREY 1
+#define ROBOT_TAGGED 2
+
+void packet_receive(char type, int source, unsigned char* packet, int length);
+
+volatile uint8_t robotState = ROBOT_HUNTER;
+volatile uint8_t color1, color2;
+volatile uint8_t tagAck;
+volatile uint8_t tagger;
+uint8_t id;
+
+void test_bom(void) {
+  int i;
+  int val;
+
+  while(1) {
+    bom_refresh(BOM_ALL);
+
+    for(i=0; i<16; i++) {
+      val = bom_get(i);
+      usb_puti(val);
+      usb_putc(' ');
+    }
+
+    usb_puts("| ");
+
+    usb_puti(range_read_distance (IR1));
+    usb_putc(' ');
+    usb_puti(range_read_distance (IR2));
+    usb_putc(' ');
+    usb_puti(range_read_distance (IR3));
+    usb_putc(' ');
+    usb_puti(range_read_distance (IR4));
+    usb_putc(' ');
+    usb_puti(range_read_distance (IR5));
+
+    usb_putc('\n');
+    delay_ms(500);
+  }
+
+}
+
+void chase(uint8_t angle) {
+
+  int omega = angle - 4;
+
+  if(angle > 16)
+    return;
+
+  if(omega >  8)
+    omega = omega - 16;
+
+  omega *= 255/8;
+
+/*   usb_puti(omega); */
+/*   usb_putc('\n'); */
+
+  move(140, omega);
+
+}
+
+int main(void) {
+
+  int frontRange;
+  uint8_t angle;
+  unsigned char packet[2];
+  
+  //intialize the robot and wireless
+  dragonfly_init(ALL_ON);
+
+  //  test_bom();
+
+  id = get_robotid();
+  packet[1] = id;
+  usb_puts("hello, I am robot \n");
+  usb_puti(id);
+  usb_putc('\n');
+
+  usb_puts("wireless.\n");
+
+  wl_basic_init(&packet_receive);
+
+  usb_puts("run around.\n");
+
+  run_around_init();
+
+  usb_puts("channel\n");
+
+  //use a specific channel to avoid interfering with other tasks
+  wl_set_channel(CHAN);
+
+  usb_puts("orb set\n");
+
+  orb_set_color(BLUE);
+  color1 = BLUE;
+  color2 = BLUE;
+
+  //if button 2 is held, you are prey
+  if(button2_read()) {
+    robotState = ROBOT_PREY;
+    bom_on();
+  }
+
+
+  while(1) {
+
+    if(robotState==ROBOT_TAGGED) {
+      usb_puts("tagged, waiting to send ACK\n");
+      //delay_ms(TAG_PAUSE);
+      move(0,0);
+      usb_puts("sending ACK to ");
+      usb_puti(tagger);
+      usb_putc('\n');
+      packet[0] = HUNTER_PREY_ACTION_ACK;
+      packet[1] = tagger;
+      wl_basic_send_global_packet (42, &packet, 2);
+      usb_puts("sent\n");
+      robotState = ROBOT_HUNTER; //no longer prey
+    }
+
+    else if(robotState == ROBOT_PREY) {
+      run_around_FSM();
+    }
+
+    else { //ROBOT_HUNTER
+
+      bom_refresh(BOM_ALL);
+
+      delay_ms(100);
+
+      frontRange = range_read_distance (IR2);
+
+/*       usb_puti(frontRange); */
+/*       usb_putc(','); */
+
+      //BUG: when get_max_bom is called, the rangefinder seems to stop
+      //working
+      angle = bom_get_max();
+/*       usb_puti(angle); */
+/*       usb_putc('\n'); */
+
+      chase(angle);
+
+      //debugging to determine tagging conditions
+      if(angle < 7 && angle > 1) {
+	if(color1 != RED) {
+	  color1 = RED;
+	  orb1_set_color(RED);
+	}
+      }
+      else {
+	if(color1 != BLUE) {
+	  color1 = BLUE;
+	  orb1_set_color(BLUE);
+	}
+      }
+
+
+      usb_puti(frontRange);
+      usb_putc('\n');
+
+/*       if(frontRange > 0 && frontRange < TAG_RANGE) { */
+/* 	if(color2 != RED) { */
+/* 	  color2 = RED; */
+/* 	  orb2_set_color(RED); */
+/* 	} */
+/*       } */
+/*       else { */
+/* 	if(color2 != BLUE) { */
+/* 	  color2 = BLUE; */
+/* 	  orb2_set_color(BLUE); */
+/* 	} */
+/*       } */
+
+
+
+      if(hunter_prey_tagged(angle, frontRange) || button1_read()) {
+	orb_set_color(YELLOW);
+	color1 = YELLOW;
+	color2 = YELLOW;
+	usb_puts("TAG!\n");
+	tagAck = 0;
+	packet[0] = HUNTER_PREY_ACTION_TAG;
+	packet[1] = id;
+	wl_basic_send_global_packet (42, &packet, 2);
+	move(0,0);
+	while(!tagAck)
+	  wl_do();
+
+	if(tagAck == id) { //if the ack was for us
+	  usb_puts("ACK!\n");
+	      
+	  move(-230,0); //back up to give the new prey some room
+	  delay_ms(TAG_PAUSE/2);
+	  move(0,0);
+
+	  robotState = ROBOT_PREY;
+	  bom_on();
+	}
+	else {
+	  usb_puts("ACK failed!\n");
+	}
+      }
+    }
+
+    wl_do();
+  }
+  
+  return 0;
+}
+
+void packet_receive(char type, int source, unsigned char* packet, int length)
+{
+
+  if(type==42 && length>=2){
+    if(packet[0] == HUNTER_PREY_ACTION_TAG) {
+      if(robotState == ROBOT_PREY) {
+	robotState = ROBOT_TAGGED;
+	bom_off();
+	color1 = BLUE;
+	color2 = BLUE;
+	orb_set_color(BLUE);
+	tagger = packet[1];
+      }
+      else {
+	usb_puts("tagged, but I'm not it!\n");
+      }
+    }
+    else if(packet[0] == HUNTER_PREY_ACTION_ACK && robotState == ROBOT_HUNTER) {
+      tagAck = packet[1];
+    }
+    else {
+      usb_puts("got '");
+      usb_putc(packet[0]);
+      usb_puti(packet[1]);
+      usb_puts("'\n");
+    }
+  }
+  else {
+    usb_puts("got unkown packet! type=");
+    usb_puti(type);
+    usb_puts(" length=");
+    usb_puti(length);
+    usb_putc('\n');
+  }
+}
+
+#define HP_BUF_IDX_ACTION 0
Index: trunk/code/behaviors/hunter_prey/smart_run_around_fsm.c
===================================================================
--- trunk/code/behaviors/hunter_prey/smart_run_around_fsm.c	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/smart_run_around_fsm.c	(revision 1484)
@@ -0,0 +1,109 @@
+#include <dragonfly_lib.h>
+#include "smart_run_around_fsm.h"
+
+void run_around_init(void)
+{
+  range_init();
+  orb_init();
+ 
+  state = SRA_FORWARD;  // start out moving forward
+  // initialize rangefinder values to 0
+  d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0;
+}
+
+/* evaluate rangefinder input and update state
+ * call this function as often as possible to avoid collisions
+ */
+void run_around_FSM(void)
+{
+    /* TODO: find a better way to handle rangefinder input
+     * robot should deal with -1s (obstacles too close or too far to detect)
+     * in a way that keeps it from crashing or driving in circles
+     */
+    // do not update distances when rangefinders return -1
+    // otherwise update distances with new rangefinder values
+    int16_t temp;
+
+    temp = range_read_distance(IR1);
+    d1 = (temp == -1) ? d1 : temp;
+
+    temp = range_read_distance(IR2);
+    d2 = (temp == -1) ? d2 : temp;
+
+    temp = range_read_distance(IR3);
+    d3 = (temp == -1) ? d3 : temp;
+
+    temp = range_read_distance(IR4);
+    d4 = (temp == -1) ? d4 : temp;
+
+    temp = range_read_distance(IR5);
+    d5 = (temp == -1) ? d5 : temp;
+
+    // update state based on rangefinder input
+    if (d2 < IR2_DANGER)    // avoid frontal collision by turning in place
+	state = SRA_SPIN;
+    /* nowhere to turn, so don't
+     * will probably need to turn around soon, but not yet
+     */
+    else if (d1 < IR13_DANGER && d3 < IR13_DANGER)
+	state = SRA_FORWARD;
+    // avoid left-side collision by turning right
+    else if (d1 < IR13_DANGER || d5 < IR45_DANGER)
+	state = SRA_RIGHT;
+    // avoid right-side collision by turning left
+    else if (d3 < IR13_DANGER || d4 < IR45_DANGER)
+	state = SRA_LEFT;
+    else if (d2 < IR2_INTEREST)	// should turn to avoid obstacle up ahead
+    {
+	if (d3 >= d1)	// more room on right
+	    state = SRA_RIGHT;
+	else	// more room on left
+	    state = SRA_LEFT;
+    }
+    else    // no obstacles close by, so keep going straight
+	state = SRA_FORWARD;
+
+    /* Debugging via USB output */
+/*     usb_puts("IR1: "); */
+/*     usb_puti(d1); */
+/*     usb_puts(" IR2: "); */
+/*     usb_puti(d2); */
+/*     usb_puts(" IR3: "); */
+/*     usb_puti(d3); */
+/*     usb_puts(" IR4: "); */
+/*     usb_puti(d4); */
+/*     usb_puts(" IR5: "); */
+/*     usb_puti(d5); */
+/*     usb_puts("\n\r"); */
+
+    evaluate_state();	// take action on updated state
+}
+
+// behave according to current state
+// TODO: adjust speeds after testing
+void evaluate_state(void)
+{
+    switch (state)
+    {
+	case SRA_FORWARD:
+	    orb_set_color(GREEN);
+	    move(220, 0);	// drive straight forward
+	    break;
+	case SRA_LEFT:
+	    orbs_set_color(GREEN, YELLOW);  // green on left side
+	    move(HALF_SPD, NRML_TURN);	// drive forward and to the left
+	    break;
+	case SRA_RIGHT:
+	    orbs_set_color(YELLOW, GREEN);  // green on right side
+	    move(HALF_SPD, -NRML_TURN);	// drive forward and to the right
+	    break;
+	case SRA_SPIN:
+	    orb_set_color(RED);
+	    move(0, NRML_TURN);	// spin CCW without traveling
+	    break;
+	default:    // should never reach this
+	    orb_set_color(PURPLE);
+	    move(0, 0);	// stop completely
+    }
+}
+

Property changes on: trunk/code/behaviors/hunter_prey/smart_run_around_fsm.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/behaviors/hunter_prey/hunter_prey.c
===================================================================
--- trunk/code/behaviors/hunter_prey/hunter_prey.c	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/hunter_prey.c	(revision 1484)
@@ -0,0 +1,43 @@
+#include "hunter_prey.h"
+#include <dragonfly_lib.h>
+
+#define TAG_TIME 3
+#define TAG_RANGE 200
+
+/**** This file should not be edited! ****/
+
+
+/*
+ * The criteria for tagging are the following:
+ *   * The max bom is betweed 1 and 7
+ *   * The front rangefinder reads less than TAG_RANGE
+ *   * -1 values from the rangefinder are ignored
+ *   * These conditions are met across TAG_TIME calls to this function
+ */
+
+uint8_t hunter_prey_tagged(int max_bom, int frontRange) {
+
+  static int onTarget = 0;
+
+  if(max_bom < 7 && max_bom > 1 && frontRange > 0 && frontRange < TAG_RANGE) {
+    if(onTarget == 0) {
+      onTarget = TAG_TIME;
+      usb_puts("On target!\n");
+    }
+    else {
+      if(--onTarget <= 0) {
+	onTarget = 0;
+	usb_puts("TAG!\n");
+	return 1;
+      }
+    }
+  }
+  else{
+    //don't reset onTarget because the robot got too close
+    if(frontRange > 0)
+      onTarget = 0;
+  }
+
+  return 0;
+
+}
Index: trunk/code/behaviors/hunter_prey/hunter_prey.h
===================================================================
--- trunk/code/behaviors/hunter_prey/hunter_prey.h	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/hunter_prey.h	(revision 1484)
@@ -0,0 +1,17 @@
+#ifndef _HUNTER_PREY_H
+#define _HUNTER_PREY_H
+
+#include <inttypes.h>
+
+/*
+ * The packet structure is 2 bytes
+ * byte 0 is the action, which is one of the values below
+ * byte 1 is the robot id
+ */
+
+#define HUNTER_PREY_ACTION_TAG 'T'
+#define HUNTER_PREY_ACTION_ACK 'A'
+
+uint8_t hunter_prey_tagged(int max_bom, int front_rangefinder);
+
+#endif
Index: trunk/code/behaviors/hunter_prey/smart_run_around_fsm.h
===================================================================
--- trunk/code/behaviors/hunter_prey/smart_run_around_fsm.h	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/smart_run_around_fsm.h	(revision 1484)
@@ -0,0 +1,40 @@
+// smart_run_around_fsm.h
+// required to run Smart Run Around functions
+// declare functions and global variables
+
+#ifndef _RUN_AROUND_FSM_H_
+#define _RUN_AROUND_FSM_H_
+
+// states (robot shall never move in reverse)
+// these constants may be changed (but can't overlap) without effect
+#define SRA_FORWARD 0   // drive straight forward
+#define SRA_LEFT 1	// drive forward and to the left
+#define SRA_RIGHT 2	// drive forward and to the right
+#define SRA_SPIN 3	// turn without traveling (last resort if otherwise stuck)
+
+/* conditions on rangefinders (in mm) informing state changes
+ * distances are 50 greater than in real life, cannot be smaller than 100
+ * naming format: SENSOR_URGENCY
+ * changing these constants affects robot operation
+ */
+#define IR2_DANGER 150	// 10 cm: dangerously close to front
+#define IR13_DANGER 200 // 15 cm: dangerously close to sides (looking ahead)
+#define IR2_INTEREST 300    // 25 cm: notably close to front
+#define IR45_DANGER 150	// dangerously close to side (looking sideways)
+
+uint8_t state;	// current state of FSM: SRA_FORWARD, SRA_LEFT, SRA_RIGHT, SRA_SPIN
+int16_t d1, d2, d3, d4, d5; // values returned by rangefinders
+
+// initialize rangefinders and global variables
+void run_around_init(void);
+
+/* evaluate rangefinder input and update state
+ * call this function as often as possible to avoid collisions
+ */
+void run_around_FSM(void);
+
+// behave according to current state
+void evaluate_state(void);
+
+#endif
+

Property changes on: trunk/code/behaviors/hunter_prey/smart_run_around_fsm.h
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/behaviors/hunter_prey/Makefile
===================================================================
--- trunk/code/behaviors/hunter_prey/Makefile	(nonexistent)
+++ trunk/code/behaviors/hunter_prey/Makefile	(revision 1484)
@@ -0,0 +1,520 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../..
+endif
+
+# Target file name (without extension).
+TARGET = main
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
+
+#
+###################################
+
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging,
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+#if you want your code to work on the Firefly++ and not Firefly+
+#then add the -DFFPP line to CDEFS
+CDEFS =
+#-DFFPP
+
+# MCU name
+MCU = atmega128
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard *.c)
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC =
+
+# Optimization level, can be [0, 1, 2, 3, s].
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG =
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS += -DF_CPU=$(F_CPU)UL
+CDEFS += -DFFP
+# for wireless library
+ifdef USE_WIRELESS
+	CDEFS += -DROBOT
+endif
+
+# Place -I, -L options here
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
+
+#---------------- Compiler Options ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS =
+# CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(CSTANDARD)
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+#PRINTF_LIB =
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB =
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+MATH_LIB = -lm
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+ifdef USE_WIRELESS
+	LDFLAGS += -lwireless
+endif
+LDFLAGS += -ldragonfly
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = avrisp
+
+# programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#don't check for device signature
+AVRDUDE_FLAGS += -F
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+	@echo
+	@echo $(MSG_BEGIN)
+
+end:
+	@echo $(MSG_END)
+	@echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+	@$(CC) --version
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set
+#     a breakpoint at main().
+gdb-config:
+	@$(REMOVE) $(GDBINIT_FILE)
+	@echo define reset >> $(GDBINIT_FILE)
+	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+	@echo end >> $(GDBINIT_FILE)
+	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
+	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+	@echo load  >> $(GDBINIT_FILE)
+endif
+	@echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+	@$(WINSHELL) /c pause
+
+else
+	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+	@echo
+	@echo $(MSG_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+	@echo
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+	@echo
+	@echo $(MSG_FLASH) $@
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+	@echo
+	@echo $(MSG_EEPROM) $@
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+	@echo
+	@echo $(MSG_EXTENDED_LISTING) $@
+	$(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+	@echo
+	@echo $(MSG_SYMBOL_TABLE) $@
+	$(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+	@echo
+	@echo $(MSG_LINKING) $@
+	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+	@echo
+	@echo $(MSG_COMPILING) $<
+	$(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+	@echo
+	@echo $(MSG_ASSEMBLING) $<
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+	@echo
+	@echo $(MSG_CLEANING)
+	$(REMOVE) $(TARGET).hex
+	$(REMOVE) $(TARGET).eep
+	$(REMOVE) $(TARGET).cof
+	$(REMOVE) $(TARGET).elf
+	$(REMOVE) $(TARGET).map
+	$(REMOVE) $(TARGET).sym
+	$(REMOVE) $(TARGET).lss
+	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LST)
+	$(REMOVE) $(SRC:.c=.s)
+	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVEDIR) .dep
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
Index: trunk/code/behaviors/BOM_test/testBot/main.c
===================================================================
--- trunk/code/behaviors/BOM_test/testBot/main.c	(nonexistent)
+++ trunk/code/behaviors/BOM_test/testBot/main.c	(revision 1484)
@@ -0,0 +1,53 @@
+#include <dragonfly_lib.h>
+
+int main(void)
+{
+
+	dragonfly_init(ALL_ON);
+	
+	int i, j, max = -1;
+	int vals[16];
+
+	orbs_set_color(RED, RED);
+	delay_ms(2000);
+	orbs_set_color(GREEN, GREEN);
+
+	while (1) {
+
+		/* Refresh and make sure the table is updated */
+		bom_refresh(BOM_ALL);
+		delay_ms(100);
+
+		/* Record values into an array */
+		for (i = 0; i < 16; i++) {
+			vals[i] = bom_get(i);
+			if (max < vals[i])
+				max = vals[i];
+		}
+
+		/* Display results */
+		for (i = 0; i < 16; i++) {
+			
+			usb_puti(vals[i]);
+			usb_putc('\t');
+
+			for (j = 0; j < (int)((max - vals[i]) / 5); j++) {
+				usb_putc('#');
+			}
+
+			usb_putc('\n');
+
+		}
+
+		usb_puts("Max: ");
+		usb_puti(bom_get_max());
+		usb_putc('\n');
+		usb_putc('\n');
+
+		delay_ms(400);
+
+	}
+
+	return 0;
+}
+
Index: trunk/code/behaviors/BOM_test/testBot/Makefile
===================================================================
--- trunk/code/behaviors/BOM_test/testBot/Makefile	(nonexistent)
+++ trunk/code/behaviors/BOM_test/testBot/Makefile	(revision 1484)
@@ -0,0 +1,520 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../../..
+endif
+
+# Target file name (without extension).
+TARGET = template
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
+
+#
+###################################
+
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging,
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+#if you want your code to work on the Firefly++ and not Firefly+
+#then add the -DFFPP line to CDEFS
+CDEFS =
+#-DFFPP
+
+# MCU name
+MCU = atmega128
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard *.c)
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC =
+
+# Optimization level, can be [0, 1, 2, 3, s].
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG =
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS += -DF_CPU=$(F_CPU)UL
+CDEFS += -DFFP
+# for wireless library
+ifdef USE_WIRELESS
+	CDEFS += -DROBOT
+endif
+
+# Place -I, -L options here
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
+
+#---------------- Compiler Options ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS =
+# CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(CSTANDARD)
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+#PRINTF_LIB =
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB =
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+MATH_LIB = -lm
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+ifdef USE_WIRELESS
+	LDFLAGS += -lwireless
+endif
+LDFLAGS += -ldragonfly
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = avrisp
+
+# programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#don't check for device signature
+AVRDUDE_FLAGS += -F
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+	@echo
+	@echo $(MSG_BEGIN)
+
+end:
+	@echo $(MSG_END)
+	@echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+	@$(CC) --version
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set
+#     a breakpoint at main().
+gdb-config:
+	@$(REMOVE) $(GDBINIT_FILE)
+	@echo define reset >> $(GDBINIT_FILE)
+	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+	@echo end >> $(GDBINIT_FILE)
+	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
+	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+	@echo load  >> $(GDBINIT_FILE)
+endif
+	@echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+	@$(WINSHELL) /c pause
+
+else
+	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+	@echo
+	@echo $(MSG_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+	@echo
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+	@echo
+	@echo $(MSG_FLASH) $@
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+	@echo
+	@echo $(MSG_EEPROM) $@
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+	@echo
+	@echo $(MSG_EXTENDED_LISTING) $@
+	$(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+	@echo
+	@echo $(MSG_SYMBOL_TABLE) $@
+	$(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+	@echo
+	@echo $(MSG_LINKING) $@
+	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+	@echo
+	@echo $(MSG_COMPILING) $<
+	$(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+	@echo
+	@echo $(MSG_ASSEMBLING) $<
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+	@echo
+	@echo $(MSG_CLEANING)
+	$(REMOVE) $(TARGET).hex
+	$(REMOVE) $(TARGET).eep
+	$(REMOVE) $(TARGET).cof
+	$(REMOVE) $(TARGET).elf
+	$(REMOVE) $(TARGET).map
+	$(REMOVE) $(TARGET).sym
+	$(REMOVE) $(TARGET).lss
+	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LST)
+	$(REMOVE) $(SRC:.c=.s)
+	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVEDIR) .dep
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
Index: trunk/code/behaviors/BOM_test/beaconBot/main.c
===================================================================
--- trunk/code/behaviors/BOM_test/beaconBot/main.c	(nonexistent)
+++ trunk/code/behaviors/BOM_test/beaconBot/main.c	(revision 1484)
@@ -0,0 +1,24 @@
+#include <dragonfly_lib.h>
+
+int main(void)
+{
+
+	/* initialize components, set wireless channel */
+	dragonfly_init(ALL_ON);
+
+	bom_on();
+	
+	while (1) {
+
+		orbs_set_color(GREEN, BLUE);
+
+		delay_ms(1000);
+
+		orbs_set_color(BLUE, GREEN);
+
+		delay_ms(1000);
+
+	}
+
+	return 0;
+}
Index: trunk/code/behaviors/BOM_test/beaconBot/Makefile
===================================================================
--- trunk/code/behaviors/BOM_test/beaconBot/Makefile	(nonexistent)
+++ trunk/code/behaviors/BOM_test/beaconBot/Makefile	(revision 1484)
@@ -0,0 +1,520 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../../..
+endif
+
+# Target file name (without extension).
+TARGET = template
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
+
+#
+###################################
+
+# Hey Emacs, this is a -*- makefile -*-
+#----------------------------------------------------------------------------
+# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
+#
+# Released to the Public Domain
+#
+# Additional material for this makefile was written by:
+# Peter Fleury
+# Tim Henigan
+# Colin O'Flynn
+# Reiner Patommel
+# Markus Pfaff
+# Sander Pool
+# Frederik Rouleau
+#
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device, using avrdude.
+#                Please customize the avrdude settings below first!
+#
+# make debug = Start either simulavr or avarice as specified for debugging,
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+#if you want your code to work on the Firefly++ and not Firefly+
+#then add the -DFFPP line to CDEFS
+CDEFS =
+#-DFFPP
+
+# MCU name
+MCU = atmega128
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+F_CPU = 8000000
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(wildcard *.c)
+
+# List Assembler source files here.
+#     Make them always end in a capital .S.  Files ending in a lowercase .s
+#     will not be considered source files but generated files (assembler
+#     output from the compiler), and will be deleted upon "make clean"!
+#     Even though the DOS/Win* filesystem matches both .s and .S the same,
+#     it will preserve the spelling of the filenames, and gcc itself does
+#     care about how the name is spelled on its command-line.
+ASRC =
+
+# Optimization level, can be [0, 1, 2, 3, s].
+#     0 = turn off optimization. s = optimize for size.
+#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Debugging format.
+#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
+#     AVR Studio 4.10 requires dwarf-2.
+#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
+DEBUG =
+
+# Compiler flag to set the C Standard level.
+#     c89   = "ANSI" C
+#     gnu89 = c89 plus GCC extensions
+#     c99   = ISO C99 standard (not yet fully implemented)
+#     gnu99 = c99 plus GCC extensions
+CSTANDARD = -std=gnu99
+
+# Place -D or -U options here
+CDEFS += -DF_CPU=$(F_CPU)UL
+CDEFS += -DFFP
+# for wireless library
+ifdef USE_WIRELESS
+	CDEFS += -DROBOT
+endif
+
+# Place -I, -L options here
+CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
+CINCS += -L$(COLONYROOT)/code/lib/bin
+ifdef USE_WIRELESS
+	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
+endif
+
+#---------------- Compiler Options ----------------
+#  -g*:          generate debugging information
+#  -O*:          optimization level
+#  -f...:        tuning, see GCC manual and avr-libc documentation
+#  -Wall...:     warning level
+#  -Wa,...:      tell GCC to pass this to the assembler.
+#    -adhlns...: create assembler listing
+CFLAGS =
+# CFLAGS = -g$(DEBUG)
+CFLAGS += $(CDEFS) $(CINCS)
+CFLAGS += -O$(OPT)
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+CFLAGS += -Wall -Wstrict-prototypes
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
+CFLAGS += $(CSTANDARD)
+
+#---------------- Assembler Options ----------------
+#  -Wa,...:   tell GCC to pass this to the assembler.
+#  -ahlms:    create listing
+#  -gstabs:   have the assembler create line number information; note that
+#             for use in COFF files, additional information about filenames
+#             and function names needs to be present in the assembler source
+#             files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+#---------------- Library Options ----------------
+# Minimalistic printf version
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires MATH_LIB = -lm below)
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
+
+# If this is left blank, then it will use the Standard printf version.
+#PRINTF_LIB =
+#PRINTF_LIB = $(PRINTF_LIB_MIN)
+PRINTF_LIB = $(PRINTF_LIB_FLOAT)
+
+
+# Minimalistic scanf version
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
+
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
+
+# If this is left blank, then it will use the Standard scanf version.
+SCANF_LIB =
+#SCANF_LIB = $(SCANF_LIB_MIN)
+#SCANF_LIB = $(SCANF_LIB_FLOAT)
+
+MATH_LIB = -lm
+
+#---------------- External Memory Options ----------------
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# used for variables (.data/.bss) and heap (malloc()).
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
+
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
+# only used for heap (malloc()).
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
+
+EXTMEMOPTS =
+
+#---------------- Linker Options ----------------
+#  -Wl,...:     tell GCC to pass this to linker.
+#    -Map:      create map file
+#    --cref:    add cross reference to  map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += $(EXTMEMOPTS)
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
+ifdef USE_WIRELESS
+	LDFLAGS += -lwireless
+endif
+LDFLAGS += -ldragonfly
+
+
+
+#---------------- Programming Options (avrdude) ----------------
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = avrisp
+
+# programmer connected to serial device
+
+AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE_COUNTER = -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_NO_VERIFY = -V
+
+# Increase verbosity level.  Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_VERBOSE = -v -v
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+
+#don't check for device signature
+AVRDUDE_FLAGS += -F
+
+
+
+#---------------- Debugging Options ----------------
+
+# For simulavr only - target MCU frequency.
+DEBUG_MFREQ = $(F_CPU)
+
+# Set the DEBUG_UI to either gdb or insight.
+# DEBUG_UI = gdb
+DEBUG_UI = insight
+
+# Set the debugging back-end to either avarice, simulavr.
+DEBUG_BACKEND = avarice
+#DEBUG_BACKEND = simulavr
+
+# GDB Init Filename.
+GDBINIT_FILE = __avr_gdbinit
+
+# When using avarice settings for the JTAG
+JTAG_DEV = /dev/com1
+
+# Debugging port used to communicate between GDB / avarice / simulavr.
+DEBUG_PORT = 4242
+
+# Debugging host used to communicate between GDB / avarice / simulavr, normally
+#     just set to localhost unless doing some sort of crazy debugging when
+#     avarice is running on a different computer.
+DEBUG_HOST = localhost
+
+
+
+#============================================================================
+
+
+# Define programs and commands.
+SHELL = sh
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+NM = avr-nm
+AVRDUDE = avrdude
+REMOVE = rm -f
+REMOVEDIR = rm -rf
+COPY = cp
+WINSHELL = cmd
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = --------  end  --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
+
+
+# Compiler flags to generate dependency files.
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
+
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+
+
+# Default target.
+all: begin gccversion sizebefore build sizeafter end
+
+build: elf hex eep lss sym
+
+elf: $(TARGET).elf
+hex: $(TARGET).hex
+eep: $(TARGET).eep
+lss: $(TARGET).lss
+sym: $(TARGET).sym
+
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+	@echo
+	@echo $(MSG_BEGIN)
+
+end:
+	@echo $(MSG_END)
+	@echo
+
+
+# Display size of file.
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
+
+sizebefore:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+sizeafter:
+	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
+	$(AVRMEM) 2>/dev/null; echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+	@$(CC) --version
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+# Generate avr-gdb config/init file which does the following:
+#     define the reset signal, load the target file, connect to target, and set
+#     a breakpoint at main().
+gdb-config:
+	@$(REMOVE) $(GDBINIT_FILE)
+	@echo define reset >> $(GDBINIT_FILE)
+	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
+	@echo end >> $(GDBINIT_FILE)
+	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
+	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
+ifeq ($(DEBUG_BACKEND),simulavr)
+	@echo load  >> $(GDBINIT_FILE)
+endif
+	@echo break main >> $(GDBINIT_FILE)
+
+debug: gdb-config $(TARGET).elf
+ifeq ($(DEBUG_BACKEND), avarice)
+	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
+	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
+	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
+	@$(WINSHELL) /c pause
+
+else
+	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
+	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
+endif
+	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+--change-section-address .data-0x800000 \
+--change-section-address .bss-0x800000 \
+--change-section-address .noinit-0x800000 \
+--change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+	@echo
+	@echo $(MSG_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+	@echo
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+	@echo
+	@echo $(MSG_FLASH) $@
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+	@echo
+	@echo $(MSG_EEPROM) $@
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+	@echo
+	@echo $(MSG_EXTENDED_LISTING) $@
+	$(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+	@echo
+	@echo $(MSG_SYMBOL_TABLE) $@
+	$(NM) -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+	@echo
+	@echo $(MSG_LINKING) $@
+	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+	@echo
+	@echo $(MSG_COMPILING) $<
+	$(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+	@echo
+	@echo $(MSG_ASSEMBLING) $<
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+# Create preprocessed source for use in sending a bug report.
+%.i : %.c
+	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
+
+
+# Target: clean project.
+clean: begin clean_list end
+
+clean_list :
+	@echo
+	@echo $(MSG_CLEANING)
+	$(REMOVE) $(TARGET).hex
+	$(REMOVE) $(TARGET).eep
+	$(REMOVE) $(TARGET).cof
+	$(REMOVE) $(TARGET).elf
+	$(REMOVE) $(TARGET).map
+	$(REMOVE) $(TARGET).sym
+	$(REMOVE) $(TARGET).lss
+	$(REMOVE) $(OBJ)
+	$(REMOVE) $(LST)
+	$(REMOVE) $(SRC:.c=.s)
+	$(REMOVE) $(SRC:.c=.d)
+	$(REMOVEDIR) .dep
+
+
+
+# Include the dependency files.
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff \
+clean clean_list program debug gdb-config
+
Index: trunk/code/projects/hunter_prey/abenico/smart_run_around_fsm.c
===================================================================
--- trunk/code/projects/hunter_prey/abenico/smart_run_around_fsm.c	(revision 1483)
+++ trunk/code/projects/hunter_prey/abenico/smart_run_around_fsm.c	(nonexistent)
@@ -1,109 +0,0 @@
-#include <dragonfly_lib.h>
-#include "smart_run_around_fsm.h"
-
-void run_around_init(void)
-{
-  //range_init();
-  //orb_init();
- 
-  state = SRA_FORWARD;  // start out moving forward
-  // initialize rangefinder values to 0
-  d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0;
-}
-
-/* evaluate rangefinder input and update state
- * call this function as often as possible to avoid collisions
- */
-void run_around_FSM(void)
-{
-    /* TODO: find a better way to handle rangefinder input
-     * robot should deal with -1s (obstacles too close or too far to detect)
-     * in a way that keeps it from crashing or driving in circles
-     */
-    // do not update distances when rangefinders return -1
-    // otherwise update distances with new rangefinder values
-    int16_t temp;
-
-    temp = range_read_distance(IR1);
-    d1 = (temp == -1) ? d1 : temp;
-
-    temp = range_read_distance(IR2);
-    d2 = (temp == -1) ? d2 : temp;
-
-    temp = range_read_distance(IR3);
-    d3 = (temp == -1) ? d3 : temp;
-
-    temp = range_read_distance(IR4);
-    d4 = (temp == -1) ? d4 : temp;
-
-    temp = range_read_distance(IR5);
-    d5 = (temp == -1) ? d5 : temp;
-
-    // update state based on rangefinder input
-    if (d2 < IR2_DANGER)    // avoid frontal collision by turning in place
-	state = SRA_SPIN;
-    /* nowhere to turn, so don't
-     * will probably need to turn around soon, but not yet
-     */
-    else if (d1 < IR13_DANGER && d3 < IR13_DANGER)
-	state = SRA_FORWARD;
-    // avoid left-side collision by turning right
-    else if (d1 < IR13_DANGER || d5 < IR45_DANGER)
-	state = SRA_RIGHT;
-    // avoid right-side collision by turning left
-    else if (d3 < IR13_DANGER || d4 < IR45_DANGER)
-	state = SRA_LEFT;
-    else if (d2 < IR2_INTEREST)	// should turn to avoid obstacle up ahead
-    {
-	if (d3 >= d1)	// more room on right
-	    state = SRA_RIGHT;
-	else	// more room on left
-	    state = SRA_LEFT;
-    }
-    else    // no obstacles close by, so keep going straight
-	state = SRA_FORWARD;
-
-    /* Debugging via USB output */
-/*     usb_puts("IR1: "); */
-/*     usb_puti(d1); */
-/*     usb_puts(" IR2: "); */
-/*     usb_puti(d2); */
-/*     usb_puts(" IR3: "); */
-/*     usb_puti(d3); */
-/*     usb_puts(" IR4: "); */
-/*     usb_puti(d4); */
-/*     usb_puts(" IR5: "); */
-/*     usb_puti(d5); */
-/*     usb_puts("\n\r"); */
-
-    evaluate_state();	// take action on updated state
-}
-
-// behave according to current state
-// TODO: adjust speeds after testing
-void evaluate_state(void)
-{
-    switch (state)
-    {
-	case SRA_FORWARD:
-	    //orb_set_color(GREEN);
-	    move(220, 0);	// drive straight forward
-	    break;
-	case SRA_LEFT:
-	    //orbs_set_color(GREEN, YELLOW);  // green on left side
-	    move(HALF_SPD, NRML_TURN);	// drive forward and to the left
-	    break;
-	case SRA_RIGHT:
-	    //orbs_set_color(YELLOW, GREEN);  // green on right side
-	    move(HALF_SPD, -NRML_TURN);	// drive forward and to the right
-	    break;
-	case SRA_SPIN:
-	    //orb_set_color(RED);
-	    move(0, NRML_TURN);	// spin CCW without traveling
-	    break;
-	default:    // should never reach this
-	    //orb_set_color(PURPLE);
-	    move(0, 0);	// stop completely
-    }
-}
-
Index: trunk/code/projects/hunter_prey/abenico/hunter_prey.h
===================================================================
--- trunk/code/projects/hunter_prey/abenico/hunter_prey.h	(revision 1483)
+++ trunk/code/projects/hunter_prey/abenico/hunter_prey.h	(nonexistent)
@@ -1,17 +0,0 @@
-#ifndef _HUNTER_PREY_H
-#define _HUNTER_PREY_H
-
-#include <inttypes.h>
-
-/*
- * The packet structure is 2 bytes
- * byte 0 is the action, which is one of the values below
- * byte 1 is the robot id
- */
-
-#define HUNTER_PREY_ACTION_TAG 'T'
-#define HUNTER_PREY_ACTION_ACK 'A'
-
-uint8_t hunter_prey_tagged(int max_bom, int front_rangefinder);
-
-#endif
Index: trunk/code/projects/hunter_prey/abenico/smart_run_around_fsm.h
===================================================================
--- trunk/code/projects/hunter_prey/abenico/smart_run_around_fsm.h	(revision 1483)
+++ trunk/code/projects/hunter_prey/abenico/smart_run_around_fsm.h	(nonexistent)
@@ -1,40 +0,0 @@
-// smart_run_around_fsm.h
-// required to run Smart Run Around functions
-// declare functions and global variables
-
-#ifndef _RUN_AROUND_FSM_H_
-#define _RUN_AROUND_FSM_H_
-
-// states (robot shall never move in reverse)
-// these constants may be changed (but can't overlap) without effect
-#define SRA_FORWARD 0   // drive straight forward
-#define SRA_LEFT 1	// drive forward and to the left
-#define SRA_RIGHT 2	// drive forward and to the right
-#define SRA_SPIN 3	// turn without traveling (last resort if otherwise stuck)
-
-/* conditions on rangefinders (in mm) informing state changes
- * distances are 50 greater than in real life, cannot be smaller than 100
- * naming format: SENSOR_URGENCY
- * changing these constants affects robot operation
- */
-#define IR2_DANGER 150	// 10 cm: dangerously close to front
-#define IR13_DANGER 200 // 15 cm: dangerously close to sides (looking ahead)
-#define IR2_INTEREST 300    // 25 cm: notably close to front
-#define IR45_DANGER 150	// dangerously close to side (looking sideways)
-
-uint8_t state;	// current state of FSM: SRA_FORWARD, SRA_LEFT, SRA_RIGHT, SRA_SPIN
-int16_t d1, d2, d3, d4, d5; // values returned by rangefinders
-
-// initialize rangefinders and global variables
-void run_around_init(void);
-
-/* evaluate rangefinder input and update state
- * call this function as often as possible to avoid collisions
- */
-void run_around_FSM(void);
-
-// behave according to current state
-void evaluate_state(void);
-
-#endif
-
Index: trunk/code/projects/hunter_prey/abenico/Makefile
===================================================================
--- trunk/code/projects/hunter_prey/abenico/Makefile	(revision 1483)
+++ trunk/code/projects/hunter_prey/abenico/Makefile	(nonexistent)
@@ -1,520 +0,0 @@
-########Update This Section########
-#
-#
-
-# Relative path to the root directory (containing lib directory)
-ifndef COLONYROOT
-COLONYROOT = ../../../..
-endif
-
-# Target file name (without extension).
-TARGET = main
-
-# Uncomment this to use the wireless library
-USE_WIRELESS = 1
-
-# com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
-
-#
-###################################
-
-# Hey Emacs, this is a -*- makefile -*-
-#----------------------------------------------------------------------------
-# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
-#
-# Released to the Public Domain
-#
-# Additional material for this makefile was written by:
-# Peter Fleury
-# Tim Henigan
-# Colin O'Flynn
-# Reiner Patommel
-# Markus Pfaff
-# Sander Pool
-# Frederik Rouleau
-#
-#----------------------------------------------------------------------------
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF.
-#
-# make extcoff = Convert ELF to AVR Extended COFF.
-#
-# make program = Download the hex file to the device, using avrdude.
-#                Please customize the avrdude settings below first!
-#
-# make debug = Start either simulavr or avarice as specified for debugging,
-#              with avr-gdb or avr-insight as the front end for debugging.
-#
-# make filename.s = Just compile filename.c into the assembler code only.
-#
-# make filename.i = Create a preprocessed source file for use in submitting
-#                   bug reports to the GCC project.
-#
-# To rebuild project do "make clean" then "make all".
-#----------------------------------------------------------------------------
-
-#if you want your code to work on the Firefly++ and not Firefly+
-#then add the -DFFPP line to CDEFS
-CDEFS =
-#-DFFPP
-
-# MCU name
-MCU = atmega128
-
-# Processor frequency.
-#     This will define a symbol, F_CPU, in all source code files equal to the
-#     processor frequency. You can then use this symbol in your source code to
-#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-#     automatically to create a 32-bit value in your source code.
-F_CPU = 8000000
-
-# Output format. (can be srec, ihex, binary)
-FORMAT = ihex
-
-# List C source files here. (C dependencies are automatically generated.)
-SRC = $(wildcard *.c)
-
-# List Assembler source files here.
-#     Make them always end in a capital .S.  Files ending in a lowercase .s
-#     will not be considered source files but generated files (assembler
-#     output from the compiler), and will be deleted upon "make clean"!
-#     Even though the DOS/Win* filesystem matches both .s and .S the same,
-#     it will preserve the spelling of the filenames, and gcc itself does
-#     care about how the name is spelled on its command-line.
-ASRC =
-
-# Optimization level, can be [0, 1, 2, 3, s].
-#     0 = turn off optimization. s = optimize for size.
-#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
-OPT = s
-
-# Debugging format.
-#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
-#     AVR Studio 4.10 requires dwarf-2.
-#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
-DEBUG =
-
-# Compiler flag to set the C Standard level.
-#     c89   = "ANSI" C
-#     gnu89 = c89 plus GCC extensions
-#     c99   = ISO C99 standard (not yet fully implemented)
-#     gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
-
-# Place -D or -U options here
-CDEFS += -DF_CPU=$(F_CPU)UL
-CDEFS += -DFFP
-# for wireless library
-ifdef USE_WIRELESS
-	CDEFS += -DROBOT
-endif
-
-# Place -I, -L options here
-CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
-CINCS += -L$(COLONYROOT)/code/lib/bin
-ifdef USE_WIRELESS
-	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
-endif
-
-#---------------- Compiler Options ----------------
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-CFLAGS =
-# CFLAGS = -g$(DEBUG)
-CFLAGS += $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-CFLAGS += -Wall -Wstrict-prototypes
-CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
-CFLAGS += $(CSTANDARD)
-
-#---------------- Assembler Options ----------------
-#  -Wa,...:   tell GCC to pass this to the assembler.
-#  -ahlms:    create listing
-#  -gstabs:   have the assembler create line number information; note that
-#             for use in COFF files, additional information about filenames
-#             and function names needs to be present in the assembler source
-#             files -- see avr-libc docs [FIXME: not yet described there]
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
-
-#---------------- Library Options ----------------
-# Minimalistic printf version
-PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
-
-# Floating point printf version (requires MATH_LIB = -lm below)
-PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
-
-# If this is left blank, then it will use the Standard printf version.
-#PRINTF_LIB =
-#PRINTF_LIB = $(PRINTF_LIB_MIN)
-PRINTF_LIB = $(PRINTF_LIB_FLOAT)
-
-
-# Minimalistic scanf version
-SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
-
-# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
-SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
-
-# If this is left blank, then it will use the Standard scanf version.
-SCANF_LIB =
-#SCANF_LIB = $(SCANF_LIB_MIN)
-#SCANF_LIB = $(SCANF_LIB_FLOAT)
-
-MATH_LIB = -lm
-
-#---------------- External Memory Options ----------------
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# used for variables (.data/.bss) and heap (malloc()).
-#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# only used for heap (malloc()).
-#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
-
-EXTMEMOPTS =
-
-#---------------- Linker Options ----------------
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += $(EXTMEMOPTS)
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
-ifdef USE_WIRELESS
-	LDFLAGS += -lwireless
-endif
-LDFLAGS += -ldragonfly
-
-
-
-#---------------- Programming Options (avrdude) ----------------
-
-# Programming hardware: alf avr910 avrisp bascom bsd
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
-#
-# Type: avrdude -c ?
-# to get a full listing.
-#
-AVRDUDE_PROGRAMMER = avrisp
-
-# programmer connected to serial device
-
-AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
-
-
-# Uncomment the following if you want avrdude's erase cycle counter.
-# Note that this counter needs to be initialized first using -Yn,
-# see avrdude manual.
-#AVRDUDE_ERASE_COUNTER = -y
-
-# Uncomment the following if you do /not/ wish a verification to be
-# performed after programming the device.
-#AVRDUDE_NO_VERIFY = -V
-
-# Increase verbosity level.  Please use this when submitting bug
-# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
-# to submit bug reports.
-#AVRDUDE_VERBOSE = -v -v
-
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
-
-#don't check for device signature
-AVRDUDE_FLAGS += -F
-
-
-
-#---------------- Debugging Options ----------------
-
-# For simulavr only - target MCU frequency.
-DEBUG_MFREQ = $(F_CPU)
-
-# Set the DEBUG_UI to either gdb or insight.
-# DEBUG_UI = gdb
-DEBUG_UI = insight
-
-# Set the debugging back-end to either avarice, simulavr.
-DEBUG_BACKEND = avarice
-#DEBUG_BACKEND = simulavr
-
-# GDB Init Filename.
-GDBINIT_FILE = __avr_gdbinit
-
-# When using avarice settings for the JTAG
-JTAG_DEV = /dev/com1
-
-# Debugging port used to communicate between GDB / avarice / simulavr.
-DEBUG_PORT = 4242
-
-# Debugging host used to communicate between GDB / avarice / simulavr, normally
-#     just set to localhost unless doing some sort of crazy debugging when
-#     avarice is running on a different computer.
-DEBUG_HOST = localhost
-
-
-
-#============================================================================
-
-
-# Define programs and commands.
-SHELL = sh
-CC = avr-gcc
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
-SIZE = avr-size
-NM = avr-nm
-AVRDUDE = avrdude
-REMOVE = rm -f
-REMOVEDIR = rm -rf
-COPY = cp
-WINSHELL = cmd
-
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = -------- begin --------
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before:
-MSG_SIZE_AFTER = Size after:
-MSG_COFF = Converting to AVR COFF:
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
-MSG_FLASH = Creating load file for Flash:
-MSG_EEPROM = Creating load file for EEPROM:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling:
-MSG_ASSEMBLING = Assembling:
-MSG_CLEANING = Cleaning project:
-
-
-
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
-
-# Define all listing files.
-LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
-
-
-# Compiler flags to generate dependency files.
-GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
-
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-
-
-
-# Default target.
-all: begin gccversion sizebefore build sizeafter end
-
-build: elf hex eep lss sym
-
-elf: $(TARGET).elf
-hex: $(TARGET).hex
-eep: $(TARGET).eep
-lss: $(TARGET).lss
-sym: $(TARGET).sym
-
-
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
-
-sizebefore:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-sizeafter:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-
-
-# Display compiler version information.
-gccversion :
-	@$(CC) --version
-
-
-
-# Program the device.
-program: $(TARGET).hex $(TARGET).eep
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
-
-
-# Generate avr-gdb config/init file which does the following:
-#     define the reset signal, load the target file, connect to target, and set
-#     a breakpoint at main().
-gdb-config:
-	@$(REMOVE) $(GDBINIT_FILE)
-	@echo define reset >> $(GDBINIT_FILE)
-	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
-	@echo end >> $(GDBINIT_FILE)
-	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
-	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
-ifeq ($(DEBUG_BACKEND),simulavr)
-	@echo load  >> $(GDBINIT_FILE)
-endif
-	@echo break main >> $(GDBINIT_FILE)
-
-debug: gdb-config $(TARGET).elf
-ifeq ($(DEBUG_BACKEND), avarice)
-	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
-	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
-	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
-	@$(WINSHELL) /c pause
-
-else
-	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
-	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
-endif
-	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
-
-
-
-
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
-COFFCONVERT=$(OBJCOPY) --debugging \
---change-section-address .data-0x800000 \
---change-section-address .bss-0x800000 \
---change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
-
-
-coff: $(TARGET).elf
-	@echo
-	@echo $(MSG_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
-	@echo
-	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
-
-
-
-# Create final output files (.hex, .eep) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
-	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-%.eep: %.elf
-	@echo
-	@echo $(MSG_EEPROM) $@
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
-	$(NM) -n $< > $@
-
-
-
-# Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
-	@echo
-	@echo $(MSG_LINKING) $@
-	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
-
-
-# Compile: create object files from C source files.
-%.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(ALL_CFLAGS) $< -o $@
-
-
-# Compile: create assembler files from C source files.
-%.s : %.c
-	$(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-%.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-# Create preprocessed source for use in sending a bug report.
-%.i : %.c
-	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
-
-
-# Target: clean project.
-clean: begin clean_list end
-
-clean_list :
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).eep
-	$(REMOVE) $(TARGET).cof
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lss
-	$(REMOVE) $(OBJ)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVEDIR) .dep
-
-
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff \
-clean clean_list program debug gdb-config
-
Index: trunk/code/projects/hunter_prey/abenico/main.c
===================================================================
--- trunk/code/projects/hunter_prey/abenico/main.c	(revision 1483)
+++ trunk/code/projects/hunter_prey/abenico/main.c	(nonexistent)
@@ -1,208 +0,0 @@
-#include <dragonfly_lib.h>
-#include <wireless.h>
-#include <wl_basic.h>
-#include "smart_run_around_fsm.h"
-#include "hunter_prey.h"
-
-#define CHAN 0xC
-#define ACK_PAUSE 5000
-
-#define ROBOT_HUNTER 0
-#define ROBOT_PREY 1
-#define ROBOT_TAGGED 2
-#define ROBOT_IDLE 3
-
-void packet_receive(unsigned char* packet, int length);
-
-volatile uint8_t robotState; // current state
-volatile uint8_t tagger;    // id of tagging robot
-uint8_t id; // my robot's id
-
-void test_bom(void) {
-  int i;
-  int val;
-
-  while(1) {
-    bom_refresh(BOM_ALL);
-
-    for(i=0; i<16; i++) {
-      val = bom_get(i);
-      usb_puti(val);
-      usb_putc(' ');
-    }
-
-    usb_puts("| ");
-
-    usb_puti(range_read_distance (IR1));
-    usb_putc(' ');
-    usb_puti(range_read_distance (IR2));
-    usb_putc(' ');
-    usb_puti(range_read_distance (IR3));
-    usb_putc(' ');
-    usb_puti(range_read_distance (IR4));
-    usb_putc(' ');
-    usb_puti(range_read_distance (IR5));
-
-    usb_putc('\n');
-    delay_ms(500);
-  }
-
-}
-
-void chase(uint8_t angle) {
-
-  int omega = angle - 4;
-
-  if(angle > 15)
-    return;
-
-  if(omega >  8)
-    omega = omega - 16;
-
-  omega *= 255/8;
-
-/*   usb_puti(omega); */
-/*   usb_putc('\n'); */
-
-  move(140, omega);
-
-}
-
-int main(void) {
-
-  int frontRange;   // reading of front rangefinder
-  uint8_t angle;    // result of bom_get_max()
-  unsigned char *packet;  // packet to send
-  int length;	// length of received packet
-  
-  //intialize the robot and wireless
-  dragonfly_init(ALL_ON);
-
-  //  test_bom();
-
-  id = get_robotid();
-  packet[1] = id;
-  usb_puts("hello, I am robot ");
-  usb_puti(id);
-  usb_putc('\n');
-
-  usb_puts("wireless.\n");
-
-  wl_basic_init_default();
-
-  usb_puts("run around.\n");
-
-  run_around_init();
-
-  usb_puts("channel");
-
-  //use a specific channel to avoid interfering with other tasks
-  wl_set_channel(CHAN);
-  usb_puti(CHAN);
-
-  usb_puts("\norb set");
-
-  // initially in hunter state
-  robotState = ROBOT_HUNTER;
-
-  //if button 2 is held, you are prey
-  if(button2_read()) {
-    robotState = ROBOT_PREY;
-    bom_on();
-  }
-
-
-  while(1) {
-
-    if(robotState==ROBOT_TAGGED) {
-      usb_puts("tagged, waiting to send ACK\n");
-      orb_set_color(YELLOW);
-      //delay_ms(TAG_PAUSE);
-      move(0,0);
-      usb_puts("sending ACK to ");
-      usb_puti(tagger);
-      usb_putc('\n');
-      packet[0] = HUNTER_PREY_ACTION_ACK;
-      packet[1] = tagger;
-      wl_basic_send_global_packet (42, &packet, 2);
-      usb_puts("sent\n");
-      robotState = ROBOT_HUNTER; //no longer prey
-    }
-
-    else if(robotState == ROBOT_PREY) {
-	orb_set_color(GREEN);
-      run_around_FSM();
-    }
-
-    else if (robotState == ROBOT_IDLE) {
-	orb_set_color(BLUE);
-	move(0,0);
-	delay_ms(ACK_PAUSE);
-	robotState = ROBOT_HUNTER;
-    }
-
-    else { //ROBOT_HUNTER
-	orb_set_color(RED);
-      bom_refresh(BOM_ALL);
-      delay_ms(100);
-
-      frontRange = range_read_distance (IR2);
-
-      //BUG: when get_max_bom is called, the rangefinder seems to stop
-      //working
-      angle = bom_get_max();
-      chase(angle);
-
-      usb_puti(frontRange);
-      usb_putc('\n');
-
-      if ((hunter_prey_tagged(angle, frontRange) && rtc_get() >= 1) || button1_read()) {
-	    usb_puts("TAG!\n");
-	    packet[0] = HUNTER_PREY_ACTION_TAG;
-	    packet[1] = id;
-	    wl_basic_send_global_packet (42, &packet, 2);
-	    wl_do();
-	    rtc_reset();
-	}
-    }
-
-    packet = wl_basic_do_default(&length);
-    if (packet)
-	packet_receive(packet, length);
-  }
-  
-  return 0;
-}
-
-void packet_receive(unsigned char* packet, int length)
-{
-
-  if(length>=2){
-    if(packet[0] == HUNTER_PREY_ACTION_TAG) {
-	usb_puts("received a tag packet\n");
-      if(robotState == ROBOT_PREY) {
-	  usb_puts("it was for me\n");
-	robotState = ROBOT_TAGGED;
-	bom_off();
-	tagger = packet[1];
-      }
-      else {
-	usb_puts("tagged, but I'm not it!\n");
-      }
-    }
-    else if(packet[0] == HUNTER_PREY_ACTION_ACK) {
-      robotState = ROBOT_IDLE;
-    }
-    usb_puts("got '");
-    usb_putc(packet[0]);
-    usb_puti(packet[1]);
-    usb_puts("'\n");
-  }
-  else {
-    usb_puts(" length=");
-    usb_puti(length);
-    usb_putc('\n');
-  }
-}
-
-#define HP_BUF_IDX_ACTION 0
Index: trunk/code/projects/hunter_prey/abenico/hunter_prey.c
===================================================================
--- trunk/code/projects/hunter_prey/abenico/hunter_prey.c	(revision 1483)
+++ trunk/code/projects/hunter_prey/abenico/hunter_prey.c	(nonexistent)
@@ -1,43 +0,0 @@
-#include "hunter_prey.h"
-#include <dragonfly_lib.h>
-
-#define TAG_TIME 3
-#define TAG_RANGE 200
-
-/**** This file should not be edited! ****/
-
-
-/*
- * The criteria for tagging are the following:
- *   * The max bom is betweed 1 and 7
- *   * The front rangefinder reads less than TAG_RANGE
- *   * -1 values from the rangefinder are ignored
- *   * These conditions are met across TAG_TIME calls to this function
- */
-
-uint8_t hunter_prey_tagged(int max_bom, int frontRange) {
-
-  static int onTarget = 0;
-
-  if(max_bom < 7 && max_bom > 1 && frontRange > 0 && frontRange < TAG_RANGE) {
-    if(onTarget == 0) {
-      onTarget = TAG_TIME;
-      usb_puts("On target!\n");
-    }
-    else {
-      if(--onTarget <= 0) {
-	onTarget = 0;
-	usb_puts("TAG!\n");
-	return 1;
-      }
-    }
-  }
-  else{
-    //don't reset onTarget because the robot got too close
-    if(frontRange > 0)
-      onTarget = 0;
-  }
-
-  return 0;
-
-}
Index: trunk/code/projects/hunter_prey/main.c
===================================================================
--- trunk/code/projects/hunter_prey/main.c	(revision 1483)
+++ trunk/code/projects/hunter_prey/main.c	(nonexistent)
@@ -1,258 +0,0 @@
-#include <dragonfly_lib.h>
-#include <wireless.h>
-#include <wl_basic.h>
-#include "smart_run_around_fsm.h"
-#include "hunter_prey.h"
-
-#define CHAN 0xC
-#define TAG_PAUSE 2000
-
-#define ROBOT_HUNTER 0
-#define ROBOT_PREY 1
-#define ROBOT_TAGGED 2
-
-void packet_receive(char type, int source, unsigned char* packet, int length);
-
-volatile uint8_t robotState = ROBOT_HUNTER;
-volatile uint8_t color1, color2;
-volatile uint8_t tagAck;
-volatile uint8_t tagger;
-uint8_t id;
-
-void test_bom(void) {
-  int i;
-  int val;
-
-  while(1) {
-    bom_refresh(BOM_ALL);
-
-    for(i=0; i<16; i++) {
-      val = bom_get(i);
-      usb_puti(val);
-      usb_putc(' ');
-    }
-
-    usb_puts("| ");
-
-    usb_puti(range_read_distance (IR1));
-    usb_putc(' ');
-    usb_puti(range_read_distance (IR2));
-    usb_putc(' ');
-    usb_puti(range_read_distance (IR3));
-    usb_putc(' ');
-    usb_puti(range_read_distance (IR4));
-    usb_putc(' ');
-    usb_puti(range_read_distance (IR5));
-
-    usb_putc('\n');
-    delay_ms(500);
-  }
-
-}
-
-void chase(uint8_t angle) {
-
-  int omega = angle - 4;
-
-  if(angle > 16)
-    return;
-
-  if(omega >  8)
-    omega = omega - 16;
-
-  omega *= 255/8;
-
-/*   usb_puti(omega); */
-/*   usb_putc('\n'); */
-
-  move(140, omega);
-
-}
-
-int main(void) {
-
-  int frontRange;
-  uint8_t angle;
-  unsigned char packet[2];
-  
-  //intialize the robot and wireless
-  dragonfly_init(ALL_ON);
-
-  //  test_bom();
-
-  id = get_robotid();
-  packet[1] = id;
-  usb_puts("hello, I am robot \n");
-  usb_puti(id);
-  usb_putc('\n');
-
-  usb_puts("wireless.\n");
-
-  wl_basic_init(&packet_receive);
-
-  usb_puts("run around.\n");
-
-  run_around_init();
-
-  usb_puts("channel\n");
-
-  //use a specific channel to avoid interfering with other tasks
-  wl_set_channel(CHAN);
-
-  usb_puts("orb set\n");
-
-  orb_set_color(BLUE);
-  color1 = BLUE;
-  color2 = BLUE;
-
-  //if button 2 is held, you are prey
-  if(button2_read()) {
-    robotState = ROBOT_PREY;
-    bom_on();
-  }
-
-
-  while(1) {
-
-    if(robotState==ROBOT_TAGGED) {
-      usb_puts("tagged, waiting to send ACK\n");
-      //delay_ms(TAG_PAUSE);
-      move(0,0);
-      usb_puts("sending ACK to ");
-      usb_puti(tagger);
-      usb_putc('\n');
-      packet[0] = HUNTER_PREY_ACTION_ACK;
-      packet[1] = tagger;
-      wl_basic_send_global_packet (42, &packet, 2);
-      usb_puts("sent\n");
-      robotState = ROBOT_HUNTER; //no longer prey
-    }
-
-    else if(robotState == ROBOT_PREY) {
-      run_around_FSM();
-    }
-
-    else { //ROBOT_HUNTER
-
-      bom_refresh(BOM_ALL);
-
-      delay_ms(100);
-
-      frontRange = range_read_distance (IR2);
-
-/*       usb_puti(frontRange); */
-/*       usb_putc(','); */
-
-      //BUG: when get_max_bom is called, the rangefinder seems to stop
-      //working
-      angle = bom_get_max();
-/*       usb_puti(angle); */
-/*       usb_putc('\n'); */
-
-      chase(angle);
-
-      //debugging to determine tagging conditions
-      if(angle < 7 && angle > 1) {
-	if(color1 != RED) {
-	  color1 = RED;
-	  orb1_set_color(RED);
-	}
-      }
-      else {
-	if(color1 != BLUE) {
-	  color1 = BLUE;
-	  orb1_set_color(BLUE);
-	}
-      }
-
-
-      usb_puti(frontRange);
-      usb_putc('\n');
-
-/*       if(frontRange > 0 && frontRange < TAG_RANGE) { */
-/* 	if(color2 != RED) { */
-/* 	  color2 = RED; */
-/* 	  orb2_set_color(RED); */
-/* 	} */
-/*       } */
-/*       else { */
-/* 	if(color2 != BLUE) { */
-/* 	  color2 = BLUE; */
-/* 	  orb2_set_color(BLUE); */
-/* 	} */
-/*       } */
-
-
-
-      if(hunter_prey_tagged(angle, frontRange) || button1_read()) {
-	orb_set_color(YELLOW);
-	color1 = YELLOW;
-	color2 = YELLOW;
-	usb_puts("TAG!\n");
-	tagAck = 0;
-	packet[0] = HUNTER_PREY_ACTION_TAG;
-	packet[1] = id;
-	wl_basic_send_global_packet (42, &packet, 2);
-	move(0,0);
-	while(!tagAck)
-	  wl_do();
-
-	if(tagAck == id) { //if the ack was for us
-	  usb_puts("ACK!\n");
-	      
-	  move(-230,0); //back up to give the new prey some room
-	  delay_ms(TAG_PAUSE/2);
-	  move(0,0);
-
-	  robotState = ROBOT_PREY;
-	  bom_on();
-	}
-	else {
-	  usb_puts("ACK failed!\n");
-	}
-      }
-    }
-
-    wl_do();
-  }
-  
-  return 0;
-}
-
-void packet_receive(char type, int source, unsigned char* packet, int length)
-{
-
-  if(type==42 && length>=2){
-    if(packet[0] == HUNTER_PREY_ACTION_TAG) {
-      if(robotState == ROBOT_PREY) {
-	robotState = ROBOT_TAGGED;
-	bom_off();
-	color1 = BLUE;
-	color2 = BLUE;
-	orb_set_color(BLUE);
-	tagger = packet[1];
-      }
-      else {
-	usb_puts("tagged, but I'm not it!\n");
-      }
-    }
-    else if(packet[0] == HUNTER_PREY_ACTION_ACK && robotState == ROBOT_HUNTER) {
-      tagAck = packet[1];
-    }
-    else {
-      usb_puts("got '");
-      usb_putc(packet[0]);
-      usb_puti(packet[1]);
-      usb_puts("'\n");
-    }
-  }
-  else {
-    usb_puts("got unkown packet! type=");
-    usb_puti(type);
-    usb_puts(" length=");
-    usb_puti(length);
-    usb_putc('\n');
-  }
-}
-
-#define HP_BUF_IDX_ACTION 0
Index: trunk/code/projects/hunter_prey/hunter_prey.c
===================================================================
--- trunk/code/projects/hunter_prey/hunter_prey.c	(revision 1483)
+++ trunk/code/projects/hunter_prey/hunter_prey.c	(nonexistent)
@@ -1,43 +0,0 @@
-#include "hunter_prey.h"
-#include <dragonfly_lib.h>
-
-#define TAG_TIME 3
-#define TAG_RANGE 200
-
-/**** This file should not be edited! ****/
-
-
-/*
- * The criteria for tagging are the following:
- *   * The max bom is betweed 1 and 7
- *   * The front rangefinder reads less than TAG_RANGE
- *   * -1 values from the rangefinder are ignored
- *   * These conditions are met across TAG_TIME calls to this function
- */
-
-uint8_t hunter_prey_tagged(int max_bom, int frontRange) {
-
-  static int onTarget = 0;
-
-  if(max_bom < 7 && max_bom > 1 && frontRange > 0 && frontRange < TAG_RANGE) {
-    if(onTarget == 0) {
-      onTarget = TAG_TIME;
-      usb_puts("On target!\n");
-    }
-    else {
-      if(--onTarget <= 0) {
-	onTarget = 0;
-	usb_puts("TAG!\n");
-	return 1;
-      }
-    }
-  }
-  else{
-    //don't reset onTarget because the robot got too close
-    if(frontRange > 0)
-      onTarget = 0;
-  }
-
-  return 0;
-
-}
Index: trunk/code/projects/hunter_prey/smart_run_around_fsm.c
===================================================================
--- trunk/code/projects/hunter_prey/smart_run_around_fsm.c	(revision 1483)
+++ trunk/code/projects/hunter_prey/smart_run_around_fsm.c	(nonexistent)
@@ -1,109 +0,0 @@
-#include <dragonfly_lib.h>
-#include "smart_run_around_fsm.h"
-
-void run_around_init(void)
-{
-  range_init();
-  orb_init();
- 
-  state = SRA_FORWARD;  // start out moving forward
-  // initialize rangefinder values to 0
-  d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0;
-}
-
-/* evaluate rangefinder input and update state
- * call this function as often as possible to avoid collisions
- */
-void run_around_FSM(void)
-{
-    /* TODO: find a better way to handle rangefinder input
-     * robot should deal with -1s (obstacles too close or too far to detect)
-     * in a way that keeps it from crashing or driving in circles
-     */
-    // do not update distances when rangefinders return -1
-    // otherwise update distances with new rangefinder values
-    int16_t temp;
-
-    temp = range_read_distance(IR1);
-    d1 = (temp == -1) ? d1 : temp;
-
-    temp = range_read_distance(IR2);
-    d2 = (temp == -1) ? d2 : temp;
-
-    temp = range_read_distance(IR3);
-    d3 = (temp == -1) ? d3 : temp;
-
-    temp = range_read_distance(IR4);
-    d4 = (temp == -1) ? d4 : temp;
-
-    temp = range_read_distance(IR5);
-    d5 = (temp == -1) ? d5 : temp;
-
-    // update state based on rangefinder input
-    if (d2 < IR2_DANGER)    // avoid frontal collision by turning in place
-	state = SRA_SPIN;
-    /* nowhere to turn, so don't
-     * will probably need to turn around soon, but not yet
-     */
-    else if (d1 < IR13_DANGER && d3 < IR13_DANGER)
-	state = SRA_FORWARD;
-    // avoid left-side collision by turning right
-    else if (d1 < IR13_DANGER || d5 < IR45_DANGER)
-	state = SRA_RIGHT;
-    // avoid right-side collision by turning left
-    else if (d3 < IR13_DANGER || d4 < IR45_DANGER)
-	state = SRA_LEFT;
-    else if (d2 < IR2_INTEREST)	// should turn to avoid obstacle up ahead
-    {
-	if (d3 >= d1)	// more room on right
-	    state = SRA_RIGHT;
-	else	// more room on left
-	    state = SRA_LEFT;
-    }
-    else    // no obstacles close by, so keep going straight
-	state = SRA_FORWARD;
-
-    /* Debugging via USB output */
-/*     usb_puts("IR1: "); */
-/*     usb_puti(d1); */
-/*     usb_puts(" IR2: "); */
-/*     usb_puti(d2); */
-/*     usb_puts(" IR3: "); */
-/*     usb_puti(d3); */
-/*     usb_puts(" IR4: "); */
-/*     usb_puti(d4); */
-/*     usb_puts(" IR5: "); */
-/*     usb_puti(d5); */
-/*     usb_puts("\n\r"); */
-
-    evaluate_state();	// take action on updated state
-}
-
-// behave according to current state
-// TODO: adjust speeds after testing
-void evaluate_state(void)
-{
-    switch (state)
-    {
-	case SRA_FORWARD:
-	    orb_set_color(GREEN);
-	    move(220, 0);	// drive straight forward
-	    break;
-	case SRA_LEFT:
-	    orbs_set_color(GREEN, YELLOW);  // green on left side
-	    move(HALF_SPD, NRML_TURN);	// drive forward and to the left
-	    break;
-	case SRA_RIGHT:
-	    orbs_set_color(YELLOW, GREEN);  // green on right side
-	    move(HALF_SPD, -NRML_TURN);	// drive forward and to the right
-	    break;
-	case SRA_SPIN:
-	    orb_set_color(RED);
-	    move(0, NRML_TURN);	// spin CCW without traveling
-	    break;
-	default:    // should never reach this
-	    orb_set_color(PURPLE);
-	    move(0, 0);	// stop completely
-    }
-}
-

Property changes on: trunk/code/projects/hunter_prey/smart_run_around_fsm.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/hunter_prey/hunter_prey.h
===================================================================
--- trunk/code/projects/hunter_prey/hunter_prey.h	(revision 1483)
+++ trunk/code/projects/hunter_prey/hunter_prey.h	(nonexistent)
@@ -1,17 +0,0 @@
-#ifndef _HUNTER_PREY_H
-#define _HUNTER_PREY_H
-
-#include <inttypes.h>
-
-/*
- * The packet structure is 2 bytes
- * byte 0 is the action, which is one of the values below
- * byte 1 is the robot id
- */
-
-#define HUNTER_PREY_ACTION_TAG 'T'
-#define HUNTER_PREY_ACTION_ACK 'A'
-
-uint8_t hunter_prey_tagged(int max_bom, int front_rangefinder);
-
-#endif
Index: trunk/code/projects/hunter_prey/ref/main.c
===================================================================
--- trunk/code/projects/hunter_prey/ref/main.c	(revision 1483)
+++ trunk/code/projects/hunter_prey/ref/main.c	(nonexistent)
@@ -1,152 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <unistd.h>
-#include "../../libwireless/lib/wl_basic.h"
-#include "../../libwireless/lib/wireless.h"
-#include "../hunter_prey.h"
-
-#define TYPE 42	// packet type for wireless communication
-
-#define NUM_BOTS 17
-#define TOTAL_GAME_TIME 600*5 //in 100 ms intervals
-
-void packet_receive(char type, int source, unsigned char* packet, int length);
-
-volatile unsigned int preyTime[20];
-volatile int preyBot=-1;
-
-void waitKey(void) {
-  unsigned char buf[10];
-
-  //read from stdin
-   while(read(0, buf, 10)==10) {
-     printf("!");
-     fflush(stdout);
-   }
-
-  while(getchar()==-1);
-}
-
-void print_stats(void) {
-
-  int i=0;
-
-  for(i=0;i<NUM_BOTS;i++) {
-    printf("%5d ", preyTime[i]);
-  }
-
-  printf("\n");
-
-}
-
-int main(int argc, char *argv[])
-{
-    char send_buffer[2];    // holds data to send
-    int data_length;	// length of data received
-    unsigned char *packet_data;	// data received
-    int ret;
-    int i;
-    int winner, maxTime=0;
-
-    unsigned int channel = 0xF;
-
-    struct timespec delay, rem;
-
-    delay.tv_sec = 0;
-    delay.tv_nsec = 100000000;
-
-
-    if(argc > 1) {
-      channel = atoi(argv[1]);
-    }
-
-    printf("using wireless channel %d\n", channel);
-
-    wl_set_com_port("/dev/ttyUSB0");
-    // set up wireless
-    ret = wl_basic_init(&packet_receive);
-
-    if(ret) {
-      printf("ERROR: wl_basic_init failed. %d\n", ret);
-      return ret;
-    }
-    //wl_set_channel(channel);
-
-    for(i=0;i<NUM_BOTS;i++) {
-      preyTime[i]=0;
-    }
-
-    ret = 0;    
-    i=0;
-
-    printf("ready\n");
-
-    //TODO: use rtc to make this more accurate
-    while(i < TOTAL_GAME_TIME) {
-      wl_do();
-
-      if(ret==0) {
-	ret = nanosleep(&delay, &rem);
-      }
-      else {
-	ret = nanosleep(&rem, &rem);
-      }
-
-      //update counts when we have waited at least enough time
-      if(ret == 0 && preyBot >= 0) {
-	preyTime[preyBot]++;
-
-	if(i==0) { //time starts on the first real tag
-	  printf("\nThe race is on!\n");
-	}
-	i++;
-      }
-
-      if((TOTAL_GAME_TIME - i)%600 == 0) {
-	printf("%d minutes remaining!\n", (TOTAL_GAME_TIME - i)/600);
-      }
-
-      if(i%10==0) {
-	print_stats();
-	if( TOTAL_GAME_TIME - i <= 100)
-	  printf("%d...\n", (TOTAL_GAME_TIME - i)/10);
-      }
-    }
-
-
-    for(i=1;i<NUM_BOTS;i++) {
-      if(preyTime[i] > maxTime) {
-	maxTime = preyTime[i];
-	winner = i;
-      }
-    }
-
-    printf("\n\GAME OVER!n\nAAAAAAAAAAND the winner is\nBOT %d!!!!\n", winner);
-
-    return 0;
-}
-
-void packet_receive(char type, int source, unsigned char* packet, int length)
-{
-
-  if(type==42 && length>=2){
-    if(packet[0] == HUNTER_PREY_ACTION_TAG) {
-      //TODO: check tag
-
-    }
-    else if(packet[0] == HUNTER_PREY_ACTION_ACK) {
-
-      preyBot = packet[1];
-      printf("bot %d is prey!\n", preyBot);
-
-    }
-    else {
-      printf("got invalid packet! %c%d\n", packet[0], packet[1]);
-    }
-  }
-  else {
-    printf("got unknown packet! type=%d, length=%d\n", type, length);
-  }
-}
-
Index: trunk/code/projects/hunter_prey/ref/Makefile
===================================================================
--- trunk/code/projects/hunter_prey/ref/Makefile	(revision 1483)
+++ trunk/code/projects/hunter_prey/ref/Makefile	(nonexistent)
@@ -1,11 +0,0 @@
-CC = gcc
-CFLAGS = -Wall -g
-
-all: ref
-
-ref: *.c ../../libwireless/lib/*.c 
-	$(CC) $(CFLAGS) *.c -L../../libwireless/lib -o ref -DWL_DEBUG -lwireless -lpthread -ggdb
-
-clean:
-	rm -f *.o ref ../lib/*.o
-
Index: trunk/code/projects/hunter_prey/smart_run_around_fsm.h
===================================================================
--- trunk/code/projects/hunter_prey/smart_run_around_fsm.h	(revision 1483)
+++ trunk/code/projects/hunter_prey/smart_run_around_fsm.h	(nonexistent)
@@ -1,40 +0,0 @@
-// smart_run_around_fsm.h
-// required to run Smart Run Around functions
-// declare functions and global variables
-
-#ifndef _RUN_AROUND_FSM_H_
-#define _RUN_AROUND_FSM_H_
-
-// states (robot shall never move in reverse)
-// these constants may be changed (but can't overlap) without effect
-#define SRA_FORWARD 0   // drive straight forward
-#define SRA_LEFT 1	// drive forward and to the left
-#define SRA_RIGHT 2	// drive forward and to the right
-#define SRA_SPIN 3	// turn without traveling (last resort if otherwise stuck)
-
-/* conditions on rangefinders (in mm) informing state changes
- * distances are 50 greater than in real life, cannot be smaller than 100
- * naming format: SENSOR_URGENCY
- * changing these constants affects robot operation
- */
-#define IR2_DANGER 150	// 10 cm: dangerously close to front
-#define IR13_DANGER 200 // 15 cm: dangerously close to sides (looking ahead)
-#define IR2_INTEREST 300    // 25 cm: notably close to front
-#define IR45_DANGER 150	// dangerously close to side (looking sideways)
-
-uint8_t state;	// current state of FSM: SRA_FORWARD, SRA_LEFT, SRA_RIGHT, SRA_SPIN
-int16_t d1, d2, d3, d4, d5; // values returned by rangefinders
-
-// initialize rangefinders and global variables
-void run_around_init(void);
-
-/* evaluate rangefinder input and update state
- * call this function as often as possible to avoid collisions
- */
-void run_around_FSM(void);
-
-// behave according to current state
-void evaluate_state(void);
-
-#endif
-

Property changes on: trunk/code/projects/hunter_prey/smart_run_around_fsm.h
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/hunter_prey/Makefile
===================================================================
--- trunk/code/projects/hunter_prey/Makefile	(revision 1483)
+++ trunk/code/projects/hunter_prey/Makefile	(nonexistent)
@@ -1,520 +0,0 @@
-########Update This Section########
-#
-#
-
-# Relative path to the root directory (containing lib directory)
-ifndef COLONYROOT
-COLONYROOT = ../../..
-endif
-
-# Target file name (without extension).
-TARGET = main
-
-# Uncomment this to use the wireless library
-USE_WIRELESS = 1
-
-# com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
-
-#
-###################################
-
-# Hey Emacs, this is a -*- makefile -*-
-#----------------------------------------------------------------------------
-# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
-#
-# Released to the Public Domain
-#
-# Additional material for this makefile was written by:
-# Peter Fleury
-# Tim Henigan
-# Colin O'Flynn
-# Reiner Patommel
-# Markus Pfaff
-# Sander Pool
-# Frederik Rouleau
-#
-#----------------------------------------------------------------------------
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF.
-#
-# make extcoff = Convert ELF to AVR Extended COFF.
-#
-# make program = Download the hex file to the device, using avrdude.
-#                Please customize the avrdude settings below first!
-#
-# make debug = Start either simulavr or avarice as specified for debugging,
-#              with avr-gdb or avr-insight as the front end for debugging.
-#
-# make filename.s = Just compile filename.c into the assembler code only.
-#
-# make filename.i = Create a preprocessed source file for use in submitting
-#                   bug reports to the GCC project.
-#
-# To rebuild project do "make clean" then "make all".
-#----------------------------------------------------------------------------
-
-#if you want your code to work on the Firefly++ and not Firefly+
-#then add the -DFFPP line to CDEFS
-CDEFS =
-#-DFFPP
-
-# MCU name
-MCU = atmega128
-
-# Processor frequency.
-#     This will define a symbol, F_CPU, in all source code files equal to the
-#     processor frequency. You can then use this symbol in your source code to
-#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-#     automatically to create a 32-bit value in your source code.
-F_CPU = 8000000
-
-# Output format. (can be srec, ihex, binary)
-FORMAT = ihex
-
-# List C source files here. (C dependencies are automatically generated.)
-SRC = $(wildcard *.c)
-
-# List Assembler source files here.
-#     Make them always end in a capital .S.  Files ending in a lowercase .s
-#     will not be considered source files but generated files (assembler
-#     output from the compiler), and will be deleted upon "make clean"!
-#     Even though the DOS/Win* filesystem matches both .s and .S the same,
-#     it will preserve the spelling of the filenames, and gcc itself does
-#     care about how the name is spelled on its command-line.
-ASRC =
-
-# Optimization level, can be [0, 1, 2, 3, s].
-#     0 = turn off optimization. s = optimize for size.
-#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
-OPT = s
-
-# Debugging format.
-#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
-#     AVR Studio 4.10 requires dwarf-2.
-#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
-DEBUG =
-
-# Compiler flag to set the C Standard level.
-#     c89   = "ANSI" C
-#     gnu89 = c89 plus GCC extensions
-#     c99   = ISO C99 standard (not yet fully implemented)
-#     gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
-
-# Place -D or -U options here
-CDEFS += -DF_CPU=$(F_CPU)UL
-CDEFS += -DFFP
-# for wireless library
-ifdef USE_WIRELESS
-	CDEFS += -DROBOT
-endif
-
-# Place -I, -L options here
-CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
-CINCS += -L$(COLONYROOT)/code/lib/bin
-ifdef USE_WIRELESS
-	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
-endif
-
-#---------------- Compiler Options ----------------
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-CFLAGS =
-# CFLAGS = -g$(DEBUG)
-CFLAGS += $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-CFLAGS += -Wall -Wstrict-prototypes
-CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
-CFLAGS += $(CSTANDARD)
-
-#---------------- Assembler Options ----------------
-#  -Wa,...:   tell GCC to pass this to the assembler.
-#  -ahlms:    create listing
-#  -gstabs:   have the assembler create line number information; note that
-#             for use in COFF files, additional information about filenames
-#             and function names needs to be present in the assembler source
-#             files -- see avr-libc docs [FIXME: not yet described there]
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
-
-#---------------- Library Options ----------------
-# Minimalistic printf version
-PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
-
-# Floating point printf version (requires MATH_LIB = -lm below)
-PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
-
-# If this is left blank, then it will use the Standard printf version.
-#PRINTF_LIB =
-#PRINTF_LIB = $(PRINTF_LIB_MIN)
-PRINTF_LIB = $(PRINTF_LIB_FLOAT)
-
-
-# Minimalistic scanf version
-SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
-
-# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
-SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
-
-# If this is left blank, then it will use the Standard scanf version.
-SCANF_LIB =
-#SCANF_LIB = $(SCANF_LIB_MIN)
-#SCANF_LIB = $(SCANF_LIB_FLOAT)
-
-MATH_LIB = -lm
-
-#---------------- External Memory Options ----------------
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# used for variables (.data/.bss) and heap (malloc()).
-#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# only used for heap (malloc()).
-#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
-
-EXTMEMOPTS =
-
-#---------------- Linker Options ----------------
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += $(EXTMEMOPTS)
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
-ifdef USE_WIRELESS
-	LDFLAGS += -lwireless
-endif
-LDFLAGS += -ldragonfly
-
-
-
-#---------------- Programming Options (avrdude) ----------------
-
-# Programming hardware: alf avr910 avrisp bascom bsd
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
-#
-# Type: avrdude -c ?
-# to get a full listing.
-#
-AVRDUDE_PROGRAMMER = avrisp
-
-# programmer connected to serial device
-
-AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
-
-
-# Uncomment the following if you want avrdude's erase cycle counter.
-# Note that this counter needs to be initialized first using -Yn,
-# see avrdude manual.
-#AVRDUDE_ERASE_COUNTER = -y
-
-# Uncomment the following if you do /not/ wish a verification to be
-# performed after programming the device.
-#AVRDUDE_NO_VERIFY = -V
-
-# Increase verbosity level.  Please use this when submitting bug
-# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
-# to submit bug reports.
-#AVRDUDE_VERBOSE = -v -v
-
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
-
-#don't check for device signature
-AVRDUDE_FLAGS += -F
-
-
-
-#---------------- Debugging Options ----------------
-
-# For simulavr only - target MCU frequency.
-DEBUG_MFREQ = $(F_CPU)
-
-# Set the DEBUG_UI to either gdb or insight.
-# DEBUG_UI = gdb
-DEBUG_UI = insight
-
-# Set the debugging back-end to either avarice, simulavr.
-DEBUG_BACKEND = avarice
-#DEBUG_BACKEND = simulavr
-
-# GDB Init Filename.
-GDBINIT_FILE = __avr_gdbinit
-
-# When using avarice settings for the JTAG
-JTAG_DEV = /dev/com1
-
-# Debugging port used to communicate between GDB / avarice / simulavr.
-DEBUG_PORT = 4242
-
-# Debugging host used to communicate between GDB / avarice / simulavr, normally
-#     just set to localhost unless doing some sort of crazy debugging when
-#     avarice is running on a different computer.
-DEBUG_HOST = localhost
-
-
-
-#============================================================================
-
-
-# Define programs and commands.
-SHELL = sh
-CC = avr-gcc
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
-SIZE = avr-size
-NM = avr-nm
-AVRDUDE = avrdude
-REMOVE = rm -f
-REMOVEDIR = rm -rf
-COPY = cp
-WINSHELL = cmd
-
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = -------- begin --------
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before:
-MSG_SIZE_AFTER = Size after:
-MSG_COFF = Converting to AVR COFF:
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
-MSG_FLASH = Creating load file for Flash:
-MSG_EEPROM = Creating load file for EEPROM:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling:
-MSG_ASSEMBLING = Assembling:
-MSG_CLEANING = Cleaning project:
-
-
-
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
-
-# Define all listing files.
-LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
-
-
-# Compiler flags to generate dependency files.
-GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
-
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-
-
-
-# Default target.
-all: begin gccversion sizebefore build sizeafter end
-
-build: elf hex eep lss sym
-
-elf: $(TARGET).elf
-hex: $(TARGET).hex
-eep: $(TARGET).eep
-lss: $(TARGET).lss
-sym: $(TARGET).sym
-
-
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
-
-sizebefore:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-sizeafter:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-
-
-# Display compiler version information.
-gccversion :
-	@$(CC) --version
-
-
-
-# Program the device.
-program: $(TARGET).hex $(TARGET).eep
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
-
-
-# Generate avr-gdb config/init file which does the following:
-#     define the reset signal, load the target file, connect to target, and set
-#     a breakpoint at main().
-gdb-config:
-	@$(REMOVE) $(GDBINIT_FILE)
-	@echo define reset >> $(GDBINIT_FILE)
-	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
-	@echo end >> $(GDBINIT_FILE)
-	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
-	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
-ifeq ($(DEBUG_BACKEND),simulavr)
-	@echo load  >> $(GDBINIT_FILE)
-endif
-	@echo break main >> $(GDBINIT_FILE)
-
-debug: gdb-config $(TARGET).elf
-ifeq ($(DEBUG_BACKEND), avarice)
-	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
-	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
-	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
-	@$(WINSHELL) /c pause
-
-else
-	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
-	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
-endif
-	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
-
-
-
-
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
-COFFCONVERT=$(OBJCOPY) --debugging \
---change-section-address .data-0x800000 \
---change-section-address .bss-0x800000 \
---change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
-
-
-coff: $(TARGET).elf
-	@echo
-	@echo $(MSG_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
-	@echo
-	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
-
-
-
-# Create final output files (.hex, .eep) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
-	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-%.eep: %.elf
-	@echo
-	@echo $(MSG_EEPROM) $@
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
-	$(NM) -n $< > $@
-
-
-
-# Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
-	@echo
-	@echo $(MSG_LINKING) $@
-	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
-
-
-# Compile: create object files from C source files.
-%.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(ALL_CFLAGS) $< -o $@
-
-
-# Compile: create assembler files from C source files.
-%.s : %.c
-	$(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-%.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-# Create preprocessed source for use in sending a bug report.
-%.i : %.c
-	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
-
-
-# Target: clean project.
-clean: begin clean_list end
-
-clean_list :
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).eep
-	$(REMOVE) $(TARGET).cof
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lss
-	$(REMOVE) $(OBJ)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVEDIR) .dep
-
-
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff \
-clean clean_list program debug gdb-config
-
Index: trunk/code/projects/hunter_prey/testbench/main.c
===================================================================
--- trunk/code/projects/hunter_prey/testbench/main.c	(revision 1483)
+++ trunk/code/projects/hunter_prey/testbench/main.c	(nonexistent)
@@ -1,291 +0,0 @@
-/* testbench for Lab 2 first checkpoint
- * determine whether robot under test complies with communication standard
- * to be conducted using XBee USB dongle
- */
-
-/* The tests shall be as follows
- * 1. Receive a TAG, send an ACK
- * - Robot passes if it sends a tag and changes to prey state
- * 2. Send a TAG, receive an ACK
- * - Pass if sends ACK, changes to wait state, then hunter state
- * 3. Receive TAG, send slightly delayed (< 1s) ACK
- * - Pass if sends one and only one TAG packet (and changes state appropriately)
- * 4. Receive TAG, do not send ACK
- * - Pass if sends one and only one TAG packet (and does not change state)
- * 5. Receive TAG, send ACK to incorrect robot
- * - Pass if goes to wait state, then back to hunter state
- * 6. Simulate TAG from robot A to B, ACK from B to A
- * - Pass if ignores TAG, goes to wait then hunter in response to ACK
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include "../../libwireless/lib/wl_basic.h"
-#include "../../libwireless/lib/wireless.h"
-#include "hunter_prey.h"
-#include <time.h>
-
-#define TYPE 42	// packet type for wireless communication
-#define ROBOTID 255 // make up a robot id because the PC doesn't have one
-
-
-void waitKey() {
-  unsigned char buf[10];
-
-  //read from stdin
-   while(read(0, buf, 10)==10) {
-     printf("!");
-     fflush(stdout);
-   }
-
-  while(getchar()==-1);
-}
-
-int main(int argc, char *argv[])
-{
-    char send_buffer[2];    // holds data to send
-    int data_length;	// length of data received
-    unsigned char *packet_data;	// data received
-    int ret;
-
-    unsigned int channel = 0xF;
-
-    struct timespec delay8, rem;
-
-    if(argc > 1) {
-      channel = atoi(argv[1]);
-    }
-
-    printf("using wireless channel %d\n", channel);
-
-    delay8.tv_sec = 2;
-    delay8.tv_nsec = 800000000;
-
-    wl_set_com_port("/dev/ttyUSB0");
-    // set up wireless
-    ret = wl_basic_init_default();
-
-    if(ret) {
-      printf("ERROR: wl_basic_init_default returned %d\n", ret);
-      return ret;
-    }
-
-    ret = wl_set_channel(channel);
-
-    if(ret) {
-      printf("ERROR: set channel failed! %d\n", ret);
-      return ret;
-    }
-
-    printf("Testing communications\n\n");
-
-    // Receive TAG, send ACK
-    printf("Receive TAG, send ACK... ");
-    fflush(stdout);
-    // Wait until we receive a packet
-    while (!(packet_data = wl_basic_do_default(&data_length)));
-
-    printf("got packet, validating and sending ack...");
-    fflush(stdout);
-
-    if (data_length > 2)
-    {
-	printf("Excessive TAG packet length... ");
-	fflush(stdout);
-    }
-
-    if (data_length >= 2 && packet_data[0] == HUNTER_PREY_ACTION_TAG)
-    {
-	// send back an ACK
-	send_buffer[0] = HUNTER_PREY_ACTION_ACK;
-	send_buffer[1] = packet_data[1];
-	printf("sending ack intended for robot %d\n", packet_data[1]);
-	fflush(stdout);
-	wl_basic_send_global_packet(TYPE, send_buffer, 2);
-
-	printf("PASSED\n");
-    }
-    else
-	printf("FAILED\n");
-
-    printf("robot should be prey\nPress enter to continue...\n");
-    waitKey();
-
-    // Send a TAG, receive an ACK
-    printf("Send TAG, wait for ACK... ");
-    fflush(stdout);
-
-    send_buffer[0] = HUNTER_PREY_ACTION_TAG;
-    send_buffer[1] = ROBOTID;
-    // robot number stays the same
-    wl_basic_send_global_packet(TYPE, send_buffer, 2);
-
-    // Wait for an ACK
-    ret = nanosleep(&delay8, &rem);  // wait for 800 ms before sending ACK
-
-    while(ret) {
-      //      printf("nanosleep not done, needs to wait %ld more\n", rem.tv_nsec);
-      ret = nanosleep(&rem, &rem);
-    }
-
-    data_length = -1;
-    packet_data = wl_basic_do_default(&data_length);
-
-    // Check ACK for presence and correctness
-    if (!packet_data || data_length < 2 ||
-	    packet_data[0] != HUNTER_PREY_ACTION_ACK ||
-        packet_data[1] != ROBOTID) {
-      printf("FAILED, packet=%p, len=%d\n", packet_data, data_length);
-      if(data_length >= 2) {
-	printf("\tpacket = [%c, %d]\n",packet_data[0], packet_data[1]);
-      }
-    }
-    else
-	printf("PASSED\n");
-
-    printf("Robot should be Hunter\nPress enter to continue...\n");
-
-    waitKey();
-
-    // Receive a TAG, send a delayed ACK
-    printf("Receive a TAG, send a delayed ACK... ");
-    fflush(stdout);
-
-    while (!(packet_data = wl_basic_do_default(&data_length)));
-
-    if (data_length >= 2 && packet_data[0] == HUNTER_PREY_ACTION_TAG)
-    {
-        printf("got TAG, waiting...");
-	fflush(stdout);
-	// wait before sending ACK back
-	//usleep(900000);
-        delay8.tv_sec = 0;
-        ret = nanosleep(&delay8, &rem);  // wait for 800 ms before sending ACK
-
-	while(ret) {
-	  printf(".");
-	  fflush(stdout);//      printf("nanosleep not done, needs to wait %ld more\n", rem.tv_nsec);
-	  ret = nanosleep(&rem, &rem);
-	}
-
-
-	if (wl_basic_do_default(&data_length))
-	    printf("FAILED, got another TAG too soon\n");
-	else
-	{
-	    // send packet
-	    send_buffer[0] = HUNTER_PREY_ACTION_ACK;
-	    send_buffer[1] = packet_data[1];
-	    wl_basic_send_global_packet(TYPE, send_buffer, 2);
-
-	    printf("PASSED\n");
-	}
-    }
-
-    else
-	printf("FAILED\n");
-
-
-    printf("robot should be prey.\n Press Enter...\n");
-    waitKey();
-
-    printf("sending courtesy tag...");
-    fflush(stdout);
-    send_buffer[0] = HUNTER_PREY_ACTION_TAG;
-    send_buffer[1] = ROBOTID;
-    // robot number stays the same
-    wl_basic_send_global_packet(TYPE, send_buffer, 2);
-    printf("done.\nwaiting for ack...");
-    fflush(stdout);
-
-    while (!(packet_data = wl_basic_do_default(&data_length)));
-
-    if (!packet_data || data_length < 2 ||
-	    packet_data[0] != HUNTER_PREY_ACTION_ACK ||
-	    packet_data[1] != ROBOTID)
-      printf("FAILED, packet=%p, len=%d\n", packet_data, data_length);
-    else
-	printf("done\n");
-
-
-    // Receive a TAG, never send an ACK
-    printf("Receive TAG, never send ACK... ");
-    fflush(stdout);
-
-    while (!(packet_data = wl_basic_do_default(&data_length)));
-
-    if (data_length >= 2 && packet_data[0] == HUNTER_PREY_ACTION_TAG)
-    {
-
-        printf("got TAG, monitoring for 5 seconds\n");
-	fflush(stdout);
-	delay8.tv_sec = 5;
-	delay8.tv_nsec = 0;
-
-	ret = nanosleep(&delay8, &rem);  // wait for 5 secs
-	while(ret) {
-	  //      printf("nanosleep not done, needs to wait %ld more\n", rem.tv_nsec);
-	  ret = nanosleep(&rem, &rem);
-	}
-
-	if (wl_basic_do_default(&data_length))
-	    printf("FAILED, robot is spamming\n");
-	else
-	    printf("PASSED\n");
-    }
-
-    else
-	printf("FAILED\n");
-
-    printf("robot should be hunter.\nPress enter...\n");
-
-    waitKey();
-
-    // Receive TAG, send ACK to incorrect robot
-    printf("Receive TAG, send ACK to incorrect robot... ");
-    fflush(stdout);
-
-    // Wait until we receive a packet
-    while (!(packet_data = wl_basic_do_default(&data_length)));
-
-    if (data_length >= 2 && packet_data[0] == HUNTER_PREY_ACTION_TAG)
-    {
-	// send back an ACK
-	send_buffer[0] = HUNTER_PREY_ACTION_ACK;
-	send_buffer[1] = packet_data[1] + 1;
-	wl_basic_send_global_packet(TYPE, send_buffer, 2);
-
-	printf("PASSED\n");
-    }
-    else
-	printf("FAILED\n");
-
-
-    printf("robot should wait and then still be hunter.\nPress Enter...\n");
-    waitKey();
-
-    // Simulate TAG from robot A to B, ACK from robot B to A
-    printf("Send TAG from robot A to B, ACK from B to A... ");
-    fflush(stdout);
-
-    // TAG
-    send_buffer[0] = HUNTER_PREY_ACTION_TAG;
-    send_buffer[1] = packet_data[1] - 1;    // robot other than testee
-    wl_basic_send_global_packet(TYPE, send_buffer, 2);
-
-    // ACK
-    send_buffer[0] = HUNTER_PREY_ACTION_ACK;
-    // send_buffer[1] stays the same
-    wl_basic_send_global_packet(TYPE, send_buffer, 2);
-
-    if (wl_basic_do_default(&data_length))
-	printf("FAILED\n");
-    else
-	printf("PASSED\n");
-
-    printf("robot should be waiting\n");
-
-    return 0;
-}
-
Index: trunk/code/projects/hunter_prey/testbench/hunter_prey.h
===================================================================
--- trunk/code/projects/hunter_prey/testbench/hunter_prey.h	(revision 1483)
+++ trunk/code/projects/hunter_prey/testbench/hunter_prey.h	(nonexistent)
@@ -1,17 +0,0 @@
-#ifndef _HUNTER_PREY_H
-#define _HUNTER_PREY_H
-
-#include <inttypes.h>
-
-/*
- * The packet structure is 2 bytes
- * byte 0 is the action, which is one of the values below
- * byte 1 is the robot id
- */
-
-#define HUNTER_PREY_ACTION_TAG 'T'
-#define HUNTER_PREY_ACTION_ACK 'A'
-
-uint8_t hunter_prey_tagged(int max_bom, int front_rangefinder);
-
-#endif
Index: trunk/code/projects/hunter_prey/testbench/Makefile
===================================================================
--- trunk/code/projects/hunter_prey/testbench/Makefile	(revision 1483)
+++ trunk/code/projects/hunter_prey/testbench/Makefile	(nonexistent)
@@ -1,11 +0,0 @@
-CC = gcc
-CFLAGS = -Wall -g
-
-all: testbench
-
-testbench: *.c ../../libwireless/lib/*.c 
-	$(CC) $(CFLAGS) *.c -L../../libwireless/lib -o testbench -DWL_DEBUG -lwireless -lpthread -ggdb
-
-clean:
-	rm -f *.o testbench ../lib/*.o
-
Index: trunk/code/projects/test/test_tokenring.c
===================================================================
--- trunk/code/projects/test/test_tokenring.c	(revision 1483)
+++ trunk/code/projects/test/test_tokenring.c	(nonexistent)
@@ -1,98 +0,0 @@
-#include <dragonfly_lib.h>
-#include <wireless.h>
-#include <wl_token_ring.h>
-
-
-/**
- * Tests the token ring and BOM
- * - prints table of bom values for every robot in token ring
- * - takes several seconds to initialize token ring
- */
- 
-#define MAX_ROBOTS 16
-
-// set a list of integers to 0
-void clearRobots(int* list) {
-  for(int i=0;i<MAX_ROBOTS;i++)
-    list[i] = 0;
-}
-
-int testtokenring(void) {
-  usb_init();
-	usb_puts("usb turned on\r\n");
-  wl_init();
-  usb_puts("wireless turned on\r\n");
-  wl_token_ring_register();
-  wl_token_ring_join(); // join token ring
-  usb_puts("token ring joined\r\n");
-  int robotList[sizeof(int)*MAX_ROBOTS];
-  int numRobots = 0;
-  delay_ms(1000);
-  
-  // start testing wireless/token ring/BOM
-  int i=0;
-  while(1) {
-    wl_do();
-    // only print table every 200 loops
-    if (i%200==0) {
-      // get token ring size values
-      usb_puts("\r\nnumber of robots in token ring:");
-      usb_puti(wl_token_get_robots_in_ring());
-      usb_puts("\r\nnumber of robots in matrix:"); 
-      usb_puti(wl_token_get_num_robots());
-      
-      // get list of robots
-      numRobots = 0;
-      clearRobots(robotList);
-      wl_token_iterator_begin();
-      while(wl_token_iterator_has_next()) {
-        int tmp = wl_token_iterator_next();
-        if (tmp < 0)
-          break;
-        robotList[tmp] = 1;
-        numRobots++;
-      }
-      if (numRobots < 1) {
-        usb_puts("\r\nNo BOM table available.");
-        continue; // skip table printing
-      } else {
-        usb_puts("\r\nBOM table: (* indicates this robot)");
-      }
-      
-      // print table of bom readings between robots
-      usb_puts("\r\ns \\ d");
-      // print header
-      for(int j=0;j<MAX_ROBOTS;j++)
-        if (robotList[j]) {
-          usb_puts("\t|");
-          if (j == wl_get_xbee_id())
-            usb_puts("*"); // indicate that this is the current bot
-          usb_puti(j);
-        }
-      usb_puts("\r\n");
-      // print body
-      for(int l=0;l<MAX_ROBOTS;l++) 
-        if (robotList[l]) {        
-          if (l == wl_get_xbee_id())
-            usb_puts("*"); // indicate that this is the current bot
-          usb_puti(l); // print label col
-          for(int k=0;k<MAX_ROBOTS;k++) 
-            if (robotList[k]) {
-              usb_puts("\t|");
-              if (k != l) {
-                int bom = wl_token_get_sensor_reading(l,k);
-                if (bom >= 0 && bom <= 15)
-                  usb_puti(bom); // print bom value
-              }
-            }
-          usb_puts("\r\n");
-        }
-      usb_puts("\r\n");
-    }
-  }
-  
-  // end testing token ring and bom
-	return 0;
-}
-
-

Property changes on: trunk/code/projects/test/test_tokenring.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/test_analog.c
===================================================================
--- trunk/code/projects/test/test_analog.c	(revision 1483)
+++ trunk/code/projects/test/test_analog.c	(nonexistent)
@@ -1,44 +0,0 @@
-#include <dragonfly_lib.h>
-
-/*
- * This function outputs to TeraTerm a table which displays the values currently
- * stored in the analog table
- */
-
-int testanalog(void) {
-
-	
-	usb_init();
-	usb_puts("usb turned on\r\n");
-	
-	range_init();
-	usb_puts("rangefinders initialized\r\n");
-	
-	usb_puts("\r\n\n");
-	delay_ms(1000);
-	
-	while (1) {
-	
-		for (int i = 0; i < 20; i++) {
-		
-			usb_puts("\r\n");
-		
-		}
-		
-		usb_puts("port# |\tvalue\r\n");
-		
-		for (int j = 1; j < 16; j++) {
-		
-			usb_puti(j);
-			usb_puts("\t");
-			usb_puti(analog10(j));
-			usb_puts("\r\n");
-		
-		}
-		
-		delay_ms(575);
-		
-	}
-	
-	return 0;
-}
\ No newline at end of file

Property changes on: trunk/code/projects/test/test_analog.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/test_lcd.c
===================================================================
--- trunk/code/projects/test/test_lcd.c	(revision 1483)
+++ trunk/code/projects/test/test_lcd.c	(nonexistent)
@@ -1,45 +0,0 @@
-#include <dragonfly_lib.h>
-
-
-/**
- * LCD Rules
- * - when changing put formats (from string to int or back)
- *   the screen will clear and start printing at beginning
- * - when outputting again in same format, an append op is performed
- * - text wraps to next line, and to beginning
- *    - when wrapping to beginning, screen is not cleared
- * - puti only does signed ints
- */
-
-int testlcd(void) {
-  usb_init();
-	usb_puts("usb turned on\n");
-  lcd_init();
-  usb_puts("lcd turned on\n");
-  lcd_clear_screen();
-  usb_puts("lcd screen cleared\n");
-  delay_ms(1000);
-  
-  // start testing lcd
-  lcd_puts("this is a test, a really long test");
-  lcd_puts("this is a test, a really long test. this is a test, a really long test");
-  usb_puts("test writing string to lcd: 'this is a test, a really long test'\n");
-  delay_ms(10000);
-  
-  /*lcd_clear_screen();
-  usb_puts("lcd screen cleared\n");
-  lcd_puti(1000000);
-  lcd_puti(100000);
-  lcd_puti(10000);
-  lcd_puti(1000);
-  lcd_puti(100);
-  lcd_puti(10);
-  lcd_puti(1);
-  usb_puts("test writing int to lcd: 1000000,100000, 10000, 1000, 100, 10, 1\n");
-  delay_ms(10000);
-  */
-  // end testing lcd
-	return 0;
-}
-
-

Property changes on: trunk/code/projects/test/test_lcd.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/test_encoders.c
===================================================================
--- trunk/code/projects/test/test_encoders.c	(revision 1483)
+++ trunk/code/projects/test/test_encoders.c	(nonexistent)
@@ -1,64 +0,0 @@
-/**
- * @file encoders unit test
- */
-#include <dragonfly_lib.h>
-
-/**
- * @brief Test encoders by outputting values to usb
- *
- * @test  Tester should start a program to read data from the robot via usb
- *        (e.g. gtkterm). Turn on the robot on then turn each wheel manually.
- *        Make sure the output on the screen makes sense.
- *        Pressing button 1 resets total distance and time count
- * @pre   Depends on serial and dio to work correctly
- */
-
-int testencoders(void)
-{
-	int encoder_left,encoder_right;
-	int x_left, x_right;
-	int v_left, v_right;
-	int tc;
-	while(1) {
-		/* button1 is pressed */
-		if (button1_read()) {
-			/* reset dx and tc */
-			encoder_rst_dx(LEFT);
-			encoder_rst_dx(RIGHT);
-			encoder_rst_tc();
-		}
-
-		encoder_left = encoder_read(LEFT);
-		encoder_right = encoder_read(RIGHT);
-		usb_puts("Encoder values (left, right): ");
-		usb_puti(encoder_left); 
-		usb_puts(", ");
-		usb_puti(encoder_right); 
-		usb_puts("\n");
-
-		x_left = encoder_get_x(LEFT);
-		x_right = encoder_get_x(RIGHT);
-		usb_puts("Total Distance (left, right): ");
-		usb_puti(x_left);
-		usb_puts(", ");
-		usb_puti(x_right);
-		usb_puts("\n");
-
-		v_left = encoder_get_v(LEFT);
-		v_right = encoder_get_v(RIGHT);
-		usb_puts("Velocity (left, right): ");
-		usb_puti(v_left);
-		usb_puts(", ");
-		usb_puti(v_right);
-		usb_puts("\n");
-
-		tc = encoder_get_tc();
-		usb_puts("Time count: ");
-		usb_puti(tc);
-		usb_puts("\n\r");
-
-		delay_ms(500);
-	}
-	return 0;
-}
-

Property changes on: trunk/code/projects/test/test_encoders.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/test_dio.c
===================================================================
--- trunk/code/projects/test/test_dio.c	(revision 1483)
+++ trunk/code/projects/test/test_dio.c	(nonexistent)
@@ -1,38 +0,0 @@
-#include <dragonfly_lib.h>
-
-int testdio(void) {
-   	
-	//test waits
-	orb_set_color(WHITE);
-	delay_ms(1000);
-	orb_set_color(ORB_OFF);
-	button1_wait();
-	orb_set_color(WHITE);
-	delay_ms(1000);
-	orb_set_color(ORB_OFF);
-	button2_wait();
-	
-	//test clicks
-	orb_set_color(WHITE);
-	delay_ms(1000);
-	orb_set_color(ORB_OFF);
-	while(!button1_click()){;}
-	orb_set_color(WHITE);
-	delay_ms(1000);
-	orb_set_color(ORB_OFF);
-	while(!button2_click()){;}
-	
-	//test reads
-	orb_set_color(WHITE);
-	delay_ms(1000);
-	orb_set_color(ORB_OFF);
-	while(!button1_read()){;}
-	orb_set_color(WHITE);
-	delay_ms(1000);
-	orb_set_color(ORB_OFF);
-	while(!button2_read()){;}
-	orb_set_color(WHITE);
-	delay_ms(1000);
-	orb_set_color(ORB_OFF);
-    return 0;
-}
Index: trunk/code/projects/test/test_xbee.c
===================================================================
--- trunk/code/projects/test/test_xbee.c	(revision 1483)
+++ trunk/code/projects/test/test_xbee.c	(nonexistent)
@@ -1,52 +0,0 @@
-#include <dragonfly_lib.h>
-#include <xbee.h>
-
-#define ROBOT
-#define WL_DEBUG
-#define WL_DEBUG_PRINT( s ) usb_puts( S )
-
-extern int xbee_send_read_at_command(char* command);
-extern int xbee_get_packet(unsigned char* dest);
-extern void xbee_terminate(void);
-
-/*
- * This function tests the xbee, returning the results to teraterm
- *
- * 
- */
- 
-int testxbee(void) {
-
-  unsigned char buf[100];
-  int i=0;
-	
-	usb_init();
-	usb_puts("usb turned on, test starting:\r\n");
-  
-  if (xbee_lib_init() != 0) {
-    usb_puts("xbee_lib_init() failed\r\n");
-    return -1;
-  } else {
-    usb_puts("xbee_lib__init successful\r\n");
-  }
- 
-	usb_puts("\r\n\n");
-	delay_ms(1000);
-	
-	// try getting xbee address
-  xbee_send_read_at_command("MY");
-  while(i++ < 10000) {
-    if(xbee_get_packet(buf) == 3) {
-      usb_puts("got response from xbee\r\n");
-      //usb_puts("packet:");
-      //usb_puts(buf);
-      //usb_puts("|end\r\n");
-      break; // got a response
-    }
-  }
-  
-  xbee_terminate();
-  usb_puts("testxbee done\r\n\r\n");
-    
-	return 0;
-}
\ No newline at end of file
Index: trunk/code/projects/test/test_motors.c
===================================================================
--- trunk/code/projects/test/test_motors.c	(revision 1483)
+++ trunk/code/projects/test/test_motors.c	(nonexistent)
@@ -1,75 +0,0 @@
-#include <dragonfly_lib.h>
-
-#define OFF 	140
-#define SLOW 	160
-#define	GO		220
-
-int testmotors(void) {
-    //usb_init();
-    //usb_puts("usb turned on\n");
-    
-	//forward
-	orb_set_color(RED);
-	motors_off();
-    delay_ms(3000);
-    orb_set_color(YELLOW);
-	motor_l_set(1, SLOW);
-    motor_r_set(1, SLOW);
-    delay_ms(3000);
-    orb_set_color(GREEN);
-	motor_l_set(1, GO);
-    motor_r_set(1, GO);
-    delay_ms(3000);
-	
-	//backward
-    orb_set_color(RED);
-	motors_off();
-    delay_ms(3000);
-    orb_set_color(YELLOW);
-	motor_l_set(0, SLOW);
-    motor_r_set(0, SLOW);
-    delay_ms(3000);
-    orb_set_color(GREEN);
-	motor_l_set(0, GO);
-    motor_r_set(0, GO);
-    delay_ms(3000);
-	
-	//spin
-	orb_set_color(RED);
-	motors_off();
-    delay_ms(3000);
-    orb_set_color(YELLOW);
-	motor_l_set(1, SLOW);
-    motor_r_set(0, SLOW);
-    delay_ms(3000);
-    orb_set_color(GREEN);
-	motor_l_set(1, GO);
-    motor_r_set(0, GO);
-    delay_ms(3000);
-	
-	//spin other way
-	orb_set_color(RED);
-	motors_off();
-    delay_ms(3000);
-    orb_set_color(YELLOW);
-	motor_l_set(0, SLOW);
-    motor_r_set(1, SLOW);
-    delay_ms(3000);
-    orb_set_color(GREEN);
-	motor_l_set(0, GO);
-    motor_r_set(1, GO);
-    delay_ms(3000);
-	//while(1){;}
-
-
-    motors_off();
-
-    return 0;
-}
-
-
-/*test data
-left >154 forward
-right >150 forward
-both >152 backward
-*/

Property changes on: trunk/code/projects/test/test_motors.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/xbee.c
===================================================================
--- trunk/code/projects/test/xbee.c	(revision 1483)
+++ trunk/code/projects/test/xbee.c	(nonexistent)
@@ -1,1029 +0,0 @@
-/**
- * Copyright (c) 2007 Colony Project
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- **/
-
-/**
- * @file xbee.c
- * @brief XBee Interface
- *
- * Implementation of low level communication with the XBee in API mode.
- *
- * @author Brian Coltin, Colony Project, CMU Robotics Club
- **/
-
-#include <xbee.h>
-#include <wl_defs.h>
-
-#define ROBOT
-#define WL_DEBUG
-#define WL_DEBUG_PRINT( s ) usb_puts( s )
-#define WL_DEBUG_PRINT_INT( i ) usb_puti(i)
-
-#ifndef ROBOT
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <errno.h>
-#include <termios.h>
-
-#else
-
-#include <serial.h>
-#include <avr/interrupt.h>
-
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define XBEE_FRAME_START 0x7E
-#define XBEE_GET_PACKET_TIMEOUT 1000
-
-/*Frame Types*/
-#define XBEE_FRAME_STATUS 0x8A
-#define XBEE_FRAME_AT_COMMAND 0x08
-#define XBEE_FRAME_AT_COMMAND_RESPONSE 0x88
-#define XBEE_FRAME_TX_REQUEST_64 0x00
-#define XBEE_FRAME_TX_REQUEST_16 0x01
-#define XBEE_FRAME_TX_STATUS XBEE_TX_STATUS
-#define XBEE_FRAME_RX_64 0x80
-#define XBEE_FRAME_RX_16 XBEE_RX
-
-/*Internal Function Prototypes*/
-
-/*I/O Functions*/
-static int xbee_send(char* buf, int size);
-static int xbee_send_string(char* c);
-
-#ifndef ROBOT
-static int xbee_read(char* buf, int size);
-#endif
-
-/*Command Mode Functions
- * Called during initialization.
- */
-static int xbee_enter_command_mode(void);
-static int xbee_exit_command_mode(void);
-static int xbee_enter_api_mode(void);
-static int xbee_exit_api_mode(void);
-static int xbee_wait_for_string(char* s, int len);
-static int xbee_wait_for_ok(void);
-
-/*API Mode Functions*/
-
-static int xbee_handle_packet(char* packet, int len);
-static void xbee_handle_at_command_response(char* command, char result, char* extra, int extraLen);
-static void xbee_handle_status(char status);
-static int xbee_verify_checksum(char* packet, int len);
-static char xbee_compute_checksum(char* packet, int len);
-static int xbee_send_frame(char* buf, int len);
-int xbee_send_read_at_command(char* command);
-static int xbee_send_modify_at_command(char* command, char* value);
-
-/*Global Variables*/
-
-#ifndef ROBOT
-static char* xbee_com_port = XBEE_PORT_DEFAULT;
-static int xbee_stream;
-static pthread_t* xbee_listen_thread;
-#endif
-
-// TODO: is this a good size?
-#define XBEE_BUFFER_SIZE	128
-#define PACKET_BUFFER_SIZE	108
-// a buffer for data received from the XBee
-char arrival_buf[XBEE_BUFFER_SIZE];
-// location of last unread byte in buffer
-volatile int buffer_last = 0;
-// first unread byte in buffer
-volatile int buffer_first = 0;
-
-
-//used to store packets as they are read
-static char xbee_buf[PACKET_BUFFER_SIZE];
-static int currentBufPos = 0;
-
-//XBee status
-static unsigned int xbee_panID = XBEE_PAN_DEFAULT;
-static unsigned int xbee_pending_panID = XBEE_PAN_DEFAULT;
-static int xbee_channel = XBEE_CHANNEL_DEFAULT;
-static int xbee_pending_channel = XBEE_CHANNEL_DEFAULT;
-static volatile unsigned int xbee_address = 0;
-
-/*Function Implementations*/
-
-#ifdef ROBOT
-
-/**
- * Interrupt for the robot. Adds bytes received from the xbee
- * to the buffer.
- **/
-#ifndef FIREFLY
-ISR(USART1_RX_vect)
-{
-	char c = UDR1;
-	arrival_buf[buffer_last] = c;
-	int t = buffer_last + 1;
-	if (t == XBEE_BUFFER_SIZE)
-		t = 0;
-	if (t == buffer_first)
-	{
-		WL_DEBUG_PRINT("\nOut of space in buffer.\n");
-	}
-	buffer_last = t;
-}
-#else
-SIGNAL(SIG_USART0_RECV)
-{
-	char c = UDR0;
-	arrival_buf[buffer_last] = c;
-	int t = buffer_last + 1;
-	if (t == XBEE_BUFFER_SIZE)
-		t = 0;
-	if (t == buffer_first)
-	{
-		WL_DEBUG_PRINT("Out of space in buffer.\n");
-	}
-	buffer_last = t;
-}
-#endif
-
-#else
-
-// Computer code
-
-/**
- * Thread that listens to the xbee.
- **/
-static void* listen_to_xbee(void* x)
-{
-	char c;
-	while (1)
-	{
-		if (xbee_read(&c, 1) != 0) {
-			WL_DEBUG_PRINT("xbee_read failed.\n");
-			return NULL;
-		}
-
-		arrival_buf[buffer_last] = c;
-		int t = buffer_last + 1;
-		if (t == XBEE_BUFFER_SIZE)
-			t = 0;
-		if (t == buffer_first)
-		{
-			WL_DEBUG_PRINT("Out of space in buffer.\n");
-		}
-		buffer_last = t;
-
-		usleep(1000);
-	}
-
-	return NULL;
-}
-
-#endif
-
-/**
- * Initializes the XBee library so that other functions may be used.
- **/
-int xbee_lib_init()
-{
-	WL_DEBUG_PRINT("in xbee_init\n");
-#ifdef ROBOT
-
-	//enable the receiving interrupt
-#ifdef FIREFLY
-	UCSR0B |= _BV(RXCIE) | _BV(RXEN);
-#else
-#ifdef BAYBOARD
-	UCSR1B |= _BV(RXCIE1);
-#else
-	UCSR1B |= _BV(RXCIE);
-#endif
-#endif
-	sei();
-#else
-	xbee_stream = open(xbee_com_port, O_RDWR);
-	if (xbee_stream == -1/* || lockf(xbee_stream, F_TEST, 0) != 0*/)
-	{
-		WL_DEBUG_PRINT("Failed to open connection to XBee on port ");
-		WL_DEBUG_PRINT_INT(xbee_com_port);
-		WL_DEBUG_PRINT(".\n");
-		return -1;
-	} else {
-	  WL_DEBUG_PRINT("Successfully opened connection to XBee on port ");
-		WL_DEBUG_PRINT_INT(xbee_com_port);
-		WL_DEBUG_PRINT(".\n");
-	}
-
-	// set baud rate, etc. correctly
-	struct termios options;
-
-	tcgetattr(xbee_stream, &options);
-	cfsetispeed(&options, B9600);
-	cfsetospeed(&options, B9600);
-	options.c_iflag &= ~ICRNL;
-	options.c_oflag &= ~OCRNL;
-	options.c_cflag |= (CLOCAL | CREAD);
-	options.c_cflag &= ~PARENB;
-	options.c_cflag &= ~CSTOPB;
-	options.c_cflag &= ~CSIZE;
-	options.c_cflag |= CS8;
-	options.c_lflag &= ~ICANON;
-	options.c_cc[VMIN] = 1;
-	options.c_cc[VTIME] = 50;
-
-	if (tcsetattr(xbee_stream, TCSANOW, &options))
-	{
-		WL_DEBUG_PRINT("Error setting attributes.\n");
-		return -1;
-	}
-
-	xbee_listen_thread = (pthread_t*)malloc(sizeof(pthread_t));
-	if (xbee_listen_thread == NULL)
-	{
-		WL_DEBUG_PRINT("Malloc failed.\n");
-		return -1;
-	}
-
-	int ret = pthread_create(xbee_listen_thread, NULL, listen_to_xbee, NULL);
-	if (ret)
-	{
-		WL_DEBUG_PRINT("Failed to create listener thread.\n");
-		return -1;
-	}
-#endif
-
-	WL_DEBUG_PRINT("Entering command mode.\n");
-
-	if (xbee_enter_command_mode() != 0) {
-		return -1;
-	}
-
-	WL_DEBUG_PRINT("Entered command mode.\n");
-
-	if (xbee_enter_api_mode() != 0) {
-		return -1;
-	}
-
-	WL_DEBUG_PRINT("Entered api mode.\n");
-
-	if (xbee_exit_command_mode() != 0) {
-	     return -1;
-	}
-	
-	WL_DEBUG_PRINT("Left command mode.\n");
-
-	if (xbee_send_read_at_command("MY")) {
-		return -1;
-	}
-	WL_DEBUG_PRINT("Getting ATMY address.\n");
-
-#ifndef ROBOT
-	int i;
-	for (i = 0; xbee_address == 0 && i < XBEE_GET_PACKET_TIMEOUT; i++) {
-	  ret = xbee_get_packet(NULL);
-
-	  usleep(1000);
-	  
-/* 	  if (ret == -1) { */
-/* 	    WL_DEBUG_PRINT("xbee_get_packet(NULL) failed.\n"); */
-/* 	    return -1; */
-/* 	  } */
-	}
-#else
-	//wait to return until the address is set
-  //TODO: this shouldn't wait indefinitely.  There should be some sort of reasonable timeout
-  // so if the address is never set right, an error can be returned instead of having the
-  // robot hang forever
-	while (xbee_address == 0) {
-	  xbee_get_packet(NULL);
-	}
-#endif
-	WL_DEBUG_PRINT("Got ATMY address.\n");
-
-#ifndef ROBOT
-	if (i == XBEE_GET_PACKET_TIMEOUT) { // We timed-out.
-
-	  WL_DEBUG_PRINT("xbee_get_packet timed out.\n");
-	  return -1;
-	} else {
-	  return 0;
-	}
-#else
-	return 0;
-#endif
-}
-
-/**
- * Call when finished using the XBee library. This releases
- * all sued resources.
- **/
-void xbee_terminate()
-{
-	#ifndef ROBOT
-	pthread_cancel(*xbee_listen_thread);
-    pthread_join(*xbee_listen_thread, NULL);
-	free(xbee_listen_thread);
-	lockf(xbee_stream, F_ULOCK, 0);
-	close(xbee_stream);
-  #else
-  xbee_exit_api_mode();
-	#endif
-}
-
-/**
- * Send a buffer buf of size bytes to the XBee.
- *
- * @param buf the buffer of data to send
- * @param size the number of bytes to send
- **/
-static int xbee_send(char* buf, int size)
-{
-#ifdef ROBOT
-	int i;
-	for (i = 0; i < size; i++) {
-		xbee_putc(buf[i]);
-	}
-
-	return 0;
-
-#else
-
-	int ret = write(xbee_stream, buf, size);
-	//success
-	if (ret == size)
-		return 0;
-	if (ret == -1)
-	{
-		//interrupted by system signal, probably timer interrupt.
-		//just try again
-		if (errno == 4)
-		{
-			return xbee_send(buf, size);
-		}
-		WL_DEBUG_PRINT("Failed to write to xbee\r\n");
-		return -1;
-	}
-
-	//write was interrupted after writing ret bytes
-	return xbee_send(buf + ret, size - ret);
-#endif
-}
-
-/**
- * Sends a string to the XBee.
- *
- * @param c the string to send to the XBEE
- **/
-static int xbee_send_string(char* c)
-{
-	return xbee_send(c, strlen(c));
-}
-
-#ifndef ROBOT
-static int xbee_read(char* buf, int size)
-{
-	if (read(xbee_stream, buf, size) == -1) {
-		WL_DEBUG_PRINT("Failed to read from xbee.\r\n");
-		return -1;
-	}
-
-	return 0;
-}
-#endif
-
-/**
- * Enter into command mode.
- **/
-static int xbee_enter_command_mode()
-{
-	if (xbee_send_string("+++") != 0) {
-		return -1;
-	}
-
-	if (xbee_wait_for_ok() != 0) {
-	  return -1;
-	}
-	  return 0;
-}
-
-/**
- * Exit from command mode.
- **/
-static int xbee_exit_command_mode()
-{
-	if (xbee_send_string("ATCN\r") != 0) {
-		return -1;
-	}
-
-	xbee_wait_for_ok();
-
-	return 0;
-}
-
-/**
- * Enter API mode.
- **/
-static int xbee_enter_api_mode()
-{
-	if (xbee_send_string("ATAP 1\r") != 0) {
-		return -1;
-	}
-	xbee_wait_for_ok();
-
-	return 0;
-}
-
-/**
- * Exit API mode.
- **/
-static int xbee_exit_api_mode()
-{
-	if (xbee_send_modify_at_command("AP","0") != 0) {
-		return -1;
-	}
-
-	return 0;
-}
-
-/**
- * Wait until the string "OK\r" is received from the XBee.
- **/
-static int xbee_wait_for_ok()
-{
-	return xbee_wait_for_string("OK\r", 3);
-}
-
-/**
- * Delay until the specified string is received from
- * the XBee. Discards all other XBee data.
- *
- * ********* Robot often hangs here ****************
- *
- * @param s the string to receive
- * @param len the length of the string
- **/
-static int xbee_wait_for_string(char* s, int len)
-{
-	char* curr = s;
-	while (curr - s < len) {
-    WL_DEBUG_PRINT("waiting for string\r\n");
-		// check if buffer is empty
-		if (buffer_last != buffer_first) {
-			char c = arrival_buf[buffer_first++];
-			if (buffer_first == XBEE_BUFFER_SIZE) {
-				buffer_first = 0;
-			}
-
-			if (c == *curr) {
-				curr++;
-			} else {
-#ifndef ROBOT
-			  //return -1; // Computer is less forgiving.
-			  curr = s;
-#else
-			  curr = s;
-#endif
-			}
-		} // else buffer is empty.
-
-#ifndef ROBOT
-		usleep(100);
-#endif
-	}
-
-	return 0;
-}
-
-/**
- * Verifies that the packets checksum is correct.
- * (If the checksum is correct, the sum of the bytes
- * is 0xFF.)
- *
- * @param packet the packet received. This includes the first
- * three bytes, which are header information from the XBee.
- *
- * @param len The length of the packet received from the XBee
- *
- * @return 0 if the checksum is incorrect, nonzero
- * otherwise
- **/
-int xbee_verify_checksum(char* packet, int len)
-{
-	unsigned char sum = 0;
-	int i;
-	for (i = 3; i < len; i++)
-		sum += (unsigned char)packet[i];
-	return sum == 0xFF;
-}
-
-/**
- * Returns the checksum of the given packet.
- *
- * @param buf the data for the packet to send
- * @param len the length of the packet in bytes
- *
- * @return the checksum of the packet, which will
- * become the last byte sent in the packet
- **/
-char xbee_compute_checksum(char* buf, int len)
-{
-	int i;
-	unsigned char sum = 0;
-	for (i = 0; i < len; i++)
-		sum += (unsigned char)buf[i];
-	return 0xFF - sum;
-}
-
-/**
- * Adds header information and checksum to the given
- * packet and sends it. Header information includes
- * XBEE_FRAME_START and the packet length, as two bytes.
- *
- * @param buf the packet data
- * @param len the size in bytes of the packet data
- *
- **/
-static int xbee_send_frame(char* buf, int len)
-{
-	char prefix[3];
-	prefix[0] = XBEE_FRAME_START;
-	prefix[1] = (len & 0xFF00) >> 8;
-	prefix[2] = len & 0xFF;
-	char checksum = xbee_compute_checksum(buf, len);
-
-	if (xbee_send(prefix, 3) != 0) {
-		return -1;
-	}
-
-	if (xbee_send(buf, len) != 0) {
-		return -1;
-	}
-
-	if (xbee_send(&checksum, 1) != 0) {
-		return -1;
-	}
-
-	return 0;
-}
-
-/**
- * Sends an AT command to read a parameter.
- *
- * @param command the AT command to send. For exmaple,
- * use ID to read the PAN ID and MY to return the XBee ID.
- * See the XBee reference guide for a complete listing.
- **/
-int xbee_send_read_at_command(char* command)
-{
-	return xbee_send_modify_at_command(command, NULL);
-}
-
-/**
- * Sends the given AT command.
- *
- * @param command the AT command to send (e.g., MY, ID)
- * @param value the value to pass as a parameter
- * (or NULL if there is no parameter)
- **/
-static int xbee_send_modify_at_command(char* command, char* value)
-{
-	char buf[16];
-	int i;
-
-	buf[0] = XBEE_FRAME_AT_COMMAND;
-	buf[1] = 1;
-	buf[2] = command[0];
-	buf[3] = command[1];
-	int valueLen = 0;
-	if (value != NULL)
-	{
-		valueLen = strlen(value);
-		if (valueLen > 8)
-		{
-			WL_DEBUG_PRINT("AT Command too large.\r\n");
-			return -1;
-		}
-
-		for (i = 0; i < valueLen; i++) {
-			buf[4 + i] = value[i];
-		}
-	}
-
-	return xbee_send_frame(buf, 4 + valueLen);
-}
-
-/**
- * Send the specified packet.
- *
- * @param packet the packet data to send
- * @param len the number of bytes in the packet
- *
- * @param dest the ID of the XBee to send the packet to,
- * or XBEE_BROADCAST to send the message to all robots
- * in the PAN.
- *
- * @param options a combination of the flags
- * XBEE_OPTIONS_NONE, XBEE_OPTIONS_DISABLE_RESPONSE and
- * XBEE_OPTIONS_BROADCAST_ALL_PANS
- *
- * @param frame the frame number to associate this packet
- * with. This will be used to identify the response when
- * the XBee alerts us as to whether or not our message
- * was received.
- **/
-int xbee_send_packet(char* packet, int len, int dest, char options, char frame)
-{
-	char buf[5];
-	char prefix[3];
-	int i;
-	unsigned char checksum = 0;
-
-	if (len > 100)
-	{
-		WL_DEBUG_PRINT("Packet is too large.\r\n");
-		return -1;
-	}
-
-	//data for sending request
-	buf[0] = XBEE_FRAME_TX_REQUEST_16;
-	buf[1] = frame;
-	buf[2] = (dest >> 8) & 0xFF;
-	buf[3] = dest & 0xFF;
-	buf[4] = options;
-
-	//packet prefix, do this here so we don't need an extra buffer
-	prefix[0] = XBEE_FRAME_START;
-	prefix[1] = ((5 + len) & 0xFF00) >> 8;
-	prefix[2] = (5 + len) & 0xFF;
-
-	for (i = 0; i < 5; i++)
-		checksum += (unsigned char)buf[i];
-	for (i = 0; i < len; i++)
-		checksum += (unsigned char)packet[i];
-	checksum = 0xFF - checksum;
-
-	if (xbee_send(prefix, 3) != 0) {
-		return -1;
-	}
-
-	if (xbee_send(buf, 5) != 0) {
-		return -1;
-	}
-
-	if (xbee_send(packet, len) != 0) {
-		return -1;
-	}
-
-	if (xbee_send((char*)&checksum, 1) != 0) {
-		return -1;
-	}
-
-	return 0;
-}
-
-/**
- * Reads a packet received from the XBee. This function
- * is non-blocking. The resulting packet is stored in dest.
- * Only returns transmission response packets and
- * received packets. The returned packet does not include
- * header information or the checksum. This method also
- * handles special packets dealt with by the XBee library,
- * and so should be called frequently while the XBee is in
- * use.<br><br>
- *
- * The first byte of the packet will be either
- * XBEE_TX_STATUS or XBEE_RX to indicated
- * a response to a sent message or a received message,
- * respectively.<br><br>
- *
- * For a status response packet:<br>
- * The first byte will be XBEE_TX_STATUS.<br>
- * The second byte will be the frame number.<br>
- * The third byte will be the result. 0 indicates success,
- * and nonzero indicates that an error ocurred in
- * transmitting the packet.<br><br>
- *
- * For a received packet:<br>
- * The first byte will be XBEE_RX.<br>
- * The second and third bytes will be the 16-bit
- * address of the packet's sender.<br>
- * The fourth byte is the signal strength.<br>
- * The fifth byte is 1 if the packet were sent to
- * a specific address, and 2 if it is a broadcast packet.<br><br>
- *
- * @param dest set to the packet data
- * @return the length of the packet, or -1 if no packet
- * is available
- **/
-int xbee_get_packet(unsigned char* dest)
-{
-     int ret;
-	//start reading a packet with XBEE_FRAME_START
-	if (currentBufPos == 0)
-	{
-		do
-		{
-			if (buffer_first == XBEE_BUFFER_SIZE)
-				buffer_first = 0;
-			// check if buffer is empty
-			if (buffer_first == buffer_last) {
-				return -1;
-			}
-		} while (arrival_buf[buffer_first++] != XBEE_FRAME_START);
-
-		if (buffer_first == XBEE_BUFFER_SIZE) {
-			buffer_first = 0;
-		}
-		xbee_buf[0] = XBEE_FRAME_START;
-		currentBufPos++;
-	}
-
-	int len = -1;
-	if (currentBufPos >= 3) {
-		len = (int)xbee_buf[2] + ((int)xbee_buf[1] << 8);
-	}
-
-	while (len == -1 //packet length has not been read yet
-		|| currentBufPos < len + 4)
-	{
-		if (currentBufPos == 3)
-		{
-			len = (int)xbee_buf[2] + ((int)xbee_buf[1] << 8);
-			if (len > 120)
-			{
-				WL_DEBUG_PRINT("Packet too large. Probably error in XBee transmission.\n");
-				currentBufPos = 0;
-				return -1;
-			}
-		}
-
-		// check if buffer is empty
-		if (buffer_first == buffer_last) {
-			return -1;
-		}
-		xbee_buf[currentBufPos++] = arrival_buf[buffer_first++];
-		if (buffer_first == XBEE_BUFFER_SIZE) {
-			buffer_first = 0;
-		}
-	}
-
-	currentBufPos = 0;
-
-	if (!xbee_verify_checksum(xbee_buf, len + 4))
-	{
-		WL_DEBUG_PRINT("XBee checksum failed.\r\n");
-		return -1;
-	}
-
-	//we will take care of the packet
-	
-	ret = xbee_handle_packet(xbee_buf+3, len);
-	if (ret == 1) {
-		return 3;
-	}
-	
-	if (dest == NULL) {
-		return -1;
-	}
-
-	int i;
-	for (i = 3; i < len + 3; i++) {
-		dest[i - 3] = xbee_buf[i];
-	}
-	return len;
-}
-
-/**
- * Handles modem status packets.
- *
- * @param status the type of status packet received.
- **/
-void xbee_handle_status(char status)
-{
-	switch (status)
-	{
-		case 0:
-			WL_DEBUG_PRINT("XBee hardware reset.\r\n");
-			break;
-		case 1:
-			WL_DEBUG_PRINT("Watchdog timer reset.\r\n");
-			break;
-		case 2:
-			WL_DEBUG_PRINT("Associated.\r\n");
-			break;
-		case 3:
-			WL_DEBUG_PRINT("Disassociated.\r\n");
-			break;
-		case 4:
-			WL_DEBUG_PRINT("Synchronization lost.\r\n");
-			break;
-		case 5:
-			WL_DEBUG_PRINT("Coordinator realignment.\r\n");
-			break;
-		case 6:
-			WL_DEBUG_PRINT("Coordinator started.\r\n");
-			break;
-	}
-}
-
-/**
- * Handles AT command response packets.
- * @param command the two character AT command, e.g. MY or ID
- * @param result 0 for success, 1 for an error
- * @param extra the hex value of the requested register
- * @param extraLen the length in bytes of extra
- **/
-static void xbee_handle_at_command_response(char* command, char result, char* extra, int extraLen)
-{
-	if (result == 1)
-	{
-		WL_DEBUG_PRINT("Error with AT");
-		WL_DEBUG_PRINT(command);
-		WL_DEBUG_PRINT(" packet.\r\n");
-	}
-	WL_DEBUG_PRINT("AT");
-	WL_DEBUG_PRINT(command);
-	WL_DEBUG_PRINT(" command was successful.\r\n");
-
-	if (command[0] == 'I' && command[1] == 'D')
-	{
-		xbee_panID = xbee_pending_panID;
-		WL_DEBUG_PRINT("PAN ID set to ");
-		WL_DEBUG_PRINT_INT(xbee_panID);
-		WL_DEBUG_PRINT(".\r\n");
-		return;
-	}
-
-	if (command[0] == 'C' && command[1] == 'H')
-	{
-		xbee_channel = xbee_pending_channel;
-		WL_DEBUG_PRINT("Channel set to ");
-		WL_DEBUG_PRINT_INT(xbee_channel);
-		WL_DEBUG_PRINT(".\r\n");
-		return;
-	}
-
-	if (command[0] == 'M' && command[1] == 'Y' && extraLen != 0)
-	{
-		xbee_address = 0;
-		int i;
-		for (i = 0; i < extraLen; i++) {
-			xbee_address = (xbee_address << 8) + extra[i];
-		}
-
-		WL_DEBUG_PRINT("XBee address is ");
-		WL_DEBUG_PRINT_INT(xbee_address);
-		WL_DEBUG_PRINT(".\r\n");
-
-		if (xbee_address == 0)
-		{
-			WL_DEBUG_PRINT("XBee 16-bit address must be set using ATMY.\r\n");
-			#ifndef ROBOT
-			exit(0);
-			#endif
-		}
-	}
-}
-
-/**
- * Attempts to handle the packet if it is dealt with
- * by the library.
- * We will handle the following packet types:
- *    Modem Status
- *    AT Command Response
- *
- * @param packet the packet to handle
- * @param len the length of the packet
- *
- * @return 1 if we have handled the packet, 0 otherwise
- */
-static int xbee_handle_packet(char* packet, int len)
-{
-
-	char command[3] = {1, 2, 3};
-	if (len <= 0) //this should not happend
-	{
-		WL_DEBUG_PRINT("Non-positive packet length.\r\n");
-		return 0;
-	}
-
-	switch ((unsigned char)packet[0]) //packet type
-	{
-		case XBEE_FRAME_STATUS:
-			xbee_handle_status(packet[1]);
-			return 1;
-		case XBEE_FRAME_AT_COMMAND_RESPONSE:
-			command[0] = packet[2];
-			command[1] = packet[3];
-			command[2] = 0;
-			xbee_handle_at_command_response(command, packet[4], packet + 5, len - 5);
-			return 1;
-	}
-	return 0;
-}
-
-/**
- * Sets the personal area network id.
- *
- * @param id the new personal area network (PAN) id
- **/
-int xbee_set_pan_id(int id)
-{
-	char s[3];
-	s[0] = (id >> 8) & 0xFF;
-	s[1] = id & 0xFF;
-	s[2] = 0;
-	xbee_pending_panID = id;
-	return xbee_send_modify_at_command("ID", s);
-}
-
-/**
- * Get the PAN ID for the XBee.
- *
- * @return the personal area network id, or
- * XBEE_PAN_DEFAULT if it has not yet been set.
- **/
-unsigned int xbee_get_pan_id()
-{
-	return xbee_panID;
-}
-
-/**
- * Set the channel the XBee is using.
- *
- * @param channel the channel the XBee will not use,
- * between 0x0B and 0x1A
- *
- * @see xbee_get_channel
- **/
-int xbee_set_channel(int channel)
-{
-	if (channel < 0x0B || channel > 0x1A)
-	{
-		WL_DEBUG_PRINT("Channel out of range.\r\n");
-		return -1;
-	}
-
-	char s[3];
-	s[0] = channel & 0xFF;
-	s[1] = 0;
-	xbee_pending_channel = channel;
-
-	return xbee_send_modify_at_command("CH", s);
-}
-
-/**
- * Returns the channel which the XBee is currently using.
- *
- * @return the channel the XBee is using
- *
- * @see xbee_set_channel
- **/
-int xbee_get_channel(void)
-{
-	return xbee_channel;
-}
-
-/**
- * Get the 16-bit address of the XBee.
- * This is used to specify who to send messages to
- * and who messages are from.
- *
- * @return the 16-bit address of the XBee.
- **/
-unsigned int xbee_get_address()
-{
-	return xbee_address;
-}
-
-#ifndef ROBOT
-void xbee_set_com_port(char* port)
-{
-	xbee_com_port = port;
-}
-#endif
Index: trunk/code/projects/test/test_rangefinder.c
===================================================================
--- trunk/code/projects/test/test_rangefinder.c	(revision 1483)
+++ trunk/code/projects/test/test_rangefinder.c	(nonexistent)
@@ -1,77 +0,0 @@
-/**
- * @file test_rangefinder.c
- * @brief Contains unit test for rangefinder.c module of libdragonfly
- *
- * Contains a function allowing the user to test whether the rangefinder module
- * works correctly.
- *
- * @author Colony Project, CMU Robotics Club
- **/
-
-/* Testing Procedure
- * - Place hand in front of orbs in 4, 3, 2, 1, 5 order
- * - Observe orbs
- *
- * Expected Behavior:
- * - Orbs flash BLUE 3 times to signal start of test
- * - During test
- *  - Orb 1 changes to reflect which sensor is under test
- *  - Orb 2 stays RED until that sensor gets a usable reading, i.e. within visible distance
- * - Orbs flash PURPLE 3 times to signal end of test
- */
-
-#include <dragonfly_lib.h>
-
-#define TEST_TIME 500	// duration of success indicator (in ms)
-#define ON_DELAY 500	// duration of flashes at beginning and end (in ms)
-#define OFF_DELAY 250	// delay between flashes at beginning and end (in ms)
-
-int testrangefinder(void) {
-    int i;  // index
-    int sensor[5] = {IR4, IR3, IR2, IR1, IR5};
-    int color[5] = {RED, ORANGE, YELLOW, GREEN, BLUE};
-    int ret;
-
-    // flash orbs BLUE 3 times
-    for (i = 0; i < 3; i++) {
-	orb_set_color(BLUE);
-	delay_ms(ON_DELAY);
-	orb_set_color(ORB_OFF);
-	delay_ms(OFF_DELAY);
-    }
-
-    for (i = 0; i < 5; i++) {
-	// indicate sensor under test
-	orb2_set_color(color[i]);
-
-	// wait for sensor interaction
-	while ((ret = range_read_distance(sensor[i])) == -1) {
-	    // stay RED until IR4 sees something
-	    orb1_set_color(RED);
-	    if(ret == -3) { //library not init'd 
-	      while(1) {
-		orb2_set_color(GREEN);
-		orb1_set_color(RED);
-		delay_ms(250);
-		orb1_set_color(GREEN);
-		orb2_set_color(RED);
-		delay_ms(250);
-	      }
-	    }
-	}
-
-	orb1_set_color(GREEN);
-	delay_ms(TEST_TIME);
-    }
-
-    // flash orbs PURPLE 3 times
-    for (i = 0; i < 3; i++) {
-	orb_set_color(PURPLE);
-	delay_ms(ON_DELAY);
-	orb_set_color(ORB_OFF);
-	delay_ms(OFF_DELAY);
-    }
-
-    return 0;
-}
-

Property changes on: trunk/code/projects/test/test_rangefinder.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/main.c
===================================================================
--- trunk/code/projects/test/main.c	(revision 1483)
+++ trunk/code/projects/test/main.c	(nonexistent)
@@ -1,26 +0,0 @@
-#include <dragonfly_lib.h>
-
-#define RUN_TEST(f) extern int f(void); f();
-
-int main(void) {
-  //RUN_TEST(testinits);
-
-  dragonfly_init(ALL_ON);
-
-  while (1) {
-    //RUN_TEST(testusb);
-    // RUN_TEST(testanalog);
-    //RUN_TEST(testeeprom);
-    // RUN_TEST(testencoders);
-    // RUN_TEST(testlcd);
-    //RUN_TEST(testlights);
-    //RUN_TEST(testmotors);
-    RUN_TEST(testrangefinder);
-    // RUN_TEST(testtokenring);
-    // RUN_TEST(testwireless);
-    //RUN_TEST(testxbee);
-    delay_ms(1000);
-  }
-
-  return 0;
-}
Index: trunk/code/projects/test/test_inits.c
===================================================================
--- trunk/code/projects/test/test_inits.c	(revision 1483)
+++ trunk/code/projects/test/test_inits.c	(nonexistent)
@@ -1,88 +0,0 @@
-#include <dragonfly_lib.h>
-
-int testinits(void) {
-
-  if(usb_init())
-    return -1;
-
-  usb_puts("usb\n");
-
-  if(xbee_init()) {
-    usb_puts("ERROR! xbee\n"); 
-    return -1;
-  }
-  usb_puts("xbee\n");
-  if(analog_init(0)) {
-    usb_puts("ERROR! analog\n");
-    return -1;
-  }
-  usb_puts("analog\n");
-  if(bom_init(BOM15)) {
-    usb_puts("ERROR! bom\n");
-    return -1;
-  }
-  usb_puts("bom\n");
-  if(motors_init()) {
-    usb_puts("ERROR! motors_init\n");
-    return -1;
-  }
-  usb_puts("motors\n");
-  if(range_init()) {
-    usb_puts("ERROR: range\n");
-    return -1;
-  }
-  usb_puts("range\n");
-  if(encoders_init()) {
-    usb_puts("ERROR! encoders_init\n");
-    return -1;
-  }
-  usb_puts("encoders\n");
-
-
-  usb_puts("\nfirst pass done, testing re-inits\n\n");
-
-
-  //now each of these should return ERROR_INIT_ALREADY_INITD
-  if(usb_init() != ERROR_INIT_ALREADY_INITD) {
-    usb_puts("ERROR! usb\n");
-    return -1;
-  }
-  usb_puts("usb\n");
-
-  if(xbee_init() != ERROR_INIT_ALREADY_INITD) {
-    usb_puts("ERROR! xbee\n"); 
-    return -1;
-  }
-  usb_puts("xbee\n");
-  if(analog_init(0) != ERROR_INIT_ALREADY_INITD) {
-    usb_puts("ERROR! analog\n");
-    return -1;
-  }
-  usb_puts("analog\n");
-  if(bom_init(BOM15) != ERROR_INIT_ALREADY_INITD) {
-    usb_puts("ERROR! bom\n");
-    return -1;
-  }
-  usb_puts("bom\n");
-  if(motors_init() != ERROR_INIT_ALREADY_INITD) {
-    usb_puts("ERROR! motors_init\n");
-    return -1;
-  }
-  usb_puts("motors\n");
-  if(range_init() != ERROR_INIT_ALREADY_INITD) {
-    usb_puts("ERROR: range\n");
-    return -1;
-  }
-  usb_puts("range\n");
-  if(encoders_init() != ERROR_INIT_ALREADY_INITD) {
-    usb_puts("ERROR! encoders_init\n");
-    return -1;
-  }
-  usb_puts("encoders\n");
-
-
-  usb_puts("init test passed!\n");
-
-  return 0;
-
-}
Index: trunk/code/projects/test/test_eeprom.c
===================================================================
--- trunk/code/projects/test/test_eeprom.c	(revision 1483)
+++ trunk/code/projects/test/test_eeprom.c	(nonexistent)
@@ -1,89 +0,0 @@
-/** @file testeeprom.c
- *  @brief tests the eeprom code
- *
- *  stores and retrives a value, then sets it back to what it was
- */
-#include <dragonfly_lib.h>
-#include "eeprom.h"
-
-#define ADDR 0
-
-int testeeprom(void) {
-    unsigned char data, data2;
-    int ret;
-    int worked=1;
-
-    
-    /* read whats there */
-    ret = eeprom_get_byte(ADDR, &data);
-    
-    if(ret) {
-        usb_puts("Error reading intial value! return code: ");
-        usb_puti(ret);
-        usb_puts(" data: ");
-        usb_puti(data);
-        usb_puts("\r\n");
-        worked=0;
-    }
-    else {
-        usb_puts("data was: ");
-        usb_puti(data);
-        usb_puts("\r\n");
-    }
-    
-    /* write something new */
-    
-    ret = eeprom_put_byte(ADDR, 123);
-    if(ret) {
-        usb_puts("Error writing data! return code: ");
-        usb_puti(ret);
-        usb_puts("\r\n");
-        worked=0;
-    }
-    else {
-        usb_puts("wrote 123\r\n");
-    }
-    
-    
-    /* check if tis really there */
-    
-    ret = eeprom_get_byte(ADDR, &data2);
-    
-    if(ret) {
-        usb_puts("Error reading second value! return code: ");
-        usb_puti(ret);
-        usb_puts(" data: ");
-        usb_puti(data2);
-        usb_puts("\r\n");
-        worked=0;
-    }
-    else {
-        if(data2==123) {
-            usb_puts("data write and re-read worked!\r\n");
-        }
-        else {
-            usb_puts("data re-read returned 0 but data was ");
-            usb_puti(data2);
-            usb_puts("\r\n");
-            worked=0;
-        }
-    }
-    
-    
-    /* restore old value */
-    
-    ret = eeprom_put_byte(ADDR, 123);
-    if(ret) {
-        usb_puts("Error writing data the second time! return code: ");
-        usb_puti(ret);
-        usb_puts("\r\n");
-        worked=0;
-    }
-    else {
-        usb_puts("re-wrote original data: ");
-        usb_puti(data);
-        usb_puts("\r\n");
-    }
-    
-    return worked;
-}

Property changes on: trunk/code/projects/test/test_eeprom.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/test_usb.c
===================================================================
--- trunk/code/projects/test/test_usb.c	(revision 1483)
+++ trunk/code/projects/test/test_usb.c	(nonexistent)
@@ -1,53 +0,0 @@
-#include <dragonfly_lib.h>
-
-/*
- * This function outputs to TeraTerm the following:
- *
- * Testing...
- * 1, 2, 3
- * 2A, 00F4, C8E1
- * done.
- * 
- */
-
-int testusb(void) {
-	
-	usb_init();
-	usb_puts("usb turned on, test starting:\r\n");
-  
-	usb_puts("\r\n\n");
-	delay_ms(1000);
-	
-	// print some values to usb
-  usb_puts("Testing...\r\n");
-  usb_puti(1);
-  usb_putc(',');
-  usb_putc(' ');
-  usb_puti(2);
-  usb_putc(',');
-  usb_putc(' ');
-  usb_puti(3);
-  usb_putc('\r');
-  usb_putc('\n');
-  usb_puth8(0x2A);  
-  usb_putc(',');
-  usb_putc(' ');
-  usb_puth16(0xF4);
-  usb_putc(',');
-  usb_putc(' ');
-  usb_puth(0xC8E1);
-  usb_putc('\r');
-  usb_putc('\n');
-  usb_puts("enter an 'a':");  
-
-  // test getting a value from usb
-  if (usb_getc() == 'a')
-    usb_puts("\r\ngetc() works\r\n");
-  else
-    usb_puts("\r\ngetc() fails\r\n");
-  
-  usb_puts("done.\r\n\r\n");
-  
-  
-	return 0;
-}
\ No newline at end of file

Property changes on: trunk/code/projects/test/test_usb.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/test_lights.c
===================================================================
--- trunk/code/projects/test/test_lights.c	(revision 1483)
+++ trunk/code/projects/test/test_lights.c	(nonexistent)
@@ -1,362 +0,0 @@
-#include <dragonfly_lib.h>
-
-
-	
-int test_lights(void) {
-	 int i=0;
-		
-	//usb_init();
-    usb_puts("usb turned on\n");
-    delay_ms(1000);	
-	
-/** Test RGB color setting (both orbs) **/
-	for(i=0;i<256;i++){
-		orb_set(i,0,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_set(0,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_set(0,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, two parameters with changing parameters (both orbs) **/
-	for(i=0;i<256;i++){
-		orb_set(i,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_set(0,i,i);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_set(i,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, all parameters with changing parameters (both orbs) **/		
-	for(i=0;i<256;i++){
-		orb_set(i,i,i);
-		delay_ms(10);
-	}
-		
-/** Test RGB color setting (orb1) **/
-	for(i=0;i<256;i++){
-		orb1_set(i,0,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb1_set(0,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb1_set(0,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, two parameters with changing parameters (orb1) **/
-	for(i=0;i<256;i++){
-		orb1_set(i,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb1_set(0,i,i);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb1_set(i,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, all parameters with changing parameters (orb1) **/		
-	for(i=0;i<256;i++){
-		orb1_set(i,i,i);
-		delay_ms(10);
-	}
-
-/** Test RGB color setting (orb2) **/
-	for(i=0;i<256;i++){
-		orb2_set(i,0,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb2_set(0,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb2_set(0,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, two parameters with changing parameters (orb2) **/
-	for(i=0;i<256;i++){
-		orb2_set(i,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb2_set(0,i,i);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb2_set(i,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, all parameters with changing parameters (orb2) **/		
-	for(i=0;i<256;i++){
-		orb2_set(i,i,i);
-		delay_ms(10);
-	}
-	
-/** Test RGB color setting (n=1) **/
-	for(i=0;i<256;i++){
-		orb_n_set(1,i,0,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_n_set(1,0,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_n_set(1,0,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, two parameters with two changing parameters (n=1) **/
-	for(i=0;i<256;i++){
-		orb_n_set(1,i,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_n_set(1,0,i,i);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_n_set(1,i,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, all parameters with two changing parameters (n=1) **/		
-	for(i=0;i<256;i++){
-		orb_n_set(1,i,i,i);
-		delay_ms(10);
-	}
-
-/** Test RGB color setting (n=2) **/
-	for(i=0;i<256;i++){
-		orb_n_set(2,i,0,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_n_set(2,0,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_n_set(2,0,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, two parameters with two changing parameters (n=2) **/
-	for(i=0;i<256;i++){
-		orb_n_set(2,i,i,0);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_n_set(2,0,i,i);
-		delay_ms(10);
-	}
-	for(i=0;i<256;i++){
-		orb_n_set(2,i,0,i);
-		delay_ms(10);
-	}
-		
-/** Test RBG color, all parameters with two changing parameters (n=2) **/		
-	for(i=0;i<256;i++){
-		orb_n_set(2,i,i,i);
-		delay_ms(10);
-	}
-
-/** Weird not even RGB color test for both orbs **/		
-	for(i=2;i<256;i++){
-		orbs_set (i,i-1,i-2,i-2,i-1,i);
-		delay_ms(10);
-	}
-
-/** Test all #define'd colors (both orbs) **/
-    orb_set_color(ORB_OFF);
-    delay_ms(1000);
-	orb_set_color(RED);
-    delay_ms(1000);
-    orb_set_color(ORANGE);
-    delay_ms(1000);
-    orb_set_color(YELLOW);
-    delay_ms(1000);
-	orb_set_color(LIME);
-    delay_ms(1000);
-    orb_set_color(GREEN);
-    delay_ms(1000);
-	orb_set_color(CYAN);
-    delay_ms(1000);
-    orb_set_color(BLUE);
-    delay_ms(1000);
-	orb_set_color(PINK);
-    delay_ms(1000);
-    orb_set_color(PURPLE);
-    delay_ms(1000);
-	orb_set_color(MAGENTA);
-    delay_ms(1000);
-	orb_set_color(WHITE);
-    delay_ms(1000);
-	orb_set_color(ORB_OFF);
-    delay_ms(1000);
-	
-/** Test all #define'd colors (orb1) **/
-    orb1_set_color(ORB_OFF);
-    delay_ms(1000);
-	orb1_set_color(RED);
-    delay_ms(1000);
-    orb1_set_color(ORANGE);
-    delay_ms(1000);
-    orb1_set_color(YELLOW);
-    delay_ms(1000);
-	orb1_set_color(LIME);
-    delay_ms(1000);
-    orb1_set_color(GREEN);
-    delay_ms(1000);
-	orb1_set_color(CYAN);
-    delay_ms(1000);
-    orb1_set_color(BLUE);
-    delay_ms(1000);
-	orb1_set_color(PINK);
-    delay_ms(1000);
-    orb1_set_color(PURPLE);
-    delay_ms(1000);
-	orb1_set_color(MAGENTA);
-    delay_ms(1000);
-	orb1_set_color(WHITE);
-    delay_ms(1000);
-	orb1_set_color(ORB_OFF);
-    delay_ms(1000);
-
-/** Test all #define'd colors (orb2) **/
-    orb2_set_color(ORB_OFF);
-    delay_ms(1000);
-	orb2_set_color(RED);
-    delay_ms(1000);
-    orb2_set_color(ORANGE);
-    delay_ms(1000);
-    orb2_set_color(YELLOW);
-    delay_ms(1000);
-	orb2_set_color(LIME);
-    delay_ms(1000);
-    orb2_set_color(GREEN);
-    delay_ms(1000);
-	orb2_set_color(CYAN);
-    delay_ms(1000);
-    orb2_set_color(BLUE);
-    delay_ms(1000);
-	orb2_set_color(PINK);
-    delay_ms(1000);
-    orb2_set_color(PURPLE);
-    delay_ms(1000);
-	orb2_set_color(MAGENTA);
-    delay_ms(1000);
-	orb2_set_color(WHITE);
-    delay_ms(1000);
-	orb2_set_color(ORB_OFF);
-    delay_ms(1000);
-	
-/** Test all #define'd colors (n=1) **/
-    orb_n_set_color(1,ORB_OFF);
-    delay_ms(1000);
-	orb_n_set_color(1,RED);
-    delay_ms(1000);
-    orb_n_set_color(1,ORANGE);
-    delay_ms(1000);
-    orb_n_set_color(1,YELLOW);
-    delay_ms(1000);
-	orb_n_set_color(1,LIME);
-    delay_ms(1000);
-    orb_n_set_color(1,GREEN);
-    delay_ms(1000);
-	orb_n_set_color(1,CYAN);
-    delay_ms(1000);
-    orb_n_set_color(1,BLUE);
-    delay_ms(1000);
-	orb_n_set_color(1,PINK);
-    delay_ms(1000);
-    orb_n_set_color(1,PURPLE);
-    delay_ms(1000);
-	orb_n_set_color(1,MAGENTA);
-    delay_ms(1000);
-	orb_n_set_color(1,WHITE);
-    delay_ms(1000);
-	orb_n_set_color(1,ORB_OFF);
-    delay_ms(1000);
-	
-/** Test all #define'd colors (n=2) **/
-    orb_n_set_color(2,ORB_OFF);
-    delay_ms(1000);
-	orb_n_set_color(2,RED);
-    delay_ms(1000);
-    orb_n_set_color(2,ORANGE);
-    delay_ms(1000);
-    orb_n_set_color(2,YELLOW);
-    delay_ms(1000);
-	orb_n_set_color(2,LIME);
-    delay_ms(1000);
-    orb_n_set_color(2,GREEN);
-    delay_ms(1000);
-	orb_n_set_color(2,CYAN);
-    delay_ms(1000);
-    orb_n_set_color(2,BLUE);
-    delay_ms(1000);
-	orb_n_set_color(2,PINK);
-    delay_ms(1000);
-    orb_n_set_color(2,PURPLE);
-    delay_ms(1000);
-	orb_n_set_color(2,MAGENTA);
-    delay_ms(1000);
-	orb_n_set_color(2,WHITE);
-    delay_ms(1000);
-	orb_n_set_color(2,ORB_OFF);
-    delay_ms(1000);
-	
-	/** Test all #define'd colors (both orbs) **/
-    orbs_set_color(ORB_OFF,ORB_OFF);
-    delay_ms(1000);
-	orbs_set_color(RED,RED);
-    delay_ms(1000);
-    orbs_set_color(ORANGE,ORANGE);
-    delay_ms(1000);
-    orbs_set_color(YELLOW,YELLOW);
-    delay_ms(1000);
-	orbs_set_color(LIME,LIME);
-    delay_ms(1000);
-    orbs_set_color(GREEN,GREEN);
-    delay_ms(1000);
-	orbs_set_color(CYAN,CYAN);
-    delay_ms(1000);
-    orbs_set_color(BLUE,BLUE);
-    delay_ms(1000);
-	orbs_set_color(PINK,PINK);
-    delay_ms(1000);
-    orbs_set_color(PURPLE,PURPLE);
-    delay_ms(1000);
-	orbs_set_color(MAGENTA,MAGENTA);
-    delay_ms(1000);
-	orbs_set_color(WHITE,WHITE);
-    delay_ms(1000);
-	orbs_set_color(ORB_OFF,ORB_OFF);
-    delay_ms(1000);
-	
-	orbs_set_color(RED,GREEN);
-	delay_ms(3000);
-	
-    return 0;
-}
-
-

Property changes on: trunk/code/projects/test/test_lights.c
___________________________________________________________________
Deleted: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/test/Makefile
===================================================================
--- trunk/code/projects/test/Makefile	(revision 1483)
+++ trunk/code/projects/test/Makefile	(nonexistent)
@@ -1,19 +0,0 @@
-########Update This Section########
-#
-#
-
-# Relative path to the root directory (containing lib directory)
-ifndef COLONYROOT
-COLONYROOT = ../../..
-endif
-
-# Target file name (without extension).
-TARGET = main
-
-# Uncomment this to use the wireless library
-USE_WIRELESS = 1
-
-# com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
-
-include $(COLONYROOT)/code/makefile_root.mk
\ No newline at end of file
Index: trunk/code/projects/test/test_wireless.c
===================================================================
--- trunk/code/projects/test/test_wireless.c	(revision 1483)
+++ trunk/code/projects/test/test_wireless.c	(nonexistent)
@@ -1,114 +0,0 @@
-/**
- * Instructions:
- *  - wait for both robots to show ORB 1 RED and ORB 2 GREEN
- *  - press BUTTON 1 on robot to send first (ROBOT 1) - orbs should turn PURPLE
- *  - press BUTTON 2 on robot to receive first (ROBOT 2) - orbs should turn ORANGE
- *  - wait at least a second, then press BUTTON 1 on both robots SIMULTANEOUSLY
- *  - ROBOT 2 orbs should cycle ORANGE to RED to BLUE
- *  - then ROBOT 1 orbs should cycle PURPLE to RED to BLUE
- *  - then orbs on both robots should turn GREEN
- *  - test will reset to ORB 1 RED and ORB 2 CYAN
- *  - test should take ~7 seconds
- *
- * Depends on:
- *  - Orbs (Lights)
- *  - Serial (for debugging)
- **/
-
-#include <dragonfly_lib.h>
-#include <wl_basic.h>
-
-unsigned char* packet;
-int length;
-
-int testwireless(void) {
-    int count = 0;
-    int is_sender = 0;
-
-    wl_basic_init_default();
-    wl_set_channel(0x0E);
-
-    orb1_set_color(RED);
-    orb2_set_color(GREEN);
-    delay_ms(500);
-    while (count < 1) {
-        if (button1_click()) {
-            is_sender = 1;
-            orb_set_color(PURPLE);
-            count++;
-        }
-        if (button2_click()) {
-            is_sender = 0;
-            orb_set_color(ORANGE);
-            count++;
-        }
-    }
-    count = 0;
-
-    delay_ms(1000);
-
-    button1_wait();
-
-    delay_ms(500);
-
-    if (is_sender == 1) {
-        delay_ms(1000);
-        wl_basic_send_global_packet(1, "r", 2);
-        usb_puts("sent RED packet\r\n");
-        delay_ms(1000);
-        wl_basic_send_global_packet(1, "b", 2);
-        usb_puts("sent BLUE packet\r\n");
-        while(count < 2) {
-            packet = wl_basic_do_default(&length);
-            if (packet != 0) {
-                if (length > 0) {
-                    if (packet[0] == 'r') {
-                        orb_set_color(RED);
-                        usb_puts("received RED packet\r\n");
-                        count++;
-                    }
-                    else if (packet[0] == 'b') {
-                        orb_set_color(BLUE);
-                        usb_puts("received BLUE packet\r\n");
-                        count++;
-                    }
-                }
-            }
-        }
-    }
-    else {
-        while(count < 2) {
-            packet = wl_basic_do_default(&length);
-            if (packet != 0) {
-                if (length > 0) {
-                    if (packet[0] == 'r') {
-                        orb_set_color(RED);
-                        usb_puts("received RED packet\r\n");
-                        count++;
-                    }
-                    else if (packet[0] == 'b') {
-                        orb_set_color(BLUE);
-                        usb_puts("received BLUE packet\r\n");
-                        count++;
-                    }
-                }
-            }
-        }
-        delay_ms(1000);
-        wl_basic_send_global_packet(1, "r", 2);
-        usb_puts("sent RED packet\r\n");
-        delay_ms(1000);
-        wl_basic_send_global_packet(1, "b", 2);
-        usb_puts("sent BLUE packet\r\n");
-    }
-    delay_ms(1000);
-
-	wl_terminate();
-
-    orb_set_color(GREEN);
-
-    delay_ms(2000);
-
-    return 0;
-}
-
Index: trunk/code/projects/target_practice/targetBot/main.c
===================================================================
--- trunk/code/projects/target_practice/targetBot/main.c	(revision 1483)
+++ trunk/code/projects/target_practice/targetBot/main.c	(nonexistent)
@@ -1,76 +0,0 @@
-#include <dragonfly_lib.h>
-#include <encoders.h>
-
-int main(void)
-{
-
-	int maxBOM, rangeVal;
-
-	dragonfly_init(ALL_ON);
-	encoders_init();
-	
-	orbs_set_color(GREEN, RED);
-	delay_ms(500);
-	orbs_set_color(RED, GREEN);
-	delay_ms(500);
-	orbs_set_color(GREEN, GREEN);
-
-	while (1) {
-		
-		bom_refresh(BOM_ALL);
-		delay_ms(100);
-		maxBOM = bom_get_max();
-		usb_puti(maxBOM);
-		usb_putc('\n');
-		if (maxBOM == 4) {
-			motors_off();
-			break;
-		}
-
-		motor_l_set(BACKWARD, 175);
-		motor_r_set(FORWARD, 175);
-
-	}
-
-	while (1) {
-
-		rangeVal = range_read_distance(IR2);
-		usb_puti(rangeVal);
-		usb_putc('\n');
-		if (rangeVal < 500 && rangeVal > 20) {
-			motors_off();
-			orbs_set_color(RED, RED);
-			break;
-		}
-
-		motor_l_set(FORWARD, 175);
-		motor_r_set(FORWARD, 175);
-
-	}
-
-	button2_wait();
-
-	motor_l_set(FORWARD, 175);
-	motor_r_set(FORWARD, 175);
-
-	while (1) {
-		if (encoder_get_x(LEFT) > 500) {
-			motors_off();
-			break;
-		}
-	}
-
-	while (1) {
-
-		orbs_set_color(BLUE, GREEN);
-		delay_ms(500);
-		orbs_set_color(GREEN, BLUE);
-		delay_ms(500);
-
-	}
-
-	while (1); /* END HERE */
-
-	return 0;
-}
-
Index: trunk/code/projects/target_practice/targetBot/Makefile
===================================================================
--- trunk/code/projects/target_practice/targetBot/Makefile	(revision 1483)
+++ trunk/code/projects/target_practice/targetBot/Makefile	(nonexistent)
@@ -1,520 +0,0 @@
-########Update This Section########
-#
-#
-
-# Relative path to the root directory (containing lib directory)
-ifndef COLONYROOT
-COLONYROOT = ../../../..
-endif
-
-# Target file name (without extension).
-TARGET = template
-
-# Uncomment this to use the wireless library
-USE_WIRELESS = 1
-
-# com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
-
-#
-###################################
-
-# Hey Emacs, this is a -*- makefile -*-
-#----------------------------------------------------------------------------
-# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
-#
-# Released to the Public Domain
-#
-# Additional material for this makefile was written by:
-# Peter Fleury
-# Tim Henigan
-# Colin O'Flynn
-# Reiner Patommel
-# Markus Pfaff
-# Sander Pool
-# Frederik Rouleau
-#
-#----------------------------------------------------------------------------
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF.
-#
-# make extcoff = Convert ELF to AVR Extended COFF.
-#
-# make program = Download the hex file to the device, using avrdude.
-#                Please customize the avrdude settings below first!
-#
-# make debug = Start either simulavr or avarice as specified for debugging,
-#              with avr-gdb or avr-insight as the front end for debugging.
-#
-# make filename.s = Just compile filename.c into the assembler code only.
-#
-# make filename.i = Create a preprocessed source file for use in submitting
-#                   bug reports to the GCC project.
-#
-# To rebuild project do "make clean" then "make all".
-#----------------------------------------------------------------------------
-
-#if you want your code to work on the Firefly++ and not Firefly+
-#then add the -DFFPP line to CDEFS
-CDEFS =
-#-DFFPP
-
-# MCU name
-MCU = atmega128
-
-# Processor frequency.
-#     This will define a symbol, F_CPU, in all source code files equal to the
-#     processor frequency. You can then use this symbol in your source code to
-#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-#     automatically to create a 32-bit value in your source code.
-F_CPU = 8000000
-
-# Output format. (can be srec, ihex, binary)
-FORMAT = ihex
-
-# List C source files here. (C dependencies are automatically generated.)
-SRC = $(wildcard *.c)
-
-# List Assembler source files here.
-#     Make them always end in a capital .S.  Files ending in a lowercase .s
-#     will not be considered source files but generated files (assembler
-#     output from the compiler), and will be deleted upon "make clean"!
-#     Even though the DOS/Win* filesystem matches both .s and .S the same,
-#     it will preserve the spelling of the filenames, and gcc itself does
-#     care about how the name is spelled on its command-line.
-ASRC =
-
-# Optimization level, can be [0, 1, 2, 3, s].
-#     0 = turn off optimization. s = optimize for size.
-#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
-OPT = s
-
-# Debugging format.
-#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
-#     AVR Studio 4.10 requires dwarf-2.
-#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
-DEBUG =
-
-# Compiler flag to set the C Standard level.
-#     c89   = "ANSI" C
-#     gnu89 = c89 plus GCC extensions
-#     c99   = ISO C99 standard (not yet fully implemented)
-#     gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
-
-# Place -D or -U options here
-CDEFS += -DF_CPU=$(F_CPU)UL
-CDEFS += -DFFP
-# for wireless library
-ifdef USE_WIRELESS
-	CDEFS += -DROBOT
-endif
-
-# Place -I, -L options here
-CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
-CINCS += -L$(COLONYROOT)/code/lib/bin
-ifdef USE_WIRELESS
-	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
-endif
-
-#---------------- Compiler Options ----------------
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-CFLAGS =
-# CFLAGS = -g$(DEBUG)
-CFLAGS += $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-CFLAGS += -Wall -Wstrict-prototypes
-CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
-CFLAGS += $(CSTANDARD)
-
-#---------------- Assembler Options ----------------
-#  -Wa,...:   tell GCC to pass this to the assembler.
-#  -ahlms:    create listing
-#  -gstabs:   have the assembler create line number information; note that
-#             for use in COFF files, additional information about filenames
-#             and function names needs to be present in the assembler source
-#             files -- see avr-libc docs [FIXME: not yet described there]
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
-
-#---------------- Library Options ----------------
-# Minimalistic printf version
-PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
-
-# Floating point printf version (requires MATH_LIB = -lm below)
-PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
-
-# If this is left blank, then it will use the Standard printf version.
-#PRINTF_LIB =
-#PRINTF_LIB = $(PRINTF_LIB_MIN)
-PRINTF_LIB = $(PRINTF_LIB_FLOAT)
-
-
-# Minimalistic scanf version
-SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
-
-# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
-SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
-
-# If this is left blank, then it will use the Standard scanf version.
-SCANF_LIB =
-#SCANF_LIB = $(SCANF_LIB_MIN)
-#SCANF_LIB = $(SCANF_LIB_FLOAT)
-
-MATH_LIB = -lm
-
-#---------------- External Memory Options ----------------
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# used for variables (.data/.bss) and heap (malloc()).
-#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# only used for heap (malloc()).
-#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
-
-EXTMEMOPTS =
-
-#---------------- Linker Options ----------------
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += $(EXTMEMOPTS)
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
-ifdef USE_WIRELESS
-	LDFLAGS += -lwireless
-endif
-LDFLAGS += -ldragonfly
-
-
-
-#---------------- Programming Options (avrdude) ----------------
-
-# Programming hardware: alf avr910 avrisp bascom bsd
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
-#
-# Type: avrdude -c ?
-# to get a full listing.
-#
-AVRDUDE_PROGRAMMER = avrisp
-
-# programmer connected to serial device
-
-AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
-
-
-# Uncomment the following if you want avrdude's erase cycle counter.
-# Note that this counter needs to be initialized first using -Yn,
-# see avrdude manual.
-#AVRDUDE_ERASE_COUNTER = -y
-
-# Uncomment the following if you do /not/ wish a verification to be
-# performed after programming the device.
-#AVRDUDE_NO_VERIFY = -V
-
-# Increase verbosity level.  Please use this when submitting bug
-# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
-# to submit bug reports.
-#AVRDUDE_VERBOSE = -v -v
-
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
-
-#don't check for device signature
-AVRDUDE_FLAGS += -F
-
-
-
-#---------------- Debugging Options ----------------
-
-# For simulavr only - target MCU frequency.
-DEBUG_MFREQ = $(F_CPU)
-
-# Set the DEBUG_UI to either gdb or insight.
-# DEBUG_UI = gdb
-DEBUG_UI = insight
-
-# Set the debugging back-end to either avarice, simulavr.
-DEBUG_BACKEND = avarice
-#DEBUG_BACKEND = simulavr
-
-# GDB Init Filename.
-GDBINIT_FILE = __avr_gdbinit
-
-# When using avarice settings for the JTAG
-JTAG_DEV = /dev/com1
-
-# Debugging port used to communicate between GDB / avarice / simulavr.
-DEBUG_PORT = 4242
-
-# Debugging host used to communicate between GDB / avarice / simulavr, normally
-#     just set to localhost unless doing some sort of crazy debugging when
-#     avarice is running on a different computer.
-DEBUG_HOST = localhost
-
-
-
-#============================================================================
-
-
-# Define programs and commands.
-SHELL = sh
-CC = avr-gcc
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
-SIZE = avr-size
-NM = avr-nm
-AVRDUDE = avrdude
-REMOVE = rm -f
-REMOVEDIR = rm -rf
-COPY = cp
-WINSHELL = cmd
-
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = -------- begin --------
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before:
-MSG_SIZE_AFTER = Size after:
-MSG_COFF = Converting to AVR COFF:
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
-MSG_FLASH = Creating load file for Flash:
-MSG_EEPROM = Creating load file for EEPROM:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling:
-MSG_ASSEMBLING = Assembling:
-MSG_CLEANING = Cleaning project:
-
-
-
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
-
-# Define all listing files.
-LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
-
-
-# Compiler flags to generate dependency files.
-GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
-
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-
-
-
-# Default target.
-all: begin gccversion sizebefore build sizeafter end
-
-build: elf hex eep lss sym
-
-elf: $(TARGET).elf
-hex: $(TARGET).hex
-eep: $(TARGET).eep
-lss: $(TARGET).lss
-sym: $(TARGET).sym
-
-
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
-
-sizebefore:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-sizeafter:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-
-
-# Display compiler version information.
-gccversion :
-	@$(CC) --version
-
-
-
-# Program the device.
-program: $(TARGET).hex $(TARGET).eep
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
-
-
-# Generate avr-gdb config/init file which does the following:
-#     define the reset signal, load the target file, connect to target, and set
-#     a breakpoint at main().
-gdb-config:
-	@$(REMOVE) $(GDBINIT_FILE)
-	@echo define reset >> $(GDBINIT_FILE)
-	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
-	@echo end >> $(GDBINIT_FILE)
-	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
-	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
-ifeq ($(DEBUG_BACKEND),simulavr)
-	@echo load  >> $(GDBINIT_FILE)
-endif
-	@echo break main >> $(GDBINIT_FILE)
-
-debug: gdb-config $(TARGET).elf
-ifeq ($(DEBUG_BACKEND), avarice)
-	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
-	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
-	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
-	@$(WINSHELL) /c pause
-
-else
-	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
-	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
-endif
-	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
-
-
-
-
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
-COFFCONVERT=$(OBJCOPY) --debugging \
---change-section-address .data-0x800000 \
---change-section-address .bss-0x800000 \
---change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
-
-
-coff: $(TARGET).elf
-	@echo
-	@echo $(MSG_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
-	@echo
-	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
-
-
-
-# Create final output files (.hex, .eep) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
-	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-%.eep: %.elf
-	@echo
-	@echo $(MSG_EEPROM) $@
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
-	$(NM) -n $< > $@
-
-
-
-# Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
-	@echo
-	@echo $(MSG_LINKING) $@
-	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
-
-
-# Compile: create object files from C source files.
-%.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(ALL_CFLAGS) $< -o $@
-
-
-# Compile: create assembler files from C source files.
-%.s : %.c
-	$(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-%.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-# Create preprocessed source for use in sending a bug report.
-%.i : %.c
-	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
-
-
-# Target: clean project.
-clean: begin clean_list end
-
-clean_list :
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).eep
-	$(REMOVE) $(TARGET).cof
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lss
-	$(REMOVE) $(OBJ)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVEDIR) .dep
-
-
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff \
-clean clean_list program debug gdb-config
-
Index: trunk/code/projects/target_practice/beaconBot/Makefile
===================================================================
--- trunk/code/projects/target_practice/beaconBot/Makefile	(revision 1483)
+++ trunk/code/projects/target_practice/beaconBot/Makefile	(nonexistent)
@@ -1,520 +0,0 @@
-########Update This Section########
-#
-#
-
-# Relative path to the root directory (containing lib directory)
-ifndef COLONYROOT
-COLONYROOT = ../../../..
-endif
-
-# Target file name (without extension).
-TARGET = template
-
-# Uncomment this to use the wireless library
-USE_WIRELESS = 1
-
-# com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
-
-#
-###################################
-
-# Hey Emacs, this is a -*- makefile -*-
-#----------------------------------------------------------------------------
-# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
-#
-# Released to the Public Domain
-#
-# Additional material for this makefile was written by:
-# Peter Fleury
-# Tim Henigan
-# Colin O'Flynn
-# Reiner Patommel
-# Markus Pfaff
-# Sander Pool
-# Frederik Rouleau
-#
-#----------------------------------------------------------------------------
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF.
-#
-# make extcoff = Convert ELF to AVR Extended COFF.
-#
-# make program = Download the hex file to the device, using avrdude.
-#                Please customize the avrdude settings below first!
-#
-# make debug = Start either simulavr or avarice as specified for debugging,
-#              with avr-gdb or avr-insight as the front end for debugging.
-#
-# make filename.s = Just compile filename.c into the assembler code only.
-#
-# make filename.i = Create a preprocessed source file for use in submitting
-#                   bug reports to the GCC project.
-#
-# To rebuild project do "make clean" then "make all".
-#----------------------------------------------------------------------------
-
-#if you want your code to work on the Firefly++ and not Firefly+
-#then add the -DFFPP line to CDEFS
-CDEFS =
-#-DFFPP
-
-# MCU name
-MCU = atmega128
-
-# Processor frequency.
-#     This will define a symbol, F_CPU, in all source code files equal to the
-#     processor frequency. You can then use this symbol in your source code to
-#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-#     automatically to create a 32-bit value in your source code.
-F_CPU = 8000000
-
-# Output format. (can be srec, ihex, binary)
-FORMAT = ihex
-
-# List C source files here. (C dependencies are automatically generated.)
-SRC = $(wildcard *.c)
-
-# List Assembler source files here.
-#     Make them always end in a capital .S.  Files ending in a lowercase .s
-#     will not be considered source files but generated files (assembler
-#     output from the compiler), and will be deleted upon "make clean"!
-#     Even though the DOS/Win* filesystem matches both .s and .S the same,
-#     it will preserve the spelling of the filenames, and gcc itself does
-#     care about how the name is spelled on its command-line.
-ASRC =
-
-# Optimization level, can be [0, 1, 2, 3, s].
-#     0 = turn off optimization. s = optimize for size.
-#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
-OPT = s
-
-# Debugging format.
-#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
-#     AVR Studio 4.10 requires dwarf-2.
-#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
-DEBUG =
-
-# Compiler flag to set the C Standard level.
-#     c89   = "ANSI" C
-#     gnu89 = c89 plus GCC extensions
-#     c99   = ISO C99 standard (not yet fully implemented)
-#     gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
-
-# Place -D or -U options here
-CDEFS += -DF_CPU=$(F_CPU)UL
-CDEFS += -DFFP
-# for wireless library
-ifdef USE_WIRELESS
-	CDEFS += -DROBOT
-endif
-
-# Place -I, -L options here
-CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
-CINCS += -L$(COLONYROOT)/code/lib/bin
-ifdef USE_WIRELESS
-	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
-endif
-
-#---------------- Compiler Options ----------------
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-CFLAGS =
-# CFLAGS = -g$(DEBUG)
-CFLAGS += $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-CFLAGS += -Wall -Wstrict-prototypes
-CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
-CFLAGS += $(CSTANDARD)
-
-#---------------- Assembler Options ----------------
-#  -Wa,...:   tell GCC to pass this to the assembler.
-#  -ahlms:    create listing
-#  -gstabs:   have the assembler create line number information; note that
-#             for use in COFF files, additional information about filenames
-#             and function names needs to be present in the assembler source
-#             files -- see avr-libc docs [FIXME: not yet described there]
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
-
-#---------------- Library Options ----------------
-# Minimalistic printf version
-PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
-
-# Floating point printf version (requires MATH_LIB = -lm below)
-PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
-
-# If this is left blank, then it will use the Standard printf version.
-#PRINTF_LIB =
-#PRINTF_LIB = $(PRINTF_LIB_MIN)
-PRINTF_LIB = $(PRINTF_LIB_FLOAT)
-
-
-# Minimalistic scanf version
-SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
-
-# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
-SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
-
-# If this is left blank, then it will use the Standard scanf version.
-SCANF_LIB =
-#SCANF_LIB = $(SCANF_LIB_MIN)
-#SCANF_LIB = $(SCANF_LIB_FLOAT)
-
-MATH_LIB = -lm
-
-#---------------- External Memory Options ----------------
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# used for variables (.data/.bss) and heap (malloc()).
-#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# only used for heap (malloc()).
-#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
-
-EXTMEMOPTS =
-
-#---------------- Linker Options ----------------
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += $(EXTMEMOPTS)
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
-ifdef USE_WIRELESS
-	LDFLAGS += -lwireless
-endif
-LDFLAGS += -ldragonfly
-
-
-
-#---------------- Programming Options (avrdude) ----------------
-
-# Programming hardware: alf avr910 avrisp bascom bsd
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
-#
-# Type: avrdude -c ?
-# to get a full listing.
-#
-AVRDUDE_PROGRAMMER = avrisp
-
-# programmer connected to serial device
-
-AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
-
-
-# Uncomment the following if you want avrdude's erase cycle counter.
-# Note that this counter needs to be initialized first using -Yn,
-# see avrdude manual.
-#AVRDUDE_ERASE_COUNTER = -y
-
-# Uncomment the following if you do /not/ wish a verification to be
-# performed after programming the device.
-#AVRDUDE_NO_VERIFY = -V
-
-# Increase verbosity level.  Please use this when submitting bug
-# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
-# to submit bug reports.
-#AVRDUDE_VERBOSE = -v -v
-
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
-
-#don't check for device signature
-AVRDUDE_FLAGS += -F
-
-
-
-#---------------- Debugging Options ----------------
-
-# For simulavr only - target MCU frequency.
-DEBUG_MFREQ = $(F_CPU)
-
-# Set the DEBUG_UI to either gdb or insight.
-# DEBUG_UI = gdb
-DEBUG_UI = insight
-
-# Set the debugging back-end to either avarice, simulavr.
-DEBUG_BACKEND = avarice
-#DEBUG_BACKEND = simulavr
-
-# GDB Init Filename.
-GDBINIT_FILE = __avr_gdbinit
-
-# When using avarice settings for the JTAG
-JTAG_DEV = /dev/com1
-
-# Debugging port used to communicate between GDB / avarice / simulavr.
-DEBUG_PORT = 4242
-
-# Debugging host used to communicate between GDB / avarice / simulavr, normally
-#     just set to localhost unless doing some sort of crazy debugging when
-#     avarice is running on a different computer.
-DEBUG_HOST = localhost
-
-
-
-#============================================================================
-
-
-# Define programs and commands.
-SHELL = sh
-CC = avr-gcc
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
-SIZE = avr-size
-NM = avr-nm
-AVRDUDE = avrdude
-REMOVE = rm -f
-REMOVEDIR = rm -rf
-COPY = cp
-WINSHELL = cmd
-
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = -------- begin --------
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before:
-MSG_SIZE_AFTER = Size after:
-MSG_COFF = Converting to AVR COFF:
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
-MSG_FLASH = Creating load file for Flash:
-MSG_EEPROM = Creating load file for EEPROM:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling:
-MSG_ASSEMBLING = Assembling:
-MSG_CLEANING = Cleaning project:
-
-
-
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
-
-# Define all listing files.
-LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
-
-
-# Compiler flags to generate dependency files.
-GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
-
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-
-
-
-# Default target.
-all: begin gccversion sizebefore build sizeafter end
-
-build: elf hex eep lss sym
-
-elf: $(TARGET).elf
-hex: $(TARGET).hex
-eep: $(TARGET).eep
-lss: $(TARGET).lss
-sym: $(TARGET).sym
-
-
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
-
-sizebefore:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-sizeafter:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-
-
-# Display compiler version information.
-gccversion :
-	@$(CC) --version
-
-
-
-# Program the device.
-program: $(TARGET).hex $(TARGET).eep
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
-
-
-# Generate avr-gdb config/init file which does the following:
-#     define the reset signal, load the target file, connect to target, and set
-#     a breakpoint at main().
-gdb-config:
-	@$(REMOVE) $(GDBINIT_FILE)
-	@echo define reset >> $(GDBINIT_FILE)
-	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
-	@echo end >> $(GDBINIT_FILE)
-	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
-	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
-ifeq ($(DEBUG_BACKEND),simulavr)
-	@echo load  >> $(GDBINIT_FILE)
-endif
-	@echo break main >> $(GDBINIT_FILE)
-
-debug: gdb-config $(TARGET).elf
-ifeq ($(DEBUG_BACKEND), avarice)
-	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
-	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
-	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
-	@$(WINSHELL) /c pause
-
-else
-	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
-	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
-endif
-	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
-
-
-
-
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
-COFFCONVERT=$(OBJCOPY) --debugging \
---change-section-address .data-0x800000 \
---change-section-address .bss-0x800000 \
---change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
-
-
-coff: $(TARGET).elf
-	@echo
-	@echo $(MSG_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
-	@echo
-	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
-
-
-
-# Create final output files (.hex, .eep) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
-	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-%.eep: %.elf
-	@echo
-	@echo $(MSG_EEPROM) $@
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
-	$(NM) -n $< > $@
-
-
-
-# Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
-	@echo
-	@echo $(MSG_LINKING) $@
-	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
-
-
-# Compile: create object files from C source files.
-%.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(ALL_CFLAGS) $< -o $@
-
-
-# Compile: create assembler files from C source files.
-%.s : %.c
-	$(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-%.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-# Create preprocessed source for use in sending a bug report.
-%.i : %.c
-	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
-
-
-# Target: clean project.
-clean: begin clean_list end
-
-clean_list :
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).eep
-	$(REMOVE) $(TARGET).cof
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lss
-	$(REMOVE) $(OBJ)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVEDIR) .dep
-
-
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff \
-clean clean_list program debug gdb-config
-
Index: trunk/code/projects/target_practice/beaconBot/main.c
===================================================================
--- trunk/code/projects/target_practice/beaconBot/main.c	(revision 1483)
+++ trunk/code/projects/target_practice/beaconBot/main.c	(nonexistent)
@@ -1,24 +0,0 @@
-#include <dragonfly_lib.h>
-
-int main(void)
-{
-
-	/* initialize components, set wireless channel */
-	dragonfly_init(ALL_ON);
-
-	bom_on();
-	
-	while (1) {
-
-		orbs_set_color(GREEN, BLUE);
-
-		delay_ms(1000);
-
-		orbs_set_color(BLUE, GREEN);
-
-		delay_ms(1000);
-
-	}
-
-	return 0;
-}
Index: trunk/code/projects/BOM_test/testBot/Makefile
===================================================================
--- trunk/code/projects/BOM_test/testBot/Makefile	(revision 1483)
+++ trunk/code/projects/BOM_test/testBot/Makefile	(nonexistent)
@@ -1,520 +0,0 @@
-########Update This Section########
-#
-#
-
-# Relative path to the root directory (containing lib directory)
-ifndef COLONYROOT
-COLONYROOT = ../../../..
-endif
-
-# Target file name (without extension).
-TARGET = template
-
-# Uncomment this to use the wireless library
-USE_WIRELESS = 1
-
-# com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
-
-#
-###################################
-
-# Hey Emacs, this is a -*- makefile -*-
-#----------------------------------------------------------------------------
-# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
-#
-# Released to the Public Domain
-#
-# Additional material for this makefile was written by:
-# Peter Fleury
-# Tim Henigan
-# Colin O'Flynn
-# Reiner Patommel
-# Markus Pfaff
-# Sander Pool
-# Frederik Rouleau
-#
-#----------------------------------------------------------------------------
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF.
-#
-# make extcoff = Convert ELF to AVR Extended COFF.
-#
-# make program = Download the hex file to the device, using avrdude.
-#                Please customize the avrdude settings below first!
-#
-# make debug = Start either simulavr or avarice as specified for debugging,
-#              with avr-gdb or avr-insight as the front end for debugging.
-#
-# make filename.s = Just compile filename.c into the assembler code only.
-#
-# make filename.i = Create a preprocessed source file for use in submitting
-#                   bug reports to the GCC project.
-#
-# To rebuild project do "make clean" then "make all".
-#----------------------------------------------------------------------------
-
-#if you want your code to work on the Firefly++ and not Firefly+
-#then add the -DFFPP line to CDEFS
-CDEFS =
-#-DFFPP
-
-# MCU name
-MCU = atmega128
-
-# Processor frequency.
-#     This will define a symbol, F_CPU, in all source code files equal to the
-#     processor frequency. You can then use this symbol in your source code to
-#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-#     automatically to create a 32-bit value in your source code.
-F_CPU = 8000000
-
-# Output format. (can be srec, ihex, binary)
-FORMAT = ihex
-
-# List C source files here. (C dependencies are automatically generated.)
-SRC = $(wildcard *.c)
-
-# List Assembler source files here.
-#     Make them always end in a capital .S.  Files ending in a lowercase .s
-#     will not be considered source files but generated files (assembler
-#     output from the compiler), and will be deleted upon "make clean"!
-#     Even though the DOS/Win* filesystem matches both .s and .S the same,
-#     it will preserve the spelling of the filenames, and gcc itself does
-#     care about how the name is spelled on its command-line.
-ASRC =
-
-# Optimization level, can be [0, 1, 2, 3, s].
-#     0 = turn off optimization. s = optimize for size.
-#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
-OPT = s
-
-# Debugging format.
-#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
-#     AVR Studio 4.10 requires dwarf-2.
-#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
-DEBUG =
-
-# Compiler flag to set the C Standard level.
-#     c89   = "ANSI" C
-#     gnu89 = c89 plus GCC extensions
-#     c99   = ISO C99 standard (not yet fully implemented)
-#     gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
-
-# Place -D or -U options here
-CDEFS += -DF_CPU=$(F_CPU)UL
-CDEFS += -DFFP
-# for wireless library
-ifdef USE_WIRELESS
-	CDEFS += -DROBOT
-endif
-
-# Place -I, -L options here
-CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
-CINCS += -L$(COLONYROOT)/code/lib/bin
-ifdef USE_WIRELESS
-	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
-endif
-
-#---------------- Compiler Options ----------------
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-CFLAGS =
-# CFLAGS = -g$(DEBUG)
-CFLAGS += $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-CFLAGS += -Wall -Wstrict-prototypes
-CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
-CFLAGS += $(CSTANDARD)
-
-#---------------- Assembler Options ----------------
-#  -Wa,...:   tell GCC to pass this to the assembler.
-#  -ahlms:    create listing
-#  -gstabs:   have the assembler create line number information; note that
-#             for use in COFF files, additional information about filenames
-#             and function names needs to be present in the assembler source
-#             files -- see avr-libc docs [FIXME: not yet described there]
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
-
-#---------------- Library Options ----------------
-# Minimalistic printf version
-PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
-
-# Floating point printf version (requires MATH_LIB = -lm below)
-PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
-
-# If this is left blank, then it will use the Standard printf version.
-#PRINTF_LIB =
-#PRINTF_LIB = $(PRINTF_LIB_MIN)
-PRINTF_LIB = $(PRINTF_LIB_FLOAT)
-
-
-# Minimalistic scanf version
-SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
-
-# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
-SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
-
-# If this is left blank, then it will use the Standard scanf version.
-SCANF_LIB =
-#SCANF_LIB = $(SCANF_LIB_MIN)
-#SCANF_LIB = $(SCANF_LIB_FLOAT)
-
-MATH_LIB = -lm
-
-#---------------- External Memory Options ----------------
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# used for variables (.data/.bss) and heap (malloc()).
-#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# only used for heap (malloc()).
-#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
-
-EXTMEMOPTS =
-
-#---------------- Linker Options ----------------
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += $(EXTMEMOPTS)
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
-ifdef USE_WIRELESS
-	LDFLAGS += -lwireless
-endif
-LDFLAGS += -ldragonfly
-
-
-
-#---------------- Programming Options (avrdude) ----------------
-
-# Programming hardware: alf avr910 avrisp bascom bsd
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
-#
-# Type: avrdude -c ?
-# to get a full listing.
-#
-AVRDUDE_PROGRAMMER = avrisp
-
-# programmer connected to serial device
-
-AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
-
-
-# Uncomment the following if you want avrdude's erase cycle counter.
-# Note that this counter needs to be initialized first using -Yn,
-# see avrdude manual.
-#AVRDUDE_ERASE_COUNTER = -y
-
-# Uncomment the following if you do /not/ wish a verification to be
-# performed after programming the device.
-#AVRDUDE_NO_VERIFY = -V
-
-# Increase verbosity level.  Please use this when submitting bug
-# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
-# to submit bug reports.
-#AVRDUDE_VERBOSE = -v -v
-
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
-
-#don't check for device signature
-AVRDUDE_FLAGS += -F
-
-
-
-#---------------- Debugging Options ----------------
-
-# For simulavr only - target MCU frequency.
-DEBUG_MFREQ = $(F_CPU)
-
-# Set the DEBUG_UI to either gdb or insight.
-# DEBUG_UI = gdb
-DEBUG_UI = insight
-
-# Set the debugging back-end to either avarice, simulavr.
-DEBUG_BACKEND = avarice
-#DEBUG_BACKEND = simulavr
-
-# GDB Init Filename.
-GDBINIT_FILE = __avr_gdbinit
-
-# When using avarice settings for the JTAG
-JTAG_DEV = /dev/com1
-
-# Debugging port used to communicate between GDB / avarice / simulavr.
-DEBUG_PORT = 4242
-
-# Debugging host used to communicate between GDB / avarice / simulavr, normally
-#     just set to localhost unless doing some sort of crazy debugging when
-#     avarice is running on a different computer.
-DEBUG_HOST = localhost
-
-
-
-#============================================================================
-
-
-# Define programs and commands.
-SHELL = sh
-CC = avr-gcc
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
-SIZE = avr-size
-NM = avr-nm
-AVRDUDE = avrdude
-REMOVE = rm -f
-REMOVEDIR = rm -rf
-COPY = cp
-WINSHELL = cmd
-
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = -------- begin --------
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before:
-MSG_SIZE_AFTER = Size after:
-MSG_COFF = Converting to AVR COFF:
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
-MSG_FLASH = Creating load file for Flash:
-MSG_EEPROM = Creating load file for EEPROM:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling:
-MSG_ASSEMBLING = Assembling:
-MSG_CLEANING = Cleaning project:
-
-
-
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
-
-# Define all listing files.
-LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
-
-
-# Compiler flags to generate dependency files.
-GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
-
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-
-
-
-# Default target.
-all: begin gccversion sizebefore build sizeafter end
-
-build: elf hex eep lss sym
-
-elf: $(TARGET).elf
-hex: $(TARGET).hex
-eep: $(TARGET).eep
-lss: $(TARGET).lss
-sym: $(TARGET).sym
-
-
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
-
-sizebefore:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-sizeafter:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-
-
-# Display compiler version information.
-gccversion :
-	@$(CC) --version
-
-
-
-# Program the device.
-program: $(TARGET).hex $(TARGET).eep
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
-
-
-# Generate avr-gdb config/init file which does the following:
-#     define the reset signal, load the target file, connect to target, and set
-#     a breakpoint at main().
-gdb-config:
-	@$(REMOVE) $(GDBINIT_FILE)
-	@echo define reset >> $(GDBINIT_FILE)
-	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
-	@echo end >> $(GDBINIT_FILE)
-	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
-	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
-ifeq ($(DEBUG_BACKEND),simulavr)
-	@echo load  >> $(GDBINIT_FILE)
-endif
-	@echo break main >> $(GDBINIT_FILE)
-
-debug: gdb-config $(TARGET).elf
-ifeq ($(DEBUG_BACKEND), avarice)
-	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
-	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
-	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
-	@$(WINSHELL) /c pause
-
-else
-	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
-	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
-endif
-	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
-
-
-
-
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
-COFFCONVERT=$(OBJCOPY) --debugging \
---change-section-address .data-0x800000 \
---change-section-address .bss-0x800000 \
---change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
-
-
-coff: $(TARGET).elf
-	@echo
-	@echo $(MSG_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
-	@echo
-	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
-
-
-
-# Create final output files (.hex, .eep) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
-	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-%.eep: %.elf
-	@echo
-	@echo $(MSG_EEPROM) $@
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
-	$(NM) -n $< > $@
-
-
-
-# Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
-	@echo
-	@echo $(MSG_LINKING) $@
-	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
-
-
-# Compile: create object files from C source files.
-%.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(ALL_CFLAGS) $< -o $@
-
-
-# Compile: create assembler files from C source files.
-%.s : %.c
-	$(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-%.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-# Create preprocessed source for use in sending a bug report.
-%.i : %.c
-	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
-
-
-# Target: clean project.
-clean: begin clean_list end
-
-clean_list :
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).eep
-	$(REMOVE) $(TARGET).cof
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lss
-	$(REMOVE) $(OBJ)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVEDIR) .dep
-
-
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff \
-clean clean_list program debug gdb-config
-
Index: trunk/code/projects/BOM_test/testBot/main.c
===================================================================
--- trunk/code/projects/BOM_test/testBot/main.c	(revision 1483)
+++ trunk/code/projects/BOM_test/testBot/main.c	(nonexistent)
@@ -1,53 +0,0 @@
-#include <dragonfly_lib.h>
-
-int main(void)
-{
-
-	dragonfly_init(ALL_ON);
-	
-	int i, j, max = -1;
-	int vals[16];
-
-	orbs_set_color(RED, RED);
-	delay_ms(2000);
-	orbs_set_color(GREEN, GREEN);
-
-	while (1) {
-
-		/* Refresh and make sure the table is updated */
-		bom_refresh(BOM_ALL);
-		delay_ms(100);
-
-		/* Record values into an array */
-		for (i = 0; i < 16; i++) {
-			vals[i] = bom_get(i);
-			if (max < vals[i])
-				max = vals[i];
-		}
-
-		/* Display results */
-		for (i = 0; i < 16; i++) {
-			
-			usb_puti(vals[i]);
-			usb_putc('\t');
-
-			for (j = 0; j < (int)((max - vals[i]) / 5); j++) {
-				usb_putc('#');
-			}
-
-			usb_putc('\n');
-
-		}
-
-		usb_puts("Max: ");
-		usb_puti(bom_get_max());
-		usb_putc('\n');
-		usb_putc('\n');
-
-		delay_ms(400);
-
-	}
-
-	return 0;
-}
-
Index: trunk/code/projects/BOM_test/beaconBot/main.c
===================================================================
--- trunk/code/projects/BOM_test/beaconBot/main.c	(revision 1483)
+++ trunk/code/projects/BOM_test/beaconBot/main.c	(nonexistent)
@@ -1,24 +0,0 @@
-#include <dragonfly_lib.h>
-
-int main(void)
-{
-
-	/* initialize components, set wireless channel */
-	dragonfly_init(ALL_ON);
-
-	bom_on();
-	
-	while (1) {
-
-		orbs_set_color(GREEN, BLUE);
-
-		delay_ms(1000);
-
-		orbs_set_color(BLUE, GREEN);
-
-		delay_ms(1000);
-
-	}
-
-	return 0;
-}
Index: trunk/code/projects/BOM_test/beaconBot/Makefile
===================================================================
--- trunk/code/projects/BOM_test/beaconBot/Makefile	(revision 1483)
+++ trunk/code/projects/BOM_test/beaconBot/Makefile	(nonexistent)
@@ -1,520 +0,0 @@
-########Update This Section########
-#
-#
-
-# Relative path to the root directory (containing lib directory)
-ifndef COLONYROOT
-COLONYROOT = ../../../..
-endif
-
-# Target file name (without extension).
-TARGET = template
-
-# Uncomment this to use the wireless library
-USE_WIRELESS = 1
-
-# com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
-
-#
-###################################
-
-# Hey Emacs, this is a -*- makefile -*-
-#----------------------------------------------------------------------------
-# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
-#
-# Released to the Public Domain
-#
-# Additional material for this makefile was written by:
-# Peter Fleury
-# Tim Henigan
-# Colin O'Flynn
-# Reiner Patommel
-# Markus Pfaff
-# Sander Pool
-# Frederik Rouleau
-#
-#----------------------------------------------------------------------------
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF.
-#
-# make extcoff = Convert ELF to AVR Extended COFF.
-#
-# make program = Download the hex file to the device, using avrdude.
-#                Please customize the avrdude settings below first!
-#
-# make debug = Start either simulavr or avarice as specified for debugging,
-#              with avr-gdb or avr-insight as the front end for debugging.
-#
-# make filename.s = Just compile filename.c into the assembler code only.
-#
-# make filename.i = Create a preprocessed source file for use in submitting
-#                   bug reports to the GCC project.
-#
-# To rebuild project do "make clean" then "make all".
-#----------------------------------------------------------------------------
-
-#if you want your code to work on the Firefly++ and not Firefly+
-#then add the -DFFPP line to CDEFS
-CDEFS =
-#-DFFPP
-
-# MCU name
-MCU = atmega128
-
-# Processor frequency.
-#     This will define a symbol, F_CPU, in all source code files equal to the
-#     processor frequency. You can then use this symbol in your source code to
-#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-#     automatically to create a 32-bit value in your source code.
-F_CPU = 8000000
-
-# Output format. (can be srec, ihex, binary)
-FORMAT = ihex
-
-# List C source files here. (C dependencies are automatically generated.)
-SRC = $(wildcard *.c)
-
-# List Assembler source files here.
-#     Make them always end in a capital .S.  Files ending in a lowercase .s
-#     will not be considered source files but generated files (assembler
-#     output from the compiler), and will be deleted upon "make clean"!
-#     Even though the DOS/Win* filesystem matches both .s and .S the same,
-#     it will preserve the spelling of the filenames, and gcc itself does
-#     care about how the name is spelled on its command-line.
-ASRC =
-
-# Optimization level, can be [0, 1, 2, 3, s].
-#     0 = turn off optimization. s = optimize for size.
-#     (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
-OPT = s
-
-# Debugging format.
-#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
-#     AVR Studio 4.10 requires dwarf-2.
-#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
-DEBUG =
-
-# Compiler flag to set the C Standard level.
-#     c89   = "ANSI" C
-#     gnu89 = c89 plus GCC extensions
-#     c99   = ISO C99 standard (not yet fully implemented)
-#     gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
-
-# Place -D or -U options here
-CDEFS += -DF_CPU=$(F_CPU)UL
-CDEFS += -DFFP
-# for wireless library
-ifdef USE_WIRELESS
-	CDEFS += -DROBOT
-endif
-
-# Place -I, -L options here
-CINCS = -I$(COLONYROOT)/code/lib/include/libdragonfly
-CINCS += -L$(COLONYROOT)/code/lib/bin
-ifdef USE_WIRELESS
-	CINCS += -I$(COLONYROOT)/code/lib/include/libwireless
-endif
-
-#---------------- Compiler Options ----------------
-#  -g*:          generate debugging information
-#  -O*:          optimization level
-#  -f...:        tuning, see GCC manual and avr-libc documentation
-#  -Wall...:     warning level
-#  -Wa,...:      tell GCC to pass this to the assembler.
-#    -adhlns...: create assembler listing
-CFLAGS =
-# CFLAGS = -g$(DEBUG)
-CFLAGS += $(CDEFS) $(CINCS)
-CFLAGS += -O$(OPT)
-CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
-CFLAGS += -Wall -Wstrict-prototypes
-CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
-CFLAGS += $(CSTANDARD)
-
-#---------------- Assembler Options ----------------
-#  -Wa,...:   tell GCC to pass this to the assembler.
-#  -ahlms:    create listing
-#  -gstabs:   have the assembler create line number information; note that
-#             for use in COFF files, additional information about filenames
-#             and function names needs to be present in the assembler source
-#             files -- see avr-libc docs [FIXME: not yet described there]
-ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
-
-
-#---------------- Library Options ----------------
-# Minimalistic printf version
-PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
-
-# Floating point printf version (requires MATH_LIB = -lm below)
-PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
-
-# If this is left blank, then it will use the Standard printf version.
-#PRINTF_LIB =
-#PRINTF_LIB = $(PRINTF_LIB_MIN)
-PRINTF_LIB = $(PRINTF_LIB_FLOAT)
-
-
-# Minimalistic scanf version
-SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
-
-# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
-SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
-
-# If this is left blank, then it will use the Standard scanf version.
-SCANF_LIB =
-#SCANF_LIB = $(SCANF_LIB_MIN)
-#SCANF_LIB = $(SCANF_LIB_FLOAT)
-
-MATH_LIB = -lm
-
-#---------------- External Memory Options ----------------
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# used for variables (.data/.bss) and heap (malloc()).
-#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
-
-# 64 KB of external RAM, starting after internal RAM (ATmega128!),
-# only used for heap (malloc()).
-#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
-
-EXTMEMOPTS =
-
-#---------------- Linker Options ----------------
-#  -Wl,...:     tell GCC to pass this to linker.
-#    -Map:      create map file
-#    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += $(EXTMEMOPTS)
-LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
-ifdef USE_WIRELESS
-	LDFLAGS += -lwireless
-endif
-LDFLAGS += -ldragonfly
-
-
-
-#---------------- Programming Options (avrdude) ----------------
-
-# Programming hardware: alf avr910 avrisp bascom bsd
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
-#
-# Type: avrdude -c ?
-# to get a full listing.
-#
-AVRDUDE_PROGRAMMER = avrisp
-
-# programmer connected to serial device
-
-AVRDUDE_WRITE_FLASH = -b 57600 -U flash:w:$(TARGET).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
-
-
-# Uncomment the following if you want avrdude's erase cycle counter.
-# Note that this counter needs to be initialized first using -Yn,
-# see avrdude manual.
-#AVRDUDE_ERASE_COUNTER = -y
-
-# Uncomment the following if you do /not/ wish a verification to be
-# performed after programming the device.
-#AVRDUDE_NO_VERIFY = -V
-
-# Increase verbosity level.  Please use this when submitting bug
-# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
-# to submit bug reports.
-#AVRDUDE_VERBOSE = -v -v
-
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
-AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
-AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
-AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
-
-#don't check for device signature
-AVRDUDE_FLAGS += -F
-
-
-
-#---------------- Debugging Options ----------------
-
-# For simulavr only - target MCU frequency.
-DEBUG_MFREQ = $(F_CPU)
-
-# Set the DEBUG_UI to either gdb or insight.
-# DEBUG_UI = gdb
-DEBUG_UI = insight
-
-# Set the debugging back-end to either avarice, simulavr.
-DEBUG_BACKEND = avarice
-#DEBUG_BACKEND = simulavr
-
-# GDB Init Filename.
-GDBINIT_FILE = __avr_gdbinit
-
-# When using avarice settings for the JTAG
-JTAG_DEV = /dev/com1
-
-# Debugging port used to communicate between GDB / avarice / simulavr.
-DEBUG_PORT = 4242
-
-# Debugging host used to communicate between GDB / avarice / simulavr, normally
-#     just set to localhost unless doing some sort of crazy debugging when
-#     avarice is running on a different computer.
-DEBUG_HOST = localhost
-
-
-
-#============================================================================
-
-
-# Define programs and commands.
-SHELL = sh
-CC = avr-gcc
-OBJCOPY = avr-objcopy
-OBJDUMP = avr-objdump
-SIZE = avr-size
-NM = avr-nm
-AVRDUDE = avrdude
-REMOVE = rm -f
-REMOVEDIR = rm -rf
-COPY = cp
-WINSHELL = cmd
-
-
-# Define Messages
-# English
-MSG_ERRORS_NONE = Errors: none
-MSG_BEGIN = -------- begin --------
-MSG_END = --------  end  --------
-MSG_SIZE_BEFORE = Size before:
-MSG_SIZE_AFTER = Size after:
-MSG_COFF = Converting to AVR COFF:
-MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
-MSG_FLASH = Creating load file for Flash:
-MSG_EEPROM = Creating load file for EEPROM:
-MSG_EXTENDED_LISTING = Creating Extended Listing:
-MSG_SYMBOL_TABLE = Creating Symbol Table:
-MSG_LINKING = Linking:
-MSG_COMPILING = Compiling:
-MSG_ASSEMBLING = Assembling:
-MSG_CLEANING = Cleaning project:
-
-
-
-
-# Define all object files.
-OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
-
-# Define all listing files.
-LST = $(SRC:.c=.lst) $(ASRC:.S=.lst)
-
-
-# Compiler flags to generate dependency files.
-GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
-
-
-# Combine all necessary flags and optional flags.
-# Add target processor to flags.
-ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
-ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
-
-
-
-
-
-# Default target.
-all: begin gccversion sizebefore build sizeafter end
-
-build: elf hex eep lss sym
-
-elf: $(TARGET).elf
-hex: $(TARGET).hex
-eep: $(TARGET).eep
-lss: $(TARGET).lss
-sym: $(TARGET).sym
-
-
-
-# Eye candy.
-# AVR Studio 3.x does not check make's exit code but relies on
-# the following magic strings to be generated by the compile job.
-begin:
-	@echo
-	@echo $(MSG_BEGIN)
-
-end:
-	@echo $(MSG_END)
-	@echo
-
-
-# Display size of file.
-HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
-ELFSIZE = $(SIZE) -A $(TARGET).elf
-AVRMEM = avr-mem.sh $(TARGET).elf $(MCU)
-
-sizebefore:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-sizeafter:
-	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
-	$(AVRMEM) 2>/dev/null; echo; fi
-
-
-
-# Display compiler version information.
-gccversion :
-	@$(CC) --version
-
-
-
-# Program the device.
-program: $(TARGET).hex $(TARGET).eep
-	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
-
-
-# Generate avr-gdb config/init file which does the following:
-#     define the reset signal, load the target file, connect to target, and set
-#     a breakpoint at main().
-gdb-config:
-	@$(REMOVE) $(GDBINIT_FILE)
-	@echo define reset >> $(GDBINIT_FILE)
-	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
-	@echo end >> $(GDBINIT_FILE)
-	@echo file $(TARGET).elf >> $(GDBINIT_FILE)
-	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE)
-ifeq ($(DEBUG_BACKEND),simulavr)
-	@echo load  >> $(GDBINIT_FILE)
-endif
-	@echo break main >> $(GDBINIT_FILE)
-
-debug: gdb-config $(TARGET).elf
-ifeq ($(DEBUG_BACKEND), avarice)
-	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
-	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
-	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
-	@$(WINSHELL) /c pause
-
-else
-	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
-	$(DEBUG_MFREQ) --port $(DEBUG_PORT)
-endif
-	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
-
-
-
-
-# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
-COFFCONVERT=$(OBJCOPY) --debugging \
---change-section-address .data-0x800000 \
---change-section-address .bss-0x800000 \
---change-section-address .noinit-0x800000 \
---change-section-address .eeprom-0x810000
-
-
-coff: $(TARGET).elf
-	@echo
-	@echo $(MSG_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
-
-
-extcoff: $(TARGET).elf
-	@echo
-	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
-	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
-
-
-
-# Create final output files (.hex, .eep) from ELF output file.
-%.hex: %.elf
-	@echo
-	@echo $(MSG_FLASH) $@
-	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
-
-%.eep: %.elf
-	@echo
-	@echo $(MSG_EEPROM) $@
-	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
-	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
-
-# Create extended listing file from ELF output file.
-%.lss: %.elf
-	@echo
-	@echo $(MSG_EXTENDED_LISTING) $@
-	$(OBJDUMP) -h -S $< > $@
-
-# Create a symbol table from ELF output file.
-%.sym: %.elf
-	@echo
-	@echo $(MSG_SYMBOL_TABLE) $@
-	$(NM) -n $< > $@
-
-
-
-# Link: create ELF output file from object files.
-.SECONDARY : $(TARGET).elf
-.PRECIOUS : $(OBJ)
-%.elf: $(OBJ)
-	@echo
-	@echo $(MSG_LINKING) $@
-	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
-
-
-# Compile: create object files from C source files.
-%.o : %.c
-	@echo
-	@echo $(MSG_COMPILING) $<
-	$(CC) -c $(ALL_CFLAGS) $< -o $@
-
-
-# Compile: create assembler files from C source files.
-%.s : %.c
-	$(CC) -S $(ALL_CFLAGS) $< -o $@
-
-
-# Assemble: create object files from assembler source files.
-%.o : %.S
-	@echo
-	@echo $(MSG_ASSEMBLING) $<
-	$(CC) -c $(ALL_ASFLAGS) $< -o $@
-
-# Create preprocessed source for use in sending a bug report.
-%.i : %.c
-	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
-
-
-# Target: clean project.
-clean: begin clean_list end
-
-clean_list :
-	@echo
-	@echo $(MSG_CLEANING)
-	$(REMOVE) $(TARGET).hex
-	$(REMOVE) $(TARGET).eep
-	$(REMOVE) $(TARGET).cof
-	$(REMOVE) $(TARGET).elf
-	$(REMOVE) $(TARGET).map
-	$(REMOVE) $(TARGET).sym
-	$(REMOVE) $(TARGET).lss
-	$(REMOVE) $(OBJ)
-	$(REMOVE) $(LST)
-	$(REMOVE) $(SRC:.c=.s)
-	$(REMOVE) $(SRC:.c=.d)
-	$(REMOVEDIR) .dep
-
-
-
-# Include the dependency files.
--include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
-
-
-# Listing of phony targets.
-.PHONY : all begin finish end sizebefore sizeafter gccversion \
-build elf hex eep lss sym coff extcoff \
-clean clean_list program debug gdb-config
-
Index: trunk/code/projects/unit_tests/Makefile
===================================================================
--- trunk/code/projects/unit_tests/Makefile	(nonexistent)
+++ trunk/code/projects/unit_tests/Makefile	(revision 1484)
@@ -0,0 +1,19 @@
+########Update This Section########
+#
+#
+
+# Relative path to the root directory (containing lib directory)
+ifndef COLONYROOT
+COLONYROOT = ../../..
+endif
+
+# Target file name (without extension).
+TARGET = main
+
+# Uncomment this to use the wireless library
+USE_WIRELESS = 1
+
+# com1 = serial port. Use lpt1 to connect to parallel port.
+AVRDUDE_PORT = $(shell if uname -s |grep -i w32 >/dev/null; then echo 'COM4:'; else echo '/dev/ttyUSB0'; fi)
+
+include $(COLONYROOT)/code/makefile_root.mk
\ No newline at end of file
Index: trunk/code/projects/unit_tests/test_inits.c
===================================================================
--- trunk/code/projects/unit_tests/test_inits.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_inits.c	(revision 1484)
@@ -0,0 +1,88 @@
+#include <dragonfly_lib.h>
+
+int testinits(void) {
+
+  if(usb_init())
+    return -1;
+
+  usb_puts("usb\n");
+
+  if(xbee_init()) {
+    usb_puts("ERROR! xbee\n"); 
+    return -1;
+  }
+  usb_puts("xbee\n");
+  if(analog_init(0)) {
+    usb_puts("ERROR! analog\n");
+    return -1;
+  }
+  usb_puts("analog\n");
+  if(bom_init(BOM15)) {
+    usb_puts("ERROR! bom\n");
+    return -1;
+  }
+  usb_puts("bom\n");
+  if(motors_init()) {
+    usb_puts("ERROR! motors_init\n");
+    return -1;
+  }
+  usb_puts("motors\n");
+  if(range_init()) {
+    usb_puts("ERROR: range\n");
+    return -1;
+  }
+  usb_puts("range\n");
+  if(encoders_init()) {
+    usb_puts("ERROR! encoders_init\n");
+    return -1;
+  }
+  usb_puts("encoders\n");
+
+
+  usb_puts("\nfirst pass done, testing re-inits\n\n");
+
+
+  //now each of these should return ERROR_INIT_ALREADY_INITD
+  if(usb_init() != ERROR_INIT_ALREADY_INITD) {
+    usb_puts("ERROR! usb\n");
+    return -1;
+  }
+  usb_puts("usb\n");
+
+  if(xbee_init() != ERROR_INIT_ALREADY_INITD) {
+    usb_puts("ERROR! xbee\n"); 
+    return -1;
+  }
+  usb_puts("xbee\n");
+  if(analog_init(0) != ERROR_INIT_ALREADY_INITD) {
+    usb_puts("ERROR! analog\n");
+    return -1;
+  }
+  usb_puts("analog\n");
+  if(bom_init(BOM15) != ERROR_INIT_ALREADY_INITD) {
+    usb_puts("ERROR! bom\n");
+    return -1;
+  }
+  usb_puts("bom\n");
+  if(motors_init() != ERROR_INIT_ALREADY_INITD) {
+    usb_puts("ERROR! motors_init\n");
+    return -1;
+  }
+  usb_puts("motors\n");
+  if(range_init() != ERROR_INIT_ALREADY_INITD) {
+    usb_puts("ERROR: range\n");
+    return -1;
+  }
+  usb_puts("range\n");
+  if(encoders_init() != ERROR_INIT_ALREADY_INITD) {
+    usb_puts("ERROR! encoders_init\n");
+    return -1;
+  }
+  usb_puts("encoders\n");
+
+
+  usb_puts("init test passed!\n");
+
+  return 0;
+
+}
Index: trunk/code/projects/unit_tests/main.c
===================================================================
--- trunk/code/projects/unit_tests/main.c	(nonexistent)
+++ trunk/code/projects/unit_tests/main.c	(revision 1484)
@@ -0,0 +1,26 @@
+#include <dragonfly_lib.h>
+
+#define RUN_TEST(f) extern int f(void); f();
+
+int main(void) {
+  //RUN_TEST(testinits);
+
+  dragonfly_init(ALL_ON);
+
+  while (1) {
+    //RUN_TEST(testusb);
+    // RUN_TEST(testanalog);
+    //RUN_TEST(testeeprom);
+    // RUN_TEST(testencoders);
+    // RUN_TEST(testlcd);
+    //RUN_TEST(testlights);
+    //RUN_TEST(testmotors);
+    RUN_TEST(testrangefinder);
+    // RUN_TEST(testtokenring);
+    // RUN_TEST(testwireless);
+    //RUN_TEST(testxbee);
+    delay_ms(1000);
+  }
+
+  return 0;
+}
Index: trunk/code/projects/unit_tests/test_motors.c
===================================================================
--- trunk/code/projects/unit_tests/test_motors.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_motors.c	(revision 1484)
@@ -0,0 +1,75 @@
+#include <dragonfly_lib.h>
+
+#define OFF 	140
+#define SLOW 	160
+#define	GO		220
+
+int testmotors(void) {
+    //usb_init();
+    //usb_puts("usb turned on\n");
+    
+	//forward
+	orb_set_color(RED);
+	motors_off();
+    delay_ms(3000);
+    orb_set_color(YELLOW);
+	motor_l_set(1, SLOW);
+    motor_r_set(1, SLOW);
+    delay_ms(3000);
+    orb_set_color(GREEN);
+	motor_l_set(1, GO);
+    motor_r_set(1, GO);
+    delay_ms(3000);
+	
+	//backward
+    orb_set_color(RED);
+	motors_off();
+    delay_ms(3000);
+    orb_set_color(YELLOW);
+	motor_l_set(0, SLOW);
+    motor_r_set(0, SLOW);
+    delay_ms(3000);
+    orb_set_color(GREEN);
+	motor_l_set(0, GO);
+    motor_r_set(0, GO);
+    delay_ms(3000);
+	
+	//spin
+	orb_set_color(RED);
+	motors_off();
+    delay_ms(3000);
+    orb_set_color(YELLOW);
+	motor_l_set(1, SLOW);
+    motor_r_set(0, SLOW);
+    delay_ms(3000);
+    orb_set_color(GREEN);
+	motor_l_set(1, GO);
+    motor_r_set(0, GO);
+    delay_ms(3000);
+	
+	//spin other way
+	orb_set_color(RED);
+	motors_off();
+    delay_ms(3000);
+    orb_set_color(YELLOW);
+	motor_l_set(0, SLOW);
+    motor_r_set(1, SLOW);
+    delay_ms(3000);
+    orb_set_color(GREEN);
+	motor_l_set(0, GO);
+    motor_r_set(1, GO);
+    delay_ms(3000);
+	//while(1){;}
+
+
+    motors_off();
+
+    return 0;
+}
+
+
+/*test data
+left >154 forward
+right >150 forward
+both >152 backward
+*/

Property changes on: trunk/code/projects/unit_tests/test_motors.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/unit_tests/test_rangefinder.c
===================================================================
--- trunk/code/projects/unit_tests/test_rangefinder.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_rangefinder.c	(revision 1484)
@@ -0,0 +1,77 @@
+/**
+ * @file test_rangefinder.c
+ * @brief Contains unit test for rangefinder.c module of libdragonfly
+ *
+ * Contains a function allowing the user to test whether the rangefinder module
+ * works correctly.
+ *
+ * @author Colony Project, CMU Robotics Club
+ **/
+
+/* Testing Procedure
+ * - Place hand in front of orbs in 4, 3, 2, 1, 5 order
+ * - Observe orbs
+ *
+ * Expected Behavior:
+ * - Orbs flash BLUE 3 times to signal start of test
+ * - During test
+ *  - Orb 1 changes to reflect which sensor is under test
+ *  - Orb 2 stays RED until that sensor gets a usable reading, i.e. within visible distance
+ * - Orbs flash PURPLE 3 times to signal end of test
+ */
+
+#include <dragonfly_lib.h>
+
+#define TEST_TIME 500	// duration of success indicator (in ms)
+#define ON_DELAY 500	// duration of flashes at beginning and end (in ms)
+#define OFF_DELAY 250	// delay between flashes at beginning and end (in ms)
+
+int testrangefinder(void) {
+    int i;  // index
+    int sensor[5] = {IR4, IR3, IR2, IR1, IR5};
+    int color[5] = {RED, ORANGE, YELLOW, GREEN, BLUE};
+    int ret;
+
+    // flash orbs BLUE 3 times
+    for (i = 0; i < 3; i++) {
+	orb_set_color(BLUE);
+	delay_ms(ON_DELAY);
+	orb_set_color(ORB_OFF);
+	delay_ms(OFF_DELAY);
+    }
+
+    for (i = 0; i < 5; i++) {
+	// indicate sensor under test
+	orb2_set_color(color[i]);
+
+	// wait for sensor interaction
+	while ((ret = range_read_distance(sensor[i])) == -1) {
+	    // stay RED until IR4 sees something
+	    orb1_set_color(RED);
+	    if(ret == -3) { //library not init'd 
+	      while(1) {
+		orb2_set_color(GREEN);
+		orb1_set_color(RED);
+		delay_ms(250);
+		orb1_set_color(GREEN);
+		orb2_set_color(RED);
+		delay_ms(250);
+	      }
+	    }
+	}
+
+	orb1_set_color(GREEN);
+	delay_ms(TEST_TIME);
+    }
+
+    // flash orbs PURPLE 3 times
+    for (i = 0; i < 3; i++) {
+	orb_set_color(PURPLE);
+	delay_ms(ON_DELAY);
+	orb_set_color(ORB_OFF);
+	delay_ms(OFF_DELAY);
+    }
+
+    return 0;
+}
+

Property changes on: trunk/code/projects/unit_tests/test_rangefinder.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/unit_tests/test_tokenring.c
===================================================================
--- trunk/code/projects/unit_tests/test_tokenring.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_tokenring.c	(revision 1484)
@@ -0,0 +1,98 @@
+#include <dragonfly_lib.h>
+#include <wireless.h>
+#include <wl_token_ring.h>
+
+
+/**
+ * Tests the token ring and BOM
+ * - prints table of bom values for every robot in token ring
+ * - takes several seconds to initialize token ring
+ */
+ 
+#define MAX_ROBOTS 16
+
+// set a list of integers to 0
+void clearRobots(int* list) {
+  for(int i=0;i<MAX_ROBOTS;i++)
+    list[i] = 0;
+}
+
+int testtokenring(void) {
+  usb_init();
+	usb_puts("usb turned on\r\n");
+  wl_init();
+  usb_puts("wireless turned on\r\n");
+  wl_token_ring_register();
+  wl_token_ring_join(); // join token ring
+  usb_puts("token ring joined\r\n");
+  int robotList[sizeof(int)*MAX_ROBOTS];
+  int numRobots = 0;
+  delay_ms(1000);
+  
+  // start testing wireless/token ring/BOM
+  int i=0;
+  while(1) {
+    wl_do();
+    // only print table every 200 loops
+    if (i%200==0) {
+      // get token ring size values
+      usb_puts("\r\nnumber of robots in token ring:");
+      usb_puti(wl_token_get_robots_in_ring());
+      usb_puts("\r\nnumber of robots in matrix:"); 
+      usb_puti(wl_token_get_num_robots());
+      
+      // get list of robots
+      numRobots = 0;
+      clearRobots(robotList);
+      wl_token_iterator_begin();
+      while(wl_token_iterator_has_next()) {
+        int tmp = wl_token_iterator_next();
+        if (tmp < 0)
+          break;
+        robotList[tmp] = 1;
+        numRobots++;
+      }
+      if (numRobots < 1) {
+        usb_puts("\r\nNo BOM table available.");
+        continue; // skip table printing
+      } else {
+        usb_puts("\r\nBOM table: (* indicates this robot)");
+      }
+      
+      // print table of bom readings between robots
+      usb_puts("\r\ns \\ d");
+      // print header
+      for(int j=0;j<MAX_ROBOTS;j++)
+        if (robotList[j]) {
+          usb_puts("\t|");
+          if (j == wl_get_xbee_id())
+            usb_puts("*"); // indicate that this is the current bot
+          usb_puti(j);
+        }
+      usb_puts("\r\n");
+      // print body
+      for(int l=0;l<MAX_ROBOTS;l++) 
+        if (robotList[l]) {        
+          if (l == wl_get_xbee_id())
+            usb_puts("*"); // indicate that this is the current bot
+          usb_puti(l); // print label col
+          for(int k=0;k<MAX_ROBOTS;k++) 
+            if (robotList[k]) {
+              usb_puts("\t|");
+              if (k != l) {
+                int bom = wl_token_get_sensor_reading(l,k);
+                if (bom >= 0 && bom <= 15)
+                  usb_puti(bom); // print bom value
+              }
+            }
+          usb_puts("\r\n");
+        }
+      usb_puts("\r\n");
+    }
+  }
+  
+  // end testing token ring and bom
+	return 0;
+}
+
+

Property changes on: trunk/code/projects/unit_tests/test_tokenring.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/unit_tests/test_xbee.c
===================================================================
--- trunk/code/projects/unit_tests/test_xbee.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_xbee.c	(revision 1484)
@@ -0,0 +1,52 @@
+#include <dragonfly_lib.h>
+#include <xbee.h>
+
+#define ROBOT
+#define WL_DEBUG
+#define WL_DEBUG_PRINT( s ) usb_puts( S )
+
+extern int xbee_send_read_at_command(char* command);
+extern int xbee_get_packet(unsigned char* dest);
+extern void xbee_terminate(void);
+
+/*
+ * This function tests the xbee, returning the results to teraterm
+ *
+ * 
+ */
+ 
+int testxbee(void) {
+
+  unsigned char buf[100];
+  int i=0;
+	
+	usb_init();
+	usb_puts("usb turned on, test starting:\r\n");
+  
+  if (xbee_lib_init() != 0) {
+    usb_puts("xbee_lib_init() failed\r\n");
+    return -1;
+  } else {
+    usb_puts("xbee_lib__init successful\r\n");
+  }
+ 
+	usb_puts("\r\n\n");
+	delay_ms(1000);
+	
+	// try getting xbee address
+  xbee_send_read_at_command("MY");
+  while(i++ < 10000) {
+    if(xbee_get_packet(buf) == 3) {
+      usb_puts("got response from xbee\r\n");
+      //usb_puts("packet:");
+      //usb_puts(buf);
+      //usb_puts("|end\r\n");
+      break; // got a response
+    }
+  }
+  
+  xbee_terminate();
+  usb_puts("testxbee done\r\n\r\n");
+    
+	return 0;
+}
\ No newline at end of file
Index: trunk/code/projects/unit_tests/xbee.c
===================================================================
--- trunk/code/projects/unit_tests/xbee.c	(nonexistent)
+++ trunk/code/projects/unit_tests/xbee.c	(revision 1484)
@@ -0,0 +1,1029 @@
+/**
+ * Copyright (c) 2007 Colony Project
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ **/
+
+/**
+ * @file xbee.c
+ * @brief XBee Interface
+ *
+ * Implementation of low level communication with the XBee in API mode.
+ *
+ * @author Brian Coltin, Colony Project, CMU Robotics Club
+ **/
+
+#include <xbee.h>
+#include <wl_defs.h>
+
+#define ROBOT
+#define WL_DEBUG
+#define WL_DEBUG_PRINT( s ) usb_puts( s )
+#define WL_DEBUG_PRINT_INT( i ) usb_puti(i)
+
+#ifndef ROBOT
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <errno.h>
+#include <termios.h>
+
+#else
+
+#include <serial.h>
+#include <avr/interrupt.h>
+
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define XBEE_FRAME_START 0x7E
+#define XBEE_GET_PACKET_TIMEOUT 1000
+
+/*Frame Types*/
+#define XBEE_FRAME_STATUS 0x8A
+#define XBEE_FRAME_AT_COMMAND 0x08
+#define XBEE_FRAME_AT_COMMAND_RESPONSE 0x88
+#define XBEE_FRAME_TX_REQUEST_64 0x00
+#define XBEE_FRAME_TX_REQUEST_16 0x01
+#define XBEE_FRAME_TX_STATUS XBEE_TX_STATUS
+#define XBEE_FRAME_RX_64 0x80
+#define XBEE_FRAME_RX_16 XBEE_RX
+
+/*Internal Function Prototypes*/
+
+/*I/O Functions*/
+static int xbee_send(char* buf, int size);
+static int xbee_send_string(char* c);
+
+#ifndef ROBOT
+static int xbee_read(char* buf, int size);
+#endif
+
+/*Command Mode Functions
+ * Called during initialization.
+ */
+static int xbee_enter_command_mode(void);
+static int xbee_exit_command_mode(void);
+static int xbee_enter_api_mode(void);
+static int xbee_exit_api_mode(void);
+static int xbee_wait_for_string(char* s, int len);
+static int xbee_wait_for_ok(void);
+
+/*API Mode Functions*/
+
+static int xbee_handle_packet(char* packet, int len);
+static void xbee_handle_at_command_response(char* command, char result, char* extra, int extraLen);
+static void xbee_handle_status(char status);
+static int xbee_verify_checksum(char* packet, int len);
+static char xbee_compute_checksum(char* packet, int len);
+static int xbee_send_frame(char* buf, int len);
+int xbee_send_read_at_command(char* command);
+static int xbee_send_modify_at_command(char* command, char* value);
+
+/*Global Variables*/
+
+#ifndef ROBOT
+static char* xbee_com_port = XBEE_PORT_DEFAULT;
+static int xbee_stream;
+static pthread_t* xbee_listen_thread;
+#endif
+
+// TODO: is this a good size?
+#define XBEE_BUFFER_SIZE	128
+#define PACKET_BUFFER_SIZE	108
+// a buffer for data received from the XBee
+char arrival_buf[XBEE_BUFFER_SIZE];
+// location of last unread byte in buffer
+volatile int buffer_last = 0;
+// first unread byte in buffer
+volatile int buffer_first = 0;
+
+
+//used to store packets as they are read
+static char xbee_buf[PACKET_BUFFER_SIZE];
+static int currentBufPos = 0;
+
+//XBee status
+static unsigned int xbee_panID = XBEE_PAN_DEFAULT;
+static unsigned int xbee_pending_panID = XBEE_PAN_DEFAULT;
+static int xbee_channel = XBEE_CHANNEL_DEFAULT;
+static int xbee_pending_channel = XBEE_CHANNEL_DEFAULT;
+static volatile unsigned int xbee_address = 0;
+
+/*Function Implementations*/
+
+#ifdef ROBOT
+
+/**
+ * Interrupt for the robot. Adds bytes received from the xbee
+ * to the buffer.
+ **/
+#ifndef FIREFLY
+ISR(USART1_RX_vect)
+{
+	char c = UDR1;
+	arrival_buf[buffer_last] = c;
+	int t = buffer_last + 1;
+	if (t == XBEE_BUFFER_SIZE)
+		t = 0;
+	if (t == buffer_first)
+	{
+		WL_DEBUG_PRINT("\nOut of space in buffer.\n");
+	}
+	buffer_last = t;
+}
+#else
+SIGNAL(SIG_USART0_RECV)
+{
+	char c = UDR0;
+	arrival_buf[buffer_last] = c;
+	int t = buffer_last + 1;
+	if (t == XBEE_BUFFER_SIZE)
+		t = 0;
+	if (t == buffer_first)
+	{
+		WL_DEBUG_PRINT("Out of space in buffer.\n");
+	}
+	buffer_last = t;
+}
+#endif
+
+#else
+
+// Computer code
+
+/**
+ * Thread that listens to the xbee.
+ **/
+static void* listen_to_xbee(void* x)
+{
+	char c;
+	while (1)
+	{
+		if (xbee_read(&c, 1) != 0) {
+			WL_DEBUG_PRINT("xbee_read failed.\n");
+			return NULL;
+		}
+
+		arrival_buf[buffer_last] = c;
+		int t = buffer_last + 1;
+		if (t == XBEE_BUFFER_SIZE)
+			t = 0;
+		if (t == buffer_first)
+		{
+			WL_DEBUG_PRINT("Out of space in buffer.\n");
+		}
+		buffer_last = t;
+
+		usleep(1000);
+	}
+
+	return NULL;
+}
+
+#endif
+
+/**
+ * Initializes the XBee library so that other functions may be used.
+ **/
+int xbee_lib_init()
+{
+	WL_DEBUG_PRINT("in xbee_init\n");
+#ifdef ROBOT
+
+	//enable the receiving interrupt
+#ifdef FIREFLY
+	UCSR0B |= _BV(RXCIE) | _BV(RXEN);
+#else
+#ifdef BAYBOARD
+	UCSR1B |= _BV(RXCIE1);
+#else
+	UCSR1B |= _BV(RXCIE);
+#endif
+#endif
+	sei();
+#else
+	xbee_stream = open(xbee_com_port, O_RDWR);
+	if (xbee_stream == -1/* || lockf(xbee_stream, F_TEST, 0) != 0*/)
+	{
+		WL_DEBUG_PRINT("Failed to open connection to XBee on port ");
+		WL_DEBUG_PRINT_INT(xbee_com_port);
+		WL_DEBUG_PRINT(".\n");
+		return -1;
+	} else {
+	  WL_DEBUG_PRINT("Successfully opened connection to XBee on port ");
+		WL_DEBUG_PRINT_INT(xbee_com_port);
+		WL_DEBUG_PRINT(".\n");
+	}
+
+	// set baud rate, etc. correctly
+	struct termios options;
+
+	tcgetattr(xbee_stream, &options);
+	cfsetispeed(&options, B9600);
+	cfsetospeed(&options, B9600);
+	options.c_iflag &= ~ICRNL;
+	options.c_oflag &= ~OCRNL;
+	options.c_cflag |= (CLOCAL | CREAD);
+	options.c_cflag &= ~PARENB;
+	options.c_cflag &= ~CSTOPB;
+	options.c_cflag &= ~CSIZE;
+	options.c_cflag |= CS8;
+	options.c_lflag &= ~ICANON;
+	options.c_cc[VMIN] = 1;
+	options.c_cc[VTIME] = 50;
+
+	if (tcsetattr(xbee_stream, TCSANOW, &options))
+	{
+		WL_DEBUG_PRINT("Error setting attributes.\n");
+		return -1;
+	}
+
+	xbee_listen_thread = (pthread_t*)malloc(sizeof(pthread_t));
+	if (xbee_listen_thread == NULL)
+	{
+		WL_DEBUG_PRINT("Malloc failed.\n");
+		return -1;
+	}
+
+	int ret = pthread_create(xbee_listen_thread, NULL, listen_to_xbee, NULL);
+	if (ret)
+	{
+		WL_DEBUG_PRINT("Failed to create listener thread.\n");
+		return -1;
+	}
+#endif
+
+	WL_DEBUG_PRINT("Entering command mode.\n");
+
+	if (xbee_enter_command_mode() != 0) {
+		return -1;
+	}
+
+	WL_DEBUG_PRINT("Entered command mode.\n");
+
+	if (xbee_enter_api_mode() != 0) {
+		return -1;
+	}
+
+	WL_DEBUG_PRINT("Entered api mode.\n");
+
+	if (xbee_exit_command_mode() != 0) {
+	     return -1;
+	}
+	
+	WL_DEBUG_PRINT("Left command mode.\n");
+
+	if (xbee_send_read_at_command("MY")) {
+		return -1;
+	}
+	WL_DEBUG_PRINT("Getting ATMY address.\n");
+
+#ifndef ROBOT
+	int i;
+	for (i = 0; xbee_address == 0 && i < XBEE_GET_PACKET_TIMEOUT; i++) {
+	  ret = xbee_get_packet(NULL);
+
+	  usleep(1000);
+	  
+/* 	  if (ret == -1) { */
+/* 	    WL_DEBUG_PRINT("xbee_get_packet(NULL) failed.\n"); */
+/* 	    return -1; */
+/* 	  } */
+	}
+#else
+	//wait to return until the address is set
+  //TODO: this shouldn't wait indefinitely.  There should be some sort of reasonable timeout
+  // so if the address is never set right, an error can be returned instead of having the
+  // robot hang forever
+	while (xbee_address == 0) {
+	  xbee_get_packet(NULL);
+	}
+#endif
+	WL_DEBUG_PRINT("Got ATMY address.\n");
+
+#ifndef ROBOT
+	if (i == XBEE_GET_PACKET_TIMEOUT) { // We timed-out.
+
+	  WL_DEBUG_PRINT("xbee_get_packet timed out.\n");
+	  return -1;
+	} else {
+	  return 0;
+	}
+#else
+	return 0;
+#endif
+}
+
+/**
+ * Call when finished using the XBee library. This releases
+ * all sued resources.
+ **/
+void xbee_terminate()
+{
+	#ifndef ROBOT
+	pthread_cancel(*xbee_listen_thread);
+    pthread_join(*xbee_listen_thread, NULL);
+	free(xbee_listen_thread);
+	lockf(xbee_stream, F_ULOCK, 0);
+	close(xbee_stream);
+  #else
+  xbee_exit_api_mode();
+	#endif
+}
+
+/**
+ * Send a buffer buf of size bytes to the XBee.
+ *
+ * @param buf the buffer of data to send
+ * @param size the number of bytes to send
+ **/
+static int xbee_send(char* buf, int size)
+{
+#ifdef ROBOT
+	int i;
+	for (i = 0; i < size; i++) {
+		xbee_putc(buf[i]);
+	}
+
+	return 0;
+
+#else
+
+	int ret = write(xbee_stream, buf, size);
+	//success
+	if (ret == size)
+		return 0;
+	if (ret == -1)
+	{
+		//interrupted by system signal, probably timer interrupt.
+		//just try again
+		if (errno == 4)
+		{
+			return xbee_send(buf, size);
+		}
+		WL_DEBUG_PRINT("Failed to write to xbee\r\n");
+		return -1;
+	}
+
+	//write was interrupted after writing ret bytes
+	return xbee_send(buf + ret, size - ret);
+#endif
+}
+
+/**
+ * Sends a string to the XBee.
+ *
+ * @param c the string to send to the XBEE
+ **/
+static int xbee_send_string(char* c)
+{
+	return xbee_send(c, strlen(c));
+}
+
+#ifndef ROBOT
+static int xbee_read(char* buf, int size)
+{
+	if (read(xbee_stream, buf, size) == -1) {
+		WL_DEBUG_PRINT("Failed to read from xbee.\r\n");
+		return -1;
+	}
+
+	return 0;
+}
+#endif
+
+/**
+ * Enter into command mode.
+ **/
+static int xbee_enter_command_mode()
+{
+	if (xbee_send_string("+++") != 0) {
+		return -1;
+	}
+
+	if (xbee_wait_for_ok() != 0) {
+	  return -1;
+	}
+	  return 0;
+}
+
+/**
+ * Exit from command mode.
+ **/
+static int xbee_exit_command_mode()
+{
+	if (xbee_send_string("ATCN\r") != 0) {
+		return -1;
+	}
+
+	xbee_wait_for_ok();
+
+	return 0;
+}
+
+/**
+ * Enter API mode.
+ **/
+static int xbee_enter_api_mode()
+{
+	if (xbee_send_string("ATAP 1\r") != 0) {
+		return -1;
+	}
+	xbee_wait_for_ok();
+
+	return 0;
+}
+
+/**
+ * Exit API mode.
+ **/
+static int xbee_exit_api_mode()
+{
+	if (xbee_send_modify_at_command("AP","0") != 0) {
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * Wait until the string "OK\r" is received from the XBee.
+ **/
+static int xbee_wait_for_ok()
+{
+	return xbee_wait_for_string("OK\r", 3);
+}
+
+/**
+ * Delay until the specified string is received from
+ * the XBee. Discards all other XBee data.
+ *
+ * ********* Robot often hangs here ****************
+ *
+ * @param s the string to receive
+ * @param len the length of the string
+ **/
+static int xbee_wait_for_string(char* s, int len)
+{
+	char* curr = s;
+	while (curr - s < len) {
+    WL_DEBUG_PRINT("waiting for string\r\n");
+		// check if buffer is empty
+		if (buffer_last != buffer_first) {
+			char c = arrival_buf[buffer_first++];
+			if (buffer_first == XBEE_BUFFER_SIZE) {
+				buffer_first = 0;
+			}
+
+			if (c == *curr) {
+				curr++;
+			} else {
+#ifndef ROBOT
+			  //return -1; // Computer is less forgiving.
+			  curr = s;
+#else
+			  curr = s;
+#endif
+			}
+		} // else buffer is empty.
+
+#ifndef ROBOT
+		usleep(100);
+#endif
+	}
+
+	return 0;
+}
+
+/**
+ * Verifies that the packets checksum is correct.
+ * (If the checksum is correct, the sum of the bytes
+ * is 0xFF.)
+ *
+ * @param packet the packet received. This includes the first
+ * three bytes, which are header information from the XBee.
+ *
+ * @param len The length of the packet received from the XBee
+ *
+ * @return 0 if the checksum is incorrect, nonzero
+ * otherwise
+ **/
+int xbee_verify_checksum(char* packet, int len)
+{
+	unsigned char sum = 0;
+	int i;
+	for (i = 3; i < len; i++)
+		sum += (unsigned char)packet[i];
+	return sum == 0xFF;
+}
+
+/**
+ * Returns the checksum of the given packet.
+ *
+ * @param buf the data for the packet to send
+ * @param len the length of the packet in bytes
+ *
+ * @return the checksum of the packet, which will
+ * become the last byte sent in the packet
+ **/
+char xbee_compute_checksum(char* buf, int len)
+{
+	int i;
+	unsigned char sum = 0;
+	for (i = 0; i < len; i++)
+		sum += (unsigned char)buf[i];
+	return 0xFF - sum;
+}
+
+/**
+ * Adds header information and checksum to the given
+ * packet and sends it. Header information includes
+ * XBEE_FRAME_START and the packet length, as two bytes.
+ *
+ * @param buf the packet data
+ * @param len the size in bytes of the packet data
+ *
+ **/
+static int xbee_send_frame(char* buf, int len)
+{
+	char prefix[3];
+	prefix[0] = XBEE_FRAME_START;
+	prefix[1] = (len & 0xFF00) >> 8;
+	prefix[2] = len & 0xFF;
+	char checksum = xbee_compute_checksum(buf, len);
+
+	if (xbee_send(prefix, 3) != 0) {
+		return -1;
+	}
+
+	if (xbee_send(buf, len) != 0) {
+		return -1;
+	}
+
+	if (xbee_send(&checksum, 1) != 0) {
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * Sends an AT command to read a parameter.
+ *
+ * @param command the AT command to send. For exmaple,
+ * use ID to read the PAN ID and MY to return the XBee ID.
+ * See the XBee reference guide for a complete listing.
+ **/
+int xbee_send_read_at_command(char* command)
+{
+	return xbee_send_modify_at_command(command, NULL);
+}
+
+/**
+ * Sends the given AT command.
+ *
+ * @param command the AT command to send (e.g., MY, ID)
+ * @param value the value to pass as a parameter
+ * (or NULL if there is no parameter)
+ **/
+static int xbee_send_modify_at_command(char* command, char* value)
+{
+	char buf[16];
+	int i;
+
+	buf[0] = XBEE_FRAME_AT_COMMAND;
+	buf[1] = 1;
+	buf[2] = command[0];
+	buf[3] = command[1];
+	int valueLen = 0;
+	if (value != NULL)
+	{
+		valueLen = strlen(value);
+		if (valueLen > 8)
+		{
+			WL_DEBUG_PRINT("AT Command too large.\r\n");
+			return -1;
+		}
+
+		for (i = 0; i < valueLen; i++) {
+			buf[4 + i] = value[i];
+		}
+	}
+
+	return xbee_send_frame(buf, 4 + valueLen);
+}
+
+/**
+ * Send the specified packet.
+ *
+ * @param packet the packet data to send
+ * @param len the number of bytes in the packet
+ *
+ * @param dest the ID of the XBee to send the packet to,
+ * or XBEE_BROADCAST to send the message to all robots
+ * in the PAN.
+ *
+ * @param options a combination of the flags
+ * XBEE_OPTIONS_NONE, XBEE_OPTIONS_DISABLE_RESPONSE and
+ * XBEE_OPTIONS_BROADCAST_ALL_PANS
+ *
+ * @param frame the frame number to associate this packet
+ * with. This will be used to identify the response when
+ * the XBee alerts us as to whether or not our message
+ * was received.
+ **/
+int xbee_send_packet(char* packet, int len, int dest, char options, char frame)
+{
+	char buf[5];
+	char prefix[3];
+	int i;
+	unsigned char checksum = 0;
+
+	if (len > 100)
+	{
+		WL_DEBUG_PRINT("Packet is too large.\r\n");
+		return -1;
+	}
+
+	//data for sending request
+	buf[0] = XBEE_FRAME_TX_REQUEST_16;
+	buf[1] = frame;
+	buf[2] = (dest >> 8) & 0xFF;
+	buf[3] = dest & 0xFF;
+	buf[4] = options;
+
+	//packet prefix, do this here so we don't need an extra buffer
+	prefix[0] = XBEE_FRAME_START;
+	prefix[1] = ((5 + len) & 0xFF00) >> 8;
+	prefix[2] = (5 + len) & 0xFF;
+
+	for (i = 0; i < 5; i++)
+		checksum += (unsigned char)buf[i];
+	for (i = 0; i < len; i++)
+		checksum += (unsigned char)packet[i];
+	checksum = 0xFF - checksum;
+
+	if (xbee_send(prefix, 3) != 0) {
+		return -1;
+	}
+
+	if (xbee_send(buf, 5) != 0) {
+		return -1;
+	}
+
+	if (xbee_send(packet, len) != 0) {
+		return -1;
+	}
+
+	if (xbee_send((char*)&checksum, 1) != 0) {
+		return -1;
+	}
+
+	return 0;
+}
+
+/**
+ * Reads a packet received from the XBee. This function
+ * is non-blocking. The resulting packet is stored in dest.
+ * Only returns transmission response packets and
+ * received packets. The returned packet does not include
+ * header information or the checksum. This method also
+ * handles special packets dealt with by the XBee library,
+ * and so should be called frequently while the XBee is in
+ * use.<br><br>
+ *
+ * The first byte of the packet will be either
+ * XBEE_TX_STATUS or XBEE_RX to indicated
+ * a response to a sent message or a received message,
+ * respectively.<br><br>
+ *
+ * For a status response packet:<br>
+ * The first byte will be XBEE_TX_STATUS.<br>
+ * The second byte will be the frame number.<br>
+ * The third byte will be the result. 0 indicates success,
+ * and nonzero indicates that an error ocurred in
+ * transmitting the packet.<br><br>
+ *
+ * For a received packet:<br>
+ * The first byte will be XBEE_RX.<br>
+ * The second and third bytes will be the 16-bit
+ * address of the packet's sender.<br>
+ * The fourth byte is the signal strength.<br>
+ * The fifth byte is 1 if the packet were sent to
+ * a specific address, and 2 if it is a broadcast packet.<br><br>
+ *
+ * @param dest set to the packet data
+ * @return the length of the packet, or -1 if no packet
+ * is available
+ **/
+int xbee_get_packet(unsigned char* dest)
+{
+     int ret;
+	//start reading a packet with XBEE_FRAME_START
+	if (currentBufPos == 0)
+	{
+		do
+		{
+			if (buffer_first == XBEE_BUFFER_SIZE)
+				buffer_first = 0;
+			// check if buffer is empty
+			if (buffer_first == buffer_last) {
+				return -1;
+			}
+		} while (arrival_buf[buffer_first++] != XBEE_FRAME_START);
+
+		if (buffer_first == XBEE_BUFFER_SIZE) {
+			buffer_first = 0;
+		}
+		xbee_buf[0] = XBEE_FRAME_START;
+		currentBufPos++;
+	}
+
+	int len = -1;
+	if (currentBufPos >= 3) {
+		len = (int)xbee_buf[2] + ((int)xbee_buf[1] << 8);
+	}
+
+	while (len == -1 //packet length has not been read yet
+		|| currentBufPos < len + 4)
+	{
+		if (currentBufPos == 3)
+		{
+			len = (int)xbee_buf[2] + ((int)xbee_buf[1] << 8);
+			if (len > 120)
+			{
+				WL_DEBUG_PRINT("Packet too large. Probably error in XBee transmission.\n");
+				currentBufPos = 0;
+				return -1;
+			}
+		}
+
+		// check if buffer is empty
+		if (buffer_first == buffer_last) {
+			return -1;
+		}
+		xbee_buf[currentBufPos++] = arrival_buf[buffer_first++];
+		if (buffer_first == XBEE_BUFFER_SIZE) {
+			buffer_first = 0;
+		}
+	}
+
+	currentBufPos = 0;
+
+	if (!xbee_verify_checksum(xbee_buf, len + 4))
+	{
+		WL_DEBUG_PRINT("XBee checksum failed.\r\n");
+		return -1;
+	}
+
+	//we will take care of the packet
+	
+	ret = xbee_handle_packet(xbee_buf+3, len);
+	if (ret == 1) {
+		return 3;
+	}
+	
+	if (dest == NULL) {
+		return -1;
+	}
+
+	int i;
+	for (i = 3; i < len + 3; i++) {
+		dest[i - 3] = xbee_buf[i];
+	}
+	return len;
+}
+
+/**
+ * Handles modem status packets.
+ *
+ * @param status the type of status packet received.
+ **/
+void xbee_handle_status(char status)
+{
+	switch (status)
+	{
+		case 0:
+			WL_DEBUG_PRINT("XBee hardware reset.\r\n");
+			break;
+		case 1:
+			WL_DEBUG_PRINT("Watchdog timer reset.\r\n");
+			break;
+		case 2:
+			WL_DEBUG_PRINT("Associated.\r\n");
+			break;
+		case 3:
+			WL_DEBUG_PRINT("Disassociated.\r\n");
+			break;
+		case 4:
+			WL_DEBUG_PRINT("Synchronization lost.\r\n");
+			break;
+		case 5:
+			WL_DEBUG_PRINT("Coordinator realignment.\r\n");
+			break;
+		case 6:
+			WL_DEBUG_PRINT("Coordinator started.\r\n");
+			break;
+	}
+}
+
+/**
+ * Handles AT command response packets.
+ * @param command the two character AT command, e.g. MY or ID
+ * @param result 0 for success, 1 for an error
+ * @param extra the hex value of the requested register
+ * @param extraLen the length in bytes of extra
+ **/
+static void xbee_handle_at_command_response(char* command, char result, char* extra, int extraLen)
+{
+	if (result == 1)
+	{
+		WL_DEBUG_PRINT("Error with AT");
+		WL_DEBUG_PRINT(command);
+		WL_DEBUG_PRINT(" packet.\r\n");
+	}
+	WL_DEBUG_PRINT("AT");
+	WL_DEBUG_PRINT(command);
+	WL_DEBUG_PRINT(" command was successful.\r\n");
+
+	if (command[0] == 'I' && command[1] == 'D')
+	{
+		xbee_panID = xbee_pending_panID;
+		WL_DEBUG_PRINT("PAN ID set to ");
+		WL_DEBUG_PRINT_INT(xbee_panID);
+		WL_DEBUG_PRINT(".\r\n");
+		return;
+	}
+
+	if (command[0] == 'C' && command[1] == 'H')
+	{
+		xbee_channel = xbee_pending_channel;
+		WL_DEBUG_PRINT("Channel set to ");
+		WL_DEBUG_PRINT_INT(xbee_channel);
+		WL_DEBUG_PRINT(".\r\n");
+		return;
+	}
+
+	if (command[0] == 'M' && command[1] == 'Y' && extraLen != 0)
+	{
+		xbee_address = 0;
+		int i;
+		for (i = 0; i < extraLen; i++) {
+			xbee_address = (xbee_address << 8) + extra[i];
+		}
+
+		WL_DEBUG_PRINT("XBee address is ");
+		WL_DEBUG_PRINT_INT(xbee_address);
+		WL_DEBUG_PRINT(".\r\n");
+
+		if (xbee_address == 0)
+		{
+			WL_DEBUG_PRINT("XBee 16-bit address must be set using ATMY.\r\n");
+			#ifndef ROBOT
+			exit(0);
+			#endif
+		}
+	}
+}
+
+/**
+ * Attempts to handle the packet if it is dealt with
+ * by the library.
+ * We will handle the following packet types:
+ *    Modem Status
+ *    AT Command Response
+ *
+ * @param packet the packet to handle
+ * @param len the length of the packet
+ *
+ * @return 1 if we have handled the packet, 0 otherwise
+ */
+static int xbee_handle_packet(char* packet, int len)
+{
+
+	char command[3] = {1, 2, 3};
+	if (len <= 0) //this should not happend
+	{
+		WL_DEBUG_PRINT("Non-positive packet length.\r\n");
+		return 0;
+	}
+
+	switch ((unsigned char)packet[0]) //packet type
+	{
+		case XBEE_FRAME_STATUS:
+			xbee_handle_status(packet[1]);
+			return 1;
+		case XBEE_FRAME_AT_COMMAND_RESPONSE:
+			command[0] = packet[2];
+			command[1] = packet[3];
+			command[2] = 0;
+			xbee_handle_at_command_response(command, packet[4], packet + 5, len - 5);
+			return 1;
+	}
+	return 0;
+}
+
+/**
+ * Sets the personal area network id.
+ *
+ * @param id the new personal area network (PAN) id
+ **/
+int xbee_set_pan_id(int id)
+{
+	char s[3];
+	s[0] = (id >> 8) & 0xFF;
+	s[1] = id & 0xFF;
+	s[2] = 0;
+	xbee_pending_panID = id;
+	return xbee_send_modify_at_command("ID", s);
+}
+
+/**
+ * Get the PAN ID for the XBee.
+ *
+ * @return the personal area network id, or
+ * XBEE_PAN_DEFAULT if it has not yet been set.
+ **/
+unsigned int xbee_get_pan_id()
+{
+	return xbee_panID;
+}
+
+/**
+ * Set the channel the XBee is using.
+ *
+ * @param channel the channel the XBee will not use,
+ * between 0x0B and 0x1A
+ *
+ * @see xbee_get_channel
+ **/
+int xbee_set_channel(int channel)
+{
+	if (channel < 0x0B || channel > 0x1A)
+	{
+		WL_DEBUG_PRINT("Channel out of range.\r\n");
+		return -1;
+	}
+
+	char s[3];
+	s[0] = channel & 0xFF;
+	s[1] = 0;
+	xbee_pending_channel = channel;
+
+	return xbee_send_modify_at_command("CH", s);
+}
+
+/**
+ * Returns the channel which the XBee is currently using.
+ *
+ * @return the channel the XBee is using
+ *
+ * @see xbee_set_channel
+ **/
+int xbee_get_channel(void)
+{
+	return xbee_channel;
+}
+
+/**
+ * Get the 16-bit address of the XBee.
+ * This is used to specify who to send messages to
+ * and who messages are from.
+ *
+ * @return the 16-bit address of the XBee.
+ **/
+unsigned int xbee_get_address()
+{
+	return xbee_address;
+}
+
+#ifndef ROBOT
+void xbee_set_com_port(char* port)
+{
+	xbee_com_port = port;
+}
+#endif
Index: trunk/code/projects/unit_tests/test_usb.c
===================================================================
--- trunk/code/projects/unit_tests/test_usb.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_usb.c	(revision 1484)
@@ -0,0 +1,53 @@
+#include <dragonfly_lib.h>
+
+/*
+ * This function outputs to TeraTerm the following:
+ *
+ * Testing...
+ * 1, 2, 3
+ * 2A, 00F4, C8E1
+ * done.
+ * 
+ */
+
+int testusb(void) {
+	
+	usb_init();
+	usb_puts("usb turned on, test starting:\r\n");
+  
+	usb_puts("\r\n\n");
+	delay_ms(1000);
+	
+	// print some values to usb
+  usb_puts("Testing...\r\n");
+  usb_puti(1);
+  usb_putc(',');
+  usb_putc(' ');
+  usb_puti(2);
+  usb_putc(',');
+  usb_putc(' ');
+  usb_puti(3);
+  usb_putc('\r');
+  usb_putc('\n');
+  usb_puth8(0x2A);  
+  usb_putc(',');
+  usb_putc(' ');
+  usb_puth16(0xF4);
+  usb_putc(',');
+  usb_putc(' ');
+  usb_puth(0xC8E1);
+  usb_putc('\r');
+  usb_putc('\n');
+  usb_puts("enter an 'a':");  
+
+  // test getting a value from usb
+  if (usb_getc() == 'a')
+    usb_puts("\r\ngetc() works\r\n");
+  else
+    usb_puts("\r\ngetc() fails\r\n");
+  
+  usb_puts("done.\r\n\r\n");
+  
+  
+	return 0;
+}
\ No newline at end of file

Property changes on: trunk/code/projects/unit_tests/test_usb.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/unit_tests/test_wireless.c
===================================================================
--- trunk/code/projects/unit_tests/test_wireless.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_wireless.c	(revision 1484)
@@ -0,0 +1,114 @@
+/**
+ * Instructions:
+ *  - wait for both robots to show ORB 1 RED and ORB 2 GREEN
+ *  - press BUTTON 1 on robot to send first (ROBOT 1) - orbs should turn PURPLE
+ *  - press BUTTON 2 on robot to receive first (ROBOT 2) - orbs should turn ORANGE
+ *  - wait at least a second, then press BUTTON 1 on both robots SIMULTANEOUSLY
+ *  - ROBOT 2 orbs should cycle ORANGE to RED to BLUE
+ *  - then ROBOT 1 orbs should cycle PURPLE to RED to BLUE
+ *  - then orbs on both robots should turn GREEN
+ *  - test will reset to ORB 1 RED and ORB 2 CYAN
+ *  - test should take ~7 seconds
+ *
+ * Depends on:
+ *  - Orbs (Lights)
+ *  - Serial (for debugging)
+ **/
+
+#include <dragonfly_lib.h>
+#include <wl_basic.h>
+
+unsigned char* packet;
+int length;
+
+int testwireless(void) {
+    int count = 0;
+    int is_sender = 0;
+
+    wl_basic_init_default();
+    wl_set_channel(0x0E);
+
+    orb1_set_color(RED);
+    orb2_set_color(GREEN);
+    delay_ms(500);
+    while (count < 1) {
+        if (button1_click()) {
+            is_sender = 1;
+            orb_set_color(PURPLE);
+            count++;
+        }
+        if (button2_click()) {
+            is_sender = 0;
+            orb_set_color(ORANGE);
+            count++;
+        }
+    }
+    count = 0;
+
+    delay_ms(1000);
+
+    button1_wait();
+
+    delay_ms(500);
+
+    if (is_sender == 1) {
+        delay_ms(1000);
+        wl_basic_send_global_packet(1, "r", 2);
+        usb_puts("sent RED packet\r\n");
+        delay_ms(1000);
+        wl_basic_send_global_packet(1, "b", 2);
+        usb_puts("sent BLUE packet\r\n");
+        while(count < 2) {
+            packet = wl_basic_do_default(&length);
+            if (packet != 0) {
+                if (length > 0) {
+                    if (packet[0] == 'r') {
+                        orb_set_color(RED);
+                        usb_puts("received RED packet\r\n");
+                        count++;
+                    }
+                    else if (packet[0] == 'b') {
+                        orb_set_color(BLUE);
+                        usb_puts("received BLUE packet\r\n");
+                        count++;
+                    }
+                }
+            }
+        }
+    }
+    else {
+        while(count < 2) {
+            packet = wl_basic_do_default(&length);
+            if (packet != 0) {
+                if (length > 0) {
+                    if (packet[0] == 'r') {
+                        orb_set_color(RED);
+                        usb_puts("received RED packet\r\n");
+                        count++;
+                    }
+                    else if (packet[0] == 'b') {
+                        orb_set_color(BLUE);
+                        usb_puts("received BLUE packet\r\n");
+                        count++;
+                    }
+                }
+            }
+        }
+        delay_ms(1000);
+        wl_basic_send_global_packet(1, "r", 2);
+        usb_puts("sent RED packet\r\n");
+        delay_ms(1000);
+        wl_basic_send_global_packet(1, "b", 2);
+        usb_puts("sent BLUE packet\r\n");
+    }
+    delay_ms(1000);
+
+	wl_terminate();
+
+    orb_set_color(GREEN);
+
+    delay_ms(2000);
+
+    return 0;
+}
+
Index: trunk/code/projects/unit_tests/test_encoders.c
===================================================================
--- trunk/code/projects/unit_tests/test_encoders.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_encoders.c	(revision 1484)
@@ -0,0 +1,64 @@
+/**
+ * @file encoders unit test
+ */
+#include <dragonfly_lib.h>
+
+/**
+ * @brief Test encoders by outputting values to usb
+ *
+ * @test  Tester should start a program to read data from the robot via usb
+ *        (e.g. gtkterm). Turn on the robot on then turn each wheel manually.
+ *        Make sure the output on the screen makes sense.
+ *        Pressing button 1 resets total distance and time count
+ * @pre   Depends on serial and dio to work correctly
+ */
+
+int testencoders(void)
+{
+	int encoder_left,encoder_right;
+	int x_left, x_right;
+	int v_left, v_right;
+	int tc;
+	while(1) {
+		/* button1 is pressed */
+		if (button1_read()) {
+			/* reset dx and tc */
+			encoder_rst_dx(LEFT);
+			encoder_rst_dx(RIGHT);
+			encoder_rst_tc();
+		}
+
+		encoder_left = encoder_read(LEFT);
+		encoder_right = encoder_read(RIGHT);
+		usb_puts("Encoder values (left, right): ");
+		usb_puti(encoder_left); 
+		usb_puts(", ");
+		usb_puti(encoder_right); 
+		usb_puts("\n");
+
+		x_left = encoder_get_x(LEFT);
+		x_right = encoder_get_x(RIGHT);
+		usb_puts("Total Distance (left, right): ");
+		usb_puti(x_left);
+		usb_puts(", ");
+		usb_puti(x_right);
+		usb_puts("\n");
+
+		v_left = encoder_get_v(LEFT);
+		v_right = encoder_get_v(RIGHT);
+		usb_puts("Velocity (left, right): ");
+		usb_puti(v_left);
+		usb_puts(", ");
+		usb_puti(v_right);
+		usb_puts("\n");
+
+		tc = encoder_get_tc();
+		usb_puts("Time count: ");
+		usb_puti(tc);
+		usb_puts("\n\r");
+
+		delay_ms(500);
+	}
+	return 0;
+}
+

Property changes on: trunk/code/projects/unit_tests/test_encoders.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/unit_tests/test_dio.c
===================================================================
--- trunk/code/projects/unit_tests/test_dio.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_dio.c	(revision 1484)
@@ -0,0 +1,38 @@
+#include <dragonfly_lib.h>
+
+int testdio(void) {
+   	
+	//test waits
+	orb_set_color(WHITE);
+	delay_ms(1000);
+	orb_set_color(ORB_OFF);
+	button1_wait();
+	orb_set_color(WHITE);
+	delay_ms(1000);
+	orb_set_color(ORB_OFF);
+	button2_wait();
+	
+	//test clicks
+	orb_set_color(WHITE);
+	delay_ms(1000);
+	orb_set_color(ORB_OFF);
+	while(!button1_click()){;}
+	orb_set_color(WHITE);
+	delay_ms(1000);
+	orb_set_color(ORB_OFF);
+	while(!button2_click()){;}
+	
+	//test reads
+	orb_set_color(WHITE);
+	delay_ms(1000);
+	orb_set_color(ORB_OFF);
+	while(!button1_read()){;}
+	orb_set_color(WHITE);
+	delay_ms(1000);
+	orb_set_color(ORB_OFF);
+	while(!button2_read()){;}
+	orb_set_color(WHITE);
+	delay_ms(1000);
+	orb_set_color(ORB_OFF);
+    return 0;
+}
Index: trunk/code/projects/unit_tests/test_lights.c
===================================================================
--- trunk/code/projects/unit_tests/test_lights.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_lights.c	(revision 1484)
@@ -0,0 +1,362 @@
+#include <dragonfly_lib.h>
+
+
+	
+int test_lights(void) {
+	 int i=0;
+		
+	//usb_init();
+    usb_puts("usb turned on\n");
+    delay_ms(1000);	
+	
+/** Test RGB color setting (both orbs) **/
+	for(i=0;i<256;i++){
+		orb_set(i,0,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_set(0,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_set(0,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, two parameters with changing parameters (both orbs) **/
+	for(i=0;i<256;i++){
+		orb_set(i,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_set(0,i,i);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_set(i,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, all parameters with changing parameters (both orbs) **/		
+	for(i=0;i<256;i++){
+		orb_set(i,i,i);
+		delay_ms(10);
+	}
+		
+/** Test RGB color setting (orb1) **/
+	for(i=0;i<256;i++){
+		orb1_set(i,0,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb1_set(0,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb1_set(0,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, two parameters with changing parameters (orb1) **/
+	for(i=0;i<256;i++){
+		orb1_set(i,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb1_set(0,i,i);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb1_set(i,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, all parameters with changing parameters (orb1) **/		
+	for(i=0;i<256;i++){
+		orb1_set(i,i,i);
+		delay_ms(10);
+	}
+
+/** Test RGB color setting (orb2) **/
+	for(i=0;i<256;i++){
+		orb2_set(i,0,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb2_set(0,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb2_set(0,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, two parameters with changing parameters (orb2) **/
+	for(i=0;i<256;i++){
+		orb2_set(i,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb2_set(0,i,i);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb2_set(i,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, all parameters with changing parameters (orb2) **/		
+	for(i=0;i<256;i++){
+		orb2_set(i,i,i);
+		delay_ms(10);
+	}
+	
+/** Test RGB color setting (n=1) **/
+	for(i=0;i<256;i++){
+		orb_n_set(1,i,0,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_n_set(1,0,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_n_set(1,0,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, two parameters with two changing parameters (n=1) **/
+	for(i=0;i<256;i++){
+		orb_n_set(1,i,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_n_set(1,0,i,i);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_n_set(1,i,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, all parameters with two changing parameters (n=1) **/		
+	for(i=0;i<256;i++){
+		orb_n_set(1,i,i,i);
+		delay_ms(10);
+	}
+
+/** Test RGB color setting (n=2) **/
+	for(i=0;i<256;i++){
+		orb_n_set(2,i,0,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_n_set(2,0,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_n_set(2,0,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, two parameters with two changing parameters (n=2) **/
+	for(i=0;i<256;i++){
+		orb_n_set(2,i,i,0);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_n_set(2,0,i,i);
+		delay_ms(10);
+	}
+	for(i=0;i<256;i++){
+		orb_n_set(2,i,0,i);
+		delay_ms(10);
+	}
+		
+/** Test RBG color, all parameters with two changing parameters (n=2) **/		
+	for(i=0;i<256;i++){
+		orb_n_set(2,i,i,i);
+		delay_ms(10);
+	}
+
+/** Weird not even RGB color test for both orbs **/		
+	for(i=2;i<256;i++){
+		orbs_set (i,i-1,i-2,i-2,i-1,i);
+		delay_ms(10);
+	}
+
+/** Test all #define'd colors (both orbs) **/
+    orb_set_color(ORB_OFF);
+    delay_ms(1000);
+	orb_set_color(RED);
+    delay_ms(1000);
+    orb_set_color(ORANGE);
+    delay_ms(1000);
+    orb_set_color(YELLOW);
+    delay_ms(1000);
+	orb_set_color(LIME);
+    delay_ms(1000);
+    orb_set_color(GREEN);
+    delay_ms(1000);
+	orb_set_color(CYAN);
+    delay_ms(1000);
+    orb_set_color(BLUE);
+    delay_ms(1000);
+	orb_set_color(PINK);
+    delay_ms(1000);
+    orb_set_color(PURPLE);
+    delay_ms(1000);
+	orb_set_color(MAGENTA);
+    delay_ms(1000);
+	orb_set_color(WHITE);
+    delay_ms(1000);
+	orb_set_color(ORB_OFF);
+    delay_ms(1000);
+	
+/** Test all #define'd colors (orb1) **/
+    orb1_set_color(ORB_OFF);
+    delay_ms(1000);
+	orb1_set_color(RED);
+    delay_ms(1000);
+    orb1_set_color(ORANGE);
+    delay_ms(1000);
+    orb1_set_color(YELLOW);
+    delay_ms(1000);
+	orb1_set_color(LIME);
+    delay_ms(1000);
+    orb1_set_color(GREEN);
+    delay_ms(1000);
+	orb1_set_color(CYAN);
+    delay_ms(1000);
+    orb1_set_color(BLUE);
+    delay_ms(1000);
+	orb1_set_color(PINK);
+    delay_ms(1000);
+    orb1_set_color(PURPLE);
+    delay_ms(1000);
+	orb1_set_color(MAGENTA);
+    delay_ms(1000);
+	orb1_set_color(WHITE);
+    delay_ms(1000);
+	orb1_set_color(ORB_OFF);
+    delay_ms(1000);
+
+/** Test all #define'd colors (orb2) **/
+    orb2_set_color(ORB_OFF);
+    delay_ms(1000);
+	orb2_set_color(RED);
+    delay_ms(1000);
+    orb2_set_color(ORANGE);
+    delay_ms(1000);
+    orb2_set_color(YELLOW);
+    delay_ms(1000);
+	orb2_set_color(LIME);
+    delay_ms(1000);
+    orb2_set_color(GREEN);
+    delay_ms(1000);
+	orb2_set_color(CYAN);
+    delay_ms(1000);
+    orb2_set_color(BLUE);
+    delay_ms(1000);
+	orb2_set_color(PINK);
+    delay_ms(1000);
+    orb2_set_color(PURPLE);
+    delay_ms(1000);
+	orb2_set_color(MAGENTA);
+    delay_ms(1000);
+	orb2_set_color(WHITE);
+    delay_ms(1000);
+	orb2_set_color(ORB_OFF);
+    delay_ms(1000);
+	
+/** Test all #define'd colors (n=1) **/
+    orb_n_set_color(1,ORB_OFF);
+    delay_ms(1000);
+	orb_n_set_color(1,RED);
+    delay_ms(1000);
+    orb_n_set_color(1,ORANGE);
+    delay_ms(1000);
+    orb_n_set_color(1,YELLOW);
+    delay_ms(1000);
+	orb_n_set_color(1,LIME);
+    delay_ms(1000);
+    orb_n_set_color(1,GREEN);
+    delay_ms(1000);
+	orb_n_set_color(1,CYAN);
+    delay_ms(1000);
+    orb_n_set_color(1,BLUE);
+    delay_ms(1000);
+	orb_n_set_color(1,PINK);
+    delay_ms(1000);
+    orb_n_set_color(1,PURPLE);
+    delay_ms(1000);
+	orb_n_set_color(1,MAGENTA);
+    delay_ms(1000);
+	orb_n_set_color(1,WHITE);
+    delay_ms(1000);
+	orb_n_set_color(1,ORB_OFF);
+    delay_ms(1000);
+	
+/** Test all #define'd colors (n=2) **/
+    orb_n_set_color(2,ORB_OFF);
+    delay_ms(1000);
+	orb_n_set_color(2,RED);
+    delay_ms(1000);
+    orb_n_set_color(2,ORANGE);
+    delay_ms(1000);
+    orb_n_set_color(2,YELLOW);
+    delay_ms(1000);
+	orb_n_set_color(2,LIME);
+    delay_ms(1000);
+    orb_n_set_color(2,GREEN);
+    delay_ms(1000);
+	orb_n_set_color(2,CYAN);
+    delay_ms(1000);
+    orb_n_set_color(2,BLUE);
+    delay_ms(1000);
+	orb_n_set_color(2,PINK);
+    delay_ms(1000);
+    orb_n_set_color(2,PURPLE);
+    delay_ms(1000);
+	orb_n_set_color(2,MAGENTA);
+    delay_ms(1000);
+	orb_n_set_color(2,WHITE);
+    delay_ms(1000);
+	orb_n_set_color(2,ORB_OFF);
+    delay_ms(1000);
+	
+	/** Test all #define'd colors (both orbs) **/
+    orbs_set_color(ORB_OFF,ORB_OFF);
+    delay_ms(1000);
+	orbs_set_color(RED,RED);
+    delay_ms(1000);
+    orbs_set_color(ORANGE,ORANGE);
+    delay_ms(1000);
+    orbs_set_color(YELLOW,YELLOW);
+    delay_ms(1000);
+	orbs_set_color(LIME,LIME);
+    delay_ms(1000);
+    orbs_set_color(GREEN,GREEN);
+    delay_ms(1000);
+	orbs_set_color(CYAN,CYAN);
+    delay_ms(1000);
+    orbs_set_color(BLUE,BLUE);
+    delay_ms(1000);
+	orbs_set_color(PINK,PINK);
+    delay_ms(1000);
+    orbs_set_color(PURPLE,PURPLE);
+    delay_ms(1000);
+	orbs_set_color(MAGENTA,MAGENTA);
+    delay_ms(1000);
+	orbs_set_color(WHITE,WHITE);
+    delay_ms(1000);
+	orbs_set_color(ORB_OFF,ORB_OFF);
+    delay_ms(1000);
+	
+	orbs_set_color(RED,GREEN);
+	delay_ms(3000);
+	
+    return 0;
+}
+
+

Property changes on: trunk/code/projects/unit_tests/test_lights.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/unit_tests/test_analog.c
===================================================================
--- trunk/code/projects/unit_tests/test_analog.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_analog.c	(revision 1484)
@@ -0,0 +1,44 @@
+#include <dragonfly_lib.h>
+
+/*
+ * This function outputs to TeraTerm a table which displays the values currently
+ * stored in the analog table
+ */
+
+int testanalog(void) {
+
+	
+	usb_init();
+	usb_puts("usb turned on\r\n");
+	
+	range_init();
+	usb_puts("rangefinders initialized\r\n");
+	
+	usb_puts("\r\n\n");
+	delay_ms(1000);
+	
+	while (1) {
+	
+		for (int i = 0; i < 20; i++) {
+		
+			usb_puts("\r\n");
+		
+		}
+		
+		usb_puts("port# |\tvalue\r\n");
+		
+		for (int j = 1; j < 16; j++) {
+		
+			usb_puti(j);
+			usb_puts("\t");
+			usb_puti(analog10(j));
+			usb_puts("\r\n");
+		
+		}
+		
+		delay_ms(575);
+		
+	}
+	
+	return 0;
+}
\ No newline at end of file

Property changes on: trunk/code/projects/unit_tests/test_analog.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/unit_tests/test_lcd.c
===================================================================
--- trunk/code/projects/unit_tests/test_lcd.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_lcd.c	(revision 1484)
@@ -0,0 +1,45 @@
+#include <dragonfly_lib.h>
+
+
+/**
+ * LCD Rules
+ * - when changing put formats (from string to int or back)
+ *   the screen will clear and start printing at beginning
+ * - when outputting again in same format, an append op is performed
+ * - text wraps to next line, and to beginning
+ *    - when wrapping to beginning, screen is not cleared
+ * - puti only does signed ints
+ */
+
+int testlcd(void) {
+  usb_init();
+	usb_puts("usb turned on\n");
+  lcd_init();
+  usb_puts("lcd turned on\n");
+  lcd_clear_screen();
+  usb_puts("lcd screen cleared\n");
+  delay_ms(1000);
+  
+  // start testing lcd
+  lcd_puts("this is a test, a really long test");
+  lcd_puts("this is a test, a really long test. this is a test, a really long test");
+  usb_puts("test writing string to lcd: 'this is a test, a really long test'\n");
+  delay_ms(10000);
+  
+  /*lcd_clear_screen();
+  usb_puts("lcd screen cleared\n");
+  lcd_puti(1000000);
+  lcd_puti(100000);
+  lcd_puti(10000);
+  lcd_puti(1000);
+  lcd_puti(100);
+  lcd_puti(10);
+  lcd_puti(1);
+  usb_puts("test writing int to lcd: 1000000,100000, 10000, 1000, 100, 10, 1\n");
+  delay_ms(10000);
+  */
+  // end testing lcd
+	return 0;
+}
+
+

Property changes on: trunk/code/projects/unit_tests/test_lcd.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
Index: trunk/code/projects/unit_tests/test_eeprom.c
===================================================================
--- trunk/code/projects/unit_tests/test_eeprom.c	(nonexistent)
+++ trunk/code/projects/unit_tests/test_eeprom.c	(revision 1484)
@@ -0,0 +1,89 @@
+/** @file testeeprom.c
+ *  @brief tests the eeprom code
+ *
+ *  stores and retrives a value, then sets it back to what it was
+ */
+#include <dragonfly_lib.h>
+#include "eeprom.h"
+
+#define ADDR 0
+
+int testeeprom(void) {
+    unsigned char data, data2;
+    int ret;
+    int worked=1;
+
+    
+    /* read whats there */
+    ret = eeprom_get_byte(ADDR, &data);
+    
+    if(ret) {
+        usb_puts("Error reading intial value! return code: ");
+        usb_puti(ret);
+        usb_puts(" data: ");
+        usb_puti(data);
+        usb_puts("\r\n");
+        worked=0;
+    }
+    else {
+        usb_puts("data was: ");
+        usb_puti(data);
+        usb_puts("\r\n");
+    }
+    
+    /* write something new */
+    
+    ret = eeprom_put_byte(ADDR, 123);
+    if(ret) {
+        usb_puts("Error writing data! return code: ");
+        usb_puti(ret);
+        usb_puts("\r\n");
+        worked=0;
+    }
+    else {
+        usb_puts("wrote 123\r\n");
+    }
+    
+    
+    /* check if tis really there */
+    
+    ret = eeprom_get_byte(ADDR, &data2);
+    
+    if(ret) {
+        usb_puts("Error reading second value! return code: ");
+        usb_puti(ret);
+        usb_puts(" data: ");
+        usb_puti(data2);
+        usb_puts("\r\n");
+        worked=0;
+    }
+    else {
+        if(data2==123) {
+            usb_puts("data write and re-read worked!\r\n");
+        }
+        else {
+            usb_puts("data re-read returned 0 but data was ");
+            usb_puti(data2);
+            usb_puts("\r\n");
+            worked=0;
+        }
+    }
+    
+    
+    /* restore old value */
+    
+    ret = eeprom_put_byte(ADDR, 123);
+    if(ret) {
+        usb_puts("Error writing data the second time! return code: ");
+        usb_puti(ret);
+        usb_puts("\r\n");
+        worked=0;
+    }
+    else {
+        usb_puts("re-wrote original data: ");
+        usb_puti(data);
+        usb_puts("\r\n");
+    }
+    
+    return worked;
+}

Property changes on: trunk/code/projects/unit_tests/test_eeprom.c
___________________________________________________________________
Added: svn:mergeinfo
## -0,0 +0,0 ##
