This commit is contained in:
M madrigal 2025-10-16 12:14:10 -04:00
parent 772c94204e
commit cba7c32c99
5 changed files with 33 additions and 63 deletions

View File

@ -17,7 +17,6 @@ from at_commands import (
get_modem_rsrp,
get_modem_rsrq,
get_modem_sinr,
set_configs,
)
from helper_functions import (
calculate_distance,
@ -76,8 +75,7 @@ def read_gps_data(
elif attempts >= 3:
gps_data = {}
break
except serial.SerialException as e:
# print(f"Serial communication error: {e}")
except serial.SerialException:
pass
except Exception as e:
print(f"Error: {e}")
@ -133,9 +131,7 @@ def get_current_location(dictionary={}):
# Ping base station
def ping_basestation(
address="10.45.0.1", dictionary={}
): # raspberry pi address 192.168.0.29, host1 is 0.30
def ping_basestation(address="10.45.0.1", name="10.45.0.1", dictionary={}) -> dict:
try:
result = subprocess.run(
["ping", "-c", "1", address], capture_output=True, text=True
@ -144,14 +140,14 @@ def ping_basestation(
if match:
time_value = match.group(1)
dictionary[f"{address}_ping_time"] = time_value
dictionary[f"{name}_ping_time"] = time_value
else:
dictionary[f"{address}_ping_time"] = "Not found"
dictionary[f"{name}_ping_time"] = "Not found"
dictionary[f"{address}_ping_stats"] = result.stdout
dictionary[f"{name}_ping_stats"] = result.stdout
except Exception as e:
dictionary["ping error"] = f"{e}"
dictionary[f"{name}_ping error"] = f"{e}"
return dictionary

View File

@ -105,7 +105,7 @@ def get_iperf_lists(data, ip_address):
reverse_sender.append(float(entry["sender_bitrate"]))
reverse_receiver.append(float(entry["receiver_bitrate"]))
reverse_distances.append(int(float(entry["start_distance"])))
except:
except Exception:
message = entry["iperf_full"]
bitrates = re.findall(r"(\d+\.\d+) Mbits/sec", message)
@ -117,7 +117,7 @@ def get_iperf_lists(data, ip_address):
sender.append(float(entry["sender_bitrate"]))
receiver.append(float(entry["receiver_bitrate"]))
distances.append(int(float(entry["start_distance"])))
except:
except Exception:
message = entry["iperf_full"]
bitrates = re.findall(r"(\d+\.\d+) Mbits/sec", message)

View File

@ -1,6 +1,4 @@
import os
import re
import subprocess
import threading
import time
@ -23,35 +21,12 @@ from communication import (
ping_basestation,
set_base_location,
)
from end_to_relay_client import collect_iperf_remote
from helper_functions import save_data_to_json
# Globals
running = False # To control start/stop
# Ping base station
def ping_basestation(address="10.45.0.1", name="10.45.0.1", dictionary={}) -> dict:
try:
result = subprocess.run(
["ping", "-c", "1", address], capture_output=True, text=True
)
match = re.search(r"time=([\d.]+)", result.stdout)
if match:
time_value = match.group(1)
dictionary[f"{name}_ping_time"] = time_value
else:
dictionary[f"{name}_ping_time"] = "Not found"
dictionary[f"{name}_ping_stats"] = result.stdout
except Exception as e:
dictionary[f"{name}_ping error"] = f"{e}"
return dictionary
def calculate_ping(
dictionary: dict, base_address: str, relay_address: str, name: str
) -> dict:
@ -91,10 +66,6 @@ def relay_iperf(
"stations": "er",
}
save_data_to_json(data=data, filename=filename)
# try:
# collect_iperf_remote(filename=filename)
# except Exception as e:
# print(f"Error collecting relay -> ground iperf: {e}")
# Collect and send data continuously
@ -133,7 +104,8 @@ def collect_data(
# Send to server
print(f"\nPing Time: {data.get('ping_time')}")
print(
f"RSRP: PRX: {data.get('RSRP PRX')} DRX: {data.get('RSRP DRX')} RX2: {data.get('RSRP RX2')} RX3: {data.get('RSRP RX3')}"
f"RSRP: PRX: {data.get('RSRP PRX')} DRX: {data.get('RSRP DRX')} \
RX2: {data.get('RSRP RX2')} RX3: {data.get('RSRP RX3')}"
)
print(f"Service: {data.get('network information')}")

View File

@ -1,13 +1,14 @@
import socket
import struct
import zmq
import numpy as np
import argparse
import socket
import time
import numpy as np
import zmq
def send_0mq(args):
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_socket.bind(('127.0.0.1', 5588))
udp_socket.bind(("127.0.0.1", 5588))
# ZMQ setup with high-performance options
context = zmq.Context()
@ -81,6 +82,7 @@ def send_0mq(args):
print(f"Publish time: {end_time-start_time:.4f}s")
start_time = end_time
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--vector_length", "-v", type=int, default=1024)