-
Notifications
You must be signed in to change notification settings - Fork 209
PythonSupport
guruofquality edited this page Nov 2, 2014
·
13 revisions
The Python bindings for SoapySDR give the user access to the complete C++ API in Python. Because most of the API calls are identical to the C++ API, users should refer to the C++ headers and Doxygen for documentation. However, some calls have changed because of language differences. We will go over these calls in the examples below.
The Python bindings require SWIG and Python development files. We chose to use SWIG because it greatly simplified the developer effort required. To install the Python bindings, simply provide these dependencies before building SoapySDR.
To get the dependencies on a debian/ubuntu system:
sudo apt-get install python-dev swig
import SoapySDR
from SoapySDR import * #SOAPY_SDR_* constants
import numpy #use numpy for buffers
#enumerate devices
results = SoapySDR.Device.enumerate()
for result in results: print(result)
#create device instance
#Notice that we dont need to use Device.make.
#The constructor is the factory in Python.
args = dict(driver="rtl")
sdr = SoapySDR.Device(args)
#query device info
print(sdr.listAntennas(SOAPY_SDR_RX, 0))
print(sdr.listGains(SOAPY_SDR_RX, 0))
freqs = sdr.getFrequencyRange(SOAPY_SDR_RX, 0)
for freq in freqs: print(freq)
#setup a stream (complex floats)
rxStream = sdr.setupStream(SOAPY_SDR_RX, "CF32")
sdr.activateStream(rxStream) #start streaming
#receive some samples
buff = numpy.array([0]*1024, numpy.complex64) #create a receive buffer
for i in range(10):
sr = sdr.readStream(rxStream, [buff], len(buff))
print sr.ret #num samples or error code
print sr.flags #flags set by receive operation
print sr.timeNs #timestamp for receive buffer
#shutdown a stream
sdr.deactivateStream(rxStream) #stop streaming
sdr.closeStream(rxStream)
- FAQ
- Build guide
- Driver guide
- SoapySDR header files
- Doxygen documentation
- Python binding support
- LuaJIT binding support
- .NET binding support
- GO binding support
- Rust binding support
- Julia binding support
- Pothos SDR Tutorial
- Help and support
- Pothos users' group
- Twitter @pothosware
- IRC chat #pothos
- Slack workspace
- Contract services
- Developer blog
- Contributing
- Donate
- Example support
- Remote access
- Multi device
- Device sharing
- SIMD converters
- Audio devices
- Osmo support
- NovenaRF support
- EVB7 support
- UHD support
- Blade RF support
- Hack RF support
- RTL-SDR support
- SDR Play support
- Radioberry support
- Red Pitaya support
- Lime Suite support
- Airspy support
- Airspy HF+ support
- PlutoSDR support
- Skylark Iris module
- Funcube Dongle Pro+
- IC-R8600 Receiver
- Epiq Sidekiq
- NetSDR support
- XTRX support
- RTL TCP support
- SpyServer support
- Afedri support
- Pothos SDR
- Cubic SDR
- Rx Tools
- LuaRadio
- GNURadio blocks
- Osmocom blocks
- QSpectrumAnalyzer
- RTL433 project
- Welle.io DAB/DAB+
- SDRangel analyzer
- RTLSDR-Airband
- HABDEC RTTY decoder
- LinHPSDR receiver
- HackTV transmitter
- ODR-DabMod
- QUISK SDR
- SigDigger
- Suscan
- SdrGlut
- QRadioLink
- OpenWebRX
- SDR++
- Seify
- Abraca DAB radio
- SkyRoof
