Shop OBEX P1 Docs P2 Docs Learn Events
BS2 Serial Question — Parallax Forums

BS2 Serial Question

ByteCowboyByteCowboy Posts: 2
edited 2006-05-09 03:47 in BASIC Stamp
I have a BS2 doing some simple monitoring and control stuff, but I would like to have it check for a command over a serial link and do something if it receives the right command. The BS2 will check the serial input every couple of seconds so the question·is how to handle the situation where·the other device sends the command while it's not listening? Will the serial comm be stalled because the BS2 doesn't respond with a handshake or do I just have to keep sending the command until the BS2 gets it? Appreciate any help, I'm just stuck trying to imagine how this this can work.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-09 02:09
    One thing you could do is use hardware flow control so that the "other device" won't send any data until the BS2 is ready (sitting on a SERIN).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-09 02:16
    ByteCowboy -

    You basically have just two directions here, as I see it. Choose your own poison.

    You can do as you suggest, check via SERIN, use a timeout routine to recover, and go back and bang your head against the wall again and again, until something comes across. FYI you will have a good deal of lost processing time (due to having to continually wait for the timeout to occur) by this method.

    -OR-

    You can add an external serial buffer (hardware UART) to the Stamp (since the PBASIC Stamp uses a software UART) and just check that, as appropriate, to see if anything has "appeared" in your ... absence from checking it. If so, you THEN read it in, with no loss of processing time.

    Just say which way you would choose to go, and we'll show you how to do it. If my answer sounds performance-biased, it IS! smile.gif

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • ByteCowboyByteCowboy Posts: 2
    edited 2006-05-09 03:47
    Thanks guys, that breals me out of·my loop :-)

    I had overlooked the fpin option, I need to test that my serial device (comtrol ethernet/serial bridge which can be a bit weird) respects flow control and if so that would be a winner. Otherwise I'll have to go the uart route.
Sign In or Register to comment.