Problem with two way XBee communication

Hi! I have some problem getting the wireless communication to work.

I have an Arduino Uno trying to controll a quadcopter with a Wireless SD Shield on it. I am using two Series 1 XBees one with an usb adapter. A C# program is used to receive and transmit bytes.

The actual problem is that the Arduino reveives the data (e.g. throttle) and responds quickly but we can't read anything (e.g. gyro) while on usb everything works really good.

I was playing with the XBee settings. The current settings are:

baud rate: 57600 XBee 1: PAN ID: 1234 MY: 1 DL: 2 XBee 2: PAN ID: 1234 MY: 2 DL: 1

While changing the codes and settings there was an other scenario when we could receive data flawlessly but the throttle response was awful.

Thanks in advance.

The actual problem is that the Arduino reveives the data (e.g. throttle) and responds quickly but we can't read anything (e.g. gyro) while on usb everything works really good.

What happens to the RX and TX lights on the Arduino? Which wireless SD shield? There are several. Which pins is the XBee connected to? Where is the Arduino code? Where is the C# code?

I have C# code that talks to the Arduino flawlessly and fast. If you can't, there is something wrong with the code on one end or the other.

The Wireless SD Shield is this one: http://arduino.cc/en/Main/ArduinoWirelessShield The RX and TX leds are both blinking but the TX seems to be instable. The RSSI led is also on. I attach the files.

Thanks.

Sorry the files are here.

final.txt (5.03 KB)

Form1.txt (5.42 KB)

The shield you have has a switch. Which position is the switch in?

                    serialPort.Read(read, 0, 8);

The read() method returns a value. Why are you ignoring it?

Reading serial data happens on the read thread. Under what circumstance is the serial_read() function actually called?

Spinning in that function until one byte arrives, and then expecting all 8 bytes to be available is unrealistic.

Your Arduino code is WAY too complex. Shitcan 90% of the code, and deal ONLY with reading and sending serial data. ONLY after that works should you add code to do anything with the data.