I am thinking about it and will test it.
But, I just wonder how much overhead it takes and what about interrupts conflict, as MODSERIAL looks like quite "interrupt intensive". PWM or PPM signal readings must have higher priority...
In my case the orientation sensor I'm using sends data in packets starting with "snp" and ending with checksum, so knowing last char readed is not too helpful - any suggestion ?
+++ Edit +++
Some errors in compilation of MODSERIAL library.
Program published here http://mbed.org/users/kinemax/programs/PwmIn_ModSerial/lpb6mh
I know it is not too clever, just tried to compile it ported from Serial to MODSERIAL...
Maybe you are making some corrections ?? 2 hours before example.cpp was running (after some code insertion to main.cpp) and now same mistakes as in published above...
Pawel Stepien wrote:
serial stream in main loop, hoping that UART buffer will be sufficient if I check it often
The standard LPC17xx UART has a 16byte FIFO. However, you can save yourself some trouble by using the MODSERIAL library. It's a drop in replacement for Serial that does exactly the same things but has extra API features you may find useful.
The auto-detect is useful because "you don't have to check it often". You can have the library tell you "a message has been receieved and is in the RX buffer". For example, GPS NMEA sentences always end in \n so rather than read all the bytes coming from a GPS and manually building a sentence seeking the \n terminator, you can just tell MODSERIAL to have a large enough buffer for the longest NMEA sentence type and then tell MODSERIAL to "callback" your program when it sees a "\n" going into that buffer.
Could save you a lot of work and help you concentrate on the harder parts of your project :)