Hey Sab,
your code is difficult to read - please repost using the “pre” and “/pre” tags to enclose it.
Have you seen our page on the serial protocol? It has some sample code at the bottom which might be super helpful.
http://cmucam.org/projects/cmucam5/wiki/Porting_Guide
Let me know if this helps!
Best,
Jesse