You Are Here:

Community: Developer Discussion Boards

Reply « Previous Thread | Next Thread »

#1 Old How to store GPS data in text file(by logging method)? - 2009-03-12, 16:50

Join Date: Sep 2008
Posts: 16
bean_ong
Offline
Registered User
How to store GPS data from built-in GPS into text file by logging method, with a simple python script? any help will be appreciated
Reply With Quote

#2 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-12, 17:41

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Online
Forum Nokia Champion
You have to do 2 things: read the GPS data and then write it to a file, by either appending or replacing the existing data from the file.
Reply With Quote

#3 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-12, 18:36

Join Date: Sep 2008
Posts: 16
bean_ong
Offline
Registered User
thanks for info, i have tried on Read the GPS data but it show me the increasing value like 100.0000, 200.0000 and so on. What is wrong at here? sorry i am dumb newbie..
Reply With Quote

#4 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-12, 18:58

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
Quote:
Originally Posted by bean_ong View Post
thanks for info, i have tried on Read the GPS data but it show me the increasing value like 100.0000, 200.0000 and so on. What is wrong at here? sorry i am dumb newbie..
hello bean_ong

the code is working very fine in my case are you sure you are getting the GPS readings like 100.000 and 200.000 because the code will actually give you three things.

Regards
Gaba88


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#5 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-12, 20:04

Join Date: Sep 2008
Posts: 16
bean_ong
Offline
Registered User
thanks for reply, i mistaken. It show 1 0.0 0.0 0.0, then 2 0.0...so on, is that mean it still acquiring for GPS data? I also have a tried to replace the variables_1&2 with pos_lat and pos_long, but it dint show in the output file..
Reply With Quote

#6 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-12, 22:18

Join Date: Oct 2008
Posts: 8
Spud_Gun31
Offline
Registered User
Hey, I had a similar problem with the values being printed just being 1 0.0, 0.0, 0.0, 2 0.0, 0.0, 0.0 etc. I switched to using LocationRequestor (https://www.iyouit.eu/portal/software.aspx) and by doing the following you can log to a file.

-----------------------------------
import locationrequestor

BATTERY_FILE = "e:\\Python\\GPS DATA.csv"
def log(data):
fi = file(BATTERY_FILE, "a")
print >> fi, data,
fi.close();

lr = locationrequestor.LocationRequestor();
lr.SetUpdateOptions(updateInterval, updateTimeout, maxAge, allowPartial);
lr.Open(lr.GetDefaultModuleId());

while(True):
pos = lr.NotifyPositionUpdate();
log(pos + "\n");

lr.Close();
-----------------------------------

This should print the position information to a csv file for you to review later!
Reply With Quote

#7 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-13, 04:04

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
Quote:
Originally Posted by bean_ong View Post
thanks for reply, i mistaken. It show 1 0.0 0.0 0.0, then 2 0.0...so on, is that mean it still acquiring for GPS data? I also have a tried to replace the variables_1&2 with pos_lat and pos_long, but it dint show in the output file..
hello bean_ong

let me tell you that the code will only get the correct GPS co-ordinates after fixing the GPS inside your device.

So prior to run this code please fix the GPS inside your device.

Enjoy Pythoning
Gaba88


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#8 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-13, 04:37

Join Date: Sep 2008
Posts: 16
bean_ong
Offline
Registered User
hi, i'm still having a problem by replacing either read the GPS data & write it to a file. Is it a way to read NMEA data from built-in gps? Because i know that in NMEA data like GGA, GMC it can string up most useful info.
Reply With Quote

#9 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-13, 04:50

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
Quote:
Originally Posted by bean_ong View Post
hi, i'm still having a problem by replacing either read the GPS data & write it to a file. Is it a way to read NMEA data from built-in gps? Because i know that in NMEA data like GGA, GMC it can string up most useful info.
hello bean_ong

i am not clear whar problem you are facing in the code.

It will be graet if you show the dibo a bit of code you are using and ofcourse whats the device you are using.

Regards
Gaba88


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#10 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-13, 06:36

Join Date: Sep 2008
Posts: 16
bean_ong
Offline
Registered User
Sorry for my dumb newbie, I am using the read the GPS data script,
Quote:
import e32, appuifw, positioning, codecs

path = "C:\\Python\Position.txt"
newline = "\n"

def gps_init():
global gps_data
gps_data = {
'satellites': {'horizontal_dop': 0.0, 'used_satellites': 0, 'vertical_dop': 0.0, 'time': 0.0,'satellites': 0, 'time_dop':0.0},
'position': {'latitude': 0.0, 'altitude': 0.0, 'vertical_accuracy': 0.0, 'longitude': 0.0, 'horizontal_accuracy': 0.0},
}
try:
positioning.select_module(positioning.default_module())
positioning.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
positioning.position(satellites=1,callback=gps, interval=100000,partial=0)
e32.ao_sleep(1)
except:
appuifw.note(u'Problem with GPS','error')

def gps(event):
global gps_data
gps_data = event

def gps_stop():
#this function stops GPS
try:
positioning.stop_position()
except:
appuifw.note(u'Problem with GPS','error')


#testing
gps_init()
count = 0
while True:
count = count + 1
sat = gps_data['satellites']['time']
pos_lat = gps_data['position']['latitude']
pos_long = gps_data['position']['longitude']
print count, sat, pos_lat, pos_long
e32.ao_sleep(1)
but how to write the text printed on screen into a file continuously?
Reply With Quote

#11 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-13, 09:15

Join Date: Sep 2005
Posts: 314
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
Quote:
Originally Posted by bean_ong View Post
Sorry for my dumb newbie, I am using the read the GPS data script, but how to write the text printed on screen into a file continuously?
1. Open the file (this is general python task, read some tutorial how to handle files)
2. Replace that line which prints on the screen with a line which writes the data to the file you opened in the beginning.
3. Close the file when you are ready to finish, you probably don't want to read gps in infinite "while True" loop.


--
Aapo Rista
http://code.google.com/p/pys60gps/
http://opennetmap.org/
Reply With Quote

#12 Old Re: How to store GPS data in text file(by logging method)? - 2009-03-14, 09:10

Join Date: Sep 2008
Posts: 16
bean_ong
Offline
Registered User
I am try like this:
HTML Code:
import e32, appuifw, positioning, codecs, thread

class Logger(object):
 
def gps_init(self):
	global gps_data
	gps_data = {
	'satellites': {'horizontal_dop': 0.0, 'used_satellites': 0, 'vertical_dop': 0.0, 'time': 0.0,'satellites': 0, 'time_dop':0.0}, 
	'position': {'latitude': 0.0, 'altitude': 0.0, 'vertical_accuracy': 0.0, 'longitude': 0.0, 'horizontal_accuracy': 0.0}
	}

	try:
		positioning.select_module(positioning.default_module())
		positioning.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
		positioning.position(satellites=1,callback=self.gps, interval=100000,partial=0)
		appuifw.note(u"GPS Connected",'info')		
		e32.ao_sleep(1)
		self.gps_init = True
	except:
		appuifw.note(u'Problem with GPS','error')
		
	self.update_debug_info()
 
def gps_stop(self):
	try:
		positioning.stop_position()
		appuifw.note(u"GPS Turn Off",'info')
	except:
		appuifw.note(u'Problem with GPS','error')
		
	self.update_debug_info()
 
def gps(self,event):
	global gps_data
	self.gps_data = event
	

def start_logging(self):
	if not self.is_running:
			if self.GPS_ON:
				self.is_running = True
			else:
				self.gps_on()
				self.is_running = True
			
			if not self.SENSORS_ON:
				self.connect_sensors()
			
			self.printf('logging...')
			app_lock.signal()
			
			self.update_debug_info()
			
			thread.start_new_thread(self.log_thread, ())

	def stop_logging(self):
		if self.is_running:
			self.is_running = False
			self.printf('stoped logging.')
			app_lock.signal()
		else:
			self.printf('nothing to stop...')
			
		self.update_debug_info()

	def log_thread(self):
		lockTHR = thread.allocate_lock()
		while logger.is_running:
			lockTHR.acquire()
			e32.ao_sleep(1)
			self.printf(str(time.ctime(time.time())))
			self.write_log('')

			lockTHR.release()
			
def write_log(self,pt):
		gpsTime = self.gps_data['satellites']['time']
		pos_lat = self.gps_data['position']['latitude']
		pos_long = self.gps_data['position']['longitude']
		
	if self.GPS_ON:
				log += str(pos_lat) + ';' + str(pos_long) + ';' + str(speed) + ';'
			else:
				log += '0;0;0;'
				
	if self.showLog:
			self.printf(log)
		
		if self.is_running:	
			try:
				f = open(u'c:\\Python\\log\\' + self.log_file + '.txt','a')
				f.writelines(log)
				f.close()
			except:
				self.printf(str(time.ctime(logTime)) + u"\nCannot save logto file: " + self.log_file)

global mainLoop, logging
mainLoop = True
logger = Logger()
	e32.ao_sleep(1)	

while mainLoop:
	app_lock = e32.Ao_lock()
	logger.setMenu()
	app_lock.wait()
and it give an error
Reply With Quote

#13 Old Re: How to store GPS data in text file(by logging method)? - 2009-09-19, 14:41

Join Date: Mar 2003
Posts: 564
cassioli's Avatar
cassioli
Offline
Super Contributor
Quote:
Originally Posted by Spud_Gun31 View Post
Hey, I had a similar problem with the values being printed just being 1 0.0, 0.0, 0.0, 2 0.0, 0.0, 0.0 etc. I switched to using LocationRequestor (https://www.iyouit.eu/portal/software.aspx) and by doing the following you can log to a file.

-----------------------------------
import locationrequestor

BATTERY_FILE = "e:\\Python\\GPS DATA.csv"
def log(data):
fi = file(BATTERY_FILE, "a")
print >> fi, data,
fi.close();

lr = locationrequestor.LocationRequestor();
lr.SetUpdateOptions(updateInterval, updateTimeout, maxAge, allowPartial);
lr.Open(lr.GetDefaultModuleId());

while(True):
pos = lr.NotifyPositionUpdate();
log(pos + "\n");

lr.Close();
-----------------------------------

This should print the position information to a csv file for you to review later!

Why does this line result in KErrNotFound?
lr.Open(lr.GetDefaultModuleId())


I also tried "positioning" module and positioning.select_module(positioning.default_module()), but in this case I get a KErrAccessDenied.

How can I access location data on my n82?!?
Reply With Quote

#14 Old Re: How to store GPS data in text file(by logging method)? - 2009-09-19, 20:18

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Offline
Forum Nokia Champion
hello cassioli

sorry for the stupid question but do you have a signed scriptshell with Location capability at least if you are using a script.

Regards,


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Last edited by gaba88 : 2009-09-20 at 19:16.
Reply With Quote

#15 Old Re: How to store GPS data in text file(by logging method)? - 2009-09-20, 12:04

Join Date: Mar 2003
Posts: 564
cassioli's Avatar
cassioli
Offline
Super Contributor
the point is that I'm really confusef about WHAT to sign and HOW, as signin process and python itself changed a lot during the yars, and I read threads which spans from 2005 to 2009, and each one say a different thing...

I'd like to know the excat steps needed TODAY to enable python 1.4.5 to access location API... any location API (built-in, or locationrequestor, or gps_location, or whatelse).
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
6212 - how to store data from midlet into internal mifare craig_mobiqa Near Field Communication 2 2009-11-12 10:48
LBS API - GPS raw data pz1974 General Symbian C++ 1 2009-02-07 17:01
How to receive GPS Data from GPS chipset using bluetooth and serial port RB_Sahu Symbian Networking & Messaging 1 2008-01-24 11:58
6600 gprs 发送大量rtp延时问题 dicson_hu Symbian 9 2005-11-04 03:12
Problem writing Unicode data with RFile Write method rushj General Symbian C++ 3 2005-08-01 14:39

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia