Hi David,
Yes you can do this.
With UART in interrupt mode it will buffer the inputs and code can go extract as many bytes at a time as you want. And then go back and get more.
If too many bytes are received before reading from the buffer, then the buffer will retain what it accumulated and drop the rest of the incoming characters. The buffer is configurable in size in the BSP file init_sci.c. It defaults to 64 bytes for the TX buffer and 64 bytes for the RX buffer.
UPDATE:
I created test code for the Tower TWR-K60D100M+TWR-SER using C:\Freescale\Freescale_MQX_4_2\mqx\examples\hello2 example.
The three key files are attached (user_config.h, twrk60d100m.h, hello.c).
Recompile the BSP/PSP and hello2 MQX application.
Run it and use terminal with 115200baud, 8-bit, 1-stop, no parity.
The default terminal output window will show below if you do not type any character as input:
Hello
- World
-------------------
No characters received in last 4 seconds.... --------------------
No characters received in last 4 seconds.... -------------------
No characters received in last 4 seconds.... --------------------
The code will check the UART Rx buffer every 4 seconds to see if any characters have been received. If not then you see the above results.
If you type 1 or more characters (I typed "1234") during the 4 second interval, then you will see following:
No characters received in last 4 seconds.... ------------1234--------
Number of characters read was 5-------------------
No characters received in last 4 seconds.... --------------------
No characters received in last 4 seconds.... --------------------
If you type more then 64 characters during the 4 second interval you will see:
No characters received in last 4 seconds.... --------------------
No characters received in last 4 seconds.... --------abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ__abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ__-----------
RX_OVERRUNS Error...
-------------------
No characters received in last 4 seconds.... -------------------
No characters received in last 4 seconds.... --------------------
You should be able to create a state machine to read your first four characters to determine what the header is telling you to do (read more, restart, other). Assuming the header indicates how many characters you need to read, they are still in the input buffer waiting for you get them.
Regards,
David