Shop OBEX P1 Docs P2 Docs Learn Events
xbee programming question, flow control... — Parallax Forums

xbee programming question, flow control...

AnnoyingAnnoying Posts: 50
edited 2010-04-15 18:16 in BASIC Stamp
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, [noparse][[/noparse]"*",pulse2.HIGHBYTE, pulse2.LOWBYTE,CR,CR]
RETURN

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


thank you...

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-04-15 15:28
    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
  • AnnoyingAnnoying Posts: 50
    edited 2010-04-15 18:16
    I don't understand how to use a loop because what would you put after LOOP UNTIL?
Sign In or Register to comment.