how to capture and store serial communication data in buffers

I sent 1preample and 4bytes in transmitting side , preample contains only 1 and 0 with 4milliseconds delay, each byte contains 8bits with 2milliseconds delay , if a bit contains 1 it will send 1millisecond high and 1millisecond low signal ,and if a bit contains 0 it will send 2millisecond continuous delay, I have a problem at receiving side how to capture and store the preample and 4byte values in a buffer , iam using ARM processor it will update every 5microsecond .. please guide me and give a valuable suggestions

Is this protocol that your are using a fixed protocol or are you allowed to change it? Also I'm assuming your program samples the input line while looping. The program should wait for a 1 to appear for 2.5 milliseconds or longer, then wait for the 1 to transition to a 0. After the transition to 0, the program should wait for 4.5 milliseconds so that the next sample occurs in the .5 milliseconds into the first data bit. After that it should delay 2 milliseconds between sampling in order to keep sampling at .5 milliseconds of each data bit period.

If the protocol can be changed, then the conventional method is for the transmitting line to be zero when not transmitting. It should then transmit a 1 as a start bit, then transmit 8 bits of data, then transmit a 0 as a stop bit. All bits are transmitted with the same time period, using your example 2 milliseconds. The program polls until it sees a 1, which is the start bit, then it delays 3 milli-seconds to sample the next 8 data bits in the middle of each data bit period. It may also want to sample the stop bit to verify that bit as well.

Note this polling method is mostly for a half duplex protocol, where data is only transmitted in one direction at a time.