forked from SlashDevin/NeoGPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNMEAbenchmark.ino
105 lines (86 loc) · 2.93 KB
/
NMEAbenchmark.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <NMEAGPS.h>
//======================================================================
// Program: NMEAbenchmark.ino
//
// Prerequisites:
//
// Description: Use GPGGA and GPRMC sentences to test
// the parser's performance.
//
// GSV sentences are tested if enabled.
//
// 'Serial' is for debug output to the Serial Monitor window.
//
// License:
// Copyright (C) 2014-2017, SlashDevin
//
// This file is part of NeoGPS
//
// NeoGPS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// NeoGPS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with NeoGPS. If not, see <http://www.gnu.org/licenses/>.
//
//======================================================================
#include <Streamers.h>
static NMEAGPS gps;
//--------------------------
static uint32_t time_it( const char *data )
{
const uint16_t ITERATIONS = 1024;
uint32_t start, end;
Serial.flush();
start = micros();
for (uint16_t i=ITERATIONS; i > 0; i--) {
char *ptr = (char *) data;
while (*ptr)
gps.decode( *ptr++ );
}
end = micros();
return (end-start)/ITERATIONS;
}
//--------------------------
void setup()
{
Serial.begin(9600);
Serial.println( F("NMEAbenchmark: started") );
Serial.print( F("fix object size = ") );
Serial.println( sizeof(gps.fix()) );
Serial.print( F(" gps object size = ") );
Serial.println( sizeof(gps) );
trace_header( Serial );
Serial.flush();
const char *gga =
"$GPGGA,092725.00,4717.11399,N,00833.91590,E,"
"1,8,1.01,499.6,M,48.0,M,,0*5B\r\n";
const char *gga_no_lat =
"$GPGGA,092725.00,,,00833.91590,E,"
"1,8,1.01,499.6,M,48.0,M,,0*0D\r\n";
Serial << F("GGA time = ") << time_it( gga ) << '\n';
trace_all( Serial, gps, gps.fix() );
Serial << F("GGA no lat time = ") << time_it( gga_no_lat ) << '\n';
trace_all( Serial, gps, gps.fix() );
const char *rmc =
"$GPRMC,083559.00,A,4717.11437,N,00833.91522,E,"
"0.004,77.52,091202,,,A*57\r\n";
Serial << F("RMC time = ") << time_it( rmc ) << '\n';
trace_all( Serial, gps, gps.fix() );
#ifdef NMEAGPS_PARSE_GSV
const char *gsv =
"$GPGSV,3,1,10,23,38,230,44,29,71,156,47,07,29,116,41,08,09,081,36*7F\r\n"
"$GPGSV,3,2,10,10,07,189,,05,05,220,,09,34,274,42,18,25,309,44*72\r\n"
"$GPGSV,3,3,10,26,82,187,47,28,43,056,46*77\r\n";
Serial << F("GSV time = ") << time_it( gsv ) << '\n';
trace_all( Serial, gps, gps.fix() );
#endif
}
//--------------------------
void loop() {}