def device_info(soapy_args=''): """Returns info about selected SoapySDR device""" text = [] try: device = simplesoapy.SoapyDevice(soapy_args) text.append('Selected device: {}'.format(device.hardware)) text.append(' Available RX channels:') text.append(' {}'.format(', '.join( str(x) for x in device.list_channels()))) text.append(' Available antennas:') text.append(' {}'.format(', '.join(device.list_antennas()))) text.append(' Available tunable elements:') text.append(' {}'.format(', '.join(device.list_frequencies()))) text.append(' Available amplification elements:') text.append(' {}'.format(', '.join(device.list_gains()))) text.append(' Available device settings:') for key, s in device.list_settings().items(): text.append( wrap('{} ... {} - {} (default: {})'.format( key, s['name'], s['description'], s['value']))) text.append(' Available stream arguments:') for key, s in device.list_stream_args().items(): text.append( wrap('{} ... {} - {} (default: {})'.format( key, s['name'], s['description'], s['value']))) text.append(' Allowed gain range [dB]:') text.append(' {:.2f} - {:.2f}'.format(*device.get_gain_range())) text.append(' Allowed frequency range [MHz]:') text.append(' {:.2f} - {:.2f}'.format( *[x / 1e6 for x in device.get_frequency_range()])) text.append(' Allowed sample rates [MHz]:') rates = [] for r in device.list_sample_rates(): if r[0] == r[1]: rates.append('{:.2f}'.format(r[0] / 1e6)) else: rates.append('{:.2f} - {:.2f}'.format(r[0] / 1e6, r[1] / 1e6)) text.append(wrap(', '.join(rates))) text.append(' Allowed bandwidths [MHz]:') bandwidths = [] for b in device.list_bandwidths(): if b[0] == b[1]: bandwidths.append('{:.2f}'.format(b[0] / 1e6)) else: bandwidths.append('{:.2f} - {:.2f}'.format( b[0] / 1e6, b[1] / 1e6)) if bandwidths: text.append(wrap(', '.join(bandwidths))) else: text.append(' N/A') except RuntimeError: device = None text.append('No devices found!') return (device, '\n'.join(text))
def __init__(self, soapy_args='', sample_rate=2.00e6, bandwidth=0, corr=0, gain=20.7, auto_gain=False, channel=0, antenna='', settings=None, force_sample_rate=False, force_bandwidth=False, output=sys.stdout, output_format='rtl_power'): self.device = simplesoapy.SoapyDevice( soapy_args=soapy_args, sample_rate=sample_rate, bandwidth=bandwidth, corr=corr, gain=gain, auto_gain=auto_gain, channel=channel, antenna=antenna, settings=settings, force_sample_rate=force_sample_rate, force_bandwidth=force_bandwidth) self._output = output self._output_format = output_format self._buffer = None self._buffer_repeats = None self._base_buffer_size = None self._max_buffer_size = None self._bins = None self._repeats = None self._tune_delay = None self._reset_stream = None self._psd = None self._writer = None
import simplesoapy import numpy #pip install SimpleSoapy # List all connected SoapySDR devices print(simplesoapy.detect_devices(as_string=True)) # Initialize SDR device #sdr = simplesoapy.SoapyDevice('driver=rtlsdr') sdr = simplesoapy.SoapyDevice('driver=miri') # Set sample rate #sdr.sample_rate = 2.56e6 sdr.sample_rate = 8e6 # Set center frequency sdr.freq = 29000000.0 # Setup base buffer and start receiving samples. Base buffer size is determined # by SoapySDR.Device.getStreamMTU(). If getStreamMTU() is not implemented by driver, # SoapyDevice.default_buffer_size is used instead sdr.start_stream() # Create numpy array for received samples samples = numpy.empty(len(sdr.buffer) * 100, numpy.complex64) # Receive all samples sdr.read_stream_into_buffer(samples) # Stop receiving sdr.stop_stream()
import simplesoapy import numpy #pip install SimpleSoapy # List all connected SoapySDR devices print(simplesoapy.detect_devices(as_string=True)) # Initialize SDR device #sdr = simplesoapy.SoapyDevice('driver=rtlsdr') sdr = simplesoapy.SoapyDevice('driver=rtlsdr') # Set sample rate sdr.sample_rate = 2.56e6 # Set center frequency sdr.freq = 88e6 # Setup base buffer and start receiving samples. Base buffer size is determined # by SoapySDR.Device.getStreamMTU(). If getStreamMTU() is not implemented by driver, # SoapyDevice.default_buffer_size is used instead sdr.start_stream() # Create numpy array for received samples samples = numpy.empty(len(sdr.buffer) * 100, numpy.complex64) # Receive all samples sdr.read_stream_into_buffer(samples) # Stop receiving sdr.stop_stream()