當前位置: 首頁>>代碼示例>>Python>>正文


Python RtlSdr.rs方法代碼示例

本文整理匯總了Python中rtlsdr.RtlSdr.rs方法的典型用法代碼示例。如果您正苦於以下問題:Python RtlSdr.rs方法的具體用法?Python RtlSdr.rs怎麽用?Python RtlSdr.rs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rtlsdr.RtlSdr的用法示例。


在下文中一共展示了RtlSdr.rs方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [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()
開發者ID:Mondego,項目名稱:pyreco,代碼行數:34,代碼來源:allPythonContent.py

示例2: main

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [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()
開發者ID:Erae11,項目名稱:pyrtlsdr,代碼行數:31,代碼來源:rtlsdraio.py

示例3: main

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [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()
開發者ID:tarquasso,項目名稱:softroboticfish4,代碼行數:18,代碼來源:demo_waterfall.py

示例4: main

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [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)
開發者ID:Wolfrax,項目名稱:pyrtlsdr,代碼行數:24,代碼來源:helpers.py

示例5: main

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [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()
開發者ID:OskarRaftegard,項目名稱:openplotter,代碼行數:24,代碼來源:waterfall.py

示例6: RtlSdr

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [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]
開發者ID:tarquasso,項目名稱:softroboticfish4,代碼行數:33,代碼來源:scope.py

示例7: RtlSdr

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [as 別名]
data_plot.addLegend()
# 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)
開發者ID:mfarhan12,項目名稱:pycon-canada-2015,代碼行數:33,代碼來源:pyqtgraph_rtl_sdr.py

示例8: RtlSdr

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [as 別名]
#!/bin/python

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from rtlsdr import RtlSdr, limit_calls
from multiprocessing import Process


sdr = RtlSdr()
# Sampling rate
sdr.rs = 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, 129), 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, 129), ylim=(-1.3,1.3))
ax.grid()
mline, = ax.plot([], [], 'b-', lw=2)

global pdata
pdata = [0] * 128
開發者ID:tarquasso,項目名稱:softroboticfish4,代碼行數:33,代碼來源:async.py

示例9: psd

# 需要導入模塊: from rtlsdr import RtlSdr [as 別名]
# 或者: from rtlsdr.RtlSdr import rs [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')

開發者ID:irl,項目名稱:websdr-plus,代碼行數:31,代碼來源:app.py


注:本文中的rtlsdr.RtlSdr.rs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。