Not transmitting to Xbee transmitter


hi have following code uploaded ardupilot mega 2560, when connect serial cable directly able receive data. when try transmit via xbee no data appears.

the xbees have been tested work software, baud rate set 57600.

am missing out something?

code: [select]
#include <string.h>
#include <ctype.h>
#include <servo.h>
char data; //data check see if receive command servo

int bytegps=-1;
char linea[300] = ""; //to fill gps data
int conta=0;
int loopcount = 0;
char comandogpr[7] = "$gprmc"; //setup header
char comandogpa[7] = "$gpgga"; //setup header
int bien=0; //check if gprmc found
int bien2=0; //check if gpgga found
void setup()
{

serial.begin(19200); // set tx , rx per xbee pin. tx 0
serial1.begin(4800); // gps fixes.
for (int i=0;i<300;i++)
{ // initialize buffer received data
linea[i]=' ';
}
}
void loop()
{
bytegps=serial1.read();
if (bytegps == -1)
{ // see if port empty yet
delay(100);
}
else
{
linea[conta]=bytegps; // if there serial2 port data, put in buffer
conta++;
//serial.println(bytegps, byte);
if (bytegps==13)
{ // if received byte = 13, end of transmission
//for (i=0,)
bien2=0;
for (int i=1;i<7;i++)
{ // verifies if received command starts $gpr
//serial.print(linea[i]);
//serial.print(",");
//serial.println(comandogpr[i-1]);
if (linea[i]==comandogpr[i-1])
{
bien++;
}
if (linea[i]==comandogpa[i-1])
{
bien2++;
}
}
if (bien == 6) //gprmc found
{
for (int i=0; i<conta;i++)
{
serial.print(linea[i]);
}
}
if (bien2 == 6) //gpgga found
{
for (int i=0; i<conta;i++)
{
serial.print(linea[i]);
}
//serial.println("//////////////////////////////////////");
}
conta=0; // reset buffer
for (int i=0;i<300;i++)
{
linea[i]=' ';
}
}
}

quote
am missing out something?

information on how xbee connect mega.
information how other xbee being used.
information whether lights flash on xbee shield.
information whether lights flash on receiver.


Arduino Forum > Using Arduino > Programming Questions > Not transmitting to Xbee transmitter


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial