本文整理匯總了Python中rtlsdr.RtlSdr.fc方法的典型用法代碼示例。如果您正苦於以下問題:Python RtlSdr.fc方法的具體用法?Python RtlSdr.fc怎麽用?Python RtlSdr.fc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rtlsdr.RtlSdr
的用法示例。
在下文中一共展示了RtlSdr.fc方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import fc [as 別名]
async def main():
import math
sdr = RtlSdr()
print('Configuring SDR...')
sdr.rs = 2.4e6
sdr.fc = 100e6
sdr.gain = 10
print(' sample rate: %0.6f MHz' % (sdr.rs/1e6))
print(' center frequency %0.6f MHz' % (sdr.fc/1e6))
print(' gain: %d dB' % sdr.gain)
print('Streaming samples...')
i = 0
async for samples in sdr.stream():
power = sum(abs(s)**2 for s in samples) / len(samples)
print('Relative power:', 10*math.log10(power), 'dB')
i += 1
if i > 100:
sdr.stop()
break
print('Done')
sdr.close()
示例2: main
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import fc [as 別名]
def main():
sdr = RtlSdr()
print 'Configuring SDR...'
sdr.rs = 2.4e6
sdr.fc = 100e6
sdr.gain = 10
print ' sample rate: %0.6f MHz' % (sdr.rs/1e6)
print ' center frequency %0.6f MHz' % (sdr.fc/1e6)
print ' gain: %d dB' % sdr.gain
print 'Reading samples...'
samples = sdr.read_samples(256*1024)
print ' signal mean:', sum(samples)/len(samples)
print 'Testing callback...'
sdr.read_samples_async(test_callback, 256*1024)
try:
import pylab as mpl
print 'Testing spectrum plotting...'
mpl.figure()
mpl.psd(samples, NFFT=1024, Fc=sdr.fc/1e6, Fs=sdr.rs/1e6)
mpl.show()
except:
# matplotlib not installed/working
pass
print 'Done\n'
sdr.close()
示例3: main
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import fc [as 別名]
def main():
sdr = RtlSdr()
wf = Waterfall(sdr)
# some defaults
# Sample rate
sdr.rs = 1e6
sdr.set_direct_sampling('q')
sdr.fc = 0
sdr.gain = 10
wf.start()
# cleanup
sdr.close()
示例4: main
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import fc [as 別名]
def main():
@limit_time(0.01)
@limit_calls(20)
def read_callback(buffer, rtlsdr_obj):
print('In callback')
print(' signal mean:', sum(buffer)/len(buffer))
from rtlsdr import RtlSdr
sdr = RtlSdr()
print('Configuring SDR...')
sdr.rs = 1e6
sdr.fc = 70e6
sdr.gain = 5
print(' sample rate: %0.6f MHz' % (sdr.rs/1e6))
print(' center ferquency %0.6f MHz' % (sdr.fc/1e6))
print(' gain: %d dB' % sdr.gain)
print('Testing callback...')
sdr.read_samples_async(read_callback)
示例5: main
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import fc [as 別名]
def main():
gin=sys.argv[1]
ppm=sys.argv[2]
chn=sys.argv[3]
if ppm=='0': ppm='1'
if chn=='a': frc=161.975e6
if chn=='b': frc=162.025e6
sdr = RtlSdr()
wf = Waterfall(sdr)
# some defaults
sdr.rs = 1e6
sdr.fc = frc
sdr.gain = float(gin)
sdr.freq_correction = int(float(ppm))
wf.start()
# cleanup
sdr.close()
示例6: RtlSdr
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import fc [as 別名]
#!/bin/python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from rtlsdr import RtlSdr
sdr = RtlSdr()
# Sampling rate
sdr.rs = 256000. #1024e3
# Pins 4 and 5
sdr.set_direct_sampling(2)
# Center frequency
sdr.fc = 0
# I don't think this is used?
sdr.gain = 1
fig = plt.figure()
ax = fig.add_subplot(211, autoscale_on=False, xlim=(-1, 513), ylim=(-1.1,1.1))
ax.grid()
rline, = ax.plot([], [], 'r-', lw=2)
iline, = ax.plot([], [], 'g-', lw=2)
ax = fig.add_subplot(212, autoscale_on=False, xlim=(-1, 513), ylim=(-1.3,1.3))
ax.grid()
mline, = ax.plot([], [], 'b-', lw=2)
def animate(i):
samples = sdr.read_samples(1024)
try:
zc = np.where(np.diff(np.sign(samples))>0)[0][0]
示例7: RtlSdr
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import fc [as 別名]
# initialize a curve for the plot
i_curve = data_plot.plot(pen='r', name = "In-Phase Signal")
q_curve = data_plot.plot(pen='y', name = "Quadrature Signal")
win.nextRow()
# initialize plot
fft_plot = win.addPlot(title="Power Vs. Frequency")
fft_plot.showGrid(True, True, alpha = 1)
fft_plot.addLegend()
# initialize a curve for the plot
curve = fft_plot.plot(pen='g', name = "Power Spectrum")
max_curve = fft_plot.plot(pen='r', name = "Max Hold")
sdr = RtlSdr()
# some defaults
sdr.rs = 2e6
sdr.fc = 106.9e6
sdr.gain = 30
max_data = []
def update():
global dut, curve, max_data
samples = sdr.read_samples(SAMPLE_SIZE)
samples = samples * np.hanning(len(samples))
pow = 20 * np.log10(np.abs(np.fft.fftshift(np.fft.fft(samples))))
i_curve.setData(samples.real)
q_curve.setData(samples.imag)
if len(max_data) == 0:
max_data = pow
else:
max_data = np.maximum(max_data, pow)
curve.setData(pow)
max_curve.setData(max_data)
示例8: psd
# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import fc [as 別名]
self.psd_scan, self.f = psd(self.samples, NFFT=NFFT)
threading.Timer(0.02, self.updateSamples).start()
def getSamples(self):
return self.psd_scan
app = Flask(__name__)
@app.route("/")
def hello():
return render_template("index.html")
@app.route("/2m.json")
def samples():
return jsonify({'samples': radio.getSamples().tolist(), 'minf': 144.0e6, 'maxf': 146.0e6})
if __name__ == "__main__":
sdr = RtlSdr()
radio = Radio(sdr)
# some defaults
sdr.rs = 2.0e6
sdr.fc = 145.0e6
sdr.gain = 10
# start polling for samples
radio.updateSamples()
app.run(debug=True, use_reloader=False, host='0.0.0.0')