PDA

View Full Version : xbee programming question, flow control...



Annoying
04-15-2010, 02:23 PM
I am communicating between two xbees on two BS2s and I want data to be sent in an alternating fashion, so one xbee sends data, then receives data, back and forth,·indefinitely. I was wondering what the best way is to have the program send the xbee #1 data until the·xbee #2·receives it and then the·xbee #2·sends its data back and so on. maybe it's obvious that the answer is flow control, but i'm really confused about how to use it from the sample code I have seen.

I think this should be enough to show what my code tries to do:

GOSUB GetOwnValue
GOSUB SendValue
·GOSUB GetOtherValue

------------a lot of IF statements-------------------

THE END.

-----subroutines----
GetOwnValue:
PULSIN Yin, HiPulse, pulse2
RETURN

SendValue:
SEROUT TX,84, ["*",pulse2.HIGHBYTE, pulse2.LOWBYTE,CR,CR]
RETURN

GetOtherValue:
SERIN RX, 84, [WAIT ("*"),pulse1.HIGHBYTE,pulse1.LOWBYTE]
RETURN


thank you...

Franklin
04-15-2010, 11:28 PM
If you put that in a loop it would be a start. It won't do the if statements until it gets the data from the other end and if the other end does not send anything or this end misses the transmission it will lock up and not continue, something to think about.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Annoying
04-16-2010, 02:16 AM
I don't understand how to use a loop because what would you put after LOOP UNTIL?