Shop OBEX P1 Docs P2 Docs Learn Events
Xbee wireless problem. Program seems to be waiting for data when I don't want it to. — Parallax Forums

Xbee wireless problem. Program seems to be waiting for data when I don't want it to.

Rick G.Rick G. Posts: 9
edited 2011-08-16 18:41 in Accessories
Hi Everyone,

first time writing here, I hope someone can help. I have a board in a submarine that needs updating for three values from time to time. When I'm not sending those new values to the sub from a remote programming pendant, I want the sub's board to continue with the program. It seems to be hanging up at the XB.rx part where it normally awaits new data. It seems to always pick up the transmitted data fine, probably because its just sitting there until it gets a valid signal.

What I need is a way to set a timeout that moves it beyond that line of code. I'll be looking through the reference book for more info. Thanks in advance.

Rick G.

Comments

  • Martin HebelMartin Hebel Posts: 1,239
    edited 2011-08-10 17:54
    The Getting Started with XBee Modules text demonstrates using separate cogs to send/receive data around page 98. You can also change .Rx to use .RxTime(value) for a timeout value - just be sure to set up CTS/RTS so that you don't miss data (recommend the separate cog method).

    http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/ProductID/718/List/0/Default.aspx?SortField=ProductName,ProductName

    -Martin
  • Rick G.Rick G. Posts: 9
    edited 2011-08-10 18:08
    Hi Martin,

    thanks. Being relatively new to using SPIN and having basically finished the code for this project, I'm a little gun shy to start a new cog for this. I thought of that earlier but was hoping for a timeout value like the one you suggested. Thanks. If that doesn't work, I'll go the way of the Cog.

    Thanks again.

    Rick
  • Rick G.Rick G. Posts: 9
    edited 2011-08-10 18:22
    Hi Martin,

    thanks for getting back to me so fast! I put that XB.rxtime(1000) in there and it works great! All it was doing while waiting for a signal was watching a reed switch for a magnet to pass by. The magnet passes the reed switch in at least a half second, probably more, so even with a much higher 'timeout' value, I still wouldn't miss the magnet. Thanks again.

    rick G.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2011-08-10 19:00
    Good to hear, you are welcome.
  • Rick G.Rick G. Posts: 9
    edited 2011-08-15 12:34
    Hi Martin,

    finished the project! Thanks again. One other note, I posted that I had put XB.rxtime(1000), oops! I didn't look that closely at first and woke up the other morning and realized that the 'time' was in ms, not uS. That would've caused some problems, but I caught my mistake and changed it appropriately. thanks again.

    Rick g.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2011-08-16 18:41
    Hey Rick, good to hear! Thought 1 second may have been a little long to still catch your sensor, but you said it was working fine, soooo :)

    Congrats on a finished project,
    -Martin
Sign In or Register to comment.