Detect timestamp regression.

This commit is contained in:
Ian Gulliver
2016-02-18 10:45:04 -08:00
parent e3cd9d4b36
commit 11eeb26b9a

View File

@@ -9,9 +9,12 @@ import adsblib
if len(sys.argv) != 3: if len(sys.argv) != 3:
print('Usage: %s <host> <port>' % sys.argv[0]) print('Usage: %s <host> <port>' % sys.argv[0])
print('Fetching samples...')
advertised_mhz = None advertised_mhz = None
start_time = None start_time = None
start_timestamp = None start_timestamp = None
last_timestamp = None
for i, event in enumerate(adsblib.GetEvents(sys.argv[1], sys.argv[2])): for i, event in enumerate(adsblib.GetEvents(sys.argv[1], sys.argv[2])):
advertised_mhz = event.get('mlat_timestamp_mhz', advertised_mhz) advertised_mhz = event.get('mlat_timestamp_mhz', advertised_mhz)
@@ -22,12 +25,19 @@ for i, event in enumerate(adsblib.GetEvents(sys.argv[1], sys.argv[2])):
start_time = time.time() start_time = time.time()
start_timestamp = event['mlat_timestamp'] start_timestamp = event['mlat_timestamp']
if last_timestamp:
if event['mlat_timestamp'] < last_timestamp:
print('\rERROR: timestamp went backwards (%d -> %d)\x1b[K' %
(last_timestamp, event['mlat_timestamp']))
last_timestamp = event['mlat_timestamp']
if i % 1000 == 0 and start_time and advertised_mhz: if i % 1000 == 0 and start_time and advertised_mhz:
time_diff = time.time() - start_time time_diff = time.time() - start_time
value_diff = event['mlat_timestamp'] - start_timestamp value_diff = event['mlat_timestamp'] - start_timestamp
measured_mhz = value_diff / time_diff / 1000000 measured_mhz = value_diff / time_diff / 1000000
print( print(
'\r%d samples, %d seconds, advertised: %d MHz, measured: %d MHz' % '\r%d samples, %d seconds, advertised: %d MHz, measured: %d MHz\x1b[K' %
(i, time_diff, advertised_mhz, measured_mhz), (i, time_diff, advertised_mhz, measured_mhz),
end='', flush=True) end='', flush=True)