You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+20-7
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,14 @@ An Arduino library to parse NMEA sentences.
4
4
5
5
NMEA is a communication standard in the marine equipment industry: GPS, anemometers,... The NMEAParser library allows you to analyze NMEA sentences and associate handlers to each of those that need to be recognized. The library provides the means to associate a handler to each identifier and also provides functions to retrieve the arguments of the sentence in different data formats: character, integer, float, character string.
6
6
7
+
## Changelog
8
+
9
+
*```1.1``` : Added joker in type. Remove binaries from ```extra```
10
+
*```1.0``` : Initial release
11
+
7
12
## Memory footprint
8
13
9
-
On an Arduino Uno, an instance of a NMEAParser requires 97 bytes with only one handler. 8 bytes per additional handler are required.
14
+
On an Arduino Uno, an instance of a NMEAParser requires 97 bytes with only one handler. 8 bytes per additional handler are required.
10
15
11
16
## Using NMEAParser
12
17
@@ -28,7 +33,7 @@ In ```setup``` you configure your parser as you wish using the following functio
28
33
29
34
### ```void addHandler(<type>, <handler>)```
30
35
31
-
where ```<type>``` is a character string and the type of sentence to recongnize, and ```<handler>``` the function to call when a sentence is recognize. ```<type>``` can be a string stored un RAM or a string stored in flash : ```F("ASTRI")```. If ```<type>``` has more than 5 characters, it is trucated.
36
+
where ```<type>``` is a character string and the type of sentence to recongnize, and ```<handler>``` the function to call when a sentence is recognize. ```<type>``` can be a string stored un RAM or a string stored in flash : ```F("ASTRI")```. If ```<type>``` has more than 5 characters, it is trucated.
32
37
33
38
For example, suppose you want to recognize the following sounder sentences which give the water depth below keel (DBK) and below surface (DBS):
```handleDepthBelowKeel``` and ```handleDepthBelowSurface``` are functions that will be called when sentences are recognized.
53
58
59
+
With version 1.1, ```<type>``` may include hyphens. An hyphens matches any character. For instance if you want the handler to match all sentences coming from the sounder, you would write:
60
+
61
+
```C++
62
+
parser.addHandler("SD---", handleSounder);
63
+
```
64
+
65
+
```handleSounder``` function would be called for any sentence with the type beginning with SD.
66
+
54
67
### ```void setDefaultHandler(<handler>)```
55
68
56
69
When a sentence is succefully parsed but none of the handler correspond to it, ```<handler>``` is called. It is a function corresponding to a ```void f(void)``` prototype. By default, no function is called.
Put the type of the sentence in ```<type>```. It can be a ```char *``` or a ```String```. Return ```true``` if a type has been parsed, ```false``` otherwise.
126
+
3 versions of ```getType``` exist. The first one puts the type of the sentence in ```<type>```. It can be a ```char *``` or a ```String```. Return ```true``` if a type has been parsed, ```false``` otherwise. The second one puts a character of the type at position ```<num>```
114
127
115
128
### ```uint8_t argCount()```
116
129
@@ -122,7 +135,7 @@ Return the error. The returned code can be:
122
135
123
136
* ```NMEA::NO_ERROR```: no error;
124
137
* ```NMEA::UNEXPECTED_CHAR```: a char which is not expected in the sentence has been encountered;
125
-
* ```NMEA::BUFFER_FULL```: the sentence is too long to fit in the buffer;
138
+
* ```NMEA::BUFFER_FULL```: the sentence is too long to fit in the buffer;
126
139
* ```NMEA::TYPE_TOO_LONG```: the sentence type has more than 5 characters;
127
140
* ```NMEA::CRC_ERROR```: the CRC is wrong;
128
141
* ```NMEA::INTERNAL_ERROR```: the internal state of the parser is wrong, should not happen by the way.
@@ -174,7 +187,7 @@ We define 2 other handlers for anything else than ```ARLED``` and for errors
174
187
voiderrorHandler()
175
188
{
176
189
Serial.print("*** Error : ");
177
-
Serial.println(parser.error());
190
+
Serial.println(parser.error());
178
191
}
179
192
180
193
voidunknownCommand()
@@ -219,7 +232,7 @@ The ```gen``` subdirectory contains ```nmeagen```, a NMEA sentence generator pro
219
232
220
233
## Test program
221
234
222
-
The ```test``` subdirectory contains a test program that compile on Linux or Mac OS X. It takes sentences from the standard input, parse them and print out the type, the arguments and if an error occured.
235
+
The ```test``` subdirectory contains a test program that compile on Linux or Mac OS X. It takes sentences from the standard input, parse them and print out the type, the arguments and if an error occured.
0 commit comments