- CS16 streams read into an int16 buffer; files hold raw SC16 Q11 (full scale 2048) instead of all zeros - bladeRF-cli backed tools release the USB claim while they run and restore RX/TX settings afterwards; loopback uses the plugin setting - calibrate_dc runs "calibrate lms" + "calibrate dc rxtx"; a bare "cal dc" only printed help and reported success - report the span of all SoapySDR ranges (rate was capped at 10 Msps) - parse "Firmware version" from bladeRF-cli 1.10 - startup banner goes to stderr, off the stdio JSON-RPC channel - shared RX chunk reader: settle discard, overflow and stall handling, stream always closed; captures report overflows, clipping, peak dBFS - spectrum power normalized to dBFS - unit tests, README troubleshooting, version 2026.10.25
76 lines
2.2 KiB
Python
76 lines
2.2 KiB
Python
import json
|
|
import subprocess
|
|
import sys
|
|
|
|
from mcbladerf import cli_fallback
|
|
|
|
# bladeRF-cli 1.10 output for `-e info -e version`
|
|
INFO_OUTPUT = """
|
|
Board: Nuand bladeRF (bladerf1)
|
|
Serial #: 0123456789abcdef0123456789abcdef
|
|
VCTCXO DAC calibration: 0x8f68
|
|
FPGA size: 40 KLE
|
|
FPGA loaded: yes
|
|
Flash size: 32 Mbit
|
|
USB bus: 4
|
|
USB address: 16
|
|
USB speed: SuperSpeed
|
|
Backend: libusb
|
|
Instance: 0
|
|
|
|
bladeRF-cli version: 1.10.0-git-fcf94233-dirty
|
|
libbladeRF version: 2.6.0-git-fcf94233-dirty
|
|
|
|
Firmware version: 2.6.0-git-09c82087
|
|
FPGA version: 0.16.0 (configured from SPI flash)
|
|
"""
|
|
|
|
|
|
def test_device_info_parses_firmware_version(monkeypatch):
|
|
monkeypatch.setattr(cli_fallback, "_run_cli", lambda *a, **k: INFO_OUTPUT)
|
|
|
|
info = cli_fallback.get_device_info()
|
|
|
|
assert info.fw_version == "2.6.0-git-09c82087"
|
|
assert info.fpga_version == "0.16.0"
|
|
assert info.fpga_loaded is True
|
|
assert info.usb_speed == "SuperSpeed"
|
|
|
|
|
|
def test_calibrate_dc_rejects_help_output(monkeypatch):
|
|
monkeypatch.setattr(
|
|
cli_fallback, "_run_cli", lambda *a, **k: "\nDescription of calibrate command:\n"
|
|
)
|
|
try:
|
|
cli_fallback.calibrate_dc()
|
|
except RuntimeError as e:
|
|
assert "rejected" in str(e)
|
|
else:
|
|
raise AssertionError("help text was reported as a successful calibration")
|
|
|
|
|
|
def test_stdout_carries_only_json_rpc():
|
|
request = {
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "initialize",
|
|
"params": {
|
|
"protocolVersion": "2025-06-18",
|
|
"capabilities": {},
|
|
"clientInfo": {"name": "test", "version": "0"},
|
|
},
|
|
}
|
|
proc = subprocess.run(
|
|
[sys.executable, "-c", "from mcbladerf.server import main; main()"],
|
|
input=json.dumps(request) + "\n",
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=30,
|
|
)
|
|
|
|
lines = [line for line in proc.stdout.splitlines() if line.strip()]
|
|
assert lines, proc.stderr
|
|
for line in lines:
|
|
json.loads(line)
|
|
assert json.loads(lines[0])["result"]["serverInfo"]["name"] == "mcbladerf"
|