Programmable XBee Problem (troubleshooting basic serial communications)

Wireless Mesh Configuration
[ul]PC <-> XB24-ZB Zigbee Coordinator API
Cerberus <-> XBP24BZ7 Zigbee Router API
Cerberus <-> XBP24BZ7 Zigbee Router API
Cerberus <-> XBP24BZ7 Zigbee Router API[/ul]

API: XBeeClient http://xbeeclient.codeplex.com/

In my ignorance I purchased [em]XBP24BZ7 [/em]XBee Modules that are programmable and thus equipped with a Freescale processor that is “in-charge”. In order to even set the modules up in X-CTU, I have to put the Freescale processor in BYPASS mode. This is accomplished by entering “\n\r\n\r\n\rB\n\r” in the terminal window. After being placed in BYPASS mode, the modules behave as normal non-programmable modules.

I have been working on getting the Cerberus to communicate with the XBee Modules but I can’t seem to get it to work. My current theory is that I can’t get the module placed into BYPASS mode but that isn’t my only problem. If I send “\n\r\n\r\n” to the serial port, like I do in X-CTU terminal, the Cerberus should get back the Freescale menu but it does not or the receive events are not firing.

Conclusion: Basic serial communications seems to be an issue.

Does anyone have any suggestions for me?

NOTE: My end goal is to help others with the programmable XBee Modules by proposing additional code in XBeeClient library to handle these devices.

[title]My test code:[/title]

        
void ProgramStarted()
{
	Debug.Print("Program Started");

	Debug.Print("Give Cerberus time to initialize...");
	Thread.Sleep(2000);

	Debug.Print("Attach a serial interface to the XBee on socket 6.");
	GT.Socket socket6 = GT.Socket.GetSocket(6, false, null, null);
	GT.Interfaces.Serial serial 
		= new Serial(socket6, 9600, 
			Serial.SerialParity.None, 
			Serial.SerialStopBits.One, 
			8, 
			Serial.HardwareFlowControl.NotRequired, 
			null);

	Debug.Print("Attach event handlers.");
	serial.DataReceived += new Serial.DataReceivedEventHandler(serial_DataReceived);
	serial.LineReceived += new Serial.LineReceivedEventHandler(serial_LineReceived);

	Debug.Print("Open the serial port.");
	serial.Open();
	Thread.Sleep(1000);

	Debug.Print("Sending serial data...");
	serial.Write("\r\n\r\n\r\n\r\n");
            
	Debug.Print("Wait for serial response...");
}

void serial_LineReceived(Serial sender, string line)
{
	Debug.Print("serial_LineReceived(): " + line);
}

void serial_DataReceived(Serial sender, System.IO.Ports.SerialData data)
{
	Debug.Print("serial_DataReceived(): " + data.ToString());
}

[title]Visual Studio Output Window for Above Code[/title]
Using mainboard GHI Electronics FEZCerberus version 1.1
Program Started
Give Cerberus Time to Initialize…
Attach a serial interface to the XBee on socket 6.
Attach a event handlers.
Open the serial port.
Sending serial data…
Wait for serial response…
The thread ‘’ (0x3) has exited with code 0 (0x0).

[title]See Attached Images [/title]
The attached images show the same action accomplished in X-CTU that I am attempting in my code. The “PC Settings” image shows the serial configuration (9600, 8, N, 1) and the “Terminal” image demonstrates what happens when I send a few Enter Key Presses to the terminal.

Sent:

Received:

B-Bypass Mode
F-Update App
T-Timeout
V-BL Version
A-App Version
R-Reset

UPDATE:

I finally hooked up to a logic analyzer. The problem appears to be that the XBP24BZ7 XBee Module in Freescale menu mode is expecting the RTS signal to go low when accepting the ‘/r’. I had the XBee Module plugged into Cerberus Socket 6 (US) that apparently does not support setting the RTS line low. I moved the XBee Module to Cerberus Slot 2 (AIKU) that does.

When running the code below and monitoring at pin 2 (DOUT), 3 (DIN), and 16 (RTS) of the XBee with the logic analyzer.

  1. RTS is set low
  2. DIN gets a ‘\r’ from the Cerberus
  3. DOUT gets a short stream of data from the XBEE (i.e. the Freescale menu).

NEW Problem: event “serial.DataReceived” is never fired.


void ProgramStarted()
        {
            Debug.Print("Attach a serial interface to the XBee on socket 6.");
            GT.Socket socket2 = GT.Socket.GetSocket(2, false, null, null);
            GT.Interfaces.Serial serial
                = new Serial(socket2, 9600,
                    Serial.SerialParity.None,
                    Serial.SerialStopBits.One,
                    8,
                    Serial.HardwareFlowControl.NotRequired,
                    null);

            Debug.Print("Open the serial port.");
            serial.Open();
            Thread.Sleep(1000);

            Debug.Print("Attach a event handlers.");
            serial.DataReceived += new Serial.DataReceivedEventHandler(serial_DataReceived);
            serial.LineReceived += new Serial.LineReceivedEventHandler(serial_LineReceived);

            Debug.Print("Sending serial data...");
            serial.Write("\r");
            Debug.Print("Wait for serial response...");
            Thread.Sleep(10000);
}

UPDATE: I have everything working with “GT.Interfaces.Serial serial”. Now I just need to implement it in XBeeClient library.