X-CTU

Digi, the manufacturer of zigbees, provides a useful tool for configuring and testing the units.  One feature of this tool is a “Range Test”.  The test is based on the concept of a loop back.  A certain packet is sent from the local zigbee to a remote zigbee.  The remote zigbee then echos the packet back.  By comparing the packet sent to the packet received errors can be detected.  The inclusion of an RSSI measurement makes the tool even more useful.

However, when running the tool with the Ardupilot Mega (v1.02) code running a range test the results returned where abysmal.  An investigation into the code revealed the code shown below.  The critical section is shown in bold where the author choose to copy the default packet into the code and simply transmit it every quarter of a second.  The abysmal results from running the range test were caused by the radios being configured at a different baud rate than the author had assumed.  Additionally, when running the rssi test a delay was introduced which resulted in the tool seeing terrible packet corruption.

test_xbee(uint8_t argc, const Menu::arg *argv)
{
	...
	while(1){
		delay(250);
		// Timeout set high enough for X-CTU RSSI Calc over XBee @ 115200
		Serial3.printf_P(PSTR("0123456789:;<=>?@ABCDEFGHIJKLMNO"));
		//Serial.print("X");
		// Default 32bit data from X-CTU Range Test
		if(Serial.available() > 0){
			return (0);
		}
	}
}

Shown here is a simple implementation of an actual loop back.  This change has been adopted by the Ardupilot project and should be available in the next release.

test_xbee(uint8_t argc, const Menu::arg *argv)
{
	...
	while(1){
                int incomingByte;
                if(Serial3.available()>0){
                      incomingByte = Serial3.read();
                      Serial3.print(incomingByte,byte);
                }
		if(Serial.available() > 0){
			return (0);
		}
	}
}