Changeset 357

Show
Ignore:
Timestamp:
07/21/09 12:23:22 (15 years ago)
Author:
sriram
Message:

some changes to receive path

Files:
1 modified

Legend:

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

    r354 r357  
    3535import copy 
    3636import sys 
    37  
     37from numpy import random 
    3838# from current dir 
    3939from pick_bitrate import pick_rx_bitrate 
    4040import usrp_options 
     41import random 
    4142 
    4243# ///////////////////////////////////////////////////////////////////////////// 
     
    341342        print "Rx Frequency:    %s"    % (eng_notation.num_to_str(self._rx_freq)) 
    342343 
    343     def get_avg_power(self,trials): 
     344    #Getting spectrum information 
     345    #Arguments... threshold - Minimum power equivalent available in spectrum 
     346#                 trials - Fft frames...should be 1  
     347#                 exceed count - Number of times threshold is exceeded...useless 
     348 
     349    def get_spec_stats(self,threshold,trials): 
    344350        power_sum = 0 #sum of powers(each power value is determined by adding the 'fft square' points..these fft square points are essentially points from the PSD curve...and adding them gives us the power contained in the spectrum) 
    345351        counter = 0 
    346          
    347         while counter < 10 : 
    348  
    349                 # Get the next message sent from the C++ code (blocking call). 
     352        #exceed = 0 
     353        while counter < trials: 
     354                # Get the next message sent from the C++ code (blocking call). 
    350355                # It contains the center frequency and the mag squared of the fft 
    351                 m = parse_msg(self.msgq.delete_head()) 
     356                m = parse_msg(self.msgq.delete_head()) 
    352357                #print "printing mag sq of fft ",sum(m.data),"\n" 
    353                 #if sum(m.data) > 1e12: 
    354358                power_sum = power_sum + sum(m.data) 
    355                 print sum(m.data),"\n" 
     359                #if sum(m.data) > threshold 
     360                #       exceed+=1 
     361                #print sum(m.data),"\n" 
    356362                # Print center freq so we know that something is happening... 
    357363                #print m.center_freq 
    358364                counter +=1 
    359365        # FIXME do something useful with the data... 
     366         
    360367         
    361368        # m.data are the mag_squared of the fft output (they are in the 
     
    364371        # m.raw_data is a string that contains the binary floats. 
    365372        # You could write this as binary to a file. 
    366  
    367         avg_power = power_sum/counter 
    368         print "printing average power ",avg_power,"\n" 
     373        print "here" 
     374        avg_power = power_sum/trials 
     375        #ch = int(random.choice('17')) 
     376        if avg_power >= threshold: 
     377                return True 
     378                #return 1,ch 
     379        else: 
     380                return False 
     381                #return 0,"no" 
     382        #print "printing average power ",avg_power,"\n" 
     383        #if exceed >= exceed_count: 
     384        #       return avg_power,True  
     385        #       return avg_power,True #True = primary user is present at this frequency  
     386        #else 
     387        #       return avg_power,False 
     388        #       return avg_power,False #False = primary user is NOT present at this frequency  
    369389 
    370390def add_freq_option(parser):