Editing PyMaemo/Python-GPSbt

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 11: Line 11:
API
API
-
* <code>gpsbt.start</code> - establishes a new GPS connection and returns a context. This one is is used to inform stop method what connection to be ended.
+
* gpsbt.start - establishes a new GPS connection and returns a context. This one is is used to inform stop method what connection to be ended.
-
<source lang="python">
+
 
-
context = gps.start()
+
  context = gps.start()
-
</source>
+
 
-
* <code>gpsbt.stop</code> - ends an active connection, passed through the context. gps.stop(context)
+
* gpsbt.stop - ends an active connection, passed through the context. gps.stop(context)
-
* <code>gpsbt.gps()</code> - the class that gets information from GPS. Through it its possible to query, get_fix, get_position, etc.
+
* gpsbt.gps() - the class that gets information from GPS. Through it its possible to query, get_fix, get_position, etc.
-
* <code>gpsbt.gps.get_fix()</code> - fills in the 'fix' structure with GPS data. The fields are: mode, time, ept, latitude, longitude, eph, altitude (meters), epv, track (degrees from true north), speed (knots), climb (meters per second), epd, eps and epc.
+
* gpsbt.gps.get_fix() - fills in the 'fix' structure with GPS data. The fields are: mode, time, ept, latitude, longitude, eph, altitude (meters), epv, track (degrees from true north), speed (knots), climb (meters per second), epd, eps and epc.
-
* <code>gpsbt.gps.get_position()</code> - its a shortcut to return (latitude, longitude) info.
+
* gpsbt.gps.get_position() - its a shortcut to return (latitude, longitude) info.
-
* <code>gpsbt.gps.query()</code> - allows user to send one letter commands to the GPS device. Its possible to group a sequence of commands to send, e.g.:
+
* gpsbt.gps.query() - allows user to send one letter commands to the GPS device. Its possible to group a sequence of commands to send, e.g.:
-
** <code>gpsbt.gps.query('a')</code> fills in the altitude field of 'fix' structure
+
** gpsbt.gps.query('a') fills in the altitude field of 'fix' structure
-
** <code>gpsbt.gps.query('as')</code> fills in the altitude and speed fields
+
** gpsbt.gps.query('as') fills in the altitude and speed fields
-
* <code>gpsbt.gps.satellites</code> - contains a list of detected satellites, including information about usage and quality.
+
* gpsbt.gps.satellites - contains a list of detected satellites, including information about usage and quality.
== Example ==
== Example ==
The code below shows how to connect with a GPS device, get data and close this connection:
The code below shows how to connect with a GPS device, get data and close this connection:
-
<source lang="python">
 
-
import gpsbt
 
-
import time
 
-
 
-
def main():
 
-
    context = gpsbt.start()
 
-
 
-
    if context == None:
 
-
        print 'Problem while connecting!'
 
-
        return
 
-
 
-
    # ensure that GPS device is ready to connect and to receive commands
 
-
    time.sleep(2)
 
-
    gpsdevice = gpsbt.gps()
 
-
 
-
    # read 3 times and show information
 
-
    for a in range(4):
 
-
        gpsdevice.get_fix()
 
-
        time.sleep(2)
 
-
 
-
        # print information stored under 'fix' variable
 
-
        print 'Altitude: %.3f'%gpsdevice.fix.altitude
 
-
        # dump all information available
 
-
        print gpsdevice
 
-
 
-
    # ends Bluetooth connection
 
-
    gpsbt.stop(context)
 
-
main()
+
  import gpsbt
-
</source>
+
  import time
 +
 
 +
  def main():
 +
      context = gpsbt.start()
 +
 
 +
      if context == None:
 +
          print 'Problem while connecting!'
 +
          return
 +
 
 +
      # ensure that GPS device is ready to connect and to receive commands
 +
      time.sleep(2)
 +
      gpsdevice = gpsbt.gps()
 +
 
 +
      # read 3 times and show information
 +
      for a in range(4):
 +
          gpsdevice.get_fix()
 +
          time.sleep(2)
 +
 
 +
          # print information stored under 'fix' variable
 +
          print 'Altitude: %.3f'%gpsdevice.fix.altitude
 +
          # dump all information available
 +
          print gpsdevice
 +
 
 +
      # ends Bluetooth connection
 +
      gpsbt.stop(context)
 +
 
 +
  main()
 +
     
Download source code [http://pymaemo.garage.maemo.org/documentation/python_gps_examples/gpsbt-example.py here].
Download source code [http://pymaemo.garage.maemo.org/documentation/python_gps_examples/gpsbt-example.py here].
[[Category:Python]]
[[Category:Python]]

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)