..
 #############################################################
 # This file was automatically generated on 2015-05-08.      #
 #                                                           #
 # If you have a bugfix for this file and want to commit it, #
 # please fix the bug in the generator. You can find a link  #
 # to the generators git repository on tinkerforge.com       #
 #############################################################


:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-shell">Software</a> / Shell - GPS Bricklet

.. |device_identifier_constant| unicode:: 0xA0
   :trim:

.. _gps_bricklet_shell:

Shell - GPS Bricklet
====================

This is the description of the :ref:`Shell API bindings <api_bindings_shell>` for the :ref:`GPS Bricklet <gps_bricklet>`. General information and technical
specifications for the GPS Bricklet are summarized in its :ref:`hardware description
<gps_bricklet_description>`.

An :ref:`installation guide <api_bindings_shell_install>` for the Shell API
bindings is part of their general description.

.. _gps_bricklet_shell_examples:


Examples
--------

The example code below is `Public Domain (CC0 1.0)
<http://creativecommons.org/publicdomain/zero/1.0/>`__.

Simple
^^^^^^

`Download (example-simple.sh) <https://github.com/Tinkerforge/gps-bricklet/raw/master/software/examples/shell/example-simple.sh>`__

.. literalinclude:: GPS_Bricklet_Shell_example-simple.sh
 :language: bash
 :linenos:
 :tab-width: 4

Callback
^^^^^^^^

`Download (example-callback.sh) <https://github.com/Tinkerforge/gps-bricklet/raw/master/software/examples/shell/example-callback.sh>`__

.. literalinclude:: GPS_Bricklet_Shell_example-callback.sh
 :language: bash
 :linenos:
 :tab-width: 4

.. _gps_bricklet_shell_api:

API
---

Possible exit codes for all ``tinkerforge`` commands are:

* 1: interrupted (ctrl+c)
* 2: syntax error
* 21: Python 2.5 or newer is required
* 22: Python ``argparse`` module is missing
* 23: socket error
* 24: other exception
* 25: invalid placeholder in format string
* 26: authentication error
* 201: timeout occurred
* 209: invalid argument value
* 210: function is not supported
* 211: unknown error



Command Structure
^^^^^^^^^^^^^^^^^

The common options of the ``call`` and ``dispatch`` commands are documented
:ref:`here <ipcon_shell_api>`. The specific command structure is shown below.

.. sh:function:: X Stinkerforge Pcall Ngps-bricklet A[<option>..] L<uid> L<function> L[<argument>..]

 :param <uid>: string
 :param <function>: string

 The ``call`` command is used to call a function of the GPS Bricklet. It can take several
 options:

 * ``--help`` shows help for the specific ``call`` command and exits
 * ``--list-functions`` shows a list of known functions of the GPS Bricklet and exits


.. sh:function:: X Stinkerforge Pdispatch Ngps-bricklet A[<option>..] L<uid> L<callback>

 :param <uid>: string
 :param <callback>: string

 The ``dispatch`` command is used to dispatch a callback of the GPS Bricklet. It can
 take several options:

 * ``--help`` shows help for the specific ``dispatch`` command and exits
 * ``--list-callbacks`` shows a list of known callbacks of the GPS Bricklet and exits


.. sh:function:: X Stinkerforge Scall Pgps-bricklet L<uid> N<function> A[<option>..] L[<argument>..]

 :param <uid>: string
 :param <function>: string

 The ``<function>`` to be called can take different options depending of its
 kind. All functions can take the following options:

 * ``--help`` shows help for the specific function and exits

 Getter functions can take the following options:

 * ``--execute <command>`` shell command line to execute for each incoming
   response (see section about :ref:`output formatting <ipcon_shell_output>`
   for details)

 Setter functions can take the following options:

 * ``--expect-response`` requests response and waits for it

 The ``--expect-response`` option for setter functions allows to detect
 timeouts and other error conditions calls of setters as well. The device will
 then send a response for this purpose. If this option is not given for a
 setter function then no response is send and errors are silently ignored,
 because they cannot be detected.


.. sh:function:: X Stinkerforge Sdispatch Pgps-bricklet L<uid> N<callback> A[<option>..]

 :param <uid>: string
 :param <callback>: string

 The ``<callback>`` to be dispatched can take several options:

 * ``--help`` shows help for the specific callback and exits
 * ``--execute <command>`` shell command line to execute for each incoming
   response (see section about :ref:`output formatting <ipcon_shell_output>`
   for details)



Basic Functions
^^^^^^^^^^^^^^^



.. sh:function:: tinkerforge call gps-bricklet <uid> get-coordinates  


 :returns latitude: int
 :returns ns: char
 :returns longitude: int
 :returns ew: char
 :returns pdop: int
 :returns hdop: int
 :returns vdop: int
 :returns epe: int

 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 <http://en.wikipedia.org/wiki/Dilution_of_precision_(GPS)>`__
 for more information. The values are give in hundredths.
 
 EPE is the "Estimated Position Error". The EPE is given in cm. This is not the
 absolute maximum error, it is the error with a specific confidence. See
 `here <http://www.nps.gov/gis/gps/WhatisEPE.html>`__ for more information.
 
 This data is only valid if there is currently a fix as indicated by
 :sh:func:`get-status <gps-bricklet get-status>`.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-status  


 :returns fix: int (has symbols)
 :returns satellites-view: int
 :returns satellites-used: int

 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:
 
 .. csv-table::
  :header: "Value", "Description"
  :widths: 10, 100
 
  "1", "No Fix, :sh:func:`get-coordinates <gps-bricklet get-coordinates>` and :sh:func:`get-altitude <gps-bricklet get-altitude>` return invalid data"
  "2", "2D Fix, only :sh:func:`get-coordinates <gps-bricklet get-coordinates>` returns valid data"
  "3", "3D Fix, :sh:func:`get-coordinates <gps-bricklet get-coordinates>` and :sh:func:`get-altitude <gps-bricklet get-altitude>` return valid data"
 
 There is also a :ref:`blue LED <gps_bricklet_fix_led>` on the Bricklet that
 indicates the fix status.
 
 The following symbols are available for this function:
 
 * ``no-fix`` = 1, for fix
 * ``2d-fix`` = 2, for fix
 * ``3d-fix`` = 3, for fix
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-altitude  


 :returns altitude: int
 :returns geoidal-separation: int

 Returns the current altitude and corresponding geoidal separation.
 
 Both values are given in cm.
 
 This data is only valid if there is currently a fix as indicated by
 :sh:func:`get-status <gps-bricklet get-status>`.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-motion  


 :returns course: int
 :returns speed: int

 Returns the current course and speed. Course is given in hundredths degree
 and speed is given in hundredths km/h. 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
 :sh:func:`get-status <gps-bricklet get-status>`.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-date-time  


 :returns date: int
 :returns time: int

 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.05.13 as date and 195923568 means 19:59:23.568 as time.
 


Advanced Functions
^^^^^^^^^^^^^^^^^^

.. sh:function:: tinkerforge call gps-bricklet <uid> restart <restart-type> 

 :param <restart-type>: int (has symbols)

 :noreturn: no output

 Restarts the GPS Bricklet, the following restart types are available:
 
 .. csv-table::
  :header: "Value", "Description"
  :widths: 10, 100
 
  "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)"
 
 The following symbols are available for this function:
 
 * ``hot-start`` = 0, for <restart-type>
 * ``warm-start`` = 1, for <restart-type>
 * ``cold-start`` = 2, for <restart-type>
 * ``factory-reset`` = 3, for <restart-type>
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-identity  


 :returns uid: string
 :returns connected-uid: string
 :returns position: char
 :returns hardware-version: int,int,int
 :returns firmware-version: int,int,int
 :returns device-identifier: int (has symbols)

 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' or 'd'.
 
 The device identifier numbers can be found :ref:`here <device_identifier>`.
 |device_identifier_constant|
 


Callback Configuration Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. sh:function:: tinkerforge call gps-bricklet <uid> set-coordinates-callback-period <period> 

 :param <period>: int

 :noreturn: no output

 Sets the period in ms with which the :sh:func:`coordinates <gps-bricklet coordinates>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :sh:func:`coordinates <gps-bricklet coordinates>` is only triggered if the coordinates changed since the
 last triggering.
 
 The default value is 0.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-coordinates-callback-period  


 :returns period: int

 Returns the period as set by :sh:func:`set-coordinates-callback-period <gps-bricklet set-coordinates-callback-period>`.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> set-status-callback-period <period> 

 :param <period>: int

 :noreturn: no output

 Sets the period in ms with which the :sh:func:`status <gps-bricklet status>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :sh:func:`status <gps-bricklet status>` is only triggered if the status changed since the
 last triggering.
 
 The default value is 0.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-status-callback-period  


 :returns period: int

 Returns the period as set by :sh:func:`set-status-callback-period <gps-bricklet set-status-callback-period>`.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> set-altitude-callback-period <period> 

 :param <period>: int

 :noreturn: no output

 Sets the period in ms with which the :sh:func:`altitude <gps-bricklet altitude>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :sh:func:`altitude <gps-bricklet altitude>` is only triggered if the altitude changed since the
 last triggering.
 
 The default value is 0.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-altitude-callback-period  


 :returns period: int

 Returns the period as set by :sh:func:`set-altitude-callback-period <gps-bricklet set-altitude-callback-period>`.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> set-motion-callback-period <period> 

 :param <period>: int

 :noreturn: no output

 Sets the period in ms with which the :sh:func:`motion <gps-bricklet motion>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :sh:func:`motion <gps-bricklet motion>` is only triggered if the motion changed since the
 last triggering.
 
 The default value is 0.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-motion-callback-period  


 :returns period: int

 Returns the period as set by :sh:func:`set-motion-callback-period <gps-bricklet set-motion-callback-period>`.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> set-date-time-callback-period <period> 

 :param <period>: int

 :noreturn: no output

 Sets the period in ms with which the :sh:func:`date-time <gps-bricklet date-time>` callback is triggered
 periodically. A value of 0 turns the callback off.
 
 :sh:func:`date-time <gps-bricklet date-time>` is only triggered if the date or time changed since the
 last triggering.
 
 The default value is 0.
 
.. sh:function:: tinkerforge call gps-bricklet <uid> get-date-time-callback-period  


 :returns period: int

 Returns the period as set by :sh:func:`set-date-time-callback-period <gps-bricklet set-date-time-callback-period>`.
 


.. _gps_bricklet_shell_callbacks:

Callbacks
^^^^^^^^^

Callbacks can be used to receive time critical or recurring data from the
device:

.. code-block:: bash

    tinkerforge dispatch gps-bricklet <uid> example

The available callbacks are described below.

.. note::
 Using callbacks for recurring events is *always* preferred
 compared to using getters. It will use less USB bandwidth and the latency
 will be a lot better, since there is no round trip time.

.. sh:function::  tinkerforge dispatch gps-bricklet <uid> coordinates

 :returns latitude: int
 :returns ns: char
 :returns longitude: int
 :returns ew: char
 :returns pdop: int
 :returns hdop: int
 :returns vdop: int
 :returns epe: int


 This callback is triggered periodically with the period that is set by
 :sh:func:`set-coordinates-callback-period <gps-bricklet set-coordinates-callback-period>`. The parameters are the same
 as for :sh:func:`get-coordinates <gps-bricklet get-coordinates>`.
 
 :sh:func:`coordinates <gps-bricklet coordinates>` is only triggered if the coordinates changed since the
 last triggering and if there is currently a fix as indicated by
 :sh:func:`get-status <gps-bricklet get-status>`.
 
.. sh:function::  tinkerforge dispatch gps-bricklet <uid> status

 :returns fix: int (has symbols)
 :returns satellites-view: int
 :returns satellites-used: int


 This callback is triggered periodically with the period that is set by
 :sh:func:`set-status-callback-period <gps-bricklet set-status-callback-period>`. The parameters are the same
 as for :sh:func:`get-status <gps-bricklet get-status>`.
 
 :sh:func:`status <gps-bricklet status>` is only triggered if the status changed since the
 last triggering.
 
 The following symbols are available for this function:
 
 * ``no-fix`` = 1, for fix
 * ``2d-fix`` = 2, for fix
 * ``3d-fix`` = 3, for fix
 
.. sh:function::  tinkerforge dispatch gps-bricklet <uid> altitude

 :returns altitude: int
 :returns geoidal-separation: int


 This callback is triggered periodically with the period that is set by
 :sh:func:`set-altitude-callback-period <gps-bricklet set-altitude-callback-period>`. The parameters are the same
 as for :sh:func:`get-altitude <gps-bricklet get-altitude>`.
 
 :sh:func:`altitude <gps-bricklet altitude>` is only triggered if the altitude changed since the
 last triggering and if there is currently a fix as indicated by
 :sh:func:`get-status <gps-bricklet get-status>`.
 
.. sh:function::  tinkerforge dispatch gps-bricklet <uid> motion

 :returns course: int
 :returns speed: int


 This callback is triggered periodically with the period that is set by
 :sh:func:`set-motion-callback-period <gps-bricklet set-motion-callback-period>`. The parameters are the same
 as for :sh:func:`get-motion <gps-bricklet get-motion>`.
 
 :sh:func:`motion <gps-bricklet motion>` is only triggered if the motion changed since the
 last triggering and if there is currently a fix as indicated by
 :sh:func:`get-status <gps-bricklet get-status>`.
 
.. sh:function::  tinkerforge dispatch gps-bricklet <uid> date-time

 :returns date: int
 :returns time: int


 This callback is triggered periodically with the period that is set by
 :sh:func:`set-date-time-callback-period <gps-bricklet set-date-time-callback-period>`. The parameters are the same
 as for :sh:func:`get-date-time <gps-bricklet get-date-time>`.
 
 :sh:func:`date-time <gps-bricklet date-time>` is only triggered if the date or time changed since the
 last triggering.
 


