![]() |
GPS timeout in python
Hello!
I've followed the guide on http://wiki.maemo.org/PyMaemo/Using_Location_API. The purpose is to every 3rd hour connect with the GPS, fetch 10 coordinates and send them to my server. If I lose my phone I can always go to my server and find the coordinates of the phone. The script works fine, but the problem occurs when I enter a closed building without GPS-reception, then my phone tries forever until it finds GPS-reception which ofcourse drains the battery. So I'd like to implement a function that cancels the update if the script takes longer than 5 minutes. How can this be made? Thanks! Code:
import location |
Re: GPS timeout in python
Just a rough explanation.
When you start the GPS register the time Code:
global StartTime Code:
PastTime = time.time() - StartTime I think this is all you need to make it work, this is also how the smscon_daemon does it. |
Re: GPS timeout in python
Yes, I've tried similar like that. But the problem is that when the GPS doesn't find any coordinates (i.e. doesnt have any reception) it doesn't change and therefore that function doesn't update. So I need to put it somewhere else
|
Re: GPS timeout in python
a suggestion...
invoke a shell script that checks for the GPS update and run the shell script in background mode using & before calling this script put a counter (timer) and if it exceeds limit (say 5 mins) , kill the shell script using PID from ps -ef <shell script name> and the kill -9 command. |
Re: GPS timeout in python
You know, you could use Google Latitude and ZapLoc to do this...
But anyway, in ZapLoc, I have two timers. One timer in the main loop, which is the polling interval. Then, when that timeout calls its function, that function setts up a second timeout, which turns the GPS back off. Note that timeouts using the gobject.timeout_add() function, if the function you call return True, it will loop and repeat your timeout, if it returns False, it will only happen once. So roughtly, I have something like this: Code:
def turn_off_gps(control): /Z |
All times are GMT. The time now is 01:58. |
vBulletin® Version 3.8.8