Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REQUEST FOR COMMENT make arduino optional #36

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
39f3911
feat: allow compilation without ARDUINO
close2 Jul 27, 2017
813f8be
feat: extract functionality into Arduino compat. libs
close2 Jul 27, 2017
31fc161
feat: continue Arduino compat declarations
close2 Jul 27, 2017
852821b
feat: add str_P to Platform.h
close2 Aug 7, 2017
e9706e3
feat[Platforms]: adapt DMS.h DMS.cpp Location.h
close2 Aug 7, 2017
491cf1d
feat: introduce templates for arduino classes
close2 Aug 19, 2017
44153e6
feat: continue converting to template functions
close2 Aug 19, 2017
c714716
feat: continue work for a linux example
close2 Aug 20, 2017
cfe0977
feat: add (hopefully) working linux serial example.
close2 Aug 20, 2017
9058e01
feat: minor tweaks to get linux version to compile
close2 Aug 20, 2017
a8b7fbe
feat: NeoGPS finally outputs something
close2 Aug 21, 2017
e9f328f
feat: add some files to gitignore
close2 Aug 25, 2017
b584def
feat: introduced NEO_GPS_{STREAM,PORT,SYSTEM}
close2 Aug 30, 2017
482cfde
feat: implement LINUX platform shims
close2 Aug 30, 2017
7728a72
feat: remove linux serial.*
close2 Aug 31, 2017
b096364
feat: linux code
close2 Sep 1, 2017
5586207
Merge branch 'master' into platform
close2 Sep 13, 2017
71fa713
feat: add deprecated when using default impl
close2 Sep 19, 2017
5c2dd11
feat: add ctype for isdigit. switch to ms in fakegps
close2 Sep 19, 2017
aff5dd9
fix: use correct initial time for next tv in fakegps
close2 Sep 19, 2017
b8082fc
fix: revert NMEAGPS_cfg.h to upstream
close2 Sep 19, 2017
5facb6c
fix: cast uint_t to int before printing (<<)
close2 Sep 19, 2017
d6ae9ad
feat: integrate latest changes from NMEA.ino into tests/NMEA.cpp
close2 Sep 19, 2017
18c8488
fix: remove a.out
close2 Sep 19, 2017
92d1ed7
feat: add + in front of all number prints
close2 Sep 20, 2017
d3f96eb
Revert "doc: fix minor documentation mistakes"
close2 Sep 20, 2017
43fb3e3
Revert "Revert "doc: fix minor documentation mistakes""
close2 Sep 20, 2017
a41ab20
Revert "feat: add some files to gitignore"
close2 Sep 20, 2017
20971ba
Revert "feat: NeoGPS finally outputs something"
close2 Sep 20, 2017
745ad6e
Revert "feat: minor tweaks to get linux version to compile"
close2 Sep 20, 2017
518e218
Revert "feat: add (hopefully) working linux serial example."
close2 Sep 20, 2017
7ff96cb
Revert "feat: continue work for a linux example"
close2 Sep 20, 2017
0722cf9
Revert "feat: continue converting to template functions"
close2 Sep 20, 2017
0b2e59f
Revert "feat: introduce templates for arduino classes"
close2 Sep 20, 2017
f2fbf1f
Revert "feat[Platforms]: adapt DMS.h DMS.cpp Location.h"
close2 Sep 20, 2017
0b62572
Revert "feat: add str_P to Platform.h"
close2 Sep 20, 2017
7908a38
Revert "feat: continue Arduino compat declarations"
close2 Sep 20, 2017
2b7d62a
Revert "feat: extract functionality into Arduino compat. libs"
close2 Sep 20, 2017
7e6a90f
Revert "feat: allow compilation without ARDUINO"
close2 Sep 20, 2017
ca93743
Merge branch 'master' into split
close2 Sep 20, 2017
a4c84c1
Merge branch 'platform' into split
close2 Sep 20, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions examples/linux/NMEA.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
//======================================================================
// Description: This program uses the fix-oriented methods available() and
// read() to handle complete fix structures.
//
// When the last character of the LAST_SENTENCE_IN_INTERVAL (see NMEAGPS_cfg.h)
// is decoded, a completed fix structure becomes available and is returned
// from read(). The new fix is saved the 'fix_data' structure, and can be used
// anywhere, at any time.
//
// If no messages are enabled in NMEAGPS_cfg.h, or
// no 'gps_fix' members are enabled in GPSfix_cfg.h, no information will be
// parsed, copied or printed.
//
// Prerequisites:
// 1) Your GPS device has been correctly powered.
// 2) Your GPS device is correctly connected using a serial adapter.
// By default /dev/ttyUSB0 is used.
// 3) You know the default baud rate of your GPS device.
// By default 9600 is assumed. If this doesn't work change it in serial.cpp
// 4) LAST_SENTENCE_IN_INTERVAL is defined to be the sentence that is
// sent *last* in each update interval (usually once per second).
// The default is NMEAGPS::NMEA_RMC (see NMEAGPS_cfg.h). Other
// programs may need to use the sentence identified by NMEAorder.ino.
// 5) NMEAGPS_RECOGNIZE_ALL is defined in NMEAGPS_cfg.h
//
//======================================================================

//------------------------------------------------------------
// For the NeoGPS example programs, "Streamers" is common set
// of printing and formatting routines for GPS data, in a
// Comma-Separated Values text format (aka CSV). The CSV
// data will be printed to the "debug output device".
// If you don't need these formatters, simply delete this section.

// platform.h must be included before NMEAGPS.h
#include <platforms/linux/platform.h>

#include <platforms/linux/GpsPort.h>
#include <NMEAGPS.h>

#include <Streamers.h>

#include <iostream>

//------------------------------------------------------------
// This object parses received characters
// into the gps.fix() data structure

static NMEAGPS gps;

//------------------------------------------------------------
// Define a set of GPS fix information. It will
// hold on to the various pieces as they are received from
// an RMC sentence. It can be used anywhere in your sketch.

static gps_fix fix_data;

//----------------------------------------------------------------
// This function gets called about once per second, during the GPS
// quiet time. It's the best place to do anything that might take
// a while: print a bunch of things, write to SD, send an SMS, etc.
//
// By doing the "hard" work during the quiet time, the CPU can get back to
// reading the GPS chars as they come in, so that no chars are lost.

static auto & DEBUG_PORT = std::cout;

static void doSomeWork()
{
// Print all the things!

trace_all( DEBUG_PORT, gps, fix_data );

} // doSomeWork

//------------------------------------
// This is the main GPS parsing loop.

static void GPSloop(GpsPort gps_port)
{
while (gps.available( gps_port )) {
fix_data = gps.read();
doSomeWork();
}

} // GPSloop

//--------------------------

GpsPort setup(const char * usbDev, const char * speed)
{
// Start the normal trace output
DEBUG_PORT << "NMEA: started\n";
DEBUG_PORT << " fix object size = ";
DEBUG_PORT << (uint32_t)sizeof(gps.fix());
DEBUG_PORT << "\n gps object size = ";
DEBUG_PORT << (uint32_t)sizeof(gps);
DEBUG_PORT << "\nLooking for GPS device on ";
DEBUG_PORT << ( usbDev == nullptr ? "default" : usbDev );
DEBUG_PORT << " with speed ";
DEBUG_PORT << ( speed == nullptr ? "default" : speed );

#ifndef NMEAGPS_RECOGNIZE_ALL
#error You must define NMEAGPS_RECOGNIZE_ALL in NMEAGPS_cfg.h!
#endif

#ifdef NMEAGPS_INTERRUPT_PROCESSING
#error You must *NOT* define NMEAGPS_INTERRUPT_PROCESSING in NMEAGPS_cfg.h!
#endif

#if !defined( NMEAGPS_PARSE_GGA ) & !defined( NMEAGPS_PARSE_GLL ) & \
!defined( NMEAGPS_PARSE_GSA ) & !defined( NMEAGPS_PARSE_GSV ) & \
!defined( NMEAGPS_PARSE_RMC ) & !defined( NMEAGPS_PARSE_VTG ) & \
!defined( NMEAGPS_PARSE_ZDA ) & !defined( NMEAGPS_PARSE_GST )

DEBUG_PORT << ( F("\nWARNING: No NMEA sentences are enabled: no fix data will be displayed.\n") );

#else
if (gps.merging == NMEAGPS::NO_MERGING) {
DEBUG_PORT << F("\nWARNING: displaying data from ");
DEBUG_PORT << gps.string_for( LAST_SENTENCE_IN_INTERVAL );
DEBUG_PORT << F(" sentences ONLY, and only if ");
DEBUG_PORT << gps.string_for( LAST_SENTENCE_IN_INTERVAL );
DEBUG_PORT << F(" is enabled.\n"
" Other sentences may be parsed, but their data will not be displayed.");
DEBUG_PORT << "\n";
}
#endif

DEBUG_PORT << "\nGPS quiet time is assumed to begin after a ";
DEBUG_PORT << gps.string_for( LAST_SENTENCE_IN_INTERVAL );
DEBUG_PORT << " sentence is received.\n"
" You should confirm this with NMEAorder.ino\n";
DEBUG_PORT << "\n";

GpsPort gps_port = GpsPort(usbDev, speed);

trace_header( DEBUG_PORT );

return gps_port;
}

//--------------------------

int main(int argc, char *argv[]) {
auto dev = argc >= 2 ? argv[1] : nullptr;
auto speed = argc >=3 ? argv[2] : nullptr;

auto gps_port = setup(dev, speed);
for (;;) {
GPSloop(gps_port);
}
return 0;
}
1 change: 1 addition & 0 deletions examples/ublox/ublox.ino
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ static MyGPS gps( &gpsPort );

static void configNMEA( uint8_t rate )
{
(void) rate;
for (uint8_t i=NMEAGPS::NMEA_FIRST_MSG; i<=NMEAGPS::NMEA_LAST_MSG; i++) {
ublox::configNMEA( gps, (NMEAGPS::nmea_msg_t) i, rate );
}
Expand Down
34 changes: 0 additions & 34 deletions src/CosaCompat.h

This file was deleted.

57 changes: 3 additions & 54 deletions src/DMS.h
Original file line number Diff line number Diff line change
@@ -1,55 +1,4 @@
#ifndef DMS_H
#define DMS_H
#pragma once

// 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 "NeoGPS_cfg.h"
#include <stdint.h>
class Print;

enum Hemisphere_t { NORTH_H = 0, SOUTH_H = 1, EAST_H = 0, WEST_H = 1 };

class DMS_t
{
public:
uint8_t degrees;
uint8_t minutes ;//NEOGPS_BF(6);
Hemisphere_t hemisphere ;//NEOGPS_BF(2); compiler bug!
uint8_t seconds_whole NEOGPS_BF(6);
uint16_t seconds_frac NEOGPS_BF(10); // 1000ths

void init() { degrees = minutes = seconds_whole = seconds_frac = 0;
hemisphere = NORTH_H; }

float secondsF() const { return seconds_whole + 0.001 * seconds_frac; };
char NS () const { return (hemisphere == SOUTH_H) ? 'S' : 'N'; };
char EW () const { return (hemisphere == WEST_H) ? 'W' : 'E'; };

//.............................................................................
// A utility function to convert from integer 'lat' or 'lon', scaled by 10^7

void From( int32_t deg_1E7 );

// Print DMS as the funky NMEA DDDMM.mmmm format
void printDDDMMmmmm( Print & outs ) const;

} NEOGPS_PACKED;

extern Print & operator << ( Print & outs, const DMS_t & );

#endif
#include "DMS.header.h"
#include "DMS.impl.h"
55 changes: 55 additions & 0 deletions src/DMS.header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef DMS_H
#define DMS_H

// 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 "NeoGPS_cfg.h"

#include "Platform.h"

enum Hemisphere_t { NORTH_H = 0, SOUTH_H = 1, EAST_H = 0, WEST_H = 1 };

class DMS_t
{
public:
uint8_t degrees;
uint8_t minutes ;//NEOGPS_BF(6);
Hemisphere_t hemisphere ;//NEOGPS_BF(2); compiler bug!
uint8_t seconds_whole NEOGPS_BF(6);
uint16_t seconds_frac NEOGPS_BF(10); // 1000ths

void init() { degrees = minutes = seconds_whole = seconds_frac = 0;
hemisphere = NORTH_H; }

float secondsF() const { return seconds_whole + 0.001 * seconds_frac; };
char NS () const { return (hemisphere == SOUTH_H) ? 'S' : 'N'; };
char EW () const { return (hemisphere == WEST_H) ? 'W' : 'E'; };

//.............................................................................
// A utility function to convert from integer 'lat' or 'lon', scaled by 10^7

void From( int32_t deg_1E7 );

// Print DMS as the funky NMEA DDDMM.mmmm format
void printDDDMMmmmm( NEO_GPS_PRINT & outs ) const NEO_GPS_PRINT_DEFAULT_IMPL_WARN;

} NEOGPS_PACKED;

NEO_GPS_PRINT & operator << ( NEO_GPS_PRINT & outs, const DMS_t & ) NEO_GPS_PRINT_DEFAULT_IMPL_WARN;

#endif
Loading