kopia lustrzana https://github.com/bristol-seds/pico-tracker
location_aprs test now uses pre-defined list of interesting locations
rodzic
df1423c581
commit
879f20ad3e
|
@ -21,7 +21,7 @@ struct location_aprs_tc_results {
|
|||
/* Function */
|
||||
__verification__ void location_aprs_tc(void) {
|
||||
|
||||
aprs_location_update(location_aprs_tc_params.lon, location_aprs_tc_params.lat, 0);
|
||||
aprs_location_update(location_aprs_tc_params.lon, location_aprs_tc_params.lat, 1000);
|
||||
|
||||
location_aprs_tc_results.tx_allow = aprs_location_tx_allow();
|
||||
location_aprs_tc_results.frequency = aprs_location_frequency();
|
||||
|
|
|
@ -17,26 +17,49 @@ from random import randint
|
|||
class location_aprs_tc:
|
||||
def __init__(self):
|
||||
self.name = self.__class__.__name__
|
||||
self.iterations = 30
|
||||
|
||||
# Load CSV file into memory
|
||||
self.locations = []
|
||||
with open("./test/tc/location_aprs_tc_list.csv") as f:
|
||||
for line in f:
|
||||
if line[0] is not "#" and len(line) is not 0:
|
||||
parts = [x.strip() for x in line.split(',')]
|
||||
if len(parts) is 4:
|
||||
self.locations.append({
|
||||
'name': parts[0],
|
||||
'frequency': float(parts[1]),
|
||||
'lat': float(parts[2]),
|
||||
'lon': float(parts[3])
|
||||
})
|
||||
self.locations_index = 0
|
||||
|
||||
|
||||
def get_test(self):
|
||||
"""Returns some suitable test parameters"""
|
||||
params = main.struct_location_aprs_tc_params()
|
||||
|
||||
params.lon = -5 + randint(0, 120)*0.1;
|
||||
params.lat = 52;
|
||||
if self.locations_index >= len(self.locations):
|
||||
return None
|
||||
|
||||
params.lon = self.locations[self.locations_index]['lon']
|
||||
params.lat = self.locations[self.locations_index]['lat']
|
||||
|
||||
return params
|
||||
|
||||
def is_correct(self, params, result, print_info):
|
||||
"""Returns if a result is correct for the given parameters"""
|
||||
|
||||
freq = result['frequency'] / (1000*1000)
|
||||
status_str = "NO"
|
||||
if result['tx_allow']:
|
||||
status_str = "Tx"
|
||||
name = self.locations[self.locations_index]['name']
|
||||
expected_freq = self.locations[self.locations_index]['frequency']
|
||||
self.locations_index += 1
|
||||
|
||||
print_info("%f, %f = %s, %f"%(params.lon, params.lat, status_str, freq))
|
||||
# What frequency did we return?
|
||||
freq = float(result['frequency']) / (1000*1000)
|
||||
|
||||
return True
|
||||
if freq == expected_freq:
|
||||
print_info("{}: {:.3f} MHz".format(name, freq))
|
||||
return True
|
||||
else:
|
||||
print_info("{} ({:.1f}, {:.1f}): Expected {:.9f}, Geofence {:.9f}".format(
|
||||
name, params.lat, params.lon, expected_freq, freq))
|
||||
return False
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
# name,frequency,lat,lon
|
||||
# not allowed
|
||||
UK,0,52,-1
|
||||
UK,0,52,0
|
||||
UK,0,52,1
|
||||
Wales,0,52,-4
|
||||
Lewis,0,58,-6.5
|
||||
NI,0,54.5,-6.5
|
||||
France,0,49,2
|
||||
Portugal,0,40,-8
|
||||
Italy,0,43,12
|
||||
Romania,0,46,24
|
||||
Sweden,0,58,12
|
||||
Stockholm,0,59.3,18
|
||||
Malmo,0,55.6,13
|
||||
Yemen,0,15,44
|
||||
NK,0,39,126
|
||||
|
||||
# 144.8
|
||||
Copenhagen,144.8,55.7,12.5
|
||||
Amsterdam,144.8,52.4,5.7
|
||||
Germany,144.8,52,9
|
||||
Poland,144.8,51,20
|
||||
Russia,144.8,55,37
|
||||
Mongolia,144.8,48,107
|
||||
Vladivostok,144.8,43,132
|
||||
Armenia,144.8,40,44
|
||||
Africa,144.8,9,2
|
||||
|
||||
# 144.39
|
||||
LA,144.39,34,-118
|
||||
New York,144.39,41,-74
|
||||
Canada,144.39,44,-76
|
||||
|
||||
# 144.62
|
||||
South Korea,144.62,37,128
|
||||
|
||||
# 144.64
|
||||
West China,144.64,39,80
|
||||
Beijing,144.64,40,116
|
||||
Hong Kong,144.64,22.4,114.1
|
||||
|
||||
# 144.66
|
||||
Japan,144.66,36,140
|
||||
|
||||
# 145.525
|
||||
Thailand,145.525,14,100
|
|
|
@ -156,7 +156,6 @@ class Tests():
|
|||
if result:
|
||||
if not test_case.is_correct(params, result, self.print_info):
|
||||
fail = True
|
||||
break
|
||||
else: # No result, Failure
|
||||
fail = True
|
||||
else:
|
||||
|
@ -171,10 +170,11 @@ class Tests():
|
|||
if result:
|
||||
if not test_case.is_correct(params, result, self.print_info):
|
||||
fail = True
|
||||
break
|
||||
else: # No result, Failure
|
||||
fail = True
|
||||
|
||||
params = test_case.get_test()
|
||||
|
||||
# Calculate time taken
|
||||
ttime = (arrow.now()-start)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue