Skip to content

Commit a73b850

Browse files
committed
solving buffer issue
1 parent 7cc303a commit a73b850

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

send_data_csv.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,22 @@ def run(self):
3232
try:
3333
gpsp.start() # start it up
3434
initial_time = datetime.now()
35+
buffer = []
36+
old_buffer_value = ""
3537
while True:
3638
current_time = datetime.now()
3739
time_diff = current_time - initial_time
3840
if (int(time_diff.total_seconds()) % 10 == 0):
39-
#It may take a second or two to get good data
40-
#print gpsd.fix.latitude,', ',gpsd.fix.longitude,' Time: ',gpsd.utc
41-
42-
print 'lat ' , gpsd.fix.latitude, 'long ' , gpsd.fix.longitude, 'time utc' , gpsd.utc, 'speed (m/s) ' , gpsd.fix.speed, '\n'
43-
#'altitude (m)' , gpsd.fix.altitude,'eps ' , gpsd.fix.eps,'epx ' , gpsd.fix.epx,'epv ' ,
44-
#gpsd.fix.epv,'ept ' , gpsd.fix.ept,'climb ' , gpsd.fix.climb,'track ' ,
45-
#gpsd.fix.track,'mode ' , gpsd.fix.mode,'sats ' , gpsd.satellites,
46-
47-
#time.sleep(0) #set to whatever
41+
# Every 10 seconds add buffer contents to list
42+
buffer.append('lat: ' + str(gpsd.fix.latitude) + ', long: ' + str(gpsd.fix.longitude) + ', time utc: '
43+
+ str(gpsd.utc) + ', speed (m/s): ' + str(gpsd.fix.speed))
44+
45+
else:
46+
if old_buffer_value == buffer[-1]: # If old buffer = new buffer do nothing
47+
pass
48+
elif old_buffer_value != buffer[-1]: # else update buffer and print new value
49+
print(buffer[-1])
50+
old_buffer_value = buffer[-1]
4851

4952
except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
5053
print "\nKilling Thread..."

send_data_dev.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
from datetime import datetime
1+
# from datetime import datetime
2+
#
3+
# initial_time = datetime.now()
4+
# while True:
5+
# current_time = datetime.now()
6+
# time_diff = current_time-initial_time
7+
# if (int(time_diff.total_seconds())%10 == 0):
8+
# print(time_diff.total_seconds())
29

3-
initial_time = datetime.now()
4-
while True:
5-
current_time = datetime.now()
6-
time_diff = current_time-initial_time
7-
if (int(time_diff.total_seconds())%10 == 0):
8-
print(time_diff.total_seconds())
10+
a = [1,2,3,4,5]
11+
print(a[-1])

0 commit comments

Comments
 (0)