mugheesahmed
Joined: 12 Jun 2006 Posts: 9
|
PROBLEM IN EXTRACTING THE REQUIRED STRING FROM SERIAL DATA |
Posted: Mon Nov 13, 2006 12:45 pm |
|
|
following is tha serial data(one packet) i am getting form a GPS at 4800 baud with small intervals.(each new line starts before the $ sign and there is a carriage return after each line)
--------------------
$GPRMC,181658,A,3404.221,N,07238.833,E,000.0,360.0,131106,002.3,E*71
$GPRMB,A,,,,,,,,,,,,V*71
$GPGGA,181658,3404.221,N,07238.833,E,1,00,2.0,367.2,M,-39.5,M,,*65
$GPGSA,A,3,,,,,,,,,,,,,6.5,2.0,3.0*30
$GPGSV,2,1,08,03,32,281,47,07,31,208,47,09,28,077,46,14,48,215,50*7F
$GPGSV,2,2(08,18,55,035,51,19,19,312,43,21,54,119,51,22,58,316,51*7F
$PGRME,15.0,M,22.5,M,15.0,M*1B
$GPGLL,3404.221,N,07238.833,E,181659,A*2C
$PGRMZ,1205,f,3*2D
$PGRMM,WGS 84*06
$GPBOD,,T,,M,,*47
$GPRTE,1,1,c,0*07
---------------------
what i want is to extract the very first i.e. $GPRMC string and then display it on the hyper terminal...
i have tried it using the following code simply but it duznt seem to work...
----------------
main()
{
while(true)
{
value=getc();
putc(value);
if (value==0x0d)//as each line ends with a CR so using this condition
break;
}
}
----------------
what i have observed is that if the condition never becomes true...the whole packet is shown correctly on the hyper terminal screen...however, if the condition is met...the result is just garbage...or first few bytes are not correct; the rest are fine but still that makes the whole string of $GPRMC useless.......however the program does manage to come out of the loop...
NEED YOUR GUYS HELP... |
|