Created
July 30, 2021 15:04
-
-
Save AlexFWulff/524e7b8174bc3dfc3c1311babd6d166f to your computer and use it in GitHub Desktop.
SoapySDR PlutoSDR Python Receive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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