Python osmosdr.source() Examples

The following are 9 code examples of osmosdr.source(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module osmosdr , or try the search function .
Example #1
Source File: Radio.py    From PLSDR with GNU General Public License v3.0 5 votes vote down vote up
def compute_dec_interp(self,a,b):
    a = int(a)
    b = int(b)
    gcd = self.gcd(a,b)
    dec = a/gcd
    interp = b/gcd
    return dec,interp
    
  # reference at  https://github.com/osmocom/gr-osmosdr/blob/master/include/osmosdr/source.h 
Example #2
Source File: usrp_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate 
        self.rf_gain = rf_gain 
        self.port = port 
        self.if_gain = if_gain 
        self.frequency = frequency 
        self.freq_correction = freq_correction 
        self.bb_gain = bb_gain 
        self.bandwidth = bandwidth 

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'uhd'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex*1, '127.0.0.1', port, False)



        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #3
Source File: bladerf_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'bladerf'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #4
Source File: hackrf_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'hackrf'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #5
Source File: sdrplay_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'sdrplay'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #6
Source File: airspy_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate 
        self.rf_gain = rf_gain 
        self.port = port 
        self.if_gain = if_gain 
        self.frequency = frequency 
        self.freq_correction = freq_correction 
        self.bb_gain = bb_gain 
        self.bandwidth = bandwidth 

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'airspy'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #7
Source File: rtl-sdr_recv.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port):
        gr.top_block.__init__(self, "Top Block")

        self.sample_rate = sample_rate
        self.rf_gain = rf_gain
        self.port = port
        self.if_gain = if_gain
        self.frequency = frequency
        self.freq_correction = freq_correction
        self.bb_gain = bb_gain
        self.bandwidth = bandwidth

        self.osmosdr_source_0 = osmosdr.source(
            args="numchan=" + str(1) + " " + 'rtl'
        )
        self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_source_0.set_sample_rate(sample_rate)
        self.osmosdr_source_0.set_center_freq(frequency, 0)
        self.osmosdr_source_0.set_freq_corr(freq_correction, 0)
        self.osmosdr_source_0.set_gain(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(bandwidth, 0)
        self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', port, False)

        self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0)) 
Example #8
Source File: meteor_qpsk.py    From autowx with MIT License 4 votes vote down vote up
def __init__(self):
        if os.path.isfile(rgb_lrpt_file):
            os.unlink(rgb_lrpt_file)
        l = open(rgb_lrpt_file, 'w+')
        l.write("[IN]\r\n")
        l.write("source=file\r\n")
        l.write("filename=" + BITSTREAM_WINDOWS_DIR + bitstream_file + "\r\n")
        l.write("mode=72K\r\n")
        l.write("[OUT]\r\n")
        l.write("rgb=122.jpg\r\n")
        l.write("rgb_q=100\r\n")
        # l.write("mono=jpg\r\n")
        l.write("logs=no\r\n")
        l.write("APID70=no\r\n")
        l.write("VCDU=no\r\n")
        l.write("path=" + IMAGES_WINDOWS_DIR + "\r\n")
        l.close()

        if os.path.isfile(mono_lrpt_file):
            os.unlink(mono_lrpt_file)
        m = open(mono_lrpt_file, 'w+')
        m.write("[IN]\r\n")
        m.write("source=file\r\n")
        m.write("filename=" + BITSTREAM_WINDOWS_DIR + bitstream_file + "\r\n")
        m.write("mode=72K\r\n")
        m.write("[OUT]\r\n")
        m.write("rgb=555.jpg\r\n")
        m.write("rgb_q=100\r\n")
        m.write("mono=jpg\r\n")
        m.write("logs=no\r\n")
        m.write("APID70=no\r\n")
        m.write("VCDU=no\r\n")
        m.write("path=" + IMAGES_WINDOWS_DIR + "\r\n")
        m.close()

        if os.path.isfile(config.get('METEOR', 'decode_script')):
            os.unlink(config.get('METEOR', 'decode_script'))
        g = open(config.get('METEOR', 'decode_script'), 'w+')
        g.write("#!/bin/bash\n")
        g.write("\n")
        g.write("/usr/local/bin/medet " + bitstream_name + " " + image_name + " -t >/tmp/METEOR_DECODE.log 2>&1\n")
        # g.write("convert -quality 97 "+image_name+".bmp "+image_name+".jpg")
        g.write("\n")
        g.close()

        os.chmod(config.get('METEOR', 'decode_script'), 0755) 
Example #9
Source File: receive345.py    From decode345 with MIT License 4 votes vote down vote up
def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.trans_width = trans_width = 10e3
        self.samp_rate = samp_rate = 1e6
        self.mult_const = mult_const = 100
        self.lowpass_decimation = lowpass_decimation = 10
        self.freq = freq = 344940000
        self.cutoff_freq = cutoff_freq = 50e3

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(0, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
          
        self.low_pass_filter_0 = filter.fir_filter_ccf(lowpass_decimation, firdes.low_pass(
        	1, samp_rate, cutoff_freq, trans_width, firdes.WIN_HAMMING, 6.76))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult_const, ))
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, '/tmp/grcfifo', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_file_sink_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_uchar_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.low_pass_filter_0, 0))