PUD: include nmealib v0.6.7
[olsrd.git] / lib / pud / nmealib / samples / parse / main.c
1 /*
2  * This file is part of nmealib.
3  *
4  * Copyright (c) 2008 Timur Sinitsyn
5  * Copyright (c) 2011 Ferry Huberts
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #include <nmea/nmea.h>
22
23 #include <stdio.h>
24 #include <string.h>
25
26 int main()
27 {
28     const char *buff[] = {
29         "$GPRMC,173843,A,3349.896,N,11808.521,W,000.0,360.0,230108,013.4,E*69\r\n",
30         "$GPGGA,111609.14,5001.27,N,3613.06,E,3,08,0.0,10.2,M,0.0,M,0.0,0000*70\r\n",
31         "$GPGSV,2,1,08,01,05,005,80,02,05,050,80,03,05,095,80,04,05,140,80*7f\r\n",
32         "$GPGSV,2,2,08,05,05,185,80,06,05,230,80,07,05,275,80,08,05,320,80*71\r\n",
33         "$GPGSA,A,3,01,02,03,04,05,06,07,08,00,00,00,00,0.0,0.0,0.0*3a\r\n",
34         "$GPRMC,111609.14,A,5001.27,N,3613.06,E,11.2,0.0,261206,0.0,E*50\r\n",
35         "$GPVTG,217.5,T,208.8,M,000.00,N,000.01,K*4C\r\n"
36     };
37
38     int it;
39     nmeaINFO info;
40     nmeaPARSER parser;
41     nmeaPOS dpos;
42
43     nmea_zero_INFO(&info);
44     nmea_parser_init(&parser);
45
46     for(it = 0; it < 6; ++it)
47     {
48         nmea_parse(&parser, buff[it], (int)strlen(buff[it]), &info);
49
50         nmea_info2pos(&info, &dpos);
51         printf("%03d, Lat: %f, Lon: %f, Sig: %d, Fix: %d\n", it, dpos.lat,
52                dpos.lon, info.sig, info.fix);
53     }
54
55     nmea_parser_destroy(&parser);
56
57     return 0;
58 }