Go Down

Topic: NMEA Library (Read 9323 times) previous topic - next topic

no clue

Hello Everyone,

I am having a bit of trouble using the NMEA library, http://www.maartenlamers.com/nmea/
If I include the library in any sketch, I get the error below.

In file included from ------------------\Documents\arduino-0015\hardware\cores\arduino/WProgram.h:4,

--documents/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'

--documents/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

--documents/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'

In file included from --Documents\arduino-0015\hardware\cores\arduino/WProgram.h:6,

I am pretty new to all this so I don't know what to do,
This is the sketch I have used to demonstrate my point,

#include <nmea.h>
void setup()
void loop()

If anyone knows why this is happening or has any ideas of how to fix it please post!!!
Thanks Everyone!

Oh and I have tried on arduino IDE 15 & 16; on 16 I get the exact same error.


I haven't tried the library you've provided, but I have used TinyGPS with results, maybe you will to?

no clue

Yes I have tried that library, and it works, but the NMEA library has many extra features. Ones that I find very handy; for example, "distance to" and "course to". I think the error could be something wrong with the nmea.h file, does anyone know how i could fix this?


Dec 13, 2009, 07:02 pm Last Edit: Dec 13, 2009, 07:03 pm by ruimmonteiro Reason: 1
are you using the arduino mega? i'm not sure but i think it won't work on an duemilanove.

Any alternatives to tinygps , just for parsing lat/log? tks

no clue

I have tried it on the mega, and duemilanove. I have receive the same error no matter what comination of arduino 0015/ arduino 0016, and arduino mega/ arduino duemilanove.


In nmea.h, after including WConstans.h, add
#undef abs
#undef random

wiring.h redefines some macros defined in standard c/c++ headers. When the "real" definitions are parsed, it barfs. The #undfines "fix" it.

no clue

OK so this is what the nmea.h file looks like now....

#ifndef nmea_h
#define nmea_h

#include "WConstants.h" #define#undef abs#undef random

but im still getting an error,
expected constructor, destructor, or type conversion before numeric constant

Im a real noob, did i do something wrong?

no clue

Nevermind, stupid mistake. Here is the working nmea.h file.
Thanks for everyone's help!

 nmea.cpp - NMEA 0183 sentence decoding library for Wiring & Arduino
 Copyright (c) 2008 Maarten Lamers, The Netherlands.
 All right reserved.

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/#ifndef nmea_h#define nmea_h#include "WConstants.h" #undef abs#undef random#define      ALL                              0                                                // connect to all datatypes
#define      GPRMC                        1                                                // connect only to GPRMC datatype
#define      MTR                              1.0                                          // meters per meter
#define      KM                              0.001                                    // kilometers per meter
#define      MI                              0.00062137112            // miles per meter
#define      NM                              0.00053995680            // nautical miles per meter
#define      PARSEC                  0.000000000000      // parsecs per meter (approximation)
#define      MPS                              0.51444444                   // meters-per-second in one knot
#define      KMPH                        1.852                                // kilometers-per-hour in one knot
#define      MPH                              1.1507794                        // miles-per-hour in one knot
#define      KTS                              1.0                                     // knots in one knot
#define      LIGHTSPEED      0.000000001716      // lightspeeds in one knot

class NMEA
           NMEA(int connect);                              // constructor for NMEA parser object; parse sentences of GPRMC or all datatypes.
           int            decode(char c);                        // parse one character received from GPS; returns 1 when full sentence found w/ checksum OK, 0 otherwise
           float      gprmc_utc();                              // returns decimal value of UTC term in last full GPRMC sentence
           char      gprmc_status();                        // returns status character in last full GPRMC sentence ('A' or 'V')
           float      gprmc_latitude();                  // signed degree-decimal value of latitude terms in last full GPRMC sentence
           float      gprmc_longitude();            // signed degree-decimal value of longitude terms in last full GPRMC sentence
           float      gprmc_speed(float unit);      // speed-on-ground term in last full GPRMC sentence
           float      gprmc_course();                        // track-angle-made-good term in last full GPRMC sentence
           float      gprmc_distance_to(float latitude, float longitude, float unit);      // returns distance from last-known GPRMC position to given position
           float gprmc_course_to(float latitude, float longitude);                  // returns initial course in degrees from last-known GPRMC position to given position            
           char*      sentence();                                    // returns last received full sentence as zero terminated string
           int            terms();                                          // returns number of terms (including data type and checksum) in last received full sentence
           char*      term(int t);                              // returns term t of last received full sentence as zero terminated string
           float      term_decimal(int t);      // returns the base-10 converted value of term[t] in last full sentence received
           int            libversion();                              // returns software version number of NMEA library
       // properties
           int            _gprmc_only;
           float      _gprmc_utc;
           char      _gprmc_status;
           float      _gprmc_lat;
           float      _gprmc_long;
           float      _gprmc_speed;
           float      _gprmc_angle;
           char      f_sentence[100];
           char*      f_term[30];
           int            f_terms;
           int            _terms;
           char      _sentence[100];
           char*      _term[30];
           int            n;
           int            _gprmc_tag;
           int            _state;
           int            _parity;
           int            _nt;
           float      _degs;
           // methods
           float distance_between (float lat1, float long1, float lat2, float long2, float units_per_meter);
           float      initial_course(float lat1, float long1, float lat2, float long2);
           int            _dehex(char a);
           float      _decimal(char* s);


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131