accept a raw IP
All checks were successful
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Successful in 19s
Publish Python 🐍 distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been skipped

This commit is contained in:
Brendan Haines 2025-01-16 23:44:04 -07:00
parent fa80af8447
commit 30fb1190bb
2 changed files with 15 additions and 8 deletions

View File

@ -36,7 +36,7 @@ class MainWindow(QMainWindow):
plots: List[PlotWidget]
def __init__(self, uri: str | None = None):
def __init__(self, ip: str | None = None):
super().__init__()
self.config_path = DEFAULT_CONFIG
@ -47,8 +47,8 @@ class MainWindow(QMainWindow):
vna_kwargs = dict(
frequency=self._frequency,
)
if uri is not None:
vna_kwargs["uri"] = uri
if ip is not None:
vna_kwargs["ip"] = ip
self.vna = Charon(**vna_kwargs)
mpl.use("QtAgg")
@ -206,12 +206,17 @@ def main() -> None:
except Exception as e:
if e.args[0] == "No device found":
dialog = QInputDialog()
text, ok = dialog.getText(None, "Pluto IP Address", "IP Address", QLineEdit.Normal, "")
text, ok = dialog.getText(
None,
"Pluto IP Address",
"Enter Pluto IP Address",
QLineEdit.Normal,
"192.168.2.1",
)
match = re.match(r"(\d{1,3}\.){3}\d{1,3}", text)
if not match:
raise ValueError(f"Invalid IP address: {text}")
uri = f"ip:{text}"
window = MainWindow(uri=uri)
window = MainWindow(ip=text)
else:
raise e

View File

@ -36,9 +36,11 @@ def generate_tone(f: float, fs: float, N: int = 1024, scale: int = 2**14):
class Charon:
FREQUENCY_OFFSET = 1e6
calibration: rf.calibration.Calibration | None = None
def __init__(
self,
uri: str = "ip:192.168.2.1",
ip: str = "192.168.2.1",
frequency: npt.ArrayLike = np.linspace(1e9, 2e9, 3),
ports: Tuple[int] = (1,),
):
@ -46,7 +48,7 @@ class Charon:
self.frequency = frequency
# everything RF
self.sdr = adi.ad9361(uri=uri)
self.sdr = adi.ad9361(uri=f"ip:{ip}")
for attr, expected in [
("adi,2rx-2tx-mode-enable", True),
# ("adi,gpo-manual-mode-enable", True),