UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

NMEAGPS Class

Module: common

Methods

NMEAGPS

(
  • uart
  • baudrate
  • enable_pin
)
Number

NMEAGPS object constructor for a UART

Parameters:

  • uart Number

    Specify which mraa uart index to use.

  • baudrate Number

    Specify the baudrate to use. The device defaults to 9600 baud.

  • enable_pin Number

    Specify the GPIO pin to use for the enable pin, -1 to not use an enable pin.

Returns:

Number:

NMEAGPS

(
  • uart
  • baudrate
)
Number

NMEAGPS object constructor for a UART

Parameters:

  • uart Const std::string *

    Specify which uart to use (fs device path)

  • baudrate Number

    Specify the baudrate to use. The device defaults to 9600 baud.

Returns:

Number:

NMEAGPS

(
  • bus
  • addr
)
Number

NMEAGPS object constructor for a UBLOX I2C interface

Parameters:

  • bus Number

    Specify which the I2C bus to use.

  • addr Number

    Specify the I2C address to use. For UBLOX devices, this typically defaults to 0x42.

Returns:

Number:

readStr

(
  • size
)
String

Read character data from the device.

Parameters:

  • size Number

    The maximum number of characters to read.

Returns:

String:

string containing the data read.

writeStr

(
  • buffer
)
Number

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

Parameters:

  • buffer Const std::string *

    The string containing the data to write.

Returns:

Number:

The number of bytes written.

enable

(
  • 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:

  • enable Boolean

    true to enable the device, false otherwise.

setBaudrate

(
  • 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:

  • baudrate Number

    The baud rate to set for the device.

dataAvailable

(
  • millis
)
Boolean

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:

  • millis Number

    The number of milliseconds to wait for data to become available.

Returns:

Boolean:

true if data is available to be read, false otherwise.

getMaxQueueDepth

() Number

Return the current maximum queue depth.

Returns:

Number:

Maximum queue depth

setMaxQueueDepth

(
  • depth
)
Number

Set the current maximum queue depth.

Parameters:

  • depth Number

    New target queue depth 1 <= depth <= 1000

Returns:

Number:

Actual maximum queue depth

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

parseStop

()

Stop a running NMEA parsing thread

isRunning

() Boolean

Is the parsing thread currently running?

Returns:

Boolean:

True if parsing

getFix

() Gps_fix

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:

GPS fix structure

getRawSentence

() String

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

Returns:

String:

NMEA raw sentence

getTxtMessage

() Nmeatxt

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

Returns:

Nmeatxt:

NMEA text message

fixQueueSize

() Number

Get the number of elements in the GPS fix queue.

Returns:

Number:

Number of fixes in the GPS fix queue

rawSentenceQueueSize

() Number

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

Returns:

Number:

Number of sentences in the raw NMEA sentence queue

txtMessageQueueSize

() Number

Get the number of messages in the NMEA message queue.

Returns:

Number:

Number of messages in the message queue

parseNMEASentence

(
  • sentence
)

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

Parameters:

  • sentence Const std::string *

    NMEA raw sentence ($...
    ) inclusive

satellites

() Std::vector satellite

Return a vector of the current satellites

Returns:

Std::vector satellite :

Current satellites

sentencesPerSecond

() Number

Get the number of sentences parsed per second

Returns:

Number:

Sentences parsed per second

bytesPerSecond

() Number

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:

Number:

Total bytes read from the device/second (bps)

__str__

() String

Provide a string representation of this class

Returns:

String:

String representing this instance