Changeset 339

Show
Ignore:
Timestamp:
07/17/09 20:39:00 (15 years ago)
Author:
sriram
Message:

Changes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/sriram/benchmark_txrxnode1.py

    r330 r339  
    1818from transmit_path import transmit_path 
    1919from receive_path import receive_path 
    20 import spec_sense_path 
     20#import spec_sense_path 
    2121 
    2222global sync_status 
     
    3838         
    3939        ########connect for the spectrum sense######### 
    40         default_min_freq = 462.4825e6 #80 Khz to the left of channel 1 (462.5625e6) in frs band  
    41         default_max_freq = 462.6425e6 #80 Khz to the right of channel 1 (462.5625e6) in frs band  
    42         self.sp_sense_path = spec_sense_path.spec_sense_top_block(default_min_freq,default_min_freq) 
    43         self.connect(self.sp_sense_path.u, self.sp_sense_path.s2v, self.sp_sense_path.fft, self.sp_sense_path.c2mag, self.sp_sense_path.stats) 
    44         #self.connect(self.txpath); 
    45         #self.connect(self.rxpath); 
     40        #default_min_freq = 462.4825e6 #80 Khz to the left of channel 1 (462.5625e6) in frs band  
     41        #default_max_freq = 462.6425e6 #80 Khz to the right of channel 1 (462.5625e6) in frs band  
     42        #self.sp_sense_path = spec_sense_path.spec_sense_top_block(default_min_freq,default_min_freq) 
     43        #self.connect(self.sp_sense_path.u, self.sp_sense_path.s2v, self.sp_sense_path.fft, self.sp_sense_path.c2mag, self.sp_sense_path.stats) 
     44 
     45        self.connect(self.txpath); 
     46        self.connect(self.rxpath); 
    4647 
    4748         
    4849#//////main//////   
    4950 
    50 global n_rcvd, n_right 
     51global n_rcvd, n_right,hop_freq 
    5152 
    5253def main(): 
    53     global n_rcvd, n_right,sync_status,mode 
     54    global n_rcvd, n_right,sync_status,mode,hop_freq 
    5455    n_rcvd = 0 
    5556    n_right = 0 
     
    5859 
    5960    def rx_callback(ok, payload): 
     61 
     62         
    6063        #print "inside rx callback" 
    61         global n_rcvd, n_right, sync_status,mode 
     64        global n_rcvd, n_right, sync_status,mode,hop_freq 
     65        tb.rxpath.min_freq = hop_freq - 80e3  
     66        tb.rxpath.max_freq = hop_freq + 80e3  
     67        tb.rxpath.get_avg_power(10) 
    6268        (pktno,) = struct.unpack('!H', payload[0:2]) 
    6369        #temp = struct.unpack('!s', payload[3:10]) 
     
    7884                                        #print "inside if2" 
    7985                                        sync_status = True 
    80                                         tb.stop() 
     86                                        #tb.stop() 
    8187                                        #print "after tb stop ans sync status is ",sync_status," sync status\n" 
    8288                                        #print "received a sync packet on channel %s\n" %(data_channel) 
     
    137143    options_tx.fusb_block_size = 4096 
    138144    options_tx.fusb_nblocks = 16 
     145    options_tx.bitrate = 0.0125e6 
    139146    ############# 
    140147    if options_tx.tx_freq is None: 
     
    183190    options_rx.fusb_block_size = 4096 
    184191    options_rx.fusb_nblocks = 16 
     192    options_rx.bitrate = 0.0125e6 
    185193    ############# 
    186194    if options_rx.rx_freq is None: 
     
    193201 
    194202    ######################## adding another top block for usrp spectrum sense ######################## 
    195     trials = 10 
     203    #This is not needed anymore 
     204    #trials = 10 
    196205     
    197206    #tb_spec_sense = spec_sense_top_block(default_min_freq,default_min_freq) 
     
    215224       print "Warning: failed to enable realtime scheduling" 
    216225 
    217     #tb.start() 
     226    tb.start() 
     227    #tb.rxpath.get_avg_power(10) #10 is the number of fft frames that we are looking at to determine the average power 
    218228    # generate and send packets 
    219229    #print "printing megamytes",options_tx.megabytes,"  $$$$\n" 
     
    237247    #resend_count= 0 #initializing resend count 
    238248    #while running 
    239      
     249    if mode  == "sync": 
     250        #nbytes = int(1e6 * .0003) 
     251        #nbytes = int(1e6 * .0003) 
     252        nbytes = 6 
     253        pkt_size = 6 
     254        print "printing packet size",pkt_size,"pkt size\n" 
     255        while sync_status != True: 
     256                #ch = random.randint(1, 7) 
     257                #ch = int(random.choice('17')) 
     258                #ch = random.randint(6,12) 
     259                ch = 1 
     260                hop_freq = float(1e6 * (462.5625+(ch-1)*0.025))#setting the centre freq frequency for sending packets 
     261                print "hop freq is ",hop_freq 
     262                 
     263                #hop_freq = float(1e6 * (462.5625+(5-1)*0.05))#setting the centre freq frequency for sending packets 
     264                tb.txpath.set_freq(hop_freq) 
     265                tb.rxpath.set_freq(hop_freq) 
     266                #print "inside while pppp printing sync channel",sync_status,"  done" 
     267                #if sync_status == "True": 
     268                #print "synchronization done..data channel is found" 
     269                #break 
     270                #else: 
     271                #print "inside else1" 
     272                n = 0 
     273                pktno = 0 
     274                print >> myfile, "out" 
     275                while n < nbytes: 
     276                        print >> myfile, "inside while" 
     277                        if options_tx.from_file is None: 
     278                                #data = (pkt_size - 2) * chr(pktno & 0xff) #0xff is 255 
     279                                data = 's'+'s'+str(ch)+str(ch) #adding redundant bits for sync and channel 
     280                                #print >> myfile, data 
     281                                #print "printing data",data,"****\n" 
     282                        else: 
     283                                data = source_file.read(pkt_size - 2) 
     284                                if data == '': 
     285                                        break; 
     286 
     287                        payload = struct.pack('!H', pktno & 0xffff) + data 
     288                        #print "printing payload",payload,"**\n" 
     289                         
     290                        send_pkt(tb,payload) 
     291                        #print "printing payload",payload,"**\n" 
     292                        n += len(payload) 
     293                        sys.stderr.write('.') 
     294                        if options_tx.discontinuous and pktno % 5 == 4: 
     295                                time.sleep(1) 
     296                        pktno += 1 
     297                        #print "before sleeping for 10 seconds and value of resend count is",resend_count 
     298 
     299                tb.rxpath.min_freq = hop_freq - 80e3  
     300                tb.rxpath.max_freq = hop_freq + 80e3  
     301                tb.rxpath.get_avg_power(10) #10 is the number of fft frames that we are looking at to determine the average power 
     302 
     303                time.sleep(0.05) 
     304                #time.sleep(2) 
     305                #resend_count += 1  
     306    print "sync channel found! and it is channel ",ch,"\n" 
     307    send_pkt(tb,eof=True) 
     308    #myfile.close() 
     309    tb.wait() 
    240310     
    241311