Linting, minor fixes
This commit is contained in:
parent
5e10cefc62
commit
1fc33eb6f4
|
@ -49,7 +49,7 @@ def get_modem_cops(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["cops error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ def get_modem_creg(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["creg error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@ def get_modem_csq(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["csq error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -150,7 +150,7 @@ def get_modem_rsrp(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["qrsrp error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -190,7 +190,7 @@ def get_modem_rsrq(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["qrsrq error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -229,7 +229,7 @@ def get_modem_sinr(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["qsinr error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -271,7 +271,7 @@ def get_modem_cpol(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["cpol error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -310,7 +310,7 @@ def get_modem_qnwcfg(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["qnwcfg error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -338,7 +338,7 @@ def get_modem_qnwinfo(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["qnwinfo error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
|
@ -366,5 +366,5 @@ def get_modem_qspn(port="/dev/ttyUSB2", baudrate=115200, dictionary={}):
|
|||
|
||||
except Exception as e:
|
||||
dictionary["qspn error"] = f"{e}"
|
||||
|
||||
|
||||
return dictionary
|
||||
|
|
|
@ -134,7 +134,7 @@ def save_data_to_json(data, filename):
|
|||
def fix_long(bad_long):
|
||||
"""
|
||||
Fix longitude values incorrectly parsed from NMEA (leading zero dropped degrees).
|
||||
|
||||
|
||||
Assumes all values should be around -79.x based on recording location.
|
||||
Removes the spurious leading digit from minutes.
|
||||
"""
|
||||
|
@ -159,18 +159,17 @@ def add_distance_after(filename: str, base_location: dict):
|
|||
with open(filename, "r") as file:
|
||||
data = json.load(file)
|
||||
except FileNotFoundError:
|
||||
print('No file by that name')
|
||||
print("No file by that name")
|
||||
return None
|
||||
|
||||
distance = 'Unknown'
|
||||
|
||||
|
||||
distance = "Unknown"
|
||||
|
||||
for dictionary in data:
|
||||
if 'latitude' in dictionary:
|
||||
# dictionary['longitude'] = fix_long(dictionary['longitude'])
|
||||
if "latitude" in dictionary and type(dictionary["latitude"]) == float:
|
||||
distance = calculate_distance(base_location, dictionary)
|
||||
dictionary["distance"] = distance
|
||||
elif 'iperf_full' in dictionary:
|
||||
dictionary['start_distance'] = distance
|
||||
elif "iperf_full" in dictionary:
|
||||
dictionary["start_distance"] = distance
|
||||
|
||||
# Save updated data back to the file
|
||||
with open(filename, "w") as file:
|
||||
|
@ -178,10 +177,15 @@ def add_distance_after(filename: str, base_location: dict):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
filename = '/home/madrigal/repos/range-testing/data/boat_relay_sept_17/test_1758123903_copy.json'
|
||||
filenames = [
|
||||
"/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758215714_copy.json",
|
||||
"/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758217711_copy.json",
|
||||
"/home/madrigal/repos/range-testing/data/boat_relay_sept_18/test_1758219350_copy.json"
|
||||
]
|
||||
base_location = {
|
||||
'latitude': 43.656328,
|
||||
'longitude': -79.307884,
|
||||
'altitude': 80,
|
||||
"latitude": 43.656328,
|
||||
"longitude": -79.307884,
|
||||
"altitude": 80,
|
||||
}
|
||||
add_distance_after(filename=filename, base_location=base_location)
|
||||
for filename in filenames:
|
||||
add_distance_after(filename=filename, base_location=base_location)
|
||||
|
|
Loading…
Reference in New Issue
Block a user