Hi,
Let me see if I got you right.
you have a routine to read a single byte from the serial port (let us call it
fnReadSerByte().
Now, you want a way to read all characters that arrive sequentially. Since you dont know how many characters will arrive, you will need a nice loop to do it.
Well, There are two ways to do it.
1. Use the First Byte to represent the number of characters that follow and then use the loop like this.....
Code:
......
int counter;
unsigned char noOfBytes;
......
noOfBytes = fnReadSerByte();
for(counter = 0; counter < noOfBytes; counter++)
var[counter] = fnReadSerByte();
...
...
2. Use a STOP character (any valid Character that will not be present in your transmission even by mistake), and read the serial port until the received character is NOT THAT CHARACTER.
Hope it Helps.
-Harsha.