sending xbee data to terminal
solder_fumes
Posts: 18
I don't know that my problem is as much as with the xbee as with my coding, so I'm posting it here for more exposure.
My setup is two Prop activity boards, and three xbee modules. I have an xbee on each activity board, with the third connected to my PC as a traffic monitor.
On board/xbee combo is set up to transmit a floating point number. This seems to work fine, as I can see the data with the traffic monitor xbee so I know it's being transmitted.
My problem is with the receive side. I can't get the received data to print either on the LCD or the terminal. If I substitute a fixed value for the variable called "data" (line 30 of the code), then all works...I see the data on the LCD and on the terminal. However when I remove line 30 and include lines 36 to 40, I don't get any data to the LCD or terminal.
My (likely mistaken) impression is that line 38 should assign the received data from the xbee as the variable named "data", and should subsequently be printed out on the devices via lines 43 and 44.
Any help greatly appreciated!
/*
receive voltage over xbee and display on lcd and terminal
*/
#include "simpletools.h" // Include required libraries
#include "fdserial.h"
#include "serial.h"
fdserial *xbee;
serial *lcd;
serial *term;
int main() // Main function
{
const int ON = 22;
const int CLR = 12;
xbee = fdserial_open(7, 6, 0, 9600); // initialize devices
lcd = serial_open(13, 13, 0, 9600);
term = serial_open(31, 30, 0, 115200);
float data; // declare data variable as type float
writeChar(lcd, ON); // prepare LCD to receive data
writeChar(lcd, CLR);
pause(1000);
data = 11.234; //when this line is included (line 30), and lines 36 to 40 are excluded
//both the lcd and term print 11.234 as expected.
//however, when line 30 is excluded and lines 36 to 40 are included
//nothing prints to either device
/*
while(1) // loop....this is line 36
{
data = fdserial_rxChar(xbee); // receive xbee data
if(data != -1);
} // this is line 40
*/
{
writeFloatPrecision(lcd, data, 5, 3); // send received data to devices as 5 characters total, precision of 3
writeFloatPrecision(term, data, 5, 3);
}
{
pause(1000);
writeChar(term, CLR);
pause(1000);
}
}
My setup is two Prop activity boards, and three xbee modules. I have an xbee on each activity board, with the third connected to my PC as a traffic monitor.
On board/xbee combo is set up to transmit a floating point number. This seems to work fine, as I can see the data with the traffic monitor xbee so I know it's being transmitted.
My problem is with the receive side. I can't get the received data to print either on the LCD or the terminal. If I substitute a fixed value for the variable called "data" (line 30 of the code), then all works...I see the data on the LCD and on the terminal. However when I remove line 30 and include lines 36 to 40, I don't get any data to the LCD or terminal.
My (likely mistaken) impression is that line 38 should assign the received data from the xbee as the variable named "data", and should subsequently be printed out on the devices via lines 43 and 44.
Any help greatly appreciated!
/*
receive voltage over xbee and display on lcd and terminal
*/
#include "simpletools.h" // Include required libraries
#include "fdserial.h"
#include "serial.h"
fdserial *xbee;
serial *lcd;
serial *term;
int main() // Main function
{
const int ON = 22;
const int CLR = 12;
xbee = fdserial_open(7, 6, 0, 9600); // initialize devices
lcd = serial_open(13, 13, 0, 9600);
term = serial_open(31, 30, 0, 115200);
float data; // declare data variable as type float
writeChar(lcd, ON); // prepare LCD to receive data
writeChar(lcd, CLR);
pause(1000);
data = 11.234; //when this line is included (line 30), and lines 36 to 40 are excluded
//both the lcd and term print 11.234 as expected.
//however, when line 30 is excluded and lines 36 to 40 are included
//nothing prints to either device
/*
while(1) // loop....this is line 36
{
data = fdserial_rxChar(xbee); // receive xbee data
if(data != -1);
} // this is line 40
*/
{
writeFloatPrecision(lcd, data, 5, 3); // send received data to devices as 5 characters total, precision of 3
writeFloatPrecision(term, data, 5, 3);
}
{
pause(1000);
writeChar(term, CLR);
pause(1000);
}
}
Comments
and here is the receive code...
As I mentioned, using a third xbee I can see that that data is being transmitted as a floating point number, so it is at least making it out of the transmitter. Thinking that the third xbee may be causing an issue, I disconnect it and try again, but it doesn't help.
Thanks!
John
Back to the references...
John