Outils pour utilisateurs

Outils du site


python:gps2osc

gps2OSC

discute avec gpsd et transfert les info en OSC

le checksum http://www.hhhh.org/wiml/proj/nmeaxor.html

# jamming mode
echo -e '$PMTK286,1*23\r\n'    > /dev/ttyS1
sleep 1
# update rate 1s
echo -e '$PMTK220,1000*1F\r\n' > /dev/ttyS1
sleep 1
# DGPS_MODE
echo -e '$PMTK301,2*2E\r\n'    > /dev/ttyS1
sleep 1
# SBAS MODE 0=off
#echo -e '$PMTK313,0*2F\r\n'    > /dev/ttyS1
#echo -e '$PMTK313,1*2E\r\n'    > /dev/ttyS1

gps2OSC.py

#! /usr/bin/python
# License: GPL 3
#

from gps import *
import threading
import liblo

gpsd = None
class GpsStream(threading.Thread):
  def __init__(self):
    threading.Thread.__init__(self)
    global gpsd
    gpsd = gps(mode=WATCH_ENABLE) # lecture ok
    self.current_value = None
    self.running = True # thread ok

  def run(self):
    global gpsd
    while gpsp.running:
      gpsd.next() #lire en boucle pour remplir

if __name__ == '__main__':
  try:
        # init OSC
        target = liblo.Address('127.0.0.1',9001)
  except liblo.AddressError, err:
        print str(err)
        sys.exit()

  gpsp = GpsStream() # thread
  try:
    gpsp.start()
    while True:
      liblo.send(target, "/GPS/latitude/", gpsd.fix.latitude)
      liblo.send(target, "/GPS/longitude/", gpsd.fix.longitude)
      liblo.send(target, "/GPS/altitude/", gpsd.fix.altitude)
      liblo.send(target, "/GPS/fixeps/", gpsd.fix.eps)
      liblo.send(target, "/GPS/fixepx/", gpsd.fix.epx)
      liblo.send(target, "/GPS/fixepv/", gpsd.fix.epv)
      liblo.send(target, "/GPS/fixept/", gpsd.fix.ept)
      liblo.send(target, "/GPS/fixmode/", gpsd.fix.mode)
      liblo.send(target, "/GPS/sat/", gpsd.satellites_used)
      #print gpsd.fix.latitude,' ',gpsd.fix.longitude,' ',gpsd.utc

#      print 'time utc    ' , gpsd.utc,' + ', gpsd.fix.time
#      print 'climb       ' , gpsd.fix.climb
#      print 'track       ' , gpsd.fix.track
#      print 'speed (m/s) ' , gpsd.fix.speed
#      print 'mode        ' , gpsd.fix.mode
#      print 'Quality:  %d p=%2.2f h=%2.2f v=%2.2f t=%2.2f g=%2.2f' % (gpsd.satellites_used, gpsd.pdop, gpsd.hdop, gpsd.vdop, gpsd.tdop, gpsd.gdop)

      time.sleep(1)

  except (KeyboardInterrupt, SystemExit):
    print "\nKill Thread..."
    gpsp.running = False
    gpsp.join()
  print "End"
python/gps2osc.txt · Dernière modification: 2017/04/11 15:13 (modification externe)