From d45606627782f55c5ef27b8566c09e0ffda44935 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Thu, 25 Aug 2016 14:04:42 -0600 Subject: [PATCH] ublox6: remove driver and replace with generic nmea_gps driver Signed-off-by: Jon Trulson --- docs/apichanges.md | 5 + examples/c++/CMakeLists.txt | 1 - examples/c++/ublox6.cxx | 97 ------------------- examples/java/CMakeLists.txt | 1 - examples/java/Ublox6Sample.java | 73 -------------- examples/javascript/ublox6.js | 81 ---------------- examples/python/ublox6.py | 82 ---------------- src/ublox6/CMakeLists.txt | 5 - src/ublox6/javaupm_ublox6.i | 30 ------ src/ublox6/jsupm_ublox6.i | 21 ---- src/ublox6/pyupm_ublox6.i | 25 ----- src/ublox6/ublox6.cxx | 167 -------------------------------- src/ublox6/ublox6.hpp | 130 ------------------------- 13 files changed, 5 insertions(+), 713 deletions(-) delete mode 100644 examples/c++/ublox6.cxx delete mode 100644 examples/java/Ublox6Sample.java delete mode 100644 examples/javascript/ublox6.js delete mode 100644 examples/python/ublox6.py delete mode 100644 src/ublox6/CMakeLists.txt delete mode 100644 src/ublox6/javaupm_ublox6.i delete mode 100644 src/ublox6/jsupm_ublox6.i delete mode 100644 src/ublox6/pyupm_ublox6.i delete mode 100644 src/ublox6/ublox6.cxx delete mode 100644 src/ublox6/ublox6.hpp diff --git a/docs/apichanges.md b/docs/apichanges.md index 88adfaec..e4ab2d10 100644 --- a/docs/apichanges.md +++ b/docs/apichanges.md @@ -4,6 +4,11 @@ API Changes {#apichanges} Here's a list of other API changes made to the library that break source/binary compatibility between releases: + * The Ublox6 driver has been removed and replaced with a generic + implementation called nmea_gps. This driver should handle all + generic serial GPS devices that output NMEA data going forward. This + new driver has been tested with ublox6, DFRobot VK2828U7 (ublox7) and + ublox LEA-6H GPS devices. * There were frequent misspellings of the word *Celsius* in the UPM code. In some cases, these were in method names, which will cause some API compatibility issues. These have all been corrected for UPM diff --git a/examples/c++/CMakeLists.txt b/examples/c++/CMakeLists.txt index 3c745e5d..f06b724a 100644 --- a/examples/c++/CMakeLists.txt +++ b/examples/c++/CMakeLists.txt @@ -150,7 +150,6 @@ add_example (grovevdiv) add_example (grovewater) add_example (guvas12d) add_example (mpr121) -add_example (ublox6) add_example (yg1006) add_example (wt5001) add_example (ppd42ns) diff --git a/examples/c++/ublox6.cxx b/examples/c++/ublox6.cxx deleted file mode 100644 index 2d3d34b3..00000000 --- a/examples/c++/ublox6.cxx +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Author: Jon Trulson - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include -#include "ublox6.hpp" - -using namespace std; - -bool shouldRun = true; - -void sig_handler(int signo) -{ - if (signo == SIGINT) - shouldRun = false; -} - -const size_t bufferLength = 256; - -int main (int argc, char **argv) -{ - signal(SIGINT, sig_handler); - -//! [Interesting] - // Instantiate a Ublox6 GPS device on uart 0. - upm::Ublox6* nmea = new upm::Ublox6(0); - - // make sure port is initialized properly. 9600 baud is the default. - if (!nmea->setupTty(B9600)) - { - cerr << "Failed to setup tty port parameters" << endl; - return 1; - } - - // Collect and output NMEA data. There are various libraries out on - // the Internet, such as tinyGPS or tinyGPS++ that can handle - // decoding NMEA data and presenting it in a more easily accessible - // format. This example will just check for, and read raw NMEA data - // from the device and output it on stdout. - - // This device also supports numerous configuration options, which - // you can set with writeData(). Please refer to the Ublox-6 data - // sheet for further information on the formats of the data sent and - // received, and the various operating modes available. - - char nmeaBuffer[bufferLength]; - while (shouldRun) - { - // we don't want the read to block in this example, so always - // check to see if data is available first. - if (nmea->dataAvailable()) - { - int rv = nmea->readData(nmeaBuffer, bufferLength); - - if (rv > 0) - write(1, nmeaBuffer, rv); - - if (rv < 0) // some sort of read error occurred - { - cerr << "Port read error." << endl; - break; - } - - continue; - } - - usleep(100000); // 100ms - } -//! [Interesting] - - cout << "Exiting..." << endl; - - delete nmea; - return 0; -} diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt index 5231edc5..6531600d 100644 --- a/examples/java/CMakeLists.txt +++ b/examples/java/CMakeLists.txt @@ -97,7 +97,6 @@ add_example(TM1637Sample tm1637) add_example(TP401Sample gas) add_example(TSL2561Sample tsl2561) add_example(TTP223Sample ttp223) -add_example(Ublox6Sample ublox6) add_example(ULN200XASample uln200xa) add_example(WaterLevelSensor waterlevel) add_example(WT5001Sample wt5001) diff --git a/examples/java/Ublox6Sample.java b/examples/java/Ublox6Sample.java deleted file mode 100644 index b7c5017f..00000000 --- a/examples/java/Ublox6Sample.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Author: Stefan Andritoiu - * Copyright (c) 2015 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -public class Ublox6Sample { - private static final int BUFFERLENGTH = 256; - - public static void main(String[] args) throws InterruptedException { - // ! [Interesting] - // Instantiate a Ublox6 GPS device on uart 0 - upm_ublox6.Ublox6 nmea = new upm_ublox6.Ublox6(0); - - // make sure port is initialized properly. 9600 baud is the default. - if (!nmea.setupTty()) { - throw new RuntimeException("Failed to setup tty port parameters"); - } - - // Collect and output NMEA data. There are various libraries out on - // the Internet, that can handle decoding NMEA data and presenting - // it in a more easily accessible format. This example will just - // check for, and read raw NMEA data from the device and output it - // on standard output. - - // This device also supports numerous configuration options, which - // you can set with writeData(). Please refer to the Ublox-6 data - // sheet for further information on the formats of the data sent and - // received, and the various operating modes available. - - byte[] nmeaBuffer = new byte[BUFFERLENGTH]; - - while (true) { - // we don't want the read to block in this example, so always - // check to see if data is available first. - if (nmea.dataAvailable()) { - int rv = nmea.readData(nmeaBuffer); - - if (rv > 0) - for (int i = 0; i < rv; i++) - System.out.print((char) nmeaBuffer[i]); - - if (rv < 0) { // some sort of read error occurred - System.err.println("Port read error."); - break; - } - continue; - } - - Thread.sleep(1000); - } - // ! [Interesting] - } - -} \ No newline at end of file diff --git a/examples/javascript/ublox6.js b/examples/javascript/ublox6.js deleted file mode 100644 index e2d9604f..00000000 --- a/examples/javascript/ublox6.js +++ /dev/null @@ -1,81 +0,0 @@ -/* -* Author: Zion Orent -* Copyright (c) 2014 Intel Corporation. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -var GPSSensor = require('jsupm_ublox6'); - -// Instantiate a Ublox6 GPS device on uart 0. -var myGPSSensor = new GPSSensor.Ublox6(0); - -if (!myGPSSensor.setupTty(GPSSensor.int_B9600)) -{ - console.log("Failed to setup tty port parameters"); - process.exit(0); -} - -// Collect and output NMEA data. - -// This device also supports numerous configuration options, which -// you can set with writeData(). Please refer to the Ublox-6 data -// sheet for further information on the formats of the data sent and -// received, and the various operating modes available. - -var bufferLength = 256; -var nmeaBuffer = new GPSSensor.charArray(bufferLength); - -function getGPSInfo() -{ - // we don't want the read to block in this example, so always - // check to see if data is available first. - if (myGPSSensor.dataAvailable()) - { - var rv = myGPSSensor.readData(nmeaBuffer, bufferLength); - - var GPSData, dataCharCode, isNewLine, lastNewLine; - var numlines= 0; - if (rv > 0) - { - GPSData = ""; - // read only the number of characters - // specified by myGPSSensor.readData - for (var x = 0; x < rv; x++) - GPSData += nmeaBuffer.getitem(x); - process.stdout.write(GPSData) - } - - if (rv < 0) // some sort of read error occurred - { - console.log("Port read error."); - process.exit(0); - } - } -} - -setInterval(getGPSInfo, 100); - -// Print message when exiting -process.on('SIGINT', function() -{ - console.log("Exiting..."); - process.exit(0); -}); diff --git a/examples/python/ublox6.py b/examples/python/ublox6.py deleted file mode 100644 index c2e03226..00000000 --- a/examples/python/ublox6.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/python -# Author: Zion Orent -# Copyright (c) 2015 Intel Corporation. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -import time, sys, signal, atexit -import pyupm_ublox6 as upmUblox6 - -# Instantiate a Ublox6 GPS device on uart 0. -myGPSSensor = upmUblox6.Ublox6(0) - - -## Exit handlers ## -# This function stops python from printing a stacktrace when you hit control-C -def SIGINTHandler(signum, frame): - raise SystemExit - -# This function lets you run code on exit, including functions from myGPSSensor -def exitHandler(): - print "Exiting" - sys.exit(0) - -# Register exit handlers -atexit.register(exitHandler) -signal.signal(signal.SIGINT, SIGINTHandler) - - -if (not myGPSSensor.setupTty(upmUblox6.cvar.int_B9600)): - print "Failed to setup tty port parameters" - sys.exit(0) - -# Collect and output NMEA data. - -# This device also supports numerous configuration options, which -# you can set with writeData(). Please refer to the Ublox-6 data -# sheet for further information on the formats of the data sent and -# received, and the various operating modes available. - - -bufferLength = 256 -nmeaBuffer = upmUblox6.charArray(bufferLength) - -def getGPSInfo(): - # we don't want the read to block in this example, so always - # check to see if data is available first. - if (myGPSSensor.dataAvailable()): - rv = myGPSSensor.readData(nmeaBuffer, bufferLength) - - numlines= 0 - if (rv > 0): - GPSData = "" - # read only the number of characters - # specified by myGPSSensor.readData - for x in range(rv): - GPSData += nmeaBuffer.__getitem__(x) - sys.stdout.write(GPSData) - - if (rv < 0): # some sort of read error occurred - print "Port read error." - sys.exit(0) - -while (1): - getGPSInfo() - time.sleep(.1) diff --git a/src/ublox6/CMakeLists.txt b/src/ublox6/CMakeLists.txt deleted file mode 100644 index 91ba1b66..00000000 --- a/src/ublox6/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "ublox6") -set (libdescription "upm u-blox 6 GPS UART support module") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init() diff --git a/src/ublox6/javaupm_ublox6.i b/src/ublox6/javaupm_ublox6.i deleted file mode 100644 index ad499570..00000000 --- a/src/ublox6/javaupm_ublox6.i +++ /dev/null @@ -1,30 +0,0 @@ -%module javaupm_ublox6 -%include "../upm.i" -%include "../java_buffer.i" - -%{ - #include "ublox6.hpp" - speed_t int_B2400 = B2400; - speed_t int_B4800 = B4800; - speed_t int_B9600 = B9600; - speed_t int_B19200 = B19200; - speed_t int_B38400 = B38400; -%} - -%include "ublox6.hpp" -speed_t int_B2400 = B2400; -speed_t int_B4800 = B4800; -speed_t int_B9600 = B9600; -speed_t int_B19200 = B19200; -speed_t int_B38400 = B38400; - -%pragma(java) jniclasscode=%{ - static { - try { - System.loadLibrary("javaupm_ublox6"); - } catch (UnsatisfiedLinkError e) { - System.err.println("Native code library failed to load. \n" + e); - System.exit(1); - } - } -%} diff --git a/src/ublox6/jsupm_ublox6.i b/src/ublox6/jsupm_ublox6.i deleted file mode 100644 index 727549db..00000000 --- a/src/ublox6/jsupm_ublox6.i +++ /dev/null @@ -1,21 +0,0 @@ -%module jsupm_ublox6 -%include "../upm.i" -%include "stdint.i" -%include "carrays.i" - -%{ - #include "ublox6.hpp" - speed_t int_B2400 = B2400; - speed_t int_B4800 = B4800; - speed_t int_B9600 = B9600; - speed_t int_B19200 = B19200; - speed_t int_B38400 = B38400; -%} - -%include "ublox6.hpp" -speed_t int_B2400 = B2400; -speed_t int_B4800 = B4800; -speed_t int_B9600 = B9600; -speed_t int_B19200 = B19200; -speed_t int_B38400 = B38400; -%array_class(char, charArray); diff --git a/src/ublox6/pyupm_ublox6.i b/src/ublox6/pyupm_ublox6.i deleted file mode 100644 index f7791015..00000000 --- a/src/ublox6/pyupm_ublox6.i +++ /dev/null @@ -1,25 +0,0 @@ -// Include doxygen-generated documentation -%include "pyupm_doxy2swig.i" -%module pyupm_ublox6 -%include "../upm.i" -%include "stdint.i" -%include "carrays.i" - -%feature("autodoc", "3"); - -%{ - #include "ublox6.hpp" - speed_t int_B2400 = B2400; - speed_t int_B4800 = B4800; - speed_t int_B9600 = B9600; - speed_t int_B19200 = B19200; - speed_t int_B38400 = B38400; -%} - -%include "ublox6.hpp" -speed_t int_B2400 = B2400; -speed_t int_B4800 = B4800; -speed_t int_B9600 = B9600; -speed_t int_B19200 = B19200; -speed_t int_B38400 = B38400; -%array_class(char, charArray); diff --git a/src/ublox6/ublox6.cxx b/src/ublox6/ublox6.cxx deleted file mode 100644 index f9eb9669..00000000 --- a/src/ublox6/ublox6.cxx +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Author: Jon Trulson - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include - -#include "ublox6.hpp" - -using namespace upm; -using namespace std; - -Ublox6::Ublox6(int uart) -{ - m_ttyFd = -1; - - if ( !(m_uart = mraa_uart_init(uart)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_uart_init() failed"); - return; - } - - // This requires a recent MRAA (1/2015) - const char *devPath = mraa_uart_get_dev_path(m_uart); - - if (!devPath) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": mraa_uart_get_dev_path() failed"); - return; - } - - // now open the tty - if ( (m_ttyFd = open(devPath, O_RDWR)) == -1) - { - string err = __FUNCTION__; - err += ": open of " + std::string(devPath) + " failed: " + - std::string(strerror(errno)); - - throw std::runtime_error(err); - return; - } -} - -Ublox6::~Ublox6() -{ - if (m_ttyFd != -1) - close(m_ttyFd); -} - -bool Ublox6::dataAvailable() -{ - if (m_ttyFd == -1) - return false; - - struct timeval timeout; - - // no waiting - timeout.tv_sec = 0; - timeout.tv_usec = 0; - - int nfds; - fd_set readfds; - - FD_ZERO(&readfds); - - FD_SET(m_ttyFd, &readfds); - - if (select(m_ttyFd + 1, &readfds, NULL, NULL, &timeout) > 0) - return true; // data is ready - else - return false; -} - -int Ublox6::readData(char *buffer, int len) -{ - if (m_ttyFd == -1) - return(-1); - - int rv = read(m_ttyFd, buffer, len); - - if (rv < 0) - { - string err = string(__FUNCTION__) + ": read failed: " + - string(strerror(errno)); - - throw std::runtime_error(err); - return rv; - } - - return rv; -} - -int Ublox6::writeData(char * buffer, int len) -{ - if (m_ttyFd == -1) - return(-1); - - int rv = write(m_ttyFd, buffer, len); - - if (rv < 0) - { - string err = string(__FUNCTION__) + ": write failed: " + - string(strerror(errno)); - - throw std::runtime_error(err); - return rv; - } - - tcdrain(m_ttyFd); - - return rv; -} - -bool Ublox6::setupTty(speed_t baud) -{ - if (m_ttyFd == -1) - return(false); - - struct termios termio; - - // get current modes - tcgetattr(m_ttyFd, &termio); - - // setup for a 'raw' mode. 81N, no echo or special character - // handling, such as flow control. - cfmakeraw(&termio); - - // set our baud rates - cfsetispeed(&termio, baud); - cfsetospeed(&termio, baud); - - // make it so - int rv; - if ( (rv = tcsetattr(m_ttyFd, TCSAFLUSH, &termio)) < 0) - { - string err = string(__FUNCTION__) + ": tcsetattr failed: " + - string(strerror(errno)); - - throw std::runtime_error(err); - return false; - } - - return true; -} diff --git a/src/ublox6/ublox6.hpp b/src/ublox6/ublox6.hpp deleted file mode 100644 index d98aad36..00000000 --- a/src/ublox6/ublox6.hpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Author: Jon Trulson - * Copyright (c) 2014 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -#pragma once - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -const int UBLOX6_DEFAULT_UART = 0; - -namespace upm { - /** - * @brief UBLOX6 & SIM28 GPS Module library - * @defgroup ublox6 libupm-ublox6 - * @ingroup seeed uart gps tsk - */ - /** - * @library ublox6 - * @sensor ublox6 - * @comname Grove GPS - * @altname U-BLOX 6 SIM28 - * @type gps - * @man seeed - * @web http://www.seeedstudio.com/depot/Grove-GPS-p-959.html - * @con uart - * @kit tsk - * - * @brief API for the U-BLOX 6 and SIM28 GPS Modules - * - * UPM support for the U-BLOX 6 GPS module. It is also compatible with - * the SIM28 GPS module. - * - * @image html ublox6.jpg - * @snippet ublox6.cxx Interesting - */ - class Ublox6 { - public: - /** - * Ublox6 object constructor - * - * @param uart Default UART to use (0 or 1) - */ - Ublox6(int uart); - - /** - * Ublox6 object destructor - */ - ~Ublox6(); - - /** - * Checks to see if there is data available for reading - * - * @return True if there is data available for reading - */ - bool dataAvailable(); - - /** - * Reads any available data in a user-supplied buffer. Note: the - * call blocks until data is available to be read. Use - * dataAvailable() to determine whether there is data available - * beforehand, to avoid blocking. - * - * @param buffer Buffer to hold the data read - * @param len Length of the buffer - * @return the Number of bytes read - */ - int readData(char *buffer, int len); - - /** - * Writes the data in the buffer to the device - * - * @param buffer Buffer to hold the data read - * @param len Length of the buffer - * @return Number of bytes written - */ - int writeData(char *buffer, int len); - - /** - * Sets up proper tty I/O modes and the baud rate. The default - * baud rate is 9,600 (B9600). - * - * @param baud Desired baud rate - * @return True if successful - */ - bool setupTty(speed_t baud=B9600); - - protected: - int ttyFd() { return m_ttyFd; }; - - private: - mraa_uart_context m_uart; - int m_ttyFd; - }; -} - -