def update_gps_coord(self): ''' Update the gps coordinates (own position). ''' # start the GPS self.gps_context = gpsbt.start() # wait for the gps to start (Needed?) time.sleep(2) # create the device gpsdevice = gpsbt.gps() # get the gps coordinates (x,y) = (0,0) tries = 0 while (x,y) == (0,0): coords = gpsdevice.get_position() (x,y) = (coords[1],coords[0]) tries += 1 if tries >= self.try_limit: break time.sleep(1) # Stop the GPS gpsbt.stop(self.gps_context) # set gps coordinates if not (x,y) == (0,0): self.gps_coord = (x,y) self.signal_new_gps_coord(str(x), str(y))
def run(self): # Startar GPSEN self.con = gpsbt.start() time.sleep(3.0) # wait for gps to come up # Getting GPS coordinats self.gps = gpsbt.gps() # Vantar pa en gps koordinat print "Waiting baby" self.waiting_for_a_fix()
def gps_pos(): #Startar GPS:en context = gpsbt.start() time.sleep(2) #Väntar för att se att GPSen startats och kan ta emot kommandon gpsdevice = gpsbt.gps() #Skriver ut Longitud och Latitud x,y = (0,0) while (x,y) == (0,0): x, y = gpsdevice.get_position() time.sleep(1) print "Longitud: ",x print "Latitud: ",y # Stänger av GPS:en gpsbt.stop(context)
def main(): rpc.set_name("rpcsender") context = gpsbt.start() # ensure that GPS device is ready to connect and to receive commands time.sleep(2) gpsdevice = gpsbt.gps() while True: # read 3 times and show information for a in range(4): gpsdevice.get_fix() time.sleep(15) while gpsdevice.get_position() == (0,0): time.sleep(1) lon, lat = gpsdevice.get_position() print rpc.send("main", "ping_with_coordinates", lon=lon, lat=lat) #stop gps devices gpsbt.stop(context)
def start(self): """ Start running """ if self.running == True: return # if we are using libGPS-Bluetooth if config.EnableGPS: self.gpscontext = gpsbt.start() if self.gpscontext == None: log.error('Unable to start GPS!') # If we are scanning on wifi if config.EnableWireless: try: self.kismet = Kismet() except socket.error: log.error('Cannot connect to Kismet') return thread = threading.Thread(target=self.kismet.loop) thread.start() self.running = True
def main(): print 'Connecting...' 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 4 times and show information for a in range(4): gpsdevice.get_fix() # print information stored under 'fix' variable print 'Altitude: %.3f' % gpsdevice.fix.altitude # dump all information available print gpsdevice time.sleep(2) # ends Bluetooth connection gpsbt.stop(context)
import time, gpsbt def has_a_fix(gps): gps.get_fix() return gps.satellites_used > 0 con = gpsbt.start() time.sleep(2.0) # wait for gps to come up gps = gpsbt.gps() print "Waiting for the sun... err... a fix" while not has_a_fix(gps): print "Wai-ting..." time.sleep(5) # do something gpsbt.stop(con)