upm
1.5.0
Sensor/Actuator repository for libmraa (v1.8.0)
|
API for the NMEA GPS Module. More...
This driver was tested with a number of GPS devices that emit NMEA data via a serial interface of some sort (typically a UART).
The I2C capablity was tested with a UBLOX LEA-6H based GPS shield from DFRobot. Currently, the I2C capability is only supported for UBLOX devices (or compatibles) that conform to the specifications outlined in the u-blox6 Receiver Description Protocol Specification, Chapter 4, DDC Port.
An example using the UART.
An example using I2C.
Public Member Functions | |
NMEAGPS (unsigned int uart, unsigned int baudrate, int enable_pin) | |
NMEAGPS (unsigned int bus, uint8_t addr) | |
~NMEAGPS () | |
std::string | readStr (size_t size) |
int | writeStr (std::string buffer) |
void | enable (bool enable) |
void | setBaudrate (unsigned int baudrate) |
bool | dataAvailable (unsigned int millis) |
Protected Attributes | |
nmea_gps_context | m_nmea_gps |
NMEAGPS | ( | unsigned int | uart, |
unsigned int | baudrate, | ||
int | enable_pin | ||
) |
NMEAGPS object constructor for a UART
uart | Specify which uart to use. |
baudrate | Specify the baudrate to use. The device defaults to 9600 baud. |
enable_pin | Specify the GPIO pin to use for the enable pin, -1 to not use an enable pin. |
NMEAGPS | ( | unsigned int | bus, |
uint8_t | addr | ||
) |
NMEAGPS object constructor for a UBLOX I2C interface
bus | Specify which the I2C bus to use. |
addr | Specify the I2C address to use. For UBLOX devices, this typically defaults to 0x42. |
std::string readStr | ( | size_t | size | ) |
Read character data from the device.
size | The maximum number of characters to read. |
int writeStr | ( | std::string | buffer | ) |
Write character data to the device. This is only valid for a UART device.
buffer | The string containing the data to write. |
void enable | ( | bool | enable | ) |
Enable or disable the device. When disabled, the device enters a low power mode and does not emit NMEA data. It will still maintain location data however.
enable | true to enable the device, false otherwise. |
void setBaudrate | ( | unsigned int | baudrate | ) |
Set the baudrate of the device. By default, the constructor will set the baudrate to 9600. This is only valid for UART devices.
baudrate | The baud rate to set for the device. |
bool dataAvailable | ( | unsigned int | millis | ) |
Determine whether there is data available to be read. In the case of a UART, this function will wait up to "millis" milliseconds for data to become available. In the case of an I2C device, the millis argument is ignored and the function will return immediately, indicating whether data is available.
millis | The number of milliseconds to wait for data to become available. |