mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 09:21:12 +03:00
ublox6: remove driver and replace with generic nmea_gps driver
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
@ -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()
|
@ -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);
|
||||
}
|
||||
}
|
||||
%}
|
@ -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);
|
@ -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);
|
@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* 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 <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#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;
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* 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 <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <mraa/uart.h>
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user