Index: trunk/code/projects/colonet/ColonetServer/colonet_wireless.cpp
===================================================================
--- trunk/code/projects/colonet/ColonetServer/colonet_wireless.cpp	(revision 396)
+++ trunk/code/projects/colonet/ColonetServer/colonet_wireless.cpp	(revision 397)
@@ -17,8 +17,8 @@
 #include <wireless.h> // Colonet wireless library.
 #include <wl_token_ring.h>
 
-#include "colonet_defs.h"
-#include "colonet_wireless.h"
+#include <colonet_defs.h>
+#include <colonet_wireless.h>
 
 /******************************* Definitions *********************************/
 
@@ -48,7 +48,7 @@
 static int log_packet(unsigned char* packet, int len);
 
 /**************************** Public functions *******************************/
-void colonet_wl_init(char* wl_port_, MsgHandlerFunction message_handler_, char* log_filename_) {
+int colonet_wl_init(char* wl_port_, MsgHandlerFunction message_handler_, char* log_filename_) {
   if (log_filename_ != NULL) {
     logging_enabled = true;
     strcpy(log_filename, log_filename_);
@@ -65,8 +65,13 @@
   wl_token_ring_register();
 
   printf("Joining token ring...\n");
-  wl_token_ring_join();
+  if (wl_token_ring_join() != 0) {
+    fprintf(stderr, "Failed to join token ring.\n");
+    return -1;
+  }
   printf("Joined token ring.\n");
+
+  return 0;
 }
 
 void colonet_wl_kill_listener_thread() {
Index: trunk/code/projects/colonet/ColonetServer/Main.cpp
===================================================================
--- trunk/code/projects/colonet/ColonetServer/Main.cpp	(revision 396)
+++ trunk/code/projects/colonet/ColonetServer/Main.cpp	(revision 397)
@@ -18,6 +18,7 @@
   }
 
   if (colonet_server.start_listening() < 0) {
+    fprintf(stderr, "ColonetServer.start_listening failed.\n");
     return -1;
   }
 
Index: trunk/code/projects/colonet/ColonetServer/includes/colonet_wireless.h
===================================================================
--- trunk/code/projects/colonet/ColonetServer/includes/colonet_wireless.h	(revision 396)
+++ trunk/code/projects/colonet/ColonetServer/includes/colonet_wireless.h	(revision 397)
@@ -23,7 +23,7 @@
  *
  * @return new ColonetWireless object
  */
-void colonet_wl_init(char* wl_port, MsgHandlerFunction message_handler_, char* log_filename_);
+int colonet_wl_init(char* wl_port, MsgHandlerFunction message_handler_, char* log_filename_);
 
 /** @brief Spawns a thread which reads data from the hardware interface
  * with the colony (either a dongle or a robot programmed to relay data)
Index: trunk/code/projects/colonet/ColonetServer/ColonetServer.cpp
===================================================================
--- trunk/code/projects/colonet/ColonetServer/ColonetServer.cpp	(revision 396)
+++ trunk/code/projects/colonet/ColonetServer/ColonetServer.cpp	(revision 397)
@@ -191,7 +191,10 @@
     printf("Logging disabled.\n");
   }
 
-  colonet_wl_init(optionsG.wireless_port, wirelessMessageHandler, log_filename);
+  if (colonet_wl_init(optionsG.wireless_port, wirelessMessageHandler, log_filename) != 0) {
+    fprintf(stderr, "ERROR - colonet_wl_init failed.\n");
+    return -1;
+  }
 
   if (colonet_wl_run_listener_thread()) {
     fprintf(stderr, "%s: colonet_wl_run_listener_thread failed.\n", __FUNCTION__);
Index: trunk/code/projects/colonet/ColonetServer/options.c
===================================================================
--- trunk/code/projects/colonet/ColonetServer/options.c	(revision 396)
+++ trunk/code/projects/colonet/ColonetServer/options.c	(revision 397)
@@ -17,7 +17,7 @@
 
 #include <colonet_defs.h>
 
-#include "includes/options.h"
+#include <options.h>
 
 ColonetServerOptionsT optionsG;
 
Index: trunk/code/projects/colonet/README
===================================================================
--- trunk/code/projects/colonet/README	(revision 396)
+++ trunk/code/projects/colonet/README	(revision 397)
@@ -12,9 +12,8 @@
 
 Part II - Server setup.
   1) Go to colony/trunk/code/projects/libwireless/lib and run "make colonet".
-  2) Go to colony/trunk/code/projects/colonet/lib/colonet_wireless and run "make".
-  3) Go to colony/trunk/code/projects/colonet/ColonetServer and run "make".
-  4) In the same directory, run "./ColonetServer".
+  2) Go to colony/trunk/code/projects/colonet/ColonetServer and run "make".
+  3) In the same directory, run "./ColonetServer".
   Now the server is ready.
 
 Part III - Client (GUI) setup.
@@ -30,4 +29,3 @@
 "Failed to write to xbee, error 9."
 The Xbee is not being recognized by the computer (assuming it is plugged in).  Try unplugging it and plugging it in
 again.
-
Index: trunk/code/projects/libwireless/lib/wl_token_ring.c
===================================================================
--- trunk/code/projects/libwireless/lib/wl_token_ring.c	(revision 396)
+++ trunk/code/projects/libwireless/lib/wl_token_ring.c	(revision 397)
@@ -1,6 +1,6 @@
 /**
  * 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
@@ -9,10 +9,10 @@
  * 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
@@ -146,7 +146,7 @@
 		WL_DEBUG_PRINT(".\r\n");
 		return;
 	}
-	
+
 	sensorMatrix = sensor_matrix_create();
 	//add ourselves to the sensor matrix
 	sensor_matrix_set_in_ring(sensorMatrix, wl_get_xbee_id(), 0);
@@ -164,7 +164,7 @@
 
 /**
  * Sets the functions that are called when the BOM ought to be
- * turned on or off. This could be used for things such as 
+ * turned on or off. This could be used for things such as
  * charging stations, which have multiple BOMs.
  *
  * @param on_function the function to be called when the BOM
@@ -209,7 +209,7 @@
 			wl_token_next_robot = -1;
 			deathDelay = DEATH_DELAY;
 		}
-		
+
 		// we may have been dropped from the ring when this is received
 		if (ringState == MEMBER)
 			wl_token_pass_token();
@@ -247,7 +247,7 @@
 
 /**
  * Called when the XBee tells us if a packet we sent has been received.
- * 
+ *
  * @param frame the frame number assigned when the packet was sent
  * @param received 1 if the packet was received, 0 otherwise
  **/
@@ -300,13 +300,16 @@
  * if no token ring exists. The token ring uses global and robot to robot
  * packets, and does not rely on any PAN.
  **/
-void wl_token_ring_join()
+int wl_token_ring_join()
 {
 	WL_DEBUG_PRINT("Joining the token ring.\r\n");
 	ringState = JOINING;
 	joinDelay = DEATH_DELAY * 2;
-	wl_send_global_packet(WL_TOKEN_RING_GROUP, WL_TOKEN_JOIN,
-		NULL, 0, 0);
+	if (wl_send_global_packet(WL_TOKEN_RING_GROUP, WL_TOKEN_JOIN, NULL, 0, 0) != 0) {
+		return -1;
+	}
+
+	return 0;
 }
 
 /**
@@ -338,7 +341,7 @@
 
 /**
  * Returns the BOM reading we have for robot dest.
- * 
+ *
  * @param dest the robot whose relative location is returned
  *
  * @return a BOM reading from us to robot dest, in the range
@@ -386,7 +389,7 @@
 	{
 		if (i == source)
 			continue;
-		
+
 		//set the sensor information we receive
 		if (j < sensorDataLength / 2 && sensorData[2 * j] == i)
 		{
@@ -419,11 +422,11 @@
 			{
 				ringState = NONMEMBER;
 				wl_token_ring_join();
-				
+
 				WL_DEBUG_PRINT("We have been removed from the ring ");
 				WL_DEBUG_PRINT("and are rejoining.\r\n");
 			}
-			
+
 			//the person who accepted us is dead... let's ask again
 			if (i == acceptor)
 			{
@@ -437,9 +440,9 @@
 	}
 
 	wl_token_next_robot = nextRobot;
-	
+
 	deathDelay = get_token_distance(wl_get_xbee_id(), nextRobot) * DEATH_DELAY;
-	
+
 	//we have the token
 	if (wl_token_next_robot == wl_get_xbee_id())
 		wl_token_get_token();
@@ -520,7 +523,7 @@
 			buf[2*j + 2] = sensor_matrix_get_reading(sensorMatrix, wl_get_xbee_id(), i);
 			j++;
 		}
-	
+
 	WL_DEBUG_PRINT("Passing the token to robot ");
 	WL_DEBUG_PRINT_INT(buf[0]);
 	WL_DEBUG_PRINT(".\r\n");
@@ -544,10 +547,10 @@
 	WL_DEBUG_PRINT("Robot ");
 	WL_DEBUG_PRINT_INT(source);
 	WL_DEBUG_PRINT(" has flashed its bom.\r\n");
-	
+
 	bom_on_count = 0;
 
-	sensor_matrix_set_reading(sensorMatrix, wl_get_xbee_id(), 
+	sensor_matrix_set_reading(sensorMatrix, wl_get_xbee_id(),
 		source, get_max_bom_function());
 }
 
@@ -555,7 +558,7 @@
  * This method is called when we receive the token. Upon receiving
  * the token, we must send a BOM_ON packet, flash the BOM, and send
  * the token to the next robot.
- * 
+ *
  * If there is a pending request for the token, this is processed first.
  **/
 void wl_token_get_token()
@@ -579,7 +582,7 @@
 		}
 		return;
 	}
-	
+
 	WL_DEBUG_PRINT("Our BOM has been flashed.\r\n");
 	wl_send_global_packet(WL_TOKEN_RING_GROUP, WL_TOKEN_BOM_ON,
 		NULL, 0, 0);
@@ -589,13 +592,13 @@
 	delay_ms(BOM_DELAY);
 	#endif
 	bom_off_function();
-	
+
 	if (!sensor_matrix_get_in_ring(sensorMatrix, wl_get_xbee_id()))
 	{
 		WL_DEBUG_PRINT("Removed from sensor matrix while flashing BOM.\r\n");
 		return;
 	}
-	
+
 	wl_token_pass_token();
 }
 
@@ -622,7 +625,7 @@
 	//we can only accept one request at a time
 	if (accepted != -1)
 		return;
-	
+
 	//check if we are the preceding robot in the token ring
 	int i = source - 1;
 	while (1)
@@ -642,7 +645,7 @@
 	accepted = source;
 	wl_send_robot_to_robot_global_packet(WL_TOKEN_RING_GROUP, WL_TOKEN_JOIN_ACCEPT,
 		NULL, 0, source, TOKEN_JOIN_ACCEPT_FRAME);
-	
+
 	WL_DEBUG_PRINT("Accepting robot ");
 	WL_DEBUG_PRINT_INT(source);
 	WL_DEBUG_PRINT(" into the token ring.\r\n");
Index: trunk/code/projects/libwireless/lib/wireless.h
===================================================================
--- trunk/code/projects/libwireless/lib/wireless.h	(revision 396)
+++ trunk/code/projects/libwireless/lib/wireless.h	(revision 397)
@@ -135,8 +135,7 @@
 void wl_send_robot_to_robot_packet(char group, char type,
 		char* data, int len, int dest, char frame);
 /**@brief Send a packet to all robots **/
-void wl_send_global_packet(char group, char type,
-		char* data, int len, char frame);
+int wl_send_global_packet(char group, char type, char* data, int len, char frame);
 /**@brief Send a packet to all robots in our PAN **/
 void wl_send_pan_packet(char group, char type,
 		char* data, int len, char frame);
Index: trunk/code/projects/libwireless/lib/xbee.c
===================================================================
--- trunk/code/projects/libwireless/lib/xbee.c	(revision 396)
+++ trunk/code/projects/libwireless/lib/xbee.c	(revision 397)
@@ -69,8 +69,8 @@
 /*Internal Function Prototypes*/
 
 /*I/O Functions*/
-void xbee_send(char* buf, int size);
-void xbee_send_string(char* c);
+static int xbee_send(char* buf, int size);
+static void xbee_send_string(char* c);
 
 #ifndef ROBOT
 void xbee_read(char* buf, int size);
@@ -89,8 +89,7 @@
 /*API Mode Functions*/
 
 int xbee_handle_packet(char* packet, int len);
-void xbee_handle_at_command_response(char* command, char result,
-	char* extra, int extraLen);
+void xbee_handle_at_command_response(char* command, char result, char* extra, int extraLen);
 void xbee_handle_status(char status);
 int xbee_verify_checksum(char* packet, int len);
 char xbee_compute_checksum(char* packet, int len);
@@ -291,7 +290,7 @@
  * @param buf the buffer of data to send
  * @param size the number of bytes to send
  **/
-void xbee_send(char* buf, int size)
+int xbee_send(char* buf, int size)
 {
 	#ifdef ROBOT
 	int i;
@@ -301,7 +300,7 @@
 	int ret = write(xbee_stream, buf, size);
 	//success
 	if (ret == size)
-		return;
+		return 0;
 	if (ret == -1)
 	{
 		//interrupted by system signal, probably timer interrupt.
@@ -308,16 +307,17 @@
 		//just try again
 		if (errno == 4)
 		{
-			xbee_send(buf, size);
-			return;
+			return xbee_send(buf, size);
 		}
 		printf("Failed to write to xbee, error %i.\r\n", errno);
-		return;
+		return -1;
 	}
 
 	//write was interrupted after writing ret bytes
 	xbee_send(buf + ret, size - ret);
 	#endif
+
+	return 0;
 }
 
 /**
@@ -529,8 +529,7 @@
  * the XBee alerts us as to whether or not our message
  * was received.
  **/
-void xbee_send_packet(char* packet, int len, int dest,
-	char options, char frame)
+int xbee_send_packet(char* packet, int len, int dest, char options, char frame)
 {
 	char buf[5];
 	char prefix[3];
@@ -540,7 +539,7 @@
 	if (len > 100)
 	{
 		WL_DEBUG_PRINT("Packet is too large.\r\n");
-		return;
+		return -1;
 	}
 
 	//data for sending request
@@ -560,10 +559,24 @@
 	for (i = 0; i < len; i++)
 		checksum += (unsigned char)packet[i];
 	checksum = 0xFF - checksum;
-	xbee_send(prefix, 3);
-	xbee_send(buf, 5);
-	xbee_send(packet, len);
-	xbee_send((char*)&checksum, 1);
+
+	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;
 }
 
 /**
Index: trunk/code/projects/libwireless/lib/wl_token_ring.h
===================================================================
--- trunk/code/projects/libwireless/lib/wl_token_ring.h	(revision 396)
+++ trunk/code/projects/libwireless/lib/wl_token_ring.h	(revision 397)
@@ -55,7 +55,7 @@
 		void (*off_function) (void), int (*max_bom_function) (void));
 
 /**@brief Join the token ring **/
-void wl_token_ring_join(void);
+int wl_token_ring_join(void);
 /**@brief Leave the token ring **/
 void wl_token_ring_leave(void);
 
Index: trunk/code/projects/libwireless/lib/xbee.h
===================================================================
--- trunk/code/projects/libwireless/lib/xbee.h	(revision 396)
+++ trunk/code/projects/libwireless/lib/xbee.h	(revision 397)
@@ -80,8 +80,7 @@
 /**@brief Get a packet from the XBee **/
 int xbee_get_packet(unsigned char* packet);
 /**@brief Send a packet to the XBee **/
-void xbee_send_packet(char* packet, int len, int dest,
-	char options, char frame);
+int xbee_send_packet(char* packet, int len, int dest, char options, char frame);
 /**@brief Set the PAN ID for the XBee **/
 void xbee_set_pan_id(int id);
 /**@brief Get the XBee's PAN ID **/
Index: trunk/code/projects/libwireless/lib/wireless.c
===================================================================
--- trunk/code/projects/libwireless/lib/wireless.c	(revision 396)
+++ trunk/code/projects/libwireless/lib/wireless.c	(revision 397)
@@ -55,8 +55,7 @@
 
 //Note: the actual frame sent has group as the first four bits and
 //frame as the last four.
-void wl_send_packet(char group, char type, char* data, int len,
-					int dest, char options, char frame);
+int wl_send_packet(char group, char type, char* data, int len, int dest, char options, char frame);
 
 /*Data Members*/
 
@@ -261,11 +260,9 @@
  * @param len the packet length in bytes
  * @param frame the frame number to see with a TX_STATUS response
  **/
-void wl_send_global_packet(char group, char type,
-		char* data, int len, char frame)
+int wl_send_global_packet(char group, char type, char* data, int len, char frame)
 {
-	wl_send_packet(group, type, data, len, XBEE_BROADCAST,
-			XBEE_OPTIONS_BROADCAST_ALL_PANS, frame);
+	return wl_send_packet(group, type, data, len, XBEE_BROADCAST, XBEE_OPTIONS_BROADCAST_ALL_PANS, frame);
 }
 
 /**
@@ -295,18 +292,19 @@
  * @param options the options for sending the packet
  * @param frame the frame number to see with a TX_STATUS response
  **/
-void wl_send_packet(char group, char type, char* data, int len,
-					int dest, char options, char frame)
+int wl_send_packet(char group, char type, char* data, int len, int dest, char options, char frame)
 {
 	char buf[128];
 	int i;
 	if (frame != 0)
 		frame = (frame & 0x0F) | ((group & 0x0F) << 4);
+
 	buf[0] = group;
 	buf[1] = type;
 	for (i = 0; i < len; i++)
 		buf[2 + i] = data[i];
-	xbee_send_packet(buf, len + 2, dest, options, frame);
+
+	return xbee_send_packet(buf, len + 2, dest, options, frame);
 }
 
 /**
