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
# Karun Matharu (ksm113@imperial.ac.uk) | |
# Imperial College London | |
# A simple python telnet script to connect to the emulator on | |
# localhost 5554 and issue geo fix commands | |
import sys | |
import telnetlib | |
import getpass | |
import time | |
import random | |
HOST = "localhost" | |
PORT = 5554 | |
TIMEOUT = 2 | |
# Sleep time between each location update | |
TIME_GAP = 4 | |
# Starting values for longitude and latitude | |
lon = 50.000000 | |
lat = 50.000000 | |
tn = telnetlib.Telnet(HOST, PORT, TIMEOUT) | |
print tn.read_some() | |
while (True): | |
a = random.random() | |
b = random.random() | |
lat = lat + a | |
lon = lon + b | |
s = "geo fix " + str(lon) + " " + str(lat) + "\n" | |
tn.write(s) | |
print(s) | |
time.sleep(TIME_GAP) |
0 comments:
Post a Comment