Handle data on serial port
I need to input some serial data via the serial port - actually whether some switched have been pushed.
This may be a good approach for your needs. It may not work for everyone, though, because often the data is "context sensitive" - in other words, you need to keep track of more than the data coming in - you also need to know what it is in response to.
I'm working on a small project that needs to check the serial port looking for input. The input will only be a _single byte_ in size and will come at intervals of maybe a few a second to maybe one every minute or so.
I have a FN to check for data in the serial buffer. It process one byte if there is something there or drops back if empty. The input buffer is set to the defalt 64 bytes.
Is is it OK to call the FN at every NullEvent? I feel guilty using them all up. Or should I somehow only check on every tenth (or whatever) NullEvent?
I know this was talked about in the last couple of weeks but sad to say I wasn't paying any attention then.
I find the On Timer FN functionName thingy to be really good at this. You specify how much time, and every time that much time passes, it calls the function (provided, of course, that your program gets back to the handleevents). You'll love it!