I am trying to read a *.txt file , then transmit packets using the code below
and receive them and write in a similar file.(similar to what is used in
benchmark example)
the transmitting code is :

target_freq = 2.4e9
interpolation = 128
#gain  = 2
class mysiso(gr.top_block):
    def __init__(self):     
        gr.top_block.__init__(self, "mysiso")
        #pdb.set_trace()
        self.mod = blks2.dbpsk_mod()#2, 0.35, True, False, False)
        self.pkt_tx = blks2.mod_pkts(self.mod )

        self.amp = gr.multiply_const_cc(8192)
##############################################
###    usrp_tx
############################################33
        self.u = usrp.sink_c(0)
        self.u.set_interp_rate(interpolation)
        self.subdev_spec = usrp.pick_tx_subdevice(self.u)
        #self.set       
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, self.subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, self.subdev_spec)
        self.subdev.set_enable(True)
        
        r = self.subdev.gain_range()    # required to set gain
        gain = (r[0] + r[1])/2  
        self.subdev.set_gain(gain)
        self.u.tune(self.subdev._which, self.subdev, target_freq)
##############################################3
##### 
############################################333
        self.connect(self.pkt_tx, self.amp, self.u)
def main():
        src_file = open('/home/usrp2user/PDF/data1.txt', 'r')
        src_data = src_file.read()
        src_file.close()
        
        gt = mysiso()
        gt.start()
   
        try:
                i = 0
                pkt_size = 10
                pkt_data = src_data[i:i+pkt_size]
                while len(pkt_data) > 0:
                        print len(pkt_data)
                        gt.pkt_tx.send_pkt(pkt_data)
                        i = i+pkt_size
                        pkt_data = src_data[i:i+pkt_size]
        except:
                pass
   
        gt.pkt_tx.send_pkt('')
        gt.pkt_tx.send_pkt(eof=True)
        gt.wait()
if __name__ == '__main__':
        main()

And the receiver code is :

samples_per_symbol = 2
decimation = 128           #even integer between [8,256]
target_freq = 2.4e9
class mysiso(gr.top_block):
        def __init__(self, rx_callback):
                gr.top_block.__init__(self, "mysiso")
                        
                self.demod = blks2.dbpsk_demod()#2, 0.35, 0.1 , None, 0.5, 
0.005,
True, False, True)
                self.pkt_rx = blks2.demod_pkts(self.demod, access_code=None,
callback=rx_callback,threshold=-1)
        
                # Design filter to get actual channel we want
                sw_decim = 1
                chan_coeffs = gr.firdes.low_pass (1.0, sw_decim *
samples_per_symbol,1.0 , 0.5 ,gr.firdes.WIN_HANN)                               
                              
                # Decimating channel filter
                # complex in and out, float taps
                self.chan_filt = gr.fft_filter_ccc(sw_decim, chan_coeffs)
                ##############################################
                ###    usrp_rx
                ############################################33
                self.u = usrp.source_c(0)
                self.u.set_decim_rate(decimation)        #decimation must be 
even between
[8,256]
                self.subdev_spec = usrp.pick_rx_subdevice(self.u)
                self.u.set_mux(usrp.determine_rx_mux_value(self.u, 
self.subdev_spec))
                self.subdev = usrp.selected_subdev(self.u, self.subdev_spec)
                self.subdev.select_rx_antenna('RX2')   # Select receive antenna 
('TX/RX'
or 'RX2'): flex boards only!
                self.u.tune(0, self.subdev, target_freq)
                r = self.subdev.gain_range()    # required to set gain
                gain = (r[0] + r[1])/2  
                print r[0]
                print r[1]      
                self.subdev.set_gain(gain)
                ##############################################3
                ##### 
                ###########################################333
                self.connect(self.u, self.chan_filt, self.pkt_rx)
                
def main():
        global dst_file
        dst_file = open('/home/usrp2user/PDF/data2.txt', 'w')
        
        def rx_callback(ok, payload):
                global dst_file
                #pdb.set_trace()
                dst_file.write(payload)

        gt = mysiso(rx_callback)   
        gt.wait()
        dst_file.close()

if __name__ == '__main__':
        main()

I do not receive any error.
 I expected this code to work but received file is empty. actually
rx_callback never is called. while I don't use USRP and directly connect
pkt_mod to pkt_demod it works perfect.

Can somebody guide me how to successfully receive the transmitted packets?

any help is appreciated,
Mehdi
 
-- 
View this message in context: 
http://www.nabble.com/problem-using-Packet--mod-demod.-tp18531641p18531641.html
Sent from the GnuRadio mailing list archive at Nabble.com.



_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to