def __init__(self): # gr.sync_block.__init__(self, # name="mrfsk_pkt_sink", # in_sig=[numpy.uint8], # out_sig=None) gr.hier_block2.__init__( self, "mrfsk_pkt_sink", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0) # Output signature ) msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) # holds packets from the PHY ## last nibble of preamble, and 0x904e for SFD uncoded packet # last byte of preamble, and 0x904e for SFD uncoded packet # add more preamble to this if excessive false triggering correlator = digital.correlate_access_code_bb('0101010101011001000001001110', 1) correlator_nrnsc = digital.correlate_access_code_bb('0101010101010110111101001110', 2) framer_sink = ieee802154g.framer_sink_mrfsk(msgq) framer_sink_nrnsc = ieee802154g.framer_sink_mrfsk_nrnsc(msgq) #connect self.connect(self, correlator, framer_sink) self.connect(self, correlator_nrnsc, framer_sink_nrnsc) #start thread _packet_decoder_thread(msgq)
def __init__(self): # gr.sync_block.__init__(self, # name="mrfsk_pkt_sink", # in_sig=[numpy.uint8], # out_sig=None) gr.hier_block2.__init__( self, "mrfsk_pkt_sink", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0) # Output signature ) msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) # holds packets from the PHY ## last nibble of preamble, and 0x904e for SFD uncoded packet # last byte of preamble, and 0x904e for SFD uncoded packet # add more preamble to this if excessive false triggering correlator = digital.correlate_access_code_bb( '0101010101011001000001001110', 1) correlator_nrnsc = digital.correlate_access_code_bb( '0101010101010110111101001110', 2) framer_sink = ieee802154g.framer_sink_mrfsk(msgq) framer_sink_nrnsc = ieee802154g.framer_sink_mrfsk_nrnsc(msgq) #connect self.connect(self, correlator, framer_sink) self.connect(self, correlator_nrnsc, framer_sink_nrnsc) #start thread _packet_decoder_thread(msgq)
def test_002_t(self): # CRC-16 test from section 5.2.1.9 in 802.15.4-2011 pad = (0xff, ) * 8 src_data = pad + (0x55, 0x55, 0x90, 0x4e, 0x10, 0x05, 0x40, 0x00, 0x56, 0x27, 0x9e) + pad src_data_list = hex_list_to_binary_list(src_data) expected_str = '\x40\x00\x56\x27\x9e' rcvd_pktq = gr.msg_queue() src = blocks.vector_source_b(src_data_list) correlator = digital.correlate_access_code_bb( '0101010101011001000001001110', 1) framer_sink = ieee802154g.framer_sink_mrfsk(rcvd_pktq) vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) self.tb.run() # check data self.assertEquals(1, rcvd_pktq.count()) result_msg = rcvd_pktq.delete_head() fec = int(result_msg.type()) self.assertEquals(0, fec) phr = int(result_msg.arg1()) self.assertEquals(0x1005, phr) crc_ok = int(result_msg.arg2()) self.assertEquals(1, crc_ok) self.assertEquals(expected_str, result_msg.to_string())
def test_003_t(self): # Annex O.3 example 2: whitening enabled pad = (0xff, ) * 8 src_data = pad + (0x55, 0x55, 0x55, 0x90, 0x4e, 0x08, 0x07, 0x4f, 0x70, 0xe5, 0x32, 0x6a, 0x62, 0x60) + pad src_data_list = hex_list_to_binary_list(src_data) expected_str = '\x40\x00\x56\x5d\x29\xfa\x28' rcvd_pktq = gr.msg_queue() src = blocks.vector_source_b(src_data_list) correlator = digital.correlate_access_code_bb( '0101010101011001000001001110', 1) framer_sink = ieee802154g.framer_sink_mrfsk(rcvd_pktq) vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) self.tb.run() # check data self.assertEquals(1, rcvd_pktq.count()) result_msg = rcvd_pktq.delete_head() fec = int(result_msg.type()) self.assertEquals(0, fec) phr = int(result_msg.arg1()) self.assertEquals(0x0807, phr) crc_ok = int(result_msg.arg2()) self.assertEquals(1, crc_ok) self.assertEquals(expected_str, result_msg.to_string())
def __init__(self, access_code='', threshold=-1, callback=None, verbose=0): """ packet_demod constructor. @param access_code AKA sync vector @param threshold detect access_code with up to threshold bits wrong (0 -> use default) @param callback a function of args: ok, payload """ #access code if not access_code: #get access code access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) self._access_code = access_code #threshold if threshold < 0: threshold = DEFAULT_THRESHOLD self._threshold = threshold #blocks msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) #holds packets from the PHY correlator = digital.correlate_access_code_bb(self._access_code, self._threshold) framer_sink = logitech_27mhz_transceiver.framer_sink(msgq) #initialize hier2 gr.hier_block2.__init__( self, "packet_decoder", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0) # Output signature ) #connect self.connect(self, correlator, framer_sink) #start thread _packet_decoder_thread(msgq, callback,verbose)
def test_002_t (self): # CRC-16 test from section 5.2.1.9 in 802.15.4-2011 pad = (0xff,) * 8 src_data = pad + (0x55, 0x55, 0x90, 0x4e, 0x10, 0x05, 0x40, 0x00, 0x56, 0x27, 0x9e) + pad src_data_list = hex_list_to_binary_list(src_data) expected_str = '\x40\x00\x56\x27\x9e' rcvd_pktq = gr.msg_queue() src = blocks.vector_source_b(src_data_list) correlator = digital.correlate_access_code_bb('0101010101011001000001001110', 1) framer_sink = ieee802154g.framer_sink_mrfsk(rcvd_pktq) vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) self.tb.run () # check data self.assertEquals(1, rcvd_pktq.count()) result_msg = rcvd_pktq.delete_head() fec = int(result_msg.type()) self.assertEquals(0, fec) phr = int(result_msg.arg1()) self.assertEquals(0x1005, phr) crc_ok = int(result_msg.arg2()) self.assertEquals(1, crc_ok) self.assertEquals(expected_str, result_msg.to_string())
def __init__(self, access_code=None, threshold=-1): """ Create a new packet deframer. @param access_code: AKA sync vector @type access_code: string of 1's and 0's @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default) @type threshold: int """ gr.hier_block2.__init__( self, "demod_pkts2", gr.io_signature(1, 1, 1), gr.io_signature(1, 1, 1), ) if not access_code: access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) if threshold == -1: threshold = 12 # FIXME raise exception msgq = gr.msg_queue(4) # holds packets from the PHY self.correlator = gr_digital.correlate_access_code_bb(access_code, threshold) self.framer_sink = gr.framer_sink_1(msgq) self.connect(self, self.correlator, self.framer_sink) self._queue_to_blob = _queue_to_blob(msgq) self.connect(self._queue_to_blob, self)
def __init__(self, sample_rate, freq_offset, queue, logger = None, group_description_csv = None): gr.hier_block2.__init__( self, "SmartZone Control Channel", gr.io_signature(1, 1, gr.sizeof_gr_complex), # input signature gr.io_signature(0, 0, 0) # output signature ) self._CC_DEVIATION = 4e3 # observed self._symbol_rate = 3600.0 # control channel rate is 3.6kb/s self._oversample = 4 # XXX reduce # get close to the desired sample rate with decimation channel_decimation = int(sample_rate / (self._oversample * self._symbol_rate)) & ~1 channel_rate = sample_rate / channel_decimation samples_per_symbol = channel_rate / self._symbol_rate # channel_bw = self._CC_DEVIATION + self._symbol_rate # from pager source channel_bw = 3 * self._symbol_rate # taps = firdes.low_pass(1, sample_rate, int(3.0 * self._symbol_rate), int(3.0 * self._symbol_rate / 10.0), firdes.WIN_HAMMING) channel_taps = firdes.low_pass(1, sample_rate, channel_bw, channel_bw / 10.0, firdes.WIN_HAMMING) channel_filter = filter.freq_xlating_fir_filter_ccf(channel_decimation, channel_taps, freq_offset, sample_rate) #quad_demod = analog.quadrature_demod_cf(1.0) quad_demod = analog.quadrature_demod_cf(channel_rate / (2 * math.pi * self._CC_DEVIATION)) clock = digital.clock_recovery_mm_ff(omega = samples_per_symbol, gain_omega = 0.001, mu = 0, gain_mu = 0.001, omega_relative_limit = 0.005) slicer = digital.binary_slicer_fb() digital_correlate = digital.correlate_access_code_bb("10101100", 0) cc_sink = control_channel_sink(logger, queue, group_description_csv) self.connect(self, channel_filter, quad_demod, clock, slicer, digital_correlate, cc_sink)
def test_002(self): code = tuple(string_to_1_0_list(default_access_code)) access_code = to_1_0_string(code) header = tuple( 2 * [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]) # len=2 pad = (0, ) * 100 src_data = code + header + \ (0, 1, 0, 0, 1, 0, 0, 0) + (0, 1, 0, 0, 1, 0, 0, 1) + pad expected_data = b'HI' rcvd_pktq = gr.msg_queue() src = blocks.vector_source_b(src_data) correlator = digital.correlate_access_code_bb(access_code, 0) framer_sink = digital.framer_sink_1(rcvd_pktq) vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) self.tb.run() result_data = rcvd_pktq.delete_head() result_data = result_data.to_string() self.assertEqual(expected_data, result_data)
def test_001_t(self): # Annex O example 4, NRNSC with 0x6f4e SFD pad = (0xff, ) * 8 src_data = pad + (0x55, 0x55, 0x55, 0x55, 0x6f, 0x4e, 0xbf, 0x7f, 0x3f, 0xff, 0xfc, 0xfd, 0xfc, 0xf2, 0x37, 0xaa, 0xbc, 0xb7, 0x5e, 0x13, 0xa4, 0x5d, 0xb2, 0xf0, 0xb4, 0x3c) + pad src_data_list = hex_list_to_binary_list(src_data) expected_str = '\x40\x00\x56\x5d\x29\xfa\x28' rcvd_pktq = gr.msg_queue() src = blocks.vector_source_b(src_data_list) correlator = digital.correlate_access_code_bb( '0101010101010110111101001110', 1) framer_sink = ieee802154g.framer_sink_mrfsk_nrnsc(rcvd_pktq) vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) self.tb.run() # check data self.assertEquals(1, rcvd_pktq.count()) result_msg = rcvd_pktq.delete_head() fec = int(result_msg.type()) self.assertEquals(1, fec) phr = int(result_msg.arg1()) self.assertEquals(0x0007, phr) crc_ok = int(result_msg.arg2()) self.assertEquals(1, crc_ok) self.assertEquals(expected_str, result_msg.to_string())
def __init__(self, packet_sink=None): #initialize hier2 gr.hier_block2.__init__( self, "ofdm_mod", gr.io_signature(1, 1, 1), # Input signature gr.io_signature(1, 1, 1) # Output signature ) #create blocks """msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT) self._msgq_out = msg_source.msgq() #connect self.connect(self, packet_sink) """ ##self.connect(self, packet_sink) #self.connect(packet_sink,self) msg_in = blocks.message_source(1, DEFAULT_MSGQ_LIMIT) msgq = msg_in.msgq() #msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) correlator = digital.correlate_access_code_bb(packet_sink._access_code, packet_sink._threshold) framer_sink = digital.framer_sink_1(msgq) self.connect(self, packet_sink) self.connect(packet_sink, self)
def __init__(self, callback=None): """ packet_demod constructor. Args: station_id: The ID of the station that we are trying to decode the data from. """ # access code self._threshold = DEFAULT_THRESHOLD access_code = STATION_CODES["default"] if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % ( access_code, ) self._access_code = access_code # blocks msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) # holds packets from the PHY correlator = digital.correlate_access_code_bb(self._access_code, self._threshold) framer_sink = digital.framer_sink_1(msgq) # initialize hier2 gr.hier_block2.__init__( self, "packet_decoder", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0) # Output signature ) # connect self.connect(self, correlator, framer_sink) # start thread _packet_decoder_thread(msgq, callback)
def __init__(self): gr.top_block.__init__(self) self.samp_rate = samp_rate = 1000000 self.dump_freq = dump_freq = 2400490000 self._u = uhd.usrp_source( device_addr="%default", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) self._u.set_gain(0, 0) self._u.set_samp_rate(self.samp_rate) treq = uhd.tune_request(self.dump_freq, 0) tr = self._u.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 self.filter1 = gr.interp_fir_filter_ccf(1, firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING, 6.76)) self.squelch = gr.pwr_squelch_cc(-100, 0.001, 0, True) self.demod = gr.quadrature_demod_cf(1) self.sync = digital.clock_recovery_mm_ff(2, 0.0076562, 0.5, 0.175, 0.005) self.slicer = digital.binary_slicer_fb() self.detect_seq = digital.correlate_access_code_bb("01010101010101010101010101010101", 1) self.dump = flysky.dumpsync() self.connect(self._u,self.filter1,self.squelch,self.demod,self.sync,self.slicer,self.detect_seq, self.dump)
def __init__( self, msgq, access_code=None, threshold=0 ): """ Create a new packet deframer. @param access_code: AKA sync vector @type access_code: string of 1's and 0's @param threshold: detect access_code with up to threshold bits wrong @type threshold: int """ gr.hier_block2.__init__( self, "packet_deframer", gr.io_signature(1, 1, 1), gr.io_signature(0, 0, 0) ) if not access_code: access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) if threshold < 0: raise ValueError, "Invalid threshold value %d" % (threshold) #default_access_code = conv_packed_binary_string_to_1_0_string('\xAC\xDD\xA4\xE2\xF2\x8C\x20\xFC') #default_preamble = conv_packed_binary_string_to_1_0_string('\xA4\xF2') self.msgq = msgq self.correlator = gr_digital.correlate_access_code_bb(access_code, threshold) self.framer_sink = gr_digital.framer_sink_1(self.msgq) self.connect(self, self.correlator, self.framer_sink)
def __init__(self, access_code=None, threshold=-1): """ Create a new packet deframer. @param access_code: AKA sync vector @type access_code: string of 1's and 0's @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default) @type threshold: int """ gr.hier_block2.__init__( self, "demod_pkts2", gr.io_signature(1, 1, 1), gr.io_signature(1, 1, 1), ) if not access_code: access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % ( access_code, ) if threshold == -1: threshold = 12 # FIXME raise exception msgq = gr.msg_queue(4) # holds packets from the PHY self.correlator = gr_digital.correlate_access_code_bb( access_code, threshold) self.framer_sink = gr.framer_sink_1(msgq) self.connect(self, self.correlator, self.framer_sink) self._queue_to_blob = _queue_to_blob(msgq) self.connect(self._queue_to_blob, self)
def __init__(self, access_code='', threshold=-1, callback=None): """ packet_demod constructor. @param access_code AKA sync vector @param threshold detect access_code with up to threshold bits wrong (0 -> use default) @param callback a function of args: ok, payload """ #access code if not access_code: #get access code access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % ( access_code, ) self._access_code = access_code #threshold if threshold < 0: threshold = DEFAULT_THRESHOLD self._threshold = threshold #blocks msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) #holds packets from the PHY correlator = digital.correlate_access_code_bb(self._access_code, self._threshold) framer_sink = gr.framer_sink_1(msgq) #initialize hier2 gr.hier_block2.__init__( self, "packet_decoder", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0) # Output signature ) #connect self.connect(self, correlator, framer_sink) #start thread _packet_decoder_thread(msgq, callback)
def test_003_t (self): # Annex O.3 example 2: whitening enabled pad = (0xff,) * 8 src_data = pad + (0x55, 0x55, 0x55, 0x90, 0x4e, 0x08, 0x07, 0x4f, 0x70, 0xe5, 0x32, 0x6a, 0x62, 0x60) + pad src_data_list = hex_list_to_binary_list(src_data) expected_str = '\x40\x00\x56\x5d\x29\xfa\x28' rcvd_pktq = gr.msg_queue() src = blocks.vector_source_b(src_data_list) correlator = digital.correlate_access_code_bb('0101010101011001000001001110', 1) framer_sink = ieee802154g.framer_sink_mrfsk(rcvd_pktq) vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) self.tb.run () # check data self.assertEquals(1, rcvd_pktq.count()) result_msg = rcvd_pktq.delete_head() fec = int(result_msg.type()) self.assertEquals(0, fec) phr = int(result_msg.arg1()) self.assertEquals(0x0807, phr) crc_ok = int(result_msg.arg2()) self.assertEquals(1, crc_ok) self.assertEquals(expected_str, result_msg.to_string())
def __init__(self, options, filename): gr.top_block.__init__(self) inf_str = None symbol_rate = 152.34e3 sample_rate = 1e6 #if len(options) != 0: # inf_str = args[0] squelch = analog.pwr_squelch_cc(float(options.squelch), 0.1, 0, True) demod = analog.quadrature_demod_cf(1.0) cr = digital.clock_recovery_mm_ff(sample_rate/symbol_rate, 0.00765625, 0, 0.175, 0.005) slicer = digital.binary_slicer_fb() corr = digital.correlate_access_code_bb(AC, 3) sink = sniffer() if False: print "Reading from: " + inf_str src = blocks.file_source(gr.sizeof_gr_complex, inf_str, False) else: freqs = { 'AA':917.0e6, 'AB':913.0e6, 'AC':914.0e6, 'AD':915.0e6, 'BA':916.0e6, 'BB':919.0e6, 'BC':920.0e6, 'BD':921.0e6, 'CA':922.0e6, 'CB':923.0e6, 'CC':907.0e6, 'CD':908.0e6, 'DA':905.5e6, 'DB':909.0e6, 'DC':911.0e6, 'DD':910.0e6} frequency = freqs[options.channel] print "Channel: " + options.channel + " (" + str(frequency/1e6) + "MHz)" # Create a UHD device source src = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32', "sc16", args="")) # Set the subdevice spec if(options.spec): src.set_subdev_spec(options.spec, 0) # Set the antenna if(options.antenna): src.set_antenna(options.antenna, 0) # Set receiver sample rate src.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: g = src.get_gain_range() options.gain = float(g.start()+g.stop())/2 print "Using mid-point gain of", options.gain, "(", g.start(), "-", g.stop(), ")" src.set_gain(options.gain) # Set frequency (tune request takes lo_offset) treq = uhd.tune_request(frequency) tr = src.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 self.connect(src, squelch, demod, cr, slicer, corr, sink)
def __init__(self, packet_sink=None): #initialize hier2 gr.hier_block2.__init__( self, "ofdm_mod", gr.io_signature(1, 1, 1), # Input signature gr.io_signature(1, 1, 1) # Output signature ) #create blocks """msg_source = blocks.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT) self._msgq_out = msg_source.msgq() #connect self.connect(self, packet_sink) """ ##self.connect(self, packet_sink) #self.connect(packet_sink,self) msg_in = blocks.message_source(1, DEFAULT_MSGQ_LIMIT) msgq = msg_in.msgq() #msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) correlator = digital.correlate_access_code_bb(packet_sink._access_code, packet_sink._threshold) framer_sink = digital.framer_sink_1(msgq) self.connect(self, packet_sink) self.connect(packet_sink, self)
def __init__(self, options, queue): gr.top_block.__init__(self) self.u = uhd.usrp_source(options.addr, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) if options.subdev is not None: self.u.set_subdev_spec(options.subdev, 0) self.u.set_samp_rate(options.rate) self.rate = self.u.get_samp_rate() # Set the antenna if(options.antenna): self.u.set_antenna(options.antenna, 0) self.centerfreq = options.centerfreq print "Tuning to: %fMHz" % (self.centerfreq - options.error) if not(self.tune(options.centerfreq - options.error)): print "Failed to set initial frequency" if options.gain is None: #set to halfway g = self.u.get_gain_range() options.gain = (g.start()+g.stop()) / 2.0 print "Setting gain to %i" % options.gain self.u.set_gain(options.gain) self.u.set_bandwidth(options.bandwidth) print "Samples per second is %i" % self.rate self._syms_per_sec = 3600; options.audiorate = 11025 options.rate = self.rate options.samples_per_second = self.rate #yeah i know it's on the list options.syms_per_sec = self._syms_per_sec options.gain_mu = 0.01 options.mu=0.5 options.omega_relative_limit = 0.3 options.syms_per_sec = self._syms_per_sec options.offset = options.centerfreq - options.freq print "Control channel offset: %f" % options.offset self.demod = fsk_demod(options) self.start_correlator = digital.correlate_access_code_bb("10101100",0) #should mark start of packet self.smartnet_sync = smartnet.sync() self.smartnet_deinterleave = smartnet.deinterleave() self.smartnet_parity = smartnet.parity() self.smartnet_crc = smartnet.crc() self.smartnet_packetize = smartnet.packetize() self.parse = smartnet.parse(queue) #packet-based. this simply posts lightly-formatted messages to the queue. self.connect(self.u, self.demod) self.connect(self.demod, self.start_correlator, self.smartnet_sync, self.smartnet_deinterleave, self.smartnet_parity, self.smartnet_crc, self.smartnet_packetize, self.parse)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.dec_rate = dec_rate = 2 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(1000000) self.uhd_usrp_source_0.set_center_freq(2400490000, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.low_pass_filter_0_0 = gr.interp_fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = gr.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING, 6.76)) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_cc(-100, 0.001, 0, True) self.flysky_dumpsync_0 = flysky.dumpsync() self.digital_correlate_access_code_bb_0_1 = digital.correlate_access_code_bb( "010101010101010101010101010101010101010001110101", 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( 2, 0.0076562, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() ################################################## # Connections ################################################## self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.gr_pwr_squelch_xx_0, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_pwr_squelch_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0_1, 0)) self.connect((self.digital_correlate_access_code_bb_0_1, 0), (self.flysky_dumpsync_0, 0))
def __init__(self, source_data, sampling_rate, carrier_hz, symbol_rate, deviation, access_code): super(FSKDemodulator, self).__init__() self._decoded = {} self._carrier_hz = carrier_hz self._deviation = deviation self._access_code = access_code samp_rate = sampling_rate #symbol_rate = 9920 self.samples_per_symbol = float(samp_rate) / symbol_rate omega = self.samples_per_symbol * 1.0 mu = 0.0 gain_mu = 0.2 gain_omega = 0.25 * gain_mu * gain_mu omega_relative_limit = 0.001 tap_count = int(math.floor(self.samples_per_symbol)) hz_n = (carrier_hz - deviation) taps_n = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_n / samp_rate) hz_p = (carrier_hz + deviation) taps_p = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_p / samp_rate) #source = blocks.file_source(gr.sizeof_gr_complex*1, filepath_in, False) # Concatenate data to compensate for correlate_access_code_bb latency source_data_padding_count = int(math.ceil(self.samples_per_symbol * 64)) source_data = numpy.concatenate((source_data, numpy.zeros((source_data_padding_count,), dtype=numpy.complex64))) source = NumpySource(source_data) filter_n = filter.fir_filter_ccc(1, taps_n.tolist()) self.connect(source, filter_n) filter_p = filter.fir_filter_ccc(1, taps_p.tolist()) self.connect(source, filter_p) mag_n = blocks.complex_to_mag(1) self.connect(filter_n, mag_n) mag_p = blocks.complex_to_mag(1) self.connect(filter_p, mag_p) sub_pn = blocks.sub_ff() self.connect(mag_p, (sub_pn, 0)) self.connect(mag_n, (sub_pn, 1)) clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) self.connect(sub_pn, clock_recovery) slicer = digital.binary_slicer_fb() self.connect(clock_recovery, slicer) access_code_correlator = digital.correlate_access_code_bb(access_code, 0) self.connect(slicer, access_code_correlator) self.packetizer = Packetizer() self.connect(access_code_correlator, self.packetizer)
def __init__(self, source_data, sampling_rate, carrier_hz, symbol_rate, deviation, access_code): super(FSKDemodulator, self).__init__() self._decoded = {} self._carrier_hz = carrier_hz self._deviation = deviation self._access_code = access_code samp_rate = sampling_rate #symbol_rate = 9920 self.samples_per_symbol = float(samp_rate) / symbol_rate omega = self.samples_per_symbol * 1.0 mu = 0.0 gain_mu = 0.2 gain_omega = 0.25 * gain_mu * gain_mu omega_relative_limit = 0.001 tap_count = int(math.floor(self.samples_per_symbol)) hz_n = (carrier_hz - deviation) taps_n = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_n / samp_rate) hz_p = (carrier_hz + deviation) taps_p = numpy.exp(numpy.arange(tap_count, dtype=numpy.float32) * 2.0j * numpy.pi * hz_p / samp_rate) #source = blocks.file_source(gr.sizeof_gr_complex*1, filepath_in, False) # Concatenate data to compensate for correlate_access_code_bb latency source_data_padding_count = int(math.ceil(self.samples_per_symbol * 64)) source_data = numpy.concatenate((source_data, numpy.zeros((source_data_padding_count,), dtype=numpy.complex64))) source = NumpySource(source_data) filter_n = filter.fir_filter_ccc(1, taps_n.tolist()) self.connect(source, filter_n) filter_p = filter.fir_filter_ccc(1, taps_p.tolist()) self.connect(source, filter_p) mag_n = blocks.complex_to_mag(1) self.connect(filter_n, mag_n) mag_p = blocks.complex_to_mag(1) self.connect(filter_p, mag_p) sub_pn = blocks.sub_ff() self.connect(mag_p, (sub_pn, 0)) self.connect(mag_n, (sub_pn, 1)) clock_recovery = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, omega_relative_limit) self.connect(sub_pn, clock_recovery) slicer = digital.binary_slicer_fb() self.connect(clock_recovery, slicer) access_code_correlator = digital.correlate_access_code_bb(access_code, 0) self.connect(slicer, access_code_correlator) self.packetizer = Packetizer() self.connect(access_code_correlator, self.packetizer)
def __init__(self): gr.top_block.__init__(self, "grc_cc1111_test_local_loop") ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 80000 self.samp_rate = samp_rate = 2e6 self.samp_per_sym = samp_per_sym = int(samp_rate / symbole_rate) self.preamble = preamble = '0101010101010101' self.myqueue_out = myqueue_out = gr.msg_queue(2) self.myqueue_in = myqueue_in = gr.msg_queue(2) self.bit_per_sym = bit_per_sym = 1 self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=int(samp_per_sym), bt=0.5, verbose=False, log=False, ) self.digital_correlate_access_code_bb_0_0 = digital.correlate_access_code_bb(access_code, 1) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0_0 = digital.binary_slicer_fb() self.cc1111_cc1111_packet_encoder_0 = cc1111.cc1111_packet_mod_base(cc1111.cc1111_packet_encoder( samples_per_symbol=samp_per_sym, bits_per_symbol=bit_per_sym, preamble=preamble, access_code=access_code, pad_for_usrp=True, do_whitening=True, add_crc=True ), source_queue=myqueue_in ) self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder(myqueue_out,True, True, False, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0_0, 0), (self.digital_correlate_access_code_bb_0_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0_0, 0), (self.cc1111_cc1111_packet_decoder_0, 0)) self.connect((self.cc1111_cc1111_packet_decoder_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.cc1111_cc1111_packet_encoder_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2000000 self.dec_rate = dec_rate = 4 ################################################## # Blocks ################################################## self.gr_throttle_1 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate/dec_rate) self.gr_or_xx_0 = gr.or_bb() self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(dec_rate, (firdes.low_pass(1,samp_rate,500000,100000)), -535000, samp_rate) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/shampoo/sdr/capture/nrf-capture/2410500000-2M-1.cap", False) self.gr_file_sink_0_0 = gr.file_sink(gr.sizeof_char*1, "/shampoo/sdr/projects/gr-nordic/gmsk-correlate2.out") self.gr_file_sink_0_0.set_unbuffered(False) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.digital_correlate_access_code_bb_0_0 = digital.correlate_access_code_bb("010101010", 0) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb("101010101", 0) ################################################## # Connections ################################################## self.connect((self.gr_file_source_0, 0), (self.gr_freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.gr_throttle_1, 0)) self.connect((self.gr_throttle_1, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.digital_correlate_access_code_bb_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0_0, 0), (self.gr_or_xx_0, 1)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.gr_or_xx_0, 0)) self.connect((self.gr_or_xx_0, 0), (self.gr_file_sink_0_0, 0))
def test_001(self): pad = (0,) * 64 # 0 0 0 1 0 0 0 1 src_data = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0,) * 7 expected_result = pad + (1, 0, 1, 1, 3, 1, 0, 1, 1, 2) + (0,) * 6 src = blocks.vector_source_b(src_data) op = digital.correlate_access_code_bb("1011", 0) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)
def test_001(self): pad = (0, ) * 64 # 0 0 0 1 0 0 0 1 src_data = (1, 0, 1, 1, 1, 1, 0, 1, 1) + pad + (0, ) * 7 expected_result = pad + (1, 0, 1, 1, 3, 1, 0, 1, 1, 2) + (0, ) * 6 src = blocks.vector_source_b(src_data) op = digital.correlate_access_code_bb("1011", 0) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)
def __init__(self, demodulator, options, access_code=None, callback=None, threshold=-1, use_coding=0, logging=-1): """ Hierarchical block for demodulating and deframing packets. The input is the complex modulated signal at baseband. Demodulated packets are sent to the handler. @param demodulator: instance of demodulator class (gr_block or hier_block2) @type demodulator: complex baseband in @param access_code: AKA sync vector @type access_code: string of 1's and 0's @param callback: function of two args: ok, payload @type callback: ok: bool; payload: string @param threshold: detect access_code with up to threshold bits wrong (-1 -> use default) @type threshold: int """ gr.hier_block2.__init__(self, "demod_pkts", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self._demodulator = demodulator if access_code is None: access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) self._access_code = access_code #just added to take coding from benchmark_rx self._use_coding = use_coding self._logging = logging self._options = options # added to simplify logging self._threshold = options.access_code_threshold if threshold == -1: threshold = 4 # FIXME raise exception self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY self._time_pktq = gr.msg_queue() # holds packet timestamps from the PHY self._chan_pktq = gr.msg_queue() # holds packet channels from the PHY self.correlator = digital.correlate_access_code_bb(access_code, threshold) self.framer_sink = framer_sink_1(self._rcvd_pktq, self._time_pktq, self._chan_pktq) self.connect(self, self._demodulator, self.correlator, self.framer_sink) self._watcher = _queue_watcher_thread(self._rcvd_pktq, self._time_pktq, self._chan_pktq, callback, self._use_coding, self._logging, self._options)
def test_002(self): code = tuple(string_to_1_0_list(default_access_code)) access_code = to_1_0_string(code) pad = (0,) * 64 #print code #print access_code src_data = code + (1, 0, 1, 1) + pad expected_result = pad + code + (3, 0, 1, 1) src = blocks.vector_source_b(src_data) op = digital.correlate_access_code_bb(access_code, 0) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)
def test_002(self): code = tuple(string_to_1_0_list(default_access_code)) access_code = to_1_0_string(code) pad = (0, ) * 64 #print code #print access_code src_data = code + (1, 0, 1, 1) + pad expected_result = pad + code + (3, 0, 1, 1) src = blocks.vector_source_b(src_data) op = digital.correlate_access_code_bb(access_code, 0) dst = blocks.vector_sink_b() self.tb.connect(src, op, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)
def test_001_t (self): ac = [1,1,1,0,0,1,0] payload = [0,0,1,0,1,0,1,0] tx_data = ac + payload*30 src = blocks.vector_source_b(tx_data, False) correlator = digital.correlate_access_code_bb("1110010", 3) trigger = west.stream_trigged_pdu('payload_start', 8) sink = blocks.message_debug() self.tb.connect(src, correlator, trigger) self.tb.msg_connect(trigger, "pdus", sink, "store") self.tb.run () for ii in xrange(sink.num_messages() ): msg = sink.get_message(ii) msg_tuple = tuple(pmt.to_python(msg)) print msg_tuple self.assertEqual(msg_tuple, tuple(payload))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.dec_rate = dec_rate = 2 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args(cpu_format="fc32", channels=range(1)) ) self.uhd_usrp_source_0.set_samp_rate(1000000) self.uhd_usrp_source_0.set_center_freq(2400490000, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.low_pass_filter_0_0 = gr.interp_fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING, 6.76) ) self.low_pass_filter_0 = gr.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, 500000, 10000, firdes.WIN_HAMMING, 6.76) ) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf(1) self.gr_pwr_squelch_xx_0 = gr.pwr_squelch_cc(-100, 0.001, 0, True) self.flysky_dumpsync_0 = flysky.dumpsync() self.digital_correlate_access_code_bb_0_1 = digital.correlate_access_code_bb( "010101010101010101010101010101010101010001110101", 1 ) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(2, 0.0076562, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() ################################################## # Connections ################################################## self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.gr_pwr_squelch_xx_0, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.gr_pwr_squelch_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0_1, 0)) self.connect((self.digital_correlate_access_code_bb_0_1, 0), (self.flysky_dumpsync_0, 0))
def __init__(self, access_code='', threshold=-1, callback=None, repeat=1, interleave=None, debug=False): """ packet_demod constructor. Args: access_code: AKA sync vector threshold: detect access_code with up to threshold bits wrong (0 -> use default) callback: a function of args: ok, payload """ self._repeat = repeat self._interleave = interleave self._debug = debug #access code if not access_code: #get access code access_code = packet_utils.default_access_code if not packet_utils.is_1_0_string(access_code): raise ValueError, "Invalid access_code %r. Must be string of 1's and 0's" % (access_code,) self._access_code = access_code #threshold if threshold < 0: threshold = DEFAULT_THRESHOLD self._threshold = threshold #blocks msgq = gr.msg_queue(DEFAULT_MSGQ_LIMIT) #holds packets from the PHY correlator = digital.correlate_access_code_bb(self._access_code, self._threshold) framer_sink = digital.framer_sink_1(msgq) #initialize hier2 gr.hier_block2.__init__( self, "packet_decoder", gr.io_signature(1, 1, gr.sizeof_char), # Input signature gr.io_signature(0, 0, 0) # Output signature ) #connect self.connect(self, correlator, framer_sink) #start thread _packet_decoder_thread(msgq, callback, repeat, interleave, debug)
def test_002(self): code = tuple(string_to_1_0_list(default_access_code)) access_code = to_1_0_string(code) header = tuple(2*[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0]) # len=2 pad = (0,) * 100 src_data = code + header + (0,1,0,0,1,0,0,0) + (0,1,0,0,1,0,0,1) + pad expected_data = 'HI' rcvd_pktq = gr.msg_queue() src = blocks.vector_source_b(src_data) correlator = digital.correlate_access_code_bb(access_code, 0) framer_sink = digital.framer_sink_1(rcvd_pktq) vsnk = blocks.vector_sink_b() self.tb.connect(src, correlator, framer_sink) self.tb.connect(correlator, vsnk) self.tb.run() result_data = rcvd_pktq.delete_head() result_data = result_data.to_string() self.assertEqual(expected_data, result_data)
def __init__(self): gr.top_block.__init__(self, "grc_cc1111_hackrf_receiver") ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 40000 self.samp_rate = samp_rate = 2e06 self.rat_interop = rat_interop = 8 self.rat_decim = rat_decim = 5 self.firdes_transition_width = firdes_transition_width = 15000 self.firdes_decim = firdes_decim = 4 self.firdes_cuttoff = firdes_cuttoff = 21e3 self.samp_per_sym = samp_per_sym = ( (samp_rate / 2 / firdes_decim) * rat_interop / rat_decim) / symbole_rate self.myqueue_out = myqueue_out = gr.msg_queue(2) self.frequency_shift = frequency_shift = 520000 self.frequency_center = frequency_center = 869.02e06 self.freq_adjust1 = freq_adjust1 = 0 self.firdes_filter = firdes_filter = firdes.low_pass( 1, samp_rate / 2, firdes_cuttoff, firdes_transition_width) self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=rat_interop, decimation=rat_decim, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "hackrf") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq( frequency_center - frequency_shift, 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(False, 0) self.osmosdr_source_0.set_gain(10, 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.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc( 2, (1, ), frequency_shift, samp_rate) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc( firdes_decim, (firdes_filter), freq_adjust1, samp_rate / 2) self.digital_correlate_access_code_bb_0_0 = digital.correlate_access_code_bb( access_code, 1) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0_0 = digital.binary_slicer_fb() self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder( myqueue_out, True, True, False, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate / 2, True) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_char * 1) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(2) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0_0, 0), (self.digital_correlate_access_code_bb_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_correlate_access_code_bb_0_0, 0), (self.cc1111_cc1111_packet_decoder_0, 0)) self.connect((self.cc1111_cc1111_packet_decoder_0, 0), (self.blocks_null_sink_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Verisure (Securitas Direct) - demodulator") ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 38450 self.samp_rate = samp_rate = 2.0e06 self.rat_interop = rat_interop = 8 self.rat_decim = rat_decim = 5 self.frequency_tune = frequency_tune = 17.22e3 self.frequency_shift = frequency_shift = 0.52e06 self.frequency_center = frequency_center = 868.5e06 self.firdes_transition_width = firdes_transition_width = 15000 self.firdes_decim = firdes_decim = 4 self.firdes_cutoff = firdes_cutoff = 21e3 self.samp_per_sym = samp_per_sym = ((samp_rate/2/firdes_decim)*rat_interop/rat_decim) / symbole_rate self.rf_gain = rf_gain = 0 self.myqueue = myqueue = gr.msg_queue(200) self.if_gain = if_gain = 20 self.frequency = frequency = frequency_center + frequency_shift + frequency_tune self.freq_display = freq_display = frequency_center + frequency_shift + frequency_tune self.firdes_filter = firdes_filter = firdes.low_pass(1,samp_rate/2, firdes_cutoff, firdes_transition_width) self.fft_sp = fft_sp = 50000 self.crc_verbose = crc_verbose = False self.bb_gain = bb_gain = 20 self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._rf_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, minimum=0, maximum=14, num_steps=15, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_rf_gain_sizer, 0, 0, 1, 1) _if_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, label="IF Gain", converter=forms.float_converter(), proportion=0, ) self._if_gain_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, minimum=0, maximum=30, num_steps=31, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_if_gain_sizer, 0, 1, 1, 1) _frequency_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._frequency_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_frequency_tune_sizer, value=self.frequency_tune, callback=self.set_frequency_tune, label="Frequency Tuning", converter=forms.float_converter(), proportion=0, ) self._frequency_tune_slider = forms.slider( parent=self.GetWin(), sizer=_frequency_tune_sizer, value=self.frequency_tune, callback=self.set_frequency_tune, minimum=-30e3, maximum=30e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_frequency_tune_sizer, 0, 3, 1, 1) _bb_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._bb_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, label="BB Gain", converter=forms.float_converter(), proportion=0, ) self._bb_gain_slider = forms.slider( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, minimum=0, maximum=30, num_steps=31, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_bb_gain_sizer, 0, 2, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency_center + frequency_shift + frequency_tune, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=fft_sp, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="FFT", peak_hold=True, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 0, 1, 4) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=rat_interop, decimation=rat_decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=int(samp_rate/2/fft_sp), taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf=0" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(frequency_center, 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(False, 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(0, 0) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(2, (1, ), frequency_shift+frequency_tune, samp_rate) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(firdes_decim, (firdes_filter), 0, samp_rate/2) self._freq_display_static_text = forms.static_text( parent=self.GetWin(), value=self.freq_display, callback=self.set_freq_display, label="Current Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_display_static_text, 1, 0, 1, 4) self.digital_correlate_access_code_bb_0_0 = digital.correlate_access_code_bb(access_code, 1) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0_0 = digital.binary_slicer_fb() self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder(myqueue,True, True, False, False) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_char*1) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(2) ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0_0, 0), (self.digital_correlate_access_code_bb_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0_0, 0), (self.cc1111_cc1111_packet_decoder_0, 0)) self.connect((self.cc1111_cc1111_packet_decoder_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))
def __init__(self): gr.top_block.__init__(self, "grc_cc1111_hackrf_receiver") ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 40000 self.samp_rate = samp_rate = 2e06 self.rat_interop = rat_interop = 8 self.rat_decim = rat_decim = 5 self.firdes_transition_width = firdes_transition_width = 15000 self.firdes_decim = firdes_decim = 4 self.firdes_cuttoff = firdes_cuttoff = 21e3 self.samp_per_sym = samp_per_sym = ((samp_rate/2/firdes_decim)*rat_interop/rat_decim) / symbole_rate self.myqueue_out = myqueue_out = gr.msg_queue(2) self.frequency_shift = frequency_shift = 520000 self.frequency_center = frequency_center = 869.02e06 self.freq_adjust1 = freq_adjust1 = 0 self.firdes_filter = firdes_filter = firdes.low_pass(1,samp_rate/2, firdes_cuttoff, firdes_transition_width) self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=rat_interop, decimation=rat_decim, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(frequency_center-frequency_shift, 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(False, 0) self.osmosdr_source_0.set_gain(10, 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.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc(2, (1, ), frequency_shift, samp_rate) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(firdes_decim, (firdes_filter), freq_adjust1, samp_rate/2) self.digital_correlate_access_code_bb_0_0 = digital.correlate_access_code_bb(access_code, 1) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0_0 = digital.binary_slicer_fb() self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder(myqueue_out,True, True, False, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate/2,True) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_char*1) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(2) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0_0, 0), (self.digital_correlate_access_code_bb_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_correlate_access_code_bb_0_0, 0), (self.cc1111_cc1111_packet_decoder_0, 0)) self.connect((self.cc1111_cc1111_packet_decoder_0, 0), (self.blocks_null_sink_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "XN297 Demodulator") ################################################## # Variables ################################################## self.channel_spacing = channel_spacing = .5e6 self.channel = channel = 18 self.samp_rate = samp_rate = 2e6 self.hearthbeat = hearthbeat = 0 self.freq_offset = freq_offset = (channel_spacing / 2) + (channel_spacing * 0.1) self.freq_fine = freq_fine = 100e3 self.freq = freq = 2.4e9 + (channel * 1e6) self.channel_trans = channel_trans = channel_spacing * 0.5 self.bitrate = bitrate = 0 ################################################## # Blocks ################################################## self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ('localhost', 1235), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread( target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() 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 + freq_offset + freq_fine, 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(False, 0) self.osmosdr_source_0.set_gain(0, 0) self.osmosdr_source_0.set_if_gain(27, 0) self.osmosdr_source_0.set_bb_gain(27, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1, samp_rate, channel_spacing, channel_trans, firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate) self.digital_gfsk_demod_0_0 = digital.gfsk_demod( samples_per_symbol=int(samp_rate / 250e3), sensitivity=1, gain_mu=0.175, mu=0.05, omega_relative_limit=0.01, freq_error=0.0, verbose=False, log=False, ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=int(samp_rate / 1e6), sensitivity=1, gain_mu=0.175, mu=0.05, omega_relative_limit=0.01, freq_error=0.0, verbose=False, log=False, ) self.digital_correlate_access_code_bb_0_0_0 = digital.correlate_access_code_bb( '011100010000111101010101', 0) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1, '127.0.0.1', 1234, 1472, True) self.bitrate_selector_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=bitrate, output_index=0, ) self.bitrate_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=bitrate, ) ################################################## # Connections ################################################## self.connect((self.bitrate_selector, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.bitrate_selector, 1), (self.digital_gfsk_demod_0_0, 0)) self.connect((self.bitrate_selector_0, 0), (self.digital_correlate_access_code_bb_0_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0_0_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.bitrate_selector_0, 0)) self.connect((self.digital_gfsk_demod_0_0, 0), (self.bitrate_selector_0, 1)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.bitrate_selector, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="grc_cc1111_hackrf_receiver") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 80000 self.samp_rate = samp_rate = 2e06 self.firdes_transition_width = firdes_transition_width = 15000 self.firdes_cuttoff = firdes_cuttoff = 21e3 self.samp_per_sym = samp_per_sym = int(samp_rate / symbole_rate) self.rat_interop = rat_interop = 8 self.rat_decim = rat_decim = 5 self.myqueue_out = myqueue_out = gr.msg_queue(2) self.frequency_shift = frequency_shift = 520000 self.frequency_center = frequency_center = 433.6e06 self.firdes_filter = firdes_filter = firdes.low_pass( 1, samp_rate / 2, firdes_cuttoff, firdes_transition_width) self.firdes_decim = firdes_decim = 4 self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=frequency_center, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=5120, fft_rate=15, average=False, avg_alpha=None, title="Source", win=window.rectangular, ) self.Add(self.wxgui_waterfallsink2_0_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=frequency_center, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=5120, fft_rate=15, average=False, avg_alpha=None, title="Filter", win=window.rectangular, ) self.Add(self.wxgui_waterfallsink2_0.win) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=rat_interop, decimation=rat_decim, taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "hackrf=1") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq( frequency_center - frequency_shift, 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(False, 0) self.osmosdr_source_0.set_gain(10, 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.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc( 2, (1, ), frequency_shift, samp_rate) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc( firdes_decim, (firdes_filter), 0, samp_rate / 2) self.digital_correlate_access_code_bb_0_0 = digital.correlate_access_code_bb( access_code, 1) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0_0 = digital.binary_slicer_fb() self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder( myqueue_out, True, False, True, False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, "/home/bkbilly/Desktop/hello_out.txt", False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(2) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.cc1111_cc1111_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0_0, 0), (self.digital_correlate_access_code_bb_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0_0, 0), (self.cc1111_cc1111_packet_decoder_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Verisure (Securitas Direct) - demodulator") ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 38450 self.samp_rate = samp_rate = 2.0e06 self.rat_interop = rat_interop = 8 self.rat_decim = rat_decim = 5 self.frequency_tune = frequency_tune = 17.22e3 self.frequency_shift = frequency_shift = 0.52e06 self.frequency_center = frequency_center = 868.5e06 self.firdes_transition_width = firdes_transition_width = 15000 self.firdes_decim = firdes_decim = 4 self.firdes_cutoff = firdes_cutoff = 21e3 self.samp_per_sym = samp_per_sym = ( (samp_rate / 2 / firdes_decim) * rat_interop / rat_decim) / symbole_rate self.rf_gain = rf_gain = 0 self.myqueue = myqueue = gr.msg_queue(200) self.if_gain = if_gain = 20 self.frequency = frequency = frequency_center + frequency_shift + frequency_tune self.freq_display = freq_display = frequency_center + frequency_shift + frequency_tune self.firdes_filter = firdes_filter = firdes.low_pass( 1, samp_rate / 2, firdes_cutoff, firdes_transition_width) self.fft_sp = fft_sp = 50000 self.crc_verbose = crc_verbose = False self.bb_gain = bb_gain = 20 self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, label="RF Gain", converter=forms.float_converter(), proportion=0, ) self._rf_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, minimum=0, maximum=14, num_steps=15, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_rf_gain_sizer, 0, 0, 1, 1) _if_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, label="IF Gain", converter=forms.float_converter(), proportion=0, ) self._if_gain_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, minimum=0, maximum=30, num_steps=31, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_if_gain_sizer, 0, 1, 1, 1) _frequency_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._frequency_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_frequency_tune_sizer, value=self.frequency_tune, callback=self.set_frequency_tune, label="Frequency Tuning", converter=forms.float_converter(), proportion=0, ) self._frequency_tune_slider = forms.slider( parent=self.GetWin(), sizer=_frequency_tune_sizer, value=self.frequency_tune, callback=self.set_frequency_tune, minimum=-30e3, maximum=30e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_frequency_tune_sizer, 0, 3, 1, 1) _bb_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._bb_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, label="BB Gain", converter=forms.float_converter(), proportion=0, ) self._bb_gain_slider = forms.slider( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, minimum=0, maximum=30, num_steps=31, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_bb_gain_sizer, 0, 2, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency_center + frequency_shift + frequency_tune, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=fft_sp, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="FFT", peak_hold=True, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 0, 1, 4) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=rat_interop, decimation=rat_decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=int(samp_rate / 2 / fft_sp), taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "hackrf=0") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(frequency_center, 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(False, 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(0, 0) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc( 2, (1, ), frequency_shift + frequency_tune, samp_rate) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc( firdes_decim, (firdes_filter), 0, samp_rate / 2) self._freq_display_static_text = forms.static_text( parent=self.GetWin(), value=self.freq_display, callback=self.set_freq_display, label="Current Frequency", converter=forms.float_converter(), ) self.GridAdd(self._freq_display_static_text, 1, 0, 1, 4) self.digital_correlate_access_code_bb_0_0 = digital.correlate_access_code_bb( access_code, 1) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0_0_0 = digital.binary_slicer_fb() self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder( myqueue, True, True, False, False) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_char * 1) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(2) ################################################## # Connections ################################################## self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0_0, 0), (self.digital_correlate_access_code_bb_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0_0, 0), (self.cc1111_cc1111_packet_decoder_0, 0)) self.connect((self.cc1111_cc1111_packet_decoder_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0))
def __init__(self, options, filename): gr.top_block.__init__(self) inf_str = None symbol_rate = 152.34e3 sample_rate = 1e6 #if len(options) != 0: # inf_str = args[0] squelch = analog.pwr_squelch_cc(float(options.squelch), 0.1, 0, True) demod = analog.quadrature_demod_cf(1.0) cr = digital.clock_recovery_mm_ff(sample_rate / symbol_rate, 0.00765625, 0, 0.175, 0.005) slicer = digital.binary_slicer_fb() corr = digital.correlate_access_code_bb(AC, 3) sink = sniffer() if False: print "Reading from: " + inf_str src = blocks.file_source(gr.sizeof_gr_complex, inf_str, False) else: freqs = { 'AA': 917.0e6, 'AB': 913.0e6, 'AC': 914.0e6, 'AD': 915.0e6, 'BA': 916.0e6, 'BB': 919.0e6, 'BC': 920.0e6, 'BD': 921.0e6, 'CA': 922.0e6, 'CB': 923.0e6, 'CC': 907.0e6, 'CD': 908.0e6, 'DA': 905.5e6, 'DB': 909.0e6, 'DC': 911.0e6, 'DD': 910.0e6 } frequency = freqs[options.channel] print "Channel: " + options.channel + " (" + str( frequency / 1e6) + "MHz)" # Create a UHD device source src = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32', "sc16", args="")) # Set the subdevice spec if (options.spec): src.set_subdev_spec(options.spec, 0) # Set the antenna if (options.antenna): src.set_antenna(options.antenna, 0) # Set receiver sample rate src.set_samp_rate(options.samp_rate) # Set receive daughterboard gain if options.gain is None: g = src.get_gain_range() options.gain = float(g.start() + g.stop()) / 2 print "Using mid-point gain of", options.gain, "(", g.start( ), "-", g.stop(), ")" src.set_gain(options.gain) # Set frequency (tune request takes lo_offset) treq = uhd.tune_request(frequency) tr = src.set_center_freq(treq) if tr == None: sys.stderr.write('Failed to set center frequency\n') raise SystemExit, 1 self.connect(src, squelch, demod, cr, slicer, corr, sink)
def __init__(self): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.throttle_rate = throttle_rate = 4000000 self.samp_rate = samp_rate = 400000 self.samp_per_sym = samp_per_sym = samp_rate / 9910.0 self.fsk_deviation_hz = fsk_deviation_hz = 41000 ################################################## # Blocks ################################################## if usefile: self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, 'driverecording400kHz.cfile', False) # Adjust offset depending on where carrier is self.freqadj = 10000 self.decim = 1 throttle_rate = 400000 else: self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(throttle_rate) self.osmosdr_source_0.set_center_freq(316e6, 0) self.osmosdr_source_0.set_freq_corr(4, 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(False, 0) self.osmosdr_source_0.set_gain(14, 0) self.osmosdr_source_0.set_if_gain(30, 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.freqadj = -1.015e6 self.decim = 10 self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( self.decim, (firdes.low_pass(1, throttle_rate, 180000, 20000, firdes.WIN_HAMMING, 6.76)), self.freqadj, throttle_rate) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, 8000, 5000, firdes.WIN_HAMMING, 6.76)) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb( '000111111001', 0) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_tpmsrx_sink_0 = tpmsrx() self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0)) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) if usefile: self.connect((self.blocks_file_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) else: self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_tpmsrx_sink_0, 0))
def __init__(self, center_freq=867.4105, find_chan_nums=False, freq_list=[866.0375, 866.2875, 866.5375, 866.7875, 867.0375, 867.2875, 867.5375, 867.7875, 868.0375, 868.2875, 868.5375, 868.7875, 866.0625, 866.3125, 866.5625, 866.8125, 867.0625, 867.3125, 867.5625, 867.8125], noise_threshold=5, sink_rate=48000, source_rate=4000000, talkgroup=1796, tone_threshold=0.1, track_analog=True, track_digital=True, voice_threshold=0.4): gr.hier_block2.__init__( self, "Trunked Radio", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_char*1]), ) ################################################## # Parameters ################################################## self.center_freq = center_freq self.find_chan_nums = find_chan_nums self.freq_list = freq_list self.noise_threshold = noise_threshold self.sink_rate = sink_rate self.source_rate = source_rate self.talkgroup = talkgroup self.tone_threshold = tone_threshold self.track_analog = track_analog self.track_digital = track_digital self.voice_threshold = voice_threshold ################################################## # Variables ################################################## self.baud_rate = baud_rate = 9600 self.samp_per_sym = samp_per_sym = sink_rate / baud_rate self.fp_sel_index = fp_sel_index = 0 ################################################## # Blocks ################################################## self.edacs_handle_eot_0 = edacs.handle_eot(sink_rate, 4800, tone_threshold, noise_threshold) def _fp_sel_index_probe(): while True: val = self.edacs_handle_eot_0.get_sel_index() try: self.set_fp_sel_index(val) except AttributeError: pass time.sleep(1.0 / (100)) _fp_sel_index_thread = threading.Thread(target=_fp_sel_index_probe) _fp_sel_index_thread.daemon = True _fp_sel_index_thread.start() self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=int(sink_rate / 8000), decimation=1, taps=None, fractional_bw=None) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc( interpolation=int(sink_rate / 1000), decimation=int(source_rate / 1000), taps=None, fractional_bw=None) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(sink_rate / 1000), decimation=int(source_rate / 100000), taps=None, fractional_bw=None) self.low_pass_filter_0 = filter.fir_filter_ccf( 100, firdes.low_pass( 1, source_rate, .00625e6, .002e6, firdes.WIN_HAMMING, 6.76)) self.edacs_proc_msg_0 = edacs.proc_msg(talkgroup, freq_list, center_freq, find_chan_nums, track_analog, track_digital) self.edacs_find_chan_nums_0 = edacs.find_chan_nums(freq_list, center_freq, source_rate, voice_threshold) self.dsd_block_ff_0 = dsd.dsd_block_ff(dsd.dsd_FRAME_PROVOICE,dsd.dsd_MOD_AUTO_SELECT,3,False,3) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=int(samp_per_sym), sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb('010101010101010101010111000100100101010101010101', 0) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1-fp_sel_index) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1024) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_1 = analog.sig_source_c(source_rate, analog.GR_COS_WAVE, 0, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_c(source_rate, analog.GR_COS_WAVE, 0, 1, 0, 0) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=sink_rate, audio_decim=1, deviation=7000, audio_pass=6.25e3, audio_stop=10e3, gain=2.0, tau=75e-6, ) ################################################## # Connections ################################################## self.msg_connect((self.edacs_find_chan_nums_0, 'status_out'), (self.edacs_proc_msg_0, 'chan_status_in')) self.msg_connect((self.edacs_handle_eot_0, 'status_out'), (self.edacs_proc_msg_0, 'eot_status_in')) self.msg_connect((self.edacs_proc_msg_0, 'ctrl_freq'), (self.analog_sig_source_x_0, 'freq')) self.msg_connect((self.edacs_proc_msg_0, 'voice_freq'), (self.analog_sig_source_x_1, 'freq')) self.msg_connect((self.edacs_proc_msg_0, 'chan_status_out'), (self.edacs_find_chan_nums_0, 'status_in')) self.msg_connect((self.edacs_proc_msg_0, 'eot_status_out'), (self.edacs_handle_eot_0, 'status_in')) self.connect((self.analog_fm_demod_cf_0, 0), (self.edacs_handle_eot_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self, 0)) self.connect((self.blocks_delay_0, 0), (self.edacs_find_chan_nums_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.blocks_not_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_not_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.edacs_proc_msg_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.edacs_handle_eot_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.edacs_handle_eot_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.edacs_proc_msg_0, 0), (self, 1)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self, 0), (self.blocks_delay_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_add_xx_0, 1))
def __init__(self): gr.top_block.__init__(self, "Mpsk Stage3") Qt.QWidget.__init__(self) self.setWindowTitle("Mpsk Stage3") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mpsk_stage3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.payload = payload = range(256) self.nfilts = nfilts = 32 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.taps = taps = [1.0 + 0.0j, ] self.samp_rate = samp_rate = 250e3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.qpsk_const = qpsk_const = digital.constellation_rect(([-1, +1]), ([0, 1]), 1, 2, 1, 1, 1).base() self.payload_str = payload_str = ''.join(map(lambda x: "{0:08b}".format(x), payload)) self.gain = gain = 50 self.freq = freq = 2.3e9 self.excess_bw = excess_bw = 0.35 self.delay = delay = 32 self.decim = decim = 1 self.arity = arity = 2 self.access_code_str = access_code_str = "1111100110101" self.access_code = access_code = [31, 53] ################################################## # Blocks ################################################## self._delay_layout = Qt.QVBoxLayout() self._delay_tool_bar = Qt.QToolBar(self) self._delay_layout.addWidget(self._delay_tool_bar) self._delay_tool_bar.addWidget(Qt.QLabel("delay"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._delay_counter = qwt_counter_pyslot() self._delay_counter.setRange(0, 100, 1) self._delay_counter.setNumButtons(2) self._delay_counter.setValue(self.delay) self._delay_tool_bar.addWidget(self._delay_counter) self._delay_counter.valueChanged.connect(self.set_delay) self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._delay_slider.setRange(0, 100, 1) self._delay_slider.setValue(self.delay) self._delay_slider.setMinimumWidth(200) self._delay_slider.valueChanged.connect(self.set_delay) self._delay_layout.addWidget(self._delay_slider) self.top_layout.addLayout(self._delay_layout) self.west_stream_trigged_pdu_0 = west.stream_trigged_pdu("start_payload", 2048) self.west_ber_pdu_0 = west.ber_pdu(payload_str) self._timing_loop_bw_layout = Qt.QVBoxLayout() self._timing_loop_bw_label = Qt.QLabel("Time: BW") self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005) self._timing_loop_bw_slider.setValue(self.timing_loop_bw) self._timing_loop_bw_slider.setMinimumWidth(200) self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw) self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label) self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider) self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 3,1,1,1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_1_0 = qtgui.const_sink_c( 1024, #size "Equalizer", #name 1 #number of inputs ) self.qtgui_const_sink_x_1_0.set_update_time(0.10) self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1_0.enable_autoscale(False) self.qtgui_const_sink_x_1_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "Clock Sync Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 2048, #size "Costas Loop Output", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0,1,1,1) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 1, taps=(rrc_taps[:-1]), flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("RF gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.015, 2) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(access_code_str, 1) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk_const, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) (self.digital_constellation_modulator_0).set_processor_affinity([2]) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const) self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(16, 1, 0.15/100., 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([135, 201]*5000 + access_code + payload*100000, False, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.0001, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.3, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.west_stream_trigged_pdu_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.west_stream_trigged_pdu_0, "pdus", self.west_ber_pdu_0, "pdus")
def __init__(self): gr.top_block.__init__(self, "bladeRF_transceiver") ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 10e3 self.samp_rate = samp_rate = 1e6 self.rat_interop = rat_interop = 8 self.rat_decim = rat_decim = 5 self.firdes_transition_width = firdes_transition_width = 15000 self.firdes_decim = firdes_decim = 4 self.firdes_cuttoff = firdes_cuttoff = 21e3 self.tx_valve_value = tx_valve_value = False self.tx_rf_gain = tx_rf_gain = 10 self.tx_bb_gain = tx_bb_gain = -20 self.samp_per_sym_source = samp_per_sym_source = ((samp_rate/2/firdes_decim)*rat_interop/rat_decim) / symbole_rate self.samp_per_sym = samp_per_sym = int(samp_rate / symbole_rate) self.rx_valve_value = rx_valve_value = False self.rx_rf_gain = rx_rf_gain = 3 self.rx_bb_gain = rx_bb_gain = 20 self.preamble = preamble = '0101010101010101' self.msg_source_msgq_in = msg_source_msgq_in = gr.msg_queue(2) self.msg_sink_msgq_out = msg_sink_msgq_out = gr.msg_queue(2) self.frequency_tx = frequency_tx = 450e6 self.frequency_shift = frequency_shift = 520000 self.frequency_rx = frequency_rx = 450.0e6 self.firdes_filter = firdes_filter = firdes.low_pass(1,samp_rate/2, firdes_cuttoff, firdes_transition_width) self.bit_per_sym = bit_per_sym = 1 self.bandwith = bandwith = 6e6 self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## self.xlating_fir_filter_1 = filter.freq_xlating_fir_filter_ccc(2, (1, ), frequency_shift, samp_rate) self.xlating_fir_filter_0 = filter.freq_xlating_fir_filter_ccc(firdes_decim, (firdes_filter), 0, samp_rate/2) self.tx_valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(tx_valve_value)) self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate/2,True) self.rx_valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rx_valve_value)) self.rational_resampler = filter.rational_resampler_ccc( interpolation=rat_interop, decimation=rat_decim, taps=None, fractional_bw=None, ) self.quadrature_demod = analog.quadrature_demod_cf(2) self.osmosdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source.set_sample_rate(samp_rate) self.osmosdr_source.set_center_freq(frequency_rx-frequency_shift, 0) self.osmosdr_source.set_freq_corr(0, 0) self.osmosdr_source.set_dc_offset_mode(0, 0) self.osmosdr_source.set_iq_balance_mode(2, 0) self.osmosdr_source.set_gain_mode(False, 0) self.osmosdr_source.set_gain(rx_rf_gain, 0) self.osmosdr_source.set_if_gain(0, 0) self.osmosdr_source.set_bb_gain(rx_bb_gain, 0) self.osmosdr_source.set_antenna("", 0) self.osmosdr_source.set_bandwidth(bandwith, 0) self.osmosdr_sink = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_sink.set_sample_rate(samp_rate) self.osmosdr_sink.set_center_freq(frequency_tx, 0) self.osmosdr_sink.set_freq_corr(0, 0) self.osmosdr_sink.set_gain(tx_rf_gain, 0) self.osmosdr_sink.set_if_gain(0, 0) self.osmosdr_sink.set_bb_gain(tx_bb_gain, 0) self.osmosdr_sink.set_antenna("", 0) self.osmosdr_sink.set_bandwidth(bandwith, 0) self.gmsk_mod = digital.gmsk_mod( samples_per_symbol=int(samp_per_sym), bt=0.5, verbose=False, log=False, ) self.correlate_access_code = digital.correlate_access_code_bb(access_code, 4) self.clock_recovery = digital.clock_recovery_mm_ff(samp_per_sym_source*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.cc1111_packet_encoder = cc1111.cc1111_packet_mod_base(cc1111.cc1111_packet_encoder( samples_per_symbol=samp_per_sym, bits_per_symbol=bit_per_sym, preamble=preamble, access_code=access_code, pad_for_usrp=True, do_whitening=True, add_crc=True ), source_queue=msg_source_msgq_in ) self.cc1111_packet_decoder = cc1111.cc1111_packet_decoder(msg_sink_msgq_out,True, True, False, True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.binary_slicer = digital.binary_slicer_fb() ################################################## # Connections ################################################## self.connect((self.binary_slicer, 0), (self.correlate_access_code, 0)) self.connect((self.cc1111_packet_decoder, 0), (self.blocks_null_sink_0, 0)) self.connect((self.cc1111_packet_encoder, 0), (self.gmsk_mod, 0)) self.connect((self.clock_recovery, 0), (self.binary_slicer, 0)) self.connect((self.correlate_access_code, 0), (self.cc1111_packet_decoder, 0)) self.connect((self.gmsk_mod, 0), (self.tx_valve, 0)) self.connect((self.osmosdr_source, 0), (self.rx_valve, 0)) self.connect((self.quadrature_demod, 0), (self.clock_recovery, 0)) self.connect((self.rational_resampler, 0), (self.quadrature_demod, 0)) self.connect((self.rx_valve, 0), (self.xlating_fir_filter_1, 0)) self.connect((self.throttle, 0), (self.xlating_fir_filter_0, 0)) self.connect((self.tx_valve, 0), (self.osmosdr_sink, 0)) self.connect((self.xlating_fir_filter_0, 0), (self.rational_resampler, 0)) self.connect((self.xlating_fir_filter_1, 0), (self.throttle, 0))
def __init__(self, filepath_in): gr.top_block.__init__(self) #grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200e3 self.bb_interpolation = bb_interpolation = 100 self.bb_decimation = bb_decimation = 612 self.samples_per_symbol = samples_per_symbol = 4 self.gain_mu = gain_mu = 0.03 self.bb_rate = bb_rate = float( samp_rate) * bb_interpolation / bb_decimation self.bb_filter_freq = bb_filter_freq = 10e3 self.omega = omega = samples_per_symbol self.mu = mu = 0.5 self.gain_omega = gain_omega = 0.25 * gain_mu * gain_mu self.bb_taps = bb_taps = gr.firdes.low_pass(1.0, samp_rate, bb_filter_freq, bb_filter_freq * 0.1) self.baud_rate = baud_rate = bb_rate / samples_per_symbol #self.average = average = 64 ################################################## # Blocks ################################################## # self.wxgui_scopesink2_1_0_0 = scopesink2.scope_sink_f( # self.GetWin(), # title="Scope Plot", # sample_rate=baud_rate, # v_scale=0, # v_offset=0, # t_scale=0, # ac_couple=False, # xy_mode=False, # num_inputs=1, # trig_mode=gr.gr_TRIG_MODE_NORM, # y_axis_label="Counts", # ) # self.Add(self.wxgui_scopesink2_1_0_0.win) #self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (bb_taps), 6e3, samp_rate) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb( "10101010101010101010101010101", 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( omega, gain_omega, mu, gain_mu, 0.0002) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(64, True) #self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() #self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) #self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/mnt/hgfs/tmp/rf_captures/315.000m_200.000k_20130623_133451_extract_am_2.cfile", True) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_gr_complex * 1, filepath_in, False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=bb_interpolation, decimation=bb_decimation, taps=None, fractional_bw=None, ) # _bb_filter_freq_sizer = wx.BoxSizer(wx.VERTICAL) # self._bb_filter_freq_text_box = forms.text_box( # parent=self.GetWin(), # sizer=_bb_filter_freq_sizer, # value=self.bb_filter_freq, # callback=self.set_bb_filter_freq, # label="BB Freq", # converter=forms.int_converter(), # proportion=0, # ) # self._bb_filter_freq_slider = forms.slider( # parent=self.GetWin(), # sizer=_bb_filter_freq_sizer, # value=self.bb_filter_freq, # callback=self.set_bb_filter_freq, # minimum=5e3, # maximum=30e3, # num_steps=250, # style=wx.SL_HORIZONTAL, # cast=int, # proportion=1, # ) # self.Add(_bb_filter_freq_sizer) # _average_sizer = wx.BoxSizer(wx.VERTICAL) # self._average_text_box = forms.text_box( # parent=self.GetWin(), # sizer=_average_sizer, # value=self.average, # callback=self.set_average, # label="Average Length", # converter=forms.int_converter(), # proportion=0, # ) # self._average_slider = forms.slider( # parent=self.GetWin(), # sizer=_average_sizer, # value=self.average, # callback=self.set_average, # minimum=0, # maximum=256, # num_steps=256, # style=wx.SL_HORIZONTAL, # cast=int, # proportion=1, # ) # self.Add(_average_sizer) ################################################## # Connections ################################################## self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) #self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_uchar_to_float_0_0, 0)) #self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) #self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) #self.connect((self.blocks_uchar_to_float_0_0, 0), (self.wxgui_scopesink2_1_0_0, 0)) #self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0, 0)) #self.connect((self.blocks_file_source_0_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_complex_to_mag_0, 0)) self.packetizer = Packetizer(82) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.packetizer, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Elster Rx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.window_size = window_size = (800,600) self.samp_rate = samp_rate = 2400000 self.rx_gain = rx_gain = 45 self.corr = corr = 0 self.channel_rate = channel_rate = 400000 self.channel_decimation = channel_decimation = 4 self.center_freq = center_freq = 904600000 ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Band spectrum") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Band waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "1-channel waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Scope") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Bit stream") self.Add(self.nb) _corr_sizer = wx.BoxSizer(wx.VERTICAL) self._corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, label="Freq. correction", converter=forms.float_converter(), proportion=0, ) self._corr_slider = forms.slider( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, minimum=-100, maximum=100, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_corr_sizer) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(2).GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-30, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=30, average=False, avg_alpha=None, title="Waterfall Plot", size=(window_size), ) self.nb.GetPage(2).Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=center_freq, dynamic_range=50, ref_level=-30, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", size=(window_size), ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=2/56.48E-6, v_scale=0.5, v_offset=1, t_scale=8*56.48E-6, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", size=(window_size), ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=channel_rate/4, v_scale=0.4, v_offset=0, t_scale=56.48E-6 *8, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", size=(window_size), ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=center_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=True, size=(window_size), ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) 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(center_freq, 0) self.osmosdr_source_0.set_freq_corr(corr, 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(0, 0) self.osmosdr_source_0.set_gain(rx_gain, 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_1 = filter.fir_filter_fff(channel_decimation, firdes.low_pass( 1, channel_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76)) self.elster_packetize_0 = elster.packetize(1) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb("1010101010101010101010101010101001010101101001011001101010100110", 0) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(channel_rate * 56.48E-6 / 2 / channel_decimation, 0.25*(0.05*0.05), 0.5, 0.05, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*1, samp_rate/channel_rate) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(-channel_rate/(115000*2*3.1416)) ################################################## # Connections ################################################## self.connect((self.blocks_uchar_to_float_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.elster_packetize_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="iSmartAlarm CC1110 Decoder") self._lock = threading.RLock() ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 38383.5 self.samp_rate = samp_rate = 6e6 self.rat_interop = rat_interop = 8 self.rat_decim = rat_decim = 5 self.frequency_tune = frequency_tune = 0 self.frequency_shift = frequency_shift = 0.52e06 self.frequency_center = frequency_center = 907481800 self.firdes_transition_width = firdes_transition_width = 13e3 self.firdes_decim = firdes_decim = 4 self.firdes_cutoff = firdes_cutoff = 17e3 self.samp_per_sym = samp_per_sym = ( (samp_rate / 2 / firdes_decim) * rat_interop / rat_decim) / symbole_rate self.myqueue = myqueue = gr.msg_queue(200) self.frequency = frequency = frequency_center + frequency_shift + frequency_tune self.freq_display = freq_display = frequency_center + frequency_shift + frequency_tune self.firdes_filter = firdes_filter = firdes.low_pass( 1, samp_rate / 2, firdes_cutoff, firdes_transition_width) self.fft_sp = fft_sp = 50000 self.crc_verbose = crc_verbose = True self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## _frequency_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._frequency_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_frequency_tune_sizer, value=self.frequency_tune, callback=self.set_frequency_tune, label='Frequency Tuning', converter=forms.float_converter(), proportion=0, ) self._frequency_tune_slider = forms.slider( parent=self.GetWin(), sizer=_frequency_tune_sizer, value=self.frequency_tune, callback=self.set_frequency_tune, minimum=-30e3, maximum=30e3, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_frequency_tune_sizer, 0, 0, 1, 1) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=frequency_center + frequency_shift + frequency_tune, y_per_div=10, y_divs=10, ref_level=-30, ref_scale=2.0, sample_rate=fft_sp, fft_size=1024, fft_rate=60, average=False, avg_alpha=None, title='FFT', peak_hold=True, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 0, 1, 4) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=rat_interop, decimation=rat_decim, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=int(samp_rate / 2 / fft_sp), taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'name=MyB210,product=B210,serial=30C62A1,type=b200,uhd') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(frequency_center, 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(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(50000, 0) self.ism_ism_packet_decoder_0 = ism.ism_packet_decoder( myqueue, True, False) self.freq_xlating_fir_filter_xxx_1_0 = filter.freq_xlating_fir_filter_ccc( firdes_decim, (firdes_filter), 0, samp_rate / 2) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_ccc( 8, (1, ), frequency_shift + frequency_tune, samp_rate) self._freq_display_static_text = forms.static_text( parent=self.GetWin(), value=self.freq_display, callback=self.set_freq_display, label='Current Frequency', converter=forms.float_converter(), ) self.GridAdd(self._freq_display_static_text, 1, 0, 1, 4) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb( access_code, 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(4) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.ism_ism_packet_decoder_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.freq_xlating_fir_filter_xxx_1_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.ism_ism_packet_decoder_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self, filepath_in): gr.top_block.__init__(self) #grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200e3 self.bb_interpolation = bb_interpolation = 100 self.bb_decimation = bb_decimation = 612 self.samples_per_symbol = samples_per_symbol = 4 self.gain_mu = gain_mu = 0.03 self.bb_rate = bb_rate = float(samp_rate) * bb_interpolation / bb_decimation self.bb_filter_freq = bb_filter_freq = 10e3 self.omega = omega = samples_per_symbol self.mu = mu = 0.5 self.gain_omega = gain_omega = 0.25 * gain_mu * gain_mu self.bb_taps = bb_taps = gr.firdes.low_pass(1.0, samp_rate, bb_filter_freq, bb_filter_freq * 0.1) self.baud_rate = baud_rate = bb_rate / samples_per_symbol #self.average = average = 64 ################################################## # Blocks ################################################## # self.wxgui_scopesink2_1_0_0 = scopesink2.scope_sink_f( # self.GetWin(), # title="Scope Plot", # sample_rate=baud_rate, # v_scale=0, # v_offset=0, # t_scale=0, # ac_couple=False, # xy_mode=False, # num_inputs=1, # trig_mode=gr.gr_TRIG_MODE_NORM, # y_axis_label="Counts", # ) # self.Add(self.wxgui_scopesink2_1_0_0.win) #self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (bb_taps), 6e3, samp_rate) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb("10101010101010101010101010101", 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(omega, gain_omega, mu, gain_mu, 0.0002) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(64, True) #self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() #self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) #self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/mnt/hgfs/tmp/rf_captures/315.000m_200.000k_20130623_133451_extract_am_2.cfile", True) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex*1, filepath_in, False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=bb_interpolation, decimation=bb_decimation, taps=None, fractional_bw=None, ) # _bb_filter_freq_sizer = wx.BoxSizer(wx.VERTICAL) # self._bb_filter_freq_text_box = forms.text_box( # parent=self.GetWin(), # sizer=_bb_filter_freq_sizer, # value=self.bb_filter_freq, # callback=self.set_bb_filter_freq, # label="BB Freq", # converter=forms.int_converter(), # proportion=0, # ) # self._bb_filter_freq_slider = forms.slider( # parent=self.GetWin(), # sizer=_bb_filter_freq_sizer, # value=self.bb_filter_freq, # callback=self.set_bb_filter_freq, # minimum=5e3, # maximum=30e3, # num_steps=250, # style=wx.SL_HORIZONTAL, # cast=int, # proportion=1, # ) # self.Add(_bb_filter_freq_sizer) # _average_sizer = wx.BoxSizer(wx.VERTICAL) # self._average_text_box = forms.text_box( # parent=self.GetWin(), # sizer=_average_sizer, # value=self.average, # callback=self.set_average, # label="Average Length", # converter=forms.int_converter(), # proportion=0, # ) # self._average_slider = forms.slider( # parent=self.GetWin(), # sizer=_average_sizer, # value=self.average, # callback=self.set_average, # minimum=0, # maximum=256, # num_steps=256, # style=wx.SL_HORIZONTAL, # cast=int, # proportion=1, # ) # self.Add(_average_sizer) ################################################## # Connections ################################################## self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) #self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_uchar_to_float_0_0, 0)) #self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) #self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) #self.connect((self.blocks_uchar_to_float_0_0, 0), (self.wxgui_scopesink2_1_0_0, 0)) #self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0, 0)) #self.connect((self.blocks_file_source_0_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_complex_to_mag_0, 0)) self.packetizer = Packetizer(82) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.packetizer, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1024000 self.decimation = decimation = 10 self.symbol_rate = symbol_rate = 38400 self.input_rate = input_rate = samp_rate / decimation self.window_symbols = window_symbols = 1 self.symbol_taps_length = symbol_taps_length = int( (float(input_rate) / symbol_rate)) self.samples_per_symbol = samples_per_symbol = float( input_rate) / symbol_rate self.grab_freq = grab_freq = 868200000 self.symbol_taps = symbol_taps = (1, ) * symbol_taps_length self.offset_sign2 = offset_sign2 = (-34780 * grab_freq) / 868200000 self.offset_sign1 = offset_sign1 = (11600 * grab_freq) / 868200000 self.gain_mu = gain_mu = 0.4 / samples_per_symbol self.fsk_deviation_hz = fsk_deviation_hz = 5200 self.average_window = average_window = int( (input_rate * window_symbols / symbol_rate)) ################################################## # Blocks ################################################## self.urmetEasyRead_urmetEasyRead_0 = urmetEasyRead.urmetEasyRead() self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb( '11010011100100011101001110010001', 1) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samples_per_symbol, 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.02) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.cc1111_cc1111_packet_decoder_0 = cc1111.cc1111_packet_decoder( gr.msg_queue(1), False, True, True, True) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, sys.argv[1], False) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((-128 - 128j, )) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(40, 1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.FXFIR1 = filter.freq_xlating_fir_filter_ccc( decimation, (1, ), -14e3, samp_rate) ################################################## # Connections ################################################## self.connect((self.FXFIR1, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.FXFIR1, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.cc1111_cc1111_packet_decoder_0, 0), (self.urmetEasyRead_urmetEasyRead_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.cc1111_cc1111_packet_decoder_0, 0)) self.connect((self.urmetEasyRead_urmetEasyRead_0, 0), (self.blocks_null_sink_1, 0))
def __init__(self): gr.top_block.__init__(self) sdr_device = '' # Front end error_ppm = 40 freq_c0 = 869000000 # Modulation parameters sample_rate = 1200000 bit_rate = 50000 deviation = 25000 max_freq_error = 50000 decim = 2 squelch_threshold = -20 sync_word = "01010010110111010010" # preamble + 2dd2 # Source self.src = osmosdr.source(sdr_device) self.src.set_sample_rate(sample_rate) self.src.set_center_freq(freq_c0) self.src.set_freq_corr(error_ppm) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) self.src.set_gain_mode(False, 0) self.src.set_gain(20, 0) self.src.set_if_gain(20, 0) self.src.set_bb_gain(20, 0) # Channel filter (bandwidth is relative to centre of channel so /2 bandwidth = 2. * (deviation + bit_rate / 2) filter_taps = gr_filter.firdes.low_pass(1, sample_rate, max_freq_error + bandwidth / 2., bit_rate / 2., gr_filter.firdes.WIN_BLACKMAN, 6.76) self.filt = gr_filter.freq_xlating_fir_filter_ccc(decim, filter_taps, 0.0, sample_rate) # FSK demod m = 2. * deviation / bit_rate # Modulation index demod_gain = float(sample_rate) / decim / bit_rate / (pi * m) squelch = gr_analog.simple_squelch_cc(squelch_threshold, 1.) demod = gr_analog.quadrature_demod_cf(demod_gain) # AM demod (RSSI) ctof = gr_blocks.complex_to_mag() # Clock recovery and slicer gain_mu = 0.175 gain_omega = 0.25 * gain_mu * gain_mu omega_rel_limit = 0.005 clock = gr_digital.clock_recovery_mm_ff(sample_rate / decim / bit_rate, gain_omega, 0.5, gain_mu, omega_rel_limit) slicer = gr_digital.binary_slicer_fb() sync = gr_digital.correlate_access_code_bb(sync_word, 0) # Sink to queue self.queue = gr.msg_queue() self.watcher = queue_thread(self.queue, None) sink = gr_blocks.message_sink(gr.sizeof_char, self.queue, False) # GUI elements fft = qtgui.freq_sink_c(512, gr_filter.firdes.WIN_BLACKMAN, freq_c0, sample_rate/decim, "Spectrum", 1) fft.enable_grid(True) fft.set_line_label(0, 'Signal') qtfft = sip.wrapinstance(fft.pyqwidget(), Qt.QWidget) self.qtwidgets.append(qtfft) plot = qtgui.time_sink_f(int(0.1 * sample_rate / decim), sample_rate / decim, "Scope", 2) plot.enable_grid(True) plot.set_update_time(0.1) plot.set_y_axis(-2, 2) plot.set_line_label(0, 'RSSI') plot.set_line_label(1, 'FSK') plot.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.1, 0, 0, '') qtplot = sip.wrapinstance(plot.pyqwidget(), Qt.QWidget) self.qtwidgets.append(qtplot) plot2 = qtgui.time_sink_f(int(0.005 * sample_rate / decim), sample_rate / decim, "Packet View", 1) plot2.enable_grid(True) plot2.set_update_time(0.1) plot2.set_y_axis(-2, 2) plot2.set_line_label(0, 'FSK') plot2.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.1, 0, 0, '') qtplot2 = sip.wrapinstance(plot2.pyqwidget(), Qt.QWidget) self.qtwidgets.append(qtplot2) # Flowgraph self.connect(self.src, self.filt, squelch, demod, clock, slicer, sync, sink) self.connect(self.src, fft) self.connect(demod, (plot, 0)) self.connect(self.filt, ctof, (plot, 1)) self.connect(demod, (plot2, 0))