nmea_gps: renamed vk2828u7 to nmea_gps

This driver will serve as a generic module for grabbing NMEA data from
various GPS devices via a serial interface.  ublox6 will also be
removed in favor of using this driver going forward.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson 2016-08-25 13:54:49 -06:00 committed by Noel Eck
parent 46460e20d9
commit a040f51cda
19 changed files with 152 additions and 155 deletions

View File

@ -274,7 +274,7 @@ add_example (l3gd20)
add_example (l3gd20-i2c) add_example (l3gd20-i2c)
add_example (bmx055) add_example (bmx055)
add_example (ms5611) add_example (ms5611)
add_example (vk2828u7) add_example (nmea_gps)
add_example (mma7361) add_example (mma7361)
add_example (bh1750) add_example (bh1750)

View File

@ -26,7 +26,7 @@
#include <iostream> #include <iostream>
#include <signal.h> #include <signal.h>
#include "vk2828u7.hpp" #include "nmea_gps.hpp"
using namespace std; using namespace std;
@ -46,9 +46,9 @@ int main()
//! [Interesting] //! [Interesting]
// Instantiate a VK2828U7 sensor on uart 0 at 9600 baud with enable // Instantiate a NMEA_GPS sensor on uart 0 at 9600 baud with enable
// pin on D3 // pin on D3. If you do not need an enable pin, you can specify -1.
upm::VK2828U7 *sensor = new upm::VK2828U7(0, 9600, 3); upm::NMEAGPS *sensor = new upm::NMEAGPS(0, 9600, 3);
// loop, dumping NMEA data out as fast as it comes in // loop, dumping NMEA data out as fast as it comes in
while (shouldRun && sensor->dataAvailable(5000)) while (shouldRun && sensor->dataAvailable(5000))

View File

@ -87,7 +87,7 @@ link_directories (${MRAA_LIBDIR})
# mq? will use module gas # mq? will use module gas
# grove* will use module grove # grove* will use module grove
add_example (dfrph) add_example (dfrph)
add_example (vk2828u7) add_example (nmea_gps)
add_example (mma7361) add_example (mma7361)
add_example (bh1750) add_example (bh1750)
add_example (urm37) add_example (urm37)

View File

@ -25,7 +25,7 @@
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include "vk2828u7.h" #include "nmea_gps.h"
bool shouldRun = true; bool shouldRun = true;
@ -43,13 +43,13 @@ int main()
//! [Interesting] //! [Interesting]
// Instantiate a VK2828U7 sensor on uart 0 at 9600 baud with enable // Instantiate a NMEA_GPS sensor on uart 0 at 9600 baud with enable
// pin on D3 // pin on D3. If you do not need an enable pin, you can specify -1.
vk2828u7_context sensor = vk2828u7_init(0, 9600, 3); nmea_gps_context sensor = nmea_gps_init(0, 9600, 3);
if (!sensor) if (!sensor)
{ {
printf("vk2828u7_init() failed.\n"); printf("nmea_gps_init() failed.\n");
return 1; return 1;
} }
@ -57,9 +57,9 @@ int main()
int rv = 0; int rv = 0;
// loop, dumping NMEA data out as fast as it comes in // loop, dumping NMEA data out as fast as it comes in
while (shouldRun && vk2828u7_data_available(sensor, 5000)) while (shouldRun && nmea_gps_data_available(sensor, 5000))
{ {
if ((rv = vk2828u7_read(sensor, buffer, bufferLength)) >= 0) if ((rv = nmea_gps_read(sensor, buffer, bufferLength)) >= 0)
{ {
int i; int i;
for (i=0; i<rv; i++) for (i=0; i<rv; i++)
@ -74,7 +74,7 @@ int main()
printf("Exiting\n"); printf("Exiting\n");
vk2828u7_close(sensor); nmea_gps_close(sensor);
return 0; return 0;
} }

View File

@ -131,7 +131,7 @@ add_example(VCAP_Example vcap)
add_example(BMP280_Example bmp280) add_example(BMP280_Example bmp280)
add_example(BNO055_Example bno055) add_example(BNO055_Example bno055)
add_example(BMX055_Example bmx055) add_example(BMX055_Example bmx055)
add_example(VK2828U7_Example vk2828u7) add_example(NMEAGPS_Example nmea_gps)
add_example(MMA7361_Example mma7361) add_example(MMA7361_Example mma7361)
add_example(BH1750_Example bh1750) add_example(BH1750_Example bh1750)

View File

@ -22,18 +22,18 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
import upm_vk2828u7.VK2828U7; import upm_nmea_gps.NMEAGPS;
public class VK2828U7_Example public class NMEAGPS_Example
{ {
public static void main(String[] args) throws InterruptedException public static void main(String[] args) throws InterruptedException
{ {
// ! [Interesting] // ! [Interesting]
System.out.println("Initializing..."); System.out.println("Initializing...");
// Instantiate a VK2828U7 sensor on uart 0 at 9600 baud with // Instantiate a NMEAGPS sensor on uart 0 at 9600 baud with
// enable pin on D3 // enable pin on D3
VK2828U7 sensor = new VK2828U7(0, 9600, 3); NMEAGPS sensor = new NMEAGPS(0, 9600, 3);
// loop, dumping NMEA data out as fast as it comes in // loop, dumping NMEA data out as fast as it comes in
while (sensor.dataAvailable(5000)) while (sensor.dataAvailable(5000))

View File

@ -25,11 +25,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
var sensorObj = require('jsupm_vk2828u7'); var sensorObj = require('jsupm_nmea_gps');
// Instantiate a VK2828U7 sensor on uart 0 at 9600 baud with enable // Instantiate a NMEAGPS sensor on uart 0 at 9600 baud with enable
// pin on D3 // pin on D3
var sensor = new sensorObj.VK2828U7(0, 9600, 3); var sensor = new sensorObj.NMEAGPS(0, 9600, 3);
// loop, dumping NMEA data out as fast as it comes in // loop, dumping NMEA data out as fast as it comes in
while (sensor.dataAvailable(5000)) while (sensor.dataAvailable(5000))

View File

@ -22,11 +22,11 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit import time, sys, signal, atexit
import pyupm_vk2828u7 as sensorObj import pyupm_nmea_gps as sensorObj
# Instantiate a VK2828U7 sensor on uart 0 at 9600 baud with enable # Instantiate a NMEAGPS sensor on uart 0 at 9600 baud with enable
# pin on D3 # pin on D3
sensor = sensorObj.VK2828U7(0, 9600, 3) sensor = sensorObj.NMEAGPS(0, 9600, 3)
## Exit handlers ## ## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C # This function stops python from printing a stacktrace when you hit control-C
@ -42,7 +42,7 @@ def exitHandler():
atexit.register(exitHandler) atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler) signal.signal(signal.SIGINT, SIGINTHandler)
# Every second, sample the VK2828U7 and output the measured lux value # Every second, sample the NMEAGPS and output the measured lux value
# loop, dumping NMEA data out as fast as it comes in # loop, dumping NMEA data out as fast as it comes in
while (sensor.dataAvailable(5000)): while (sensor.dataAvailable(5000)):

View File

@ -0,0 +1,9 @@
upm_mixed_module_init (NAME nmea_gps
DESCRIPTION "UPM Generic driver for GPS NMEA sensors"
C_HDR nmea_gps.h
C_SRC nmea_gps.c
CPP_HDR nmea_gps.hpp
CPP_SRC nmea_gps.cxx
FTI_SRC nmea_gps_fti.c
CPP_WRAPS_C
REQUIRES mraa)

View File

@ -1,17 +1,17 @@
%module javaupm_vk2828u7 %module javaupm_nmea_gps
%include "../upm.i" %include "../upm.i"
%include "std_string.i" %include "std_string.i"
%include "typemaps.i" %include "typemaps.i"
%include "vk2828u7.hpp" %include "nmea_gps.hpp"
%{ %{
#include "vk2828u7.hpp" #include "nmea_gps.hpp"
%} %}
%pragma(java) jniclasscode=%{ %pragma(java) jniclasscode=%{
static { static {
try { try {
System.loadLibrary("javaupm_vk2828u7"); System.loadLibrary("javaupm_nmea_gps");
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e); System.err.println("Native code library failed to load. \n" + e);
System.exit(1); System.exit(1);

View File

@ -0,0 +1,9 @@
%module jsupm_nmea_gps
%include "../upm.i"
%include "std_string.i"
%include "nmea_gps.hpp"
%{
#include "nmea_gps.hpp"
%}

View File

@ -25,21 +25,21 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include "vk2828u7.h" #include "nmea_gps.h"
#include "upm_utilities.h" #include "upm_utilities.h"
vk2828u7_context vk2828u7_init(unsigned int uart, unsigned int baudrate, nmea_gps_context nmea_gps_init(unsigned int uart, unsigned int baudrate,
int enable_pin) int enable_pin)
{ {
vk2828u7_context dev = nmea_gps_context dev =
(vk2828u7_context)malloc(sizeof(struct _vk2828u7_context)); (nmea_gps_context)malloc(sizeof(struct _nmea_gps_context));
if (!dev) if (!dev)
return NULL; return NULL;
// zero out context // zero out context
memset((void *)dev, 0, sizeof(struct _vk2828u7_context)); memset((void *)dev, 0, sizeof(struct _nmea_gps_context));
dev->uart = NULL; dev->uart = NULL;
dev->gpio_en = NULL; dev->gpio_en = NULL;
@ -50,14 +50,14 @@ vk2828u7_context vk2828u7_init(unsigned int uart, unsigned int baudrate,
if (!(dev->uart = mraa_uart_init(uart))) if (!(dev->uart = mraa_uart_init(uart)))
{ {
printf("%s: mraa_uart_init() failed.\n", __FUNCTION__); printf("%s: mraa_uart_init() failed.\n", __FUNCTION__);
vk2828u7_close(dev); nmea_gps_close(dev);
return NULL; return NULL;
} }
if (vk2828u7_set_baudrate(dev, baudrate)) if (nmea_gps_set_baudrate(dev, baudrate))
{ {
printf("%s: vk2828u7_set_baudrate() failed.\n", __FUNCTION__); printf("%s: nmea_gps_set_baudrate() failed.\n", __FUNCTION__);
vk2828u7_close(dev); nmea_gps_close(dev);
return NULL; return NULL;
} }
@ -69,25 +69,25 @@ vk2828u7_context vk2828u7_init(unsigned int uart, unsigned int baudrate,
if (!(dev->gpio_en = mraa_gpio_init(enable_pin))) if (!(dev->gpio_en = mraa_gpio_init(enable_pin)))
{ {
printf("%s: mraa_gpio_init() failed.\n", __FUNCTION__); printf("%s: mraa_gpio_init() failed.\n", __FUNCTION__);
vk2828u7_close(dev); nmea_gps_close(dev);
return NULL; return NULL;
} }
mraa_gpio_dir(dev->gpio_en, MRAA_GPIO_OUT); mraa_gpio_dir(dev->gpio_en, MRAA_GPIO_OUT);
// wake up // wake up
vk2828u7_enable(dev, true); nmea_gps_enable(dev, true);
} }
return dev; return dev;
} }
void vk2828u7_close(vk2828u7_context dev) void nmea_gps_close(nmea_gps_context dev)
{ {
assert(dev != NULL); assert(dev != NULL);
// sleepy-time // sleepy-time
vk2828u7_enable(dev, false); nmea_gps_enable(dev, false);
if (dev->uart) if (dev->uart)
mraa_uart_stop(dev->uart); mraa_uart_stop(dev->uart);
@ -97,7 +97,7 @@ void vk2828u7_close(vk2828u7_context dev)
free(dev); free(dev);
} }
upm_result_t vk2828u7_enable(const vk2828u7_context dev, bool enable) upm_result_t nmea_gps_enable(const nmea_gps_context dev, bool enable)
{ {
assert(dev != NULL); assert(dev != NULL);
@ -112,21 +112,21 @@ upm_result_t vk2828u7_enable(const vk2828u7_context dev, bool enable)
return UPM_SUCCESS; return UPM_SUCCESS;
} }
int vk2828u7_read(const vk2828u7_context dev, char *buffer, size_t len) int nmea_gps_read(const nmea_gps_context dev, char *buffer, size_t len)
{ {
assert(dev != NULL); assert(dev != NULL);
return mraa_uart_read(dev->uart, buffer, len); return mraa_uart_read(dev->uart, buffer, len);
} }
int vk2828u7_write(const vk2828u7_context dev, char *buffer, size_t len) int nmea_gps_write(const nmea_gps_context dev, char *buffer, size_t len)
{ {
assert(dev != NULL); assert(dev != NULL);
return mraa_uart_write(dev->uart, buffer, len); return mraa_uart_write(dev->uart, buffer, len);
} }
bool vk2828u7_data_available(const vk2828u7_context dev, unsigned int millis) bool nmea_gps_data_available(const nmea_gps_context dev, unsigned int millis)
{ {
assert(dev != NULL); assert(dev != NULL);
@ -136,7 +136,7 @@ bool vk2828u7_data_available(const vk2828u7_context dev, unsigned int millis)
return false; return false;
} }
upm_result_t vk2828u7_set_baudrate(const vk2828u7_context dev, upm_result_t nmea_gps_set_baudrate(const nmea_gps_context dev,
unsigned int baudrate) unsigned int baudrate)
{ {
assert(dev != NULL); assert(dev != NULL);

View File

@ -25,65 +25,65 @@
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include "vk2828u7.hpp" #include "nmea_gps.hpp"
using namespace upm; using namespace upm;
using namespace std; using namespace std;
VK2828U7::VK2828U7(unsigned int uart, unsigned int baudrate, NMEAGPS::NMEAGPS(unsigned int uart, unsigned int baudrate,
int enable_pin) : int enable_pin) :
m_vk2828u7(vk2828u7_init(uart, baudrate, enable_pin)) m_nmea_gps(nmea_gps_init(uart, baudrate, enable_pin))
{ {
if (!m_vk2828u7) if (!m_nmea_gps)
throw std::runtime_error(string(__FUNCTION__) throw std::runtime_error(string(__FUNCTION__)
+ ": vk2828u7_init() failed"); + ": nmea_gps_init() failed");
} }
VK2828U7::~VK2828U7() NMEAGPS::~NMEAGPS()
{ {
vk2828u7_close(m_vk2828u7); nmea_gps_close(m_nmea_gps);
} }
std::string VK2828U7::readStr(unsigned int size) std::string NMEAGPS::readStr(unsigned int size)
{ {
char buffer[size]; char buffer[size];
int rv; int rv;
if ((rv = vk2828u7_read(m_vk2828u7, buffer, size)) < 0) if ((rv = nmea_gps_read(m_nmea_gps, buffer, size)) < 0)
throw std::runtime_error(string(__FUNCTION__) throw std::runtime_error(string(__FUNCTION__)
+ ": vk2828u7_read() failed"); + ": nmea_gps_read() failed");
return string(buffer, rv); return string(buffer, rv);
} }
int VK2828U7::writeStr(std::string buffer) int NMEAGPS::writeStr(std::string buffer)
{ {
int rv; int rv;
if ((rv = vk2828u7_write(m_vk2828u7, (char*)buffer.data(), if ((rv = nmea_gps_write(m_nmea_gps, (char*)buffer.data(),
buffer.size())) < 0) buffer.size())) < 0)
throw std::runtime_error(string(__FUNCTION__) throw std::runtime_error(string(__FUNCTION__)
+ ": vk2828u7_write() failed"); + ": nmea_gps_write() failed");
return rv; return rv;
} }
void VK2828U7::enable(bool enable) void NMEAGPS::enable(bool enable)
{ {
if (vk2828u7_enable(m_vk2828u7, enable)) if (nmea_gps_enable(m_nmea_gps, enable))
throw std::runtime_error(string(__FUNCTION__) throw std::runtime_error(string(__FUNCTION__)
+ ": vk2828u7_enable() failed"); + ": nmea_gps_enable() failed");
} }
void VK2828U7::setBaudrate(unsigned int baudrate) void NMEAGPS::setBaudrate(unsigned int baudrate)
{ {
if (vk2828u7_set_baudrate(m_vk2828u7, baudrate)) if (nmea_gps_set_baudrate(m_nmea_gps, baudrate))
throw std::runtime_error(string(__FUNCTION__) throw std::runtime_error(string(__FUNCTION__)
+ ": vk2828u7_baudrate() failed"); + ": nmea_gps_baudrate() failed");
} }
bool VK2828U7::dataAvailable(unsigned int millis) bool NMEAGPS::dataAvailable(unsigned int millis)
{ {
return vk2828u7_data_available(m_vk2828u7, millis); return nmea_gps_data_available(m_nmea_gps, millis);
} }

View File

@ -34,24 +34,24 @@ extern "C" {
#endif #endif
/** /**
* @brief UPM C API for the DFRobot VK2828U7 GPS Module * @brief UPM C API for a generic GPS serial device reporting NMEA data
* *
* The driver was tested with the DFRobot VK2828U7 GPS Module. It * This driver was tested with a number of GPS devices that emit
* is accessed via a UART and provides NMEA data. * NMEA data via a serial interface of some sort (typically a UART).
* *
* @snippet vk2828u7.c Interesting * @snippet nmea_gps.c Interesting
*/ */
/** /**
* Device context * Device context
*/ */
typedef struct _vk2828u7_context { typedef struct _nmea_gps_context {
mraa_uart_context uart; mraa_uart_context uart;
mraa_gpio_context gpio_en; mraa_gpio_context gpio_en;
} *vk2828u7_context; } *nmea_gps_context;
/** /**
* VK2828U7 Initializer * NMEA_GPS Initializer
* *
* @param uart Specify which uart to use. * @param uart Specify which uart to use.
* @param baudrate Specify the baudrate to use. The device defaults * @param baudrate Specify the baudrate to use. The device defaults
@ -60,13 +60,13 @@ extern "C" {
* -1 to not use an enable pin. * -1 to not use an enable pin.
* @return an initialized device context on success, NULL on error. * @return an initialized device context on success, NULL on error.
*/ */
vk2828u7_context vk2828u7_init(unsigned int uart, unsigned int baudrate, nmea_gps_context nmea_gps_init(unsigned int uart, unsigned int baudrate,
int enable_pin); int enable_pin);
/** /**
* VK2828U7 sensor close function * NMEA_GPS sensor close function
*/ */
void vk2828u7_close(vk2828u7_context dev); void nmea_gps_close(nmea_gps_context dev);
/** /**
* Read character data from the device. * Read character data from the device.
@ -76,7 +76,7 @@ extern "C" {
* @param len The maximum size of the buffer * @param len The maximum size of the buffer
* @return The number of bytes successfully read, or -1 on error * @return The number of bytes successfully read, or -1 on error
*/ */
int vk2828u7_read(const vk2828u7_context dev, char *buffer, size_t len); int nmea_gps_read(const nmea_gps_context dev, char *buffer, size_t len);
/** /**
* Write character data to the device. * Write character data to the device.
@ -86,7 +86,7 @@ extern "C" {
* @param len The number of bytes to write. * @param len The number of bytes to write.
* @return The number of bytes successfully written, or -1 on error. * @return The number of bytes successfully written, or -1 on error.
*/ */
int vk2828u7_write(const vk2828u7_context dev, char *buffer, size_t len); int nmea_gps_write(const nmea_gps_context dev, char *buffer, size_t len);
/** /**
* Enable or disable the device. When disabled, the device enters a * Enable or disable the device. When disabled, the device enters a
@ -97,17 +97,17 @@ extern "C" {
* @param enable true to enable the device, false otherwise. * @param enable true to enable the device, false otherwise.
* @return UPM result * @return UPM result
*/ */
upm_result_t vk2828u7_enable(const vk2828u7_context dev, bool enable); upm_result_t nmea_gps_enable(const nmea_gps_context dev, bool enable);
/** /**
* Set the baudrate of the device. By default, vk2828u7_init() will * Set the baudrate of the device. By default, nmea_gps_init() will
* set the baudrate to 9600. * set the baudrate to 9600.
* *
* @param dev sensor context * @param dev sensor context
* @param baudrate The baud rate to set for the device. * @param baudrate The baud rate to set for the device.
* @return UPM result * @return UPM result
*/ */
upm_result_t vk2828u7_set_baudrate(const vk2828u7_context dev, upm_result_t nmea_gps_set_baudrate(const nmea_gps_context dev,
unsigned int baudrate); unsigned int baudrate);
/** /**
@ -118,7 +118,7 @@ extern "C" {
* become available. * become available.
* @return true if data is available to be read, false otherwise. * @return true if data is available to be read, false otherwise.
*/ */
bool vk2828u7_data_available(const vk2828u7_context dev, bool nmea_gps_data_available(const nmea_gps_context dev,
unsigned int millis); unsigned int millis);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -29,40 +29,37 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "vk2828u7.h" #include "nmea_gps.h"
namespace upm { namespace upm {
/** /**
* @brief UPM C++ API for the DFRobot VK2828U7 Analog Accelerometer * @brief UPM C++ API for a generic GPS serial device reporting NMEA data
* @defgroup vk2828u7 libupm-vk2828u7 * @defgroup nmea_gps libupm-nmea_gps
* @ingroup dfrobot uart gpio gps * @ingroup uart gpio gps
*/ */
/** /**
* @library vk2828u7 * @library nmea_gps
* @sensor vk2828u7 * @sensor nmea_gps
* @comname DFRobot VK2828U7 GPS Module * @comname Generic Serial GPS NMEA device
* @type gps * @type gps
* @man dfrobot * @man dfrobot seed
* @con uart gpio * @con uart gpio
* @web http://www.dfrobot.com/index.php?route=product/product&search=gps&description=true&product_id=1302#.V7tMfN9ytNK * @altname VK2828u7 ublox LEA-6H
* *
* @brief API for the DFRobot VK2828U7 GPS Module * @brief API for the NMEA GPS Module
* *
* The driver was tested with the DFRobot VK2828U7 GPS module. The * This driver was tested with a number of GPS devices that emit
* website claims the device can be run at 5v, however the datasheet * NMEA data via a serial interface of some sort (typically a UART).
* says the logic inputs and outputs can only handle 3.3v, and there
* does not appear to be a schematic available. So this module was
* tested only at 3.3v.
* *
* @snippet vk2828u7.cxx Interesting * @snippet nmea_gps.cxx Interesting
*/ */
class VK2828U7 { class NMEAGPS {
public: public:
/** /**
* VK2828U7 object constructor * NMEAGPS object constructor
* *
* @param uart Specify which uart to use. * @param uart Specify which uart to use.
* @param baudrate Specify the baudrate to use. The device defaults * @param baudrate Specify the baudrate to use. The device defaults
@ -70,13 +67,13 @@ namespace upm {
* @param enable_pin Specify the GPIO pin to use for the enable pin, * @param enable_pin Specify the GPIO pin to use for the enable pin,
* -1 to not use an enable pin. * -1 to not use an enable pin.
*/ */
VK2828U7(unsigned int uart, unsigned int baudrate, NMEAGPS(unsigned int uart, unsigned int baudrate,
int enable_pin); int enable_pin);
/** /**
* VK2828U7 object destructor * NMEAGPS object destructor
*/ */
~VK2828U7(); ~NMEAGPS();
/** /**
* Read character data from the device. * Read character data from the device.
@ -121,8 +118,8 @@ namespace upm {
bool dataAvailable(unsigned int millis); bool dataAvailable(unsigned int millis);
protected: protected:
// vk2828u7 device context // nmeaGPS device context
vk2828u7_context m_vk2828u7; nmea_gps_context m_nmea_gps;
private: private:
}; };

View File

@ -22,40 +22,40 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "vk2828u7.h" #include "nmea_gps.h"
#include "upm_fti.h" #include "upm_fti.h"
/** /**
* This file implements the Function Table Interface (FTI) for this sensor * This file implements the Function Table Interface (FTI) for this sensor
*/ */
const char upm_vk2828u7_name[] = "VK2828U7"; const char upm_nmea_gps_name[] = "NMEA_GPS";
const char upm_vk2828u7_description[] = "Serial GPS (providing NMEA data)"; const char upm_nmea_gps_description[] = "Serial GPS (providing NMEA data)";
const upm_protocol_t upm_vk2828u7_protocol[] = {UPM_UART, UPM_GPIO}; const upm_protocol_t upm_nmea_gps_protocol[] = {UPM_UART, UPM_GPIO};
const upm_sensor_t upm_vk2828u7_category[] = {UPM_STREAM}; const upm_sensor_t upm_nmea_gps_category[] = {UPM_STREAM};
// forward declarations // forward declarations
const void* upm_vk2828u7_get_ft(upm_sensor_t sensor_type); const void* upm_nmea_gps_get_ft(upm_sensor_t sensor_type);
void* upm_vk2828u7_init_name(); void* upm_nmea_gps_init_name();
void upm_vk2828u7_close(void *dev); void upm_nmea_gps_close(void *dev);
int upm_vk2828u7_read(void *dev, char *buffer, int len); int upm_nmea_gps_read(void *dev, char *buffer, int len);
int upm_vk2828u7_write(void *dev, char *buffer, int len); int upm_nmea_gps_write(void *dev, char *buffer, int len);
bool upm_vk2828u7_data_available(void *dev, unsigned int timeout); bool upm_nmea_gps_data_available(void *dev, unsigned int timeout);
static const upm_sensor_ft ft = static const upm_sensor_ft ft =
{ {
.upm_sensor_init_name = &upm_vk2828u7_init_name, .upm_sensor_init_name = &upm_nmea_gps_init_name,
.upm_sensor_close = &upm_vk2828u7_close, .upm_sensor_close = &upm_nmea_gps_close,
}; };
static const upm_stream_ft sft = static const upm_stream_ft sft =
{ {
.upm_stream_read = upm_vk2828u7_read, .upm_stream_read = upm_nmea_gps_read,
.upm_stream_write = upm_vk2828u7_write, .upm_stream_write = upm_nmea_gps_write,
.upm_stream_data_available = upm_vk2828u7_data_available .upm_stream_data_available = upm_nmea_gps_data_available
}; };
const void* upm_vk2828u7_get_ft(upm_sensor_t sensor_type) const void* upm_nmea_gps_get_ft(upm_sensor_t sensor_type)
{ {
switch(sensor_type) switch(sensor_type)
{ {
@ -70,27 +70,27 @@ const void* upm_vk2828u7_get_ft(upm_sensor_t sensor_type)
} }
} }
void* upm_vk2828u7_init_name() void* upm_nmea_gps_init_name()
{ {
return NULL; return NULL;
} }
void upm_vk2828u7_close(void *dev) void upm_nmea_gps_close(void *dev)
{ {
vk2828u7_close((vk2828u7_context)dev); nmea_gps_close((nmea_gps_context)dev);
} }
int upm_vk2828u7_read(void *dev, char *buffer, int len) int upm_nmea_gps_read(void *dev, char *buffer, int len)
{ {
return vk2828u7_read((vk2828u7_context)dev, buffer, len); return nmea_gps_read((nmea_gps_context)dev, buffer, len);
} }
int upm_vk2828u7_write(void *dev, char *buffer, int len) int upm_nmea_gps_write(void *dev, char *buffer, int len)
{ {
return vk2828u7_write((vk2828u7_context)dev, buffer, len); return nmea_gps_write((nmea_gps_context)dev, buffer, len);
} }
bool upm_vk2828u7_data_available(void *dev, unsigned int timeout) bool upm_nmea_gps_data_available(void *dev, unsigned int timeout)
{ {
return vk2828u7_data_available((vk2828u7_context)dev, timeout); return nmea_gps_data_available((nmea_gps_context)dev, timeout);
} }

View File

@ -1,13 +1,13 @@
// Include doxygen-generated documentation // Include doxygen-generated documentation
%include "pyupm_doxy2swig.i" %include "pyupm_doxy2swig.i"
%module pyupm_vk2828u7 %module pyupm_nmea_gps
%include "../upm.i" %include "../upm.i"
%include "std_string.i" %include "std_string.i"
%feature("autodoc", "3"); %feature("autodoc", "3");
%include "vk2828u7.hpp" %include "nmea_gps.hpp"
%{ %{
#include "vk2828u7.hpp" #include "nmea_gps.hpp"
%} %}

View File

@ -1,9 +0,0 @@
upm_mixed_module_init (NAME vk2828u7
DESCRIPTION "upm dfrobot VK2828u7/NMEA serial GPS sensor"
C_HDR vk2828u7.h
C_SRC vk2828u7.c
CPP_HDR vk2828u7.hpp
CPP_SRC vk2828u7.cxx
FTI_SRC vk2828u7_fti.c
CPP_WRAPS_C
REQUIRES mraa)

View File

@ -1,9 +0,0 @@
%module jsupm_vk2828u7
%include "../upm.i"
%include "std_string.i"
%include "vk2828u7.hpp"
%{
#include "vk2828u7.hpp"
%}