I am trying to extend the basic GPS logger from http://gagravarr.org/code/show_nmea_location.py so that it also uploads NMEA sentences via HTTP. This is so that I can track the phone's location from a website.
However, I have found strange problems when I try to add this ability: the phone prompts for an internet connection as expected, and uploads the first sentence without any problem. However, it then 'hangs' after a seemingly random number of uploads, and furthermore, seems to do this in the part of the code that is due doing the reading from the GPS, not in the bit that is doing the upload.
The code I have added is as follows:
postdata = urllib.urlencode({'line' : data})
fh = urllib.urlopen(URL, postdata)
fh.close()
where data is the NMEA sentence, and URL is a remote URL.
If I remove this code, the script logs without any problems.
Equally, I have tested the urllib part of it by reading from a logfile previously generated by the GPS, and it will upload everything without complaint - it just seems to be the combination of reading from the GPS via Bluetooth and doing the uploads via urllib that seems to cause this unpredictable behaviour.
So... does anybody have any idea what could be wrong?
Failing that (or even as well as), does anybody know of another script which will read from a GPS via bluetooth and periodically upload results to the internet?
Many thanks.
-Tristan.

), does anybody know of another script which will read from a GPS via bluetooth and periodically upload results to the internet?
Reply With Quote



