Created
May 11, 2011 23:25
-
-
Save archie/967616 to your computer and use it in GitHub Desktop.
Updating Android Emulator gps coordinates using Telnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to instruct Android emulator to move to coordinates | |
# Heavily inspired by @pauloricardomg's GPS-server | |
# Parses a file that contains lat-long tuples, i.e "-91.7674044575329,73.90620635916805" | |
# KML files can be converted using: | |
# cat file.kml | grep coordinates | sed 's/.*>\(.*\),0/\1/;s/<\/coordinates>//g' > coords.out | |
# Hacked by @mljungblad | |
import socket | |
import sys | |
import time | |
HOST = "localhost" | |
PORT = 5556 | |
SPEED = 1 # updates / second | |
def move(lat, lon): | |
s.send("geo fix " + lat + " " + lon + "\n") | |
print "Sent move to " + lat + ", " + lon | |
if __name__ == "__main__": | |
f = open(sys.argv[1], 'r') | |
print "Opening file: " + sys.argv[1] | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((HOST, PORT)) | |
print "Connected to emulator: " + HOST + ":" + str(PORT) | |
for line in f.xreadlines(): | |
coord = line.split(',') | |
move(coord[0], coord[1]) | |
time.sleep(1.0/SPEED) | |
s.close() | |
f.close() | |
print "Finished" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment