Changeset 4748

Show
Ignore:
Timestamp:
08/17/07 12:44:14 (7 years ago)
Author:
jgaeddert
Message:

fixing frequency metadata in USRP branch

Location:
platform/USRP/branches/USRP-metadata/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • platform/USRP/branches/USRP-metadata/src/USRP.h

    r4747 r4748  
    116116    USRP_TX_Control_i(const USRP_TX_Control_i &); // No copying 
    117117 
     118    /// return pointer to daughterboard 
     119    void get_db_reference(unsigned long channel, db_base *& db); 
     120  
    118121    USRP_i *usrp; 
    119122 
  • platform/USRP/branches/USRP-metadata/src/port_impl.cpp

    r4747 r4748  
    9696} 
    9797 
     98void USRP_TX_Control_i::get_db_reference(unsigned long channel, db_base *& db) 
     99{ 
     100    omni_mutex_lock l(usrp->rx_control_access); 
     101    if (channel == 0) { 
     102        if (usrp->rx_db0_control) 
     103            db = usrp->rx_db0_control; 
     104    } else if (channel == 1) { 
     105        if (usrp->rx_db1_control) 
     106            db = usrp->rx_db1_control; 
     107    } else { 
     108        std::cerr << "Bad channel specified" << std::endl; 
     109        return; ///\todo throw bad channel exception 
     110    } 
     111} 
     112 
     113 
    98114void USRP_TX_Control_i::set_frequency(unsigned long channel, float f) 
    99115{ 
     
    102118    class db_base *db(NULL); 
    103119 
    104     omni_mutex_lock l(usrp->tx_control_access); 
    105     if (channel == 0) { 
    106         if (usrp->tx_db0_control) 
    107             db = usrp->tx_db0_control; 
    108     } else if (channel == 1) { 
    109         if (usrp->tx_db1_control) 
    110             db = usrp->tx_db1_control; 
    111     } else { 
    112         return; ///\todo throw bad channel exception 
    113     } 
     120    // get reference for daughter board on this channel 
     121    get_db_reference(channel, db); 
    114122 
    115123    if (!db) 
     
    144152void USRP_TX_Control_i::get_frequency(unsigned long channel, float &f) 
    145153{ 
    146     f = usrp->usrp_tx->tx_freq(channel); 
     154    float ddc_freq = usrp->usrp_rx->rx_freq(channel); // DDC frequency 
     155 
     156    // Get local oscillator frequency on daughterboard (if available) 
     157    //float lo_freq(0.0f) 
     158    db_base * db(NULL); 
     159    get_db_reference(channel, db); 
     160    if (!db) { 
     161        // No daughterboard present 
     162        std::cerr << "ERROR: USRP_RX_Control_i::get_frequency(): " << std::endl 
     163                  << "  Attempt to get frequency for slot with no board (channel " 
     164                  << channel << ")" << std::endl; 
     165        ///\todo: throw better exception 
     166        throw 0; 
     167    } 
     168 
     169    if (db->db_has_lo()) { 
     170        // get lo_freq here 
     171        // db->get_db_freq(lo_freq) 
     172    } 
     173 
     174    f = ddc_freq + db_lo_freq; 
    147175} 
    148176 
     
    305333void USRP_RX_Control_i::get_db_reference(unsigned long channel, db_base *& db) 
    306334{ 
    307      
    308 } 
    309  
    310 void USRP_RX_Control_i::set_frequency(unsigned long channel, float f) 
    311 { 
    312     DEBUG(3, USRP, "In RX Control set frequency channel: " << channel << ", frequency: " << f); 
    313  
    314     class db_base *db(NULL); 
    315  
    316335    omni_mutex_lock l(usrp->rx_control_access); 
    317336    if (channel == 0) { 
     
    325344        return; ///\todo throw bad channel exception 
    326345    } 
    327      
     346} 
     347 
     348void USRP_RX_Control_i::set_frequency(unsigned long channel, float f) 
     349{ 
     350    DEBUG(3, USRP, "In RX Control set frequency channel: " << channel << ", frequency: " << f); 
     351 
     352    class db_base *db(NULL); 
     353 
     354    // get reference for daughter board on this channel 
     355    get_db_reference(channel, db); 
     356 
    328357    if (!db) { 
    329358        // No daughterboard present 
    330         std::cerr << "ERROR: USRP_RX_Control_i::get_frequency(): " << std::endl 
     359        std::cerr << "ERROR: USRP_RX_Control_i::set_frequency(): " << std::endl 
    331360                  << "  Attempt to set frequency for slot with no board (channel " 
    332361                  << channel << ")" << std::endl; 
     
    375404 
    376405    // Get local oscillator frequency on daughterboard (if available) 
    377     float lo_freq(0.0f); 
     406    //float lo_freq(0.0f) 
    378407    db_base * db(NULL); 
    379408    get_db_reference(channel, db); 
     
    392421    } 
    393422 
    394     f = ddc_freq + lo_freq; 
     423    f = ddc_freq + db_lo_freq; 
    395424} 
    396425