source: pacpussensors/trunk/NMEA0183/src/FIELD.cpp

Last change on this file was 59, checked in by DHERBOMEZ Gérald, 10 years ago

Integration of new modules:

  • GPS NMEA0183 decoder
  • Span CPT Decoder

Update of:

File size: 1.1 KB
Line 
1#include "nmea0183.h"
2
3const QString& field( int desired_field_number, const QString& sentence )
4{
5 static QString return_string;
6
7 //return_string.Empty();
8
9 int index = 1; // Skip over the $ at the begining of the sentence
10 int return_index = 0;
11 int current_field_number = 0;
12 int string_length = 0;
13
14 string_length = sentence.length();
15
16 while( current_field_number < desired_field_number && index < string_length )
17 {
18 if ( sentence[ index ] == ',' || sentence[ index ] == '*' )
19 {
20 current_field_number++;
21 }
22 else
23 {
24 /*
25 ** Do Nothing
26 */
27 }
28
29 index++;
30 }
31
32 if ( current_field_number == desired_field_number )
33 {
34 while( index < string_length &&
35 sentence[ index ] != ',' &&
36 sentence[ index ] != '*' &&
37 sentence[ index ] != (char)0x00 )
38 {
39 return_string += sentence[ index ];
40 index++;
41 }
42 }
43 else
44 {
45 /*
46 ** Do Nothing
47 */
48 }
49
50 return( return_string );
51}
Note: See TracBrowser for help on using the repository browser.