upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Protected Attributes
NMEAGPS Class Reference

Public Member Functions

 NMEAGPS (unsigned int uart, unsigned int baudrate, int enable_pin)
 
 NMEAGPS (const std::string &uart, unsigned int baudrate)
 
 NMEAGPS (unsigned int bus, uint8_t addr)
 
 ~NMEAGPS ()
 
std::string readStr (size_t size)
 
int writeStr (const std::string &buffer)
 
void enable (bool enable)
 
void setBaudrate (unsigned int baudrate)
 
bool dataAvailable (unsigned int millis)
 
size_t getMaxQueueDepth ()
 
size_t setMaxQueueDepth (size_t depth)
 
void parseStart ()
 
void parseStop ()
 
bool isRunning ()
 
gps_fix getFix ()
 
std::string getRawSentence ()
 
nmeatxt getTxtMessage ()
 
size_t fixQueueSize ()
 
size_t rawSentenceQueueSize ()
 
size_t txtMessageQueueSize ()
 
void parseNMEASentence (const std::string &sentence)
 
std::vector< satellitesatellites ()
 
double sentencesPerSecond ()
 
double bytesPerSecond ()
 
std::string __str__ ()
 

Protected Attributes

nmea_gps_context m_nmea_gps
 

Constructor & Destructor Documentation

NMEAGPS ( unsigned int  uart,
unsigned int  baudrate,
int  enable_pin 
)

NMEAGPS object constructor for a UART

Parameters
uartSpecify which mraa uart index to use.
baudrateSpecify the baudrate to use. The device defaults to 9600 baud.
enable_pinSpecify the GPIO pin to use for the enable pin, -1 to not use an enable pin.
NMEAGPS ( const std::string &  uart,
unsigned int  baudrate 
)

NMEAGPS object constructor for a UART

Parameters
uartSpecify which uart to use (fs device path)
baudrateSpecify the baudrate to use. The device defaults to 9600 baud.
NMEAGPS ( unsigned int  bus,
uint8_t  addr 
)

NMEAGPS object constructor for a UBLOX I2C interface

Parameters
busSpecify which the I2C bus to use.
addrSpecify the I2C address to use. For UBLOX devices, this typically defaults to 0x42.
~NMEAGPS ( )

NMEAGPS object destructor

Member Function Documentation

std::string readStr ( size_t  size)

Read character data from the device.

Parameters
sizeThe maximum number of characters to read.
Returns
string containing the data read.

Here is the caller graph for this function:

int writeStr ( const std::string &  buffer)

Write character data to the device. This is only valid for a UART device.

Parameters
bufferThe string containing the data to write.
Returns
The number of bytes written.
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.

Parameters
enabletrue 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.

Parameters
baudrateThe 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.

Parameters
millisThe number of milliseconds to wait for data to become available.
Returns
true if data is available to be read, false otherwise.

Here is the caller graph for this function:

size_t getMaxQueueDepth ( )

Return the current maximum queue depth.

Returns
Maximum queue depth

Here is the caller graph for this function:

size_t setMaxQueueDepth ( size_t  depth)

Set the current maximum queue depth.

Parameters
depthNew target queue depth 1 <= depth <= 1000
Returns
Actual maximum queue depth
void parseStart ( )

Start a NMEA parsing thread for reading/parsing NMEA sentences. The thread calls the readStr method, parsing NMEA sentences as they are encountered. Each sentence type is pushed into a corresponding queue of size

void parseStop ( )

Stop a running NMEA parsing thread

bool isRunning ( )
inline

Is the parsing thread currently running?

Returns
True if parsing

Here is the call graph for this function:

Here is the caller graph for this function:

gps_fix getFix ( )

Pop and return a GPS fix structure from the GPS fix queue. A GPS fix should only be used if valid is true.

Returns
GPS fix structure
std::string getRawSentence ( )

Pop and return a raw NMEA sentence from the NMEA sentence queue. If the queue contains no elements, an empty string is returned

Returns
NMEA raw sentence
nmeatxt getTxtMessage ( )

Pop and return a message from the message queue (GPTXT sentences) If the queue contains no elements, an empty string is returned

Returns
NMEA text message

Here is the caller graph for this function:

size_t fixQueueSize ( )

Get the number of elements in the GPS fix queue.

Returns
Number of fixes in the GPS fix queue

Here is the caller graph for this function:

size_t rawSentenceQueueSize ( )

Get the number of elements in the NMEA raw sentence queue.

Returns
Number of sentences in the raw NMEA sentence queue

Here is the caller graph for this function:

size_t txtMessageQueueSize ( )

Get the number of messages in the NMEA message queue.

Returns
Number of messages in the message queue

Here is the caller graph for this function:

void parseNMEASentence ( const std::string &  sentence)

Parse NMEA sentences. Raw sentence is placed into sentence queue. Additional structures are parsed depending on sentence type

Parameters
sentenceNMEA raw sentence ($...
) inclusive

Here is the call graph for this function:

std::vector< satellite > satellites ( )

Return a vector of the current satellites

Returns
Current satellites

Here is the caller graph for this function:

double sentencesPerSecond ( )

Get the number of sentences parsed per second

Returns
Sentences parsed per second

Here is the caller graph for this function:

double bytesPerSecond ( )

Get the throughput of the device. This number shows a rough data-rate as well as provides a bit of debug since it will show bps even if sentences are not getting parsed correctly.

Returns
Total bytes read from the device/second (bps)

Here is the caller graph for this function:

std::string __str__ ( )

Provide a string representation of this class

Returns
String representing this instance

Here is the call graph for this function:

Field Documentation

nmea_gps_context m_nmea_gps
protected

nmeaGPS device context

Collaboration diagram for NMEAGPS:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: