Currently I am running a program which is able to read in data values from a digital compass thru the serial port. My problem is that the values are not refreshed each time a new value comes in. I suspect this has something to do with the buffer. So what command do i use to constantly flush out the old input values in the buffer so that new values are able to be displayed?
This is part of my code. What I want to do is that every time the digital compass is moved, a new coordinate"$b" is supposed to come in but what happens now is that the new coordinate “$b” which comes in is not displayed, instead it keeps on displaying the previous coordinate"$a" . Only when I terminate the program and re-run it, the coordinate “$b” will then appear. So what flush command should I use and where should I insert it into my code? The values which I want to capture and display is about 17 characters long. The coordinates need to be refreshed and displayed every time the digital compass is moved.
Thanks in advance.
int myReadFunc(int fd, void *data, unsigned mode)
int iFileDescriptor, iBytesRead, iExit=0;
//Read in any data if present
iBytesRead = read(iFileDescriptor, szMessage, 100);
for (tempi=0; tempi<sizeof(szMessage); tempi++)
printf(char_buffer4, “%c”, szMessage[tempi]);
//Check if data was successfully read
//Check if the first letter is $
if(szMessage  =="$")