Adds logging for modem reconnections.

This commit is contained in:
Lukas Prause
2022-11-14 13:28:20 +01:00
parent c568e03ca8
commit 69e6284550

View File

@@ -250,7 +250,7 @@ def monitor_gps(ser, output_file):
ser.readline() ser.readline()
try: try:
while ser.is_open: while ser.is_open:
nmea_sentence = ser.readline() #GPRMC nmea_sentence = ser.readline() # GPRMC
nmea_str = nmea_sentence.decode("utf-8") nmea_str = nmea_sentence.decode("utf-8")
if nmea_str.startswith("$GPRMC"): if nmea_str.startswith("$GPRMC"):
write_to_file(output_file, nmea_str) write_to_file(output_file, nmea_str)
@@ -603,7 +603,6 @@ class Client:
sleep(2) sleep(2)
print_message("done...") print_message("done...")
def ping(self): def ping(self):
c = "ping {} -I {} -i {} -c {}".format( c = "ping {} -I {} -i {} -c {}".format(
self.config["server"], self.config["server"],
@@ -769,6 +768,12 @@ class Client:
print_message("Use ws filter: {}".format(ws_filter)) print_message("Use ws filter: {}".format(ws_filter))
for n in range(1, self.config["number_of_measurements"] + 1): for n in range(1, self.config["number_of_measurements"] + 1):
if not is_modem_connected(): if not is_modem_connected():
background_write_to_file(
filepath="{}{}_reconnect.log".format(
self.config["folder"], self.config["prefix"]
),
content='{}"'.format(datetime.timestamp(datetime.now())),
)
reconnect_modem() reconnect_modem()
print_message( print_message(
"{} of {}".format(n, self.config["number_of_measurements"]) "{} of {}".format(n, self.config["number_of_measurements"])
@@ -813,12 +818,26 @@ class Client:
iperf_return = 0 iperf_return = 0
while not is_measurement_done or iperf_return != 0: while not is_measurement_done or iperf_return != 0:
if iperf_return != 0: if iperf_return != 0:
background_write_to_file(
filepath="{}{}_reconnect.log".format(
self.config["folder"], self.config["prefix"]
),
content='{}"'.format(datetime.timestamp(datetime.now())),
)
reconnect_modem() reconnect_modem()
try: try:
try: try:
iperf_return = subprocess.call(iperf_command, timeout=float(time) + TIMEOUT_OFFSET) iperf_return = subprocess.call(
iperf_command, timeout=float(time) + TIMEOUT_OFFSET
)
except: except:
print_message("iPerf timed out...") print_message("iPerf timed out...")
background_write_to_file(
filepath="{}{}_reconnect.log".format(
self.config["folder"], self.config["prefix"]
),
content='{}"'.format(datetime.timestamp(datetime.now())),
)
reconnect_modem() reconnect_modem()
except KeyboardInterrupt: except KeyboardInterrupt:
exit() exit()
@@ -838,6 +857,12 @@ class Client:
print_message("tcp probe is now enabled") print_message("tcp probe is now enabled")
for n in range(1, self.config["number_of_measurements"] + 1): for n in range(1, self.config["number_of_measurements"] + 1):
if not is_modem_connected(): if not is_modem_connected():
background_write_to_file(
filepath="{}{}_reconnect.log".format(
self.config["folder"], self.config["prefix"]
),
content='{}"'.format(datetime.timestamp(datetime.now())),
)
reconnect_modem() reconnect_modem()
print_message( print_message(
"{} of {}".format(n, self.config["number_of_measurements"]) "{} of {}".format(n, self.config["number_of_measurements"])
@@ -881,12 +906,26 @@ class Client:
iperf_return = 0 iperf_return = 0
while not is_measurement_done or iperf_return != 0: while not is_measurement_done or iperf_return != 0:
if iperf_return != 0: if iperf_return != 0:
background_write_to_file(
filepath="{}{}_reconnect.log".format(
self.config["folder"], self.config["prefix"]
),
content='{}"'.format(datetime.timestamp(datetime.now())),
)
reconnect_modem() reconnect_modem()
try: try:
try: try:
iperf_return = subprocess.call(iperf_command, timeout=float(time) + TIMEOUT_OFFSET) iperf_return = subprocess.call(
iperf_command, timeout=float(time) + TIMEOUT_OFFSET
)
except: except:
print_message("iPerf timed out...") print_message("iPerf timed out...")
background_write_to_file(
filepath="{}{}_reconnect.log".format(
self.config["folder"], self.config["prefix"]
),
content='{}"'.format(datetime.timestamp(datetime.now())),
)
reconnect_modem() reconnect_modem()
except KeyboardInterrupt: except KeyboardInterrupt:
exit() exit()