PDA

View Full Version : BS2 Serial Question



ByteCowboy
05-09-2006, 08:53 AM
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.

Jon Williams
05-09-2006, 09:09 AM
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 Bates
05-09-2006, 09:16 AM
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! http://forums.parallax.com/images/smilies/smile.gif

Regards,

Bruce Bates

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->

ByteCowboy
05-09-2006, 10:47 AM
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.