class Tinkerforge::BrickletGPS

Determine position, velocity and altitude using GPS

Constants

CALLBACK_ALTITUDE

This callback is triggered periodically with the period that is set by BrickletGPS#set_altitude_callback_period. The parameters are the same as for BrickletGPS#get_altitude.

The CALLBACK_ALTITUDE callback is only triggered if the altitude changed since the last triggering and if there is currently a fix as indicated by BrickletGPS#get_status.

CALLBACK_COORDINATES

This callback is triggered periodically with the period that is set by BrickletGPS#set_coordinates_callback_period. The parameters are the same as for BrickletGPS#get_coordinates.

The CALLBACK_COORDINATES callback is only triggered if the coordinates changed since the last triggering and if there is currently a fix as indicated by BrickletGPS#get_status.

CALLBACK_DATE_TIME

This callback is triggered periodically with the period that is set by BrickletGPS#set_date_time_callback_period. The parameters are the same as for BrickletGPS#get_date_time.

The CALLBACK_DATE_TIME callback is only triggered if the date or time changed since the last triggering.

CALLBACK_MOTION

This callback is triggered periodically with the period that is set by BrickletGPS#set_motion_callback_period. The parameters are the same as for BrickletGPS#get_motion.

The CALLBACK_MOTION callback is only triggered if the motion changed since the last triggering and if there is currently a fix as indicated by BrickletGPS#get_status.

CALLBACK_STATUS

This callback is triggered periodically with the period that is set by BrickletGPS#set_status_callback_period. The parameters are the same as for BrickletGPS#get_status.

The CALLBACK_STATUS callback is only triggered if the status changed since the last triggering.

Public Class Methods

new(uid, ipcon) click to toggle source

Creates an object with the unique device ID uid and adds it to the IP Connection ipcon.

Calls superclass method
# File lib/tinkerforge/bricklet_gps.rb, line 90
def initialize(uid, ipcon)
  super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME

  @api_version = [2, 0, 1]

  @response_expected[FUNCTION_GET_COORDINATES] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_ALTITUDE] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_MOTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_DATE_TIME] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_RESTART] = RESPONSE_EXPECTED_FALSE
  @response_expected[FUNCTION_SET_COORDINATES_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_COORDINATES_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_STATUS_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_STATUS_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_ALTITUDE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_ALTITUDE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_MOTION_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_MOTION_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_SET_DATE_TIME_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
  @response_expected[FUNCTION_GET_DATE_TIME_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE

  @callback_formats[CALLBACK_COORDINATES] = [26, 'L k L k S S S S']
  @callback_formats[CALLBACK_STATUS] = [11, 'C C C']
  @callback_formats[CALLBACK_ALTITUDE] = [16, 'l l']
  @callback_formats[CALLBACK_MOTION] = [16, 'L L']
  @callback_formats[CALLBACK_DATE_TIME] = [16, 'L L']

  @ipcon.add_device self
end

Public Instance Methods

get_altitude() click to toggle source

Returns the current altitude and corresponding geoidal separation.

This data is only valid if there is currently a fix as indicated by BrickletGPS#get_status.

# File lib/tinkerforge/bricklet_gps.rb, line 169
def get_altitude
  check_validity

  send_request FUNCTION_GET_ALTITUDE, [], '', 16, 'l l'
end
get_altitude_callback_period() click to toggle source

Returns the period as set by BrickletGPS#set_altitude_callback_period.

# File lib/tinkerforge/bricklet_gps.rb, line 261
def get_altitude_callback_period
  check_validity

  send_request FUNCTION_GET_ALTITUDE_CALLBACK_PERIOD, [], '', 12, 'L'
end
get_coordinates() click to toggle source

Returns the GPS coordinates. Latitude and longitude are given in the “DD.dddddd°“ format, the value 57123468 means 57.123468°. The parameter “ns“ and “ew“ are the cardinal directions for latitude and longitude. Possible values for “ns“ and “ew“ are 'N', 'S', 'E' and 'W' (north, south, east and west).

PDOP, HDOP and VDOP are the dilution of precision (DOP) values. They specify the additional multiplicative effect of GPS satellite geometry on GPS precision. See `here <`__“>www.nps.gov/gis/gps/WhatisEPE.html>`__ for more information.

This data is only valid if there is currently a fix as indicated by BrickletGPS#get_status.

# File lib/tinkerforge/bricklet_gps.rb, line 140
def get_coordinates
  check_validity

  send_request FUNCTION_GET_COORDINATES, [], '', 26, 'L k L k S S S S'
end
get_coordinates_callback_period() click to toggle source

Returns the period as set by BrickletGPS#set_coordinates_callback_period.

# File lib/tinkerforge/bricklet_gps.rb, line 225
def get_coordinates_callback_period
  check_validity

  send_request FUNCTION_GET_COORDINATES_CALLBACK_PERIOD, [], '', 12, 'L'
end
get_date_time() click to toggle source

Returns the current date and time. The date is given in the format “ddmmyy“ and the time is given in the format “hhmmss.sss“. For example, 140713 means 14.07.13 as date and 195923568 means 19:59:23.568 as time.

# File lib/tinkerforge/bricklet_gps.rb, line 193
def get_date_time
  check_validity

  send_request FUNCTION_GET_DATE_TIME, [], '', 16, 'L L'
end
get_date_time_callback_period() click to toggle source

Returns the period as set by BrickletGPS#set_date_time_callback_period.

# File lib/tinkerforge/bricklet_gps.rb, line 297
def get_date_time_callback_period
  check_validity

  send_request FUNCTION_GET_DATE_TIME_CALLBACK_PERIOD, [], '', 12, 'L'
end
get_identity() click to toggle source

Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.

The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'.

The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|

# File lib/tinkerforge/bricklet_gps.rb, line 313
def get_identity
  send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
end
get_motion() click to toggle source

Returns the current course and speed. A course of 0° means the Bricklet is traveling north bound and 90° means it is traveling east bound.

Please note that this only returns useful values if an actual movement is present.

This data is only valid if there is currently a fix as indicated by BrickletGPS#get_status.

# File lib/tinkerforge/bricklet_gps.rb, line 183
def get_motion
  check_validity

  send_request FUNCTION_GET_MOTION, [], '', 16, 'L L'
end
get_motion_callback_period() click to toggle source

Returns the period as set by BrickletGPS#set_motion_callback_period.

# File lib/tinkerforge/bricklet_gps.rb, line 279
def get_motion_callback_period
  check_validity

  send_request FUNCTION_GET_MOTION_CALLBACK_PERIOD, [], '', 12, 'L'
end
get_status() click to toggle source

Returns the current fix status, the number of satellites that are in view and the number of satellites that are currently used.

Possible fix status values can be:

"Value", "Description"

"1", "No Fix, BrickletGPS#get_coordinates, BrickletGPS#get_altitude and BrickletGPS#get_motion return invalid data"
"2", "2D Fix, only BrickletGPS#get_coordinates and BrickletGPS#get_motion return valid data"
"3", "3D Fix, BrickletGPS#get_coordinates, BrickletGPS#get_altitude and BrickletGPS#get_motion return valid data"

There is also a :ref:`blue LED <gps_bricklet_fix_led>` on the Bricklet that indicates the fix status.

# File lib/tinkerforge/bricklet_gps.rb, line 159
def get_status
  check_validity

  send_request FUNCTION_GET_STATUS, [], '', 11, 'C C C'
end
get_status_callback_period() click to toggle source

Returns the period as set by BrickletGPS#set_status_callback_period.

# File lib/tinkerforge/bricklet_gps.rb, line 243
def get_status_callback_period
  check_validity

  send_request FUNCTION_GET_STATUS_CALLBACK_PERIOD, [], '', 12, 'L'
end
register_callback(id, &block) click to toggle source

Registers a callback with ID id to the block block.

# File lib/tinkerforge/bricklet_gps.rb, line 318
def register_callback(id, &block)
  callback = block
  @registered_callbacks[id] = callback
end
restart(restart_type) click to toggle source

Restarts the GPS Bricklet, the following restart types are available:

"Value", "Description"

"0", "Hot start (use all available data in the NV store)"
"1", "Warm start (don't use ephemeris at restart)"
"2", "Cold start (don't use time, position, almanacs and ephemeris at restart)"
"3", "Factory reset (clear all system/user configurations at restart)"
# File lib/tinkerforge/bricklet_gps.rb, line 207
def restart(restart_type)
  check_validity

  send_request FUNCTION_RESTART, [restart_type], 'C', 8, ''
end
set_altitude_callback_period(period) click to toggle source

Sets the period with which the CALLBACK_ALTITUDE callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_ALTITUDE callback is only triggered if the altitude changed since the last triggering.

# File lib/tinkerforge/bricklet_gps.rb, line 254
def set_altitude_callback_period(period)
  check_validity

  send_request FUNCTION_SET_ALTITUDE_CALLBACK_PERIOD, [period], 'L', 8, ''
end
set_coordinates_callback_period(period) click to toggle source

Sets the period with which the CALLBACK_COORDINATES callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_COORDINATES callback is only triggered if the coordinates changed since the last triggering.

# File lib/tinkerforge/bricklet_gps.rb, line 218
def set_coordinates_callback_period(period)
  check_validity

  send_request FUNCTION_SET_COORDINATES_CALLBACK_PERIOD, [period], 'L', 8, ''
end
set_date_time_callback_period(period) click to toggle source

Sets the period with which the CALLBACK_DATE_TIME callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_DATE_TIME callback is only triggered if the date or time changed since the last triggering.

# File lib/tinkerforge/bricklet_gps.rb, line 290
def set_date_time_callback_period(period)
  check_validity

  send_request FUNCTION_SET_DATE_TIME_CALLBACK_PERIOD, [period], 'L', 8, ''
end
set_motion_callback_period(period) click to toggle source

Sets the period with which the CALLBACK_MOTION callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_MOTION callback is only triggered if the motion changed since the last triggering.

# File lib/tinkerforge/bricklet_gps.rb, line 272
def set_motion_callback_period(period)
  check_validity

  send_request FUNCTION_SET_MOTION_CALLBACK_PERIOD, [period], 'L', 8, ''
end
set_status_callback_period(period) click to toggle source

Sets the period with which the CALLBACK_STATUS callback is triggered periodically. A value of 0 turns the callback off.

The CALLBACK_STATUS callback is only triggered if the status changed since the last triggering.

# File lib/tinkerforge/bricklet_gps.rb, line 236
def set_status_callback_period(period)
  check_validity

  send_request FUNCTION_SET_STATUS_CALLBACK_PERIOD, [period], 'L', 8, ''
end