Skip to content

Instantly share code, notes, and snippets.

@AlexFWulff
Created July 30, 2021 15:04
Show Gist options
  • Save AlexFWulff/524e7b8174bc3dfc3c1311babd6d166f to your computer and use it in GitHub Desktop.
Save AlexFWulff/524e7b8174bc3dfc3c1311babd6d166f to your computer and use it in GitHub Desktop.
SoapySDR PlutoSDR Python Receive
import SoapySDR
from SoapySDR import *
import numpy
import time
args = dict(driver="plutosdr", hostname="192.168.2.1")
sdr = SoapySDR.Device(args)
# Setup device
sdr.setSampleRate(SOAPY_SDR_RX, 0, 10e6)
sdr.setFrequency(SOAPY_SDR_RX, 0, 450e6)
# Make stream and buffers
rxStream = sdr.setupStream(SOAPY_SDR_RX, SOAPY_SDR_CS16)
mtu = int(sdr.getStreamMTU(rxStream))
actual_nsamp = mtu*2
buff = numpy.array([0]*actual_nsamp, numpy.int16)
sdr.activateStream(rxStream)
start_time = time.time()
rx_time = 5
nsamp = 0
while time.time()-start_time < rx_time:
sr = sdr.readStream(rxStream, [buff], mtu)
nsamp = nsamp + sr.ret
sps = (nsamp/rx_time)/1e6
print(f"{sps:0.3f} M IQ samps/s")
#shutdown the stream
sdr.deactivateStream(rxStream) #stop streaming
sdr.closeStream(rxStream)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment