BS2 Serial Question
ByteCowboy
Posts: 2
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 Williams
Applications Engineer, Parallax
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!
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
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.