예제 #1
0
	def _poll(self):
		try:
			# Check the gps module
			self.s_locks['ld3w'].acquire()
			state											= nmea.get_data(self.s_connects.bodies['ld3w']['cons'][0]['sock'])
			self.s_locks['ld3w'].release()

			# Display very detailed information
			self.display('%s:\t\t\t\t%s' % (self.getName(), state), level=75)

			# Display not-so detailed information
			self.display('', level=50)
			self.display('%s:\t\t\t\tType:\t\t\t%s' % (self.getName(), state['type']), level=50)
			if state['type'] == 'GGA':
				self.display('%s:\t\t\t\tLongitude:\t\t%s' % (self.getName(), state['long']), level=50)
				self.display('%s:\t\t\t\tLatitude:\t\t%s' % (self.getName(), state['lat']), level=50)
				self.display('%s:\t\t\t\tQuality:\t\t%s' % (self.getName(), state['quality']), level=50)

			if state['type'] == 'GSA':
				self.display('%s:\t\t\t\tH dilute:\t\t%s' % (self.getName(), state['hdop']), level=50)
				self.display('%s:\t\t\t\tV dilute:\t\t%s' % (self.getName(), state['vdop']), level=50)
				self.display('%s:\t\t\t\tDimentions:\t\t%s' % (self.getName(), state['fix']), level=50)

			if state['type'] == 'GSV':
				self.display('%s:\t\t\t\tSatellites:\t\t%s' % (self.getName(), state['count']), level=50)

			if state['type'] == 'RMC':
				self.display('%s:\t\t\t\tStatus:\t\t\t%s' % (self.getName(), state['status']), level=50)
				self.display('%s:\t\t\t\tSpeed:\t\t\t%s' % (self.getName(), state['speed']), level=50)
				self.display('%s:\t\t\t\tTrack:\t\t\t%s' % (self.getName(), state['track']), level=50)
				self.display('%s:\t\t\t\tLongitude:\t\t%s' % (self.getName(), state['long']), level=50)
				self.display('%s:\t\t\t\tLatitude:\t\t%s' % (self.getName(), state['lat']), level=50)
		except:
			self.display('%s:\t\t\t\tUnable to poll for position' % self.getName(), level=25)
예제 #2
0
	def get_position(self):
		""" We query the gps device to try get a position. When we have a new
			position, we return it to the caller.
		"""
		try:
			cur_pos											= {}
			cur_pos['type']									= 'NON'
			# Make sure we only use GGA nmea packets
			while cur_pos['type'] != 'GGA':
				self.parse_queue(timeout=1)
				self.s_locks['ld3w'].acquire()
				cur_pos				= nmea.get_data(self.s_connects.bodies['ld3w']['cons'][0]['sock'])
				self.s_locks['ld3w'].release()
				self.display('%s:\t\t\t\tew:%s sn:%s' % (self.getName(), cur_pos['long'], cur_pos['lat']), level=0)
		except:
				self.display('%s:\t\t\t\tUnable to get position' % self.getName(), level=0)