Changeset 8606

Show
Ignore:
Timestamp:
01/28/09 21:48:06 (4 years ago)
Author:
ttsou
Message:

Implementation with GNU Radio C++ USRP API

Location:
ossiedev/branches/ttsou/dist/platform/USRP
Files:
5 added
12 removed
7 modified

Legend:

Unmodified
Added
Removed
  • ossiedev/branches/ttsou/dist/platform/USRP/Makefile.am

    r5861 r8606  
    88    src/USRP.cpp                \ 
    99    src/port_impl.cpp           \ 
    10     src/USRP.h                  \ 
    11     src/db_base.h               \ 
    12     src/db_base.cpp             \ 
    13     src/flex.h                  \ 
    14     src/flex.cpp                \ 
    15     src/basic.h                 \ 
    16     src/basic.cpp               \ 
    17     src/dbsrx.h                 \ 
    18     src/dbsrx.cpp               \ 
    19     src/tvrx.h                  \ 
    20     src/tvrx.cpp                \ 
    21     src/lf.h                    \ 
    22     src/lf.cpp 
     10    src/USRP.h  
    2311 
    2412ossieName = USRP 
  • ossiedev/branches/ttsou/dist/platform/USRP/configure.ac

    r6343 r8606  
    1515 
    1616AC_CHECK_LIB([omniORB4], [main], [], [AC_MSG_ERROR([cannot find omniORBi4 library])]) 
     17AC_CHECK_LIB([omnithread], [main], [], [AC_MSG_ERROR([cannot find omnithread library])]) 
    1718AC_CHECK_LIB([omniDynamic4], [main], [], [AC_MSG_ERROR([cannot find omniDynamic4 library])]) 
    1819AC_CHECK_HEADERS([omniORB4/CORBA.h], [], [AC_MSG_ERROR([cannot find omniORB4 header files])]) 
    1920 
     21AX_BOOST_BASE([1.35]) 
     22CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" 
     23CFLAGS="$CFLAGS $BOOST_CPPFLAGS" 
     24 
    2025AC_CHECK_LIB([usrp], [main], [], [AC_MSG_ERROR([cannot find usrp libraries])]) 
     26AC_CHECK_HEADERS([db_base.h], [], [AC_MSG_ERROR([cannot find db_base header file])]) 
    2127AC_CHECK_HEADERS([usrp_standard.h], [], [AC_MSG_ERROR([cannot find usrp_standard header file])]) 
    22 AC_CHECK_HEADERS([usrp_dbid.h], [], [AC_MSG_ERROR([cannot find usrp_dbid header file])]) 
    23 AC_CHECK_HEADERS([usrp_prims.h], [], [AC_MSG_ERROR([cannot find usrp_prims header file])]) 
    2428 
    2529AC_CHECK_LIB([standardInterfaces], [main], [], [AC_MSG_ERROR([cannot find standardInterfaces])]) 
  • ossiedev/branches/ttsou/dist/platform/USRP/reconf

    r4522 r8606  
    11#!/bin/sh 
    22 
    3 rm -f config.cache 
    4 aclocal 
     3rm -rf config.cache autom4te*.cache 
     4aclocal -I config 
    55autoconf 
    66automake --foreign --add-missing 
  • ossiedev/branches/ttsou/dist/platform/USRP/src/USRP.cpp

    r4522 r8606  
    2222****************************************************************************/ 
    2323 
    24 // Defining LOG_DATA writes the I channel data sent to the USRP to I_out.dat  
    25 //#define LOG_DATA 
    26  
     24#include <byteswap.h> 
    2725#include <iostream> 
    28 #include <string> 
    29 #ifdef LOG_DATA 
    30 #include <fstream> 
    31 #endif 
    32  
    33 #include <byteswap.h> 
    3426 
    3527#include "ossie/cf.h" 
     
    3931#include "ossie/debug.h" 
    4032 
    41  
    4233#include "USRP.h" 
    43 #include "flex.h" 
    44 #include "basic.h" 
    45 #include "lf.h" 
    46 #include "dbsrx.h" 
    47 #include "tvrx.h" 
    4834 
    4935USRP_i::USRP_i(char *id, char *label, char *profile) :  
    5036    Device_impl(id, label, profile), 
    51     rx_db0_control(NULL), 
    52     rx_db1_control(NULL), 
    53     tx_db0_control(NULL), 
    54     tx_db1_control(NULL), 
    5537    set_rx_packet_count(-1), 
    5638    rx_packet_count(1024), 
     
    6042    complex(true), 
    6143    rx_overruns(0), 
    62     rx_active(0), 
    63     tx_active(0) 
    64 { 
    65     // Create device ports 
     44    rx_active(false), 
     45    tx_active(false) 
     46{ 
    6647    // Create USRP Control ports for TX and RX 
    67  
    6848    rx_control_port = new USRP_RX_Control_i(this, "RX_Control", "DomainName1"); 
    69  
    7049    tx_control_port = new USRP_TX_Control_i(this, "TX_Control", "DomainName1"); 
    7150 
    7251    // Create the ports for TX data 
    73  
    7452    tx_data_port = new standardInterfaces_i::complexShort_p("TX_Data", "DomainName1"); 
    7553 
    7654    // Create the ports for RX Data 
    77  
    7855    rx_data_1_port = new standardInterfaces_i::complexShort_u("RX_Data_1", "DomainName1"); 
    7956    rx_data_2_port = new standardInterfaces_i::complexShort_u("RX_Data_2", "DomainName1"); 
    80  
    8157} 
    8258 
    8359void USRP_i::start() throw (CF::Resource::StartError, CORBA::SystemException) 
    84  
    8560{ 
    8661    DEBUG(3, USRP, "Start USRP called") 
    87  
    8862} 
    8963 
    9064void USRP_i::stop() throw (CF::Resource::StopError, CORBA::SystemException) 
    91  
    9265{ 
    9366    DEBUG(3, USRP, "Stop USRP called") 
    94  
    9567} 
    9668 
     
    11789} 
    11890 
    119 void USRP_i::PrintDaughterboardWarning(const char * db_name) { 
    120     std::cout << "The daughterboard is not yet tested: " << db_name << std::endl 
    121               << "Please contact OSSIE team to verify and activate. " << std::endl 
    122               << "  http://ossie-dev.mprg.org:8080/trac" << std::endl; 
    123 } 
    124  
    12591void USRP_i::initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException) 
    126  
    12792{ 
    12893    DEBUG(3, USRP, "USRP Initialize called") 
     
    135100    } 
    136101 
    137     //usrp_tx = usrp_standard_tx::make(0,512, 1, 0xba98, 4096, 16); 
    138102    usrp_tx = usrp_standard_tx::make(0,512); 
    139103 
     
    143107    } 
    144108 
    145  
    146     // Check for RX daughterboards 
    147  
     109    // Check for daughterboards and assign first subdevice 
    148110    rx_db0 = usrp_rx->daughterboard_id(0); 
    149111    rx_db1 = usrp_rx->daughterboard_id(1); 
     112    rx_db0_control = usrp_rx->db(0)[0]; 
     113    rx_db1_control = usrp_rx->db(1)[0]; 
     114 
     115    tx_db0 = usrp_tx->daughterboard_id(0); 
     116    tx_db1 = usrp_tx->daughterboard_id(1); 
     117    tx_db0_control = usrp_tx->db(0)[0]; 
     118    tx_db1_control = usrp_tx->db(1)[0]; 
    150119 
    151120    DEBUG(1, USRP, "RX daughterboard slot 0 : " << usrp_dbid_to_string(rx_db0)) 
    152121    DEBUG(1, USRP, "RX daughterboard slot 1 : " << usrp_dbid_to_string(rx_db1)) 
    153  
    154     switch (rx_db0) { 
    155     case USRP_DBID_FLEX_400_RX: 
    156         rx_db0_control = new db_flex400_rx(usrp_rx, 0); 
    157         break; 
    158     case USRP_DBID_FLEX_400_RX_MIMO_A: 
    159         //rx_db0_control = new db_flex400_rx_mimo_a(usrp_rx, 0); 
    160         PrintDaughterboardWarning("USRP_DBID_FLEX_400_RX_MIMO_A"); 
    161         break; 
    162     case USRP_DBID_FLEX_400_RX_MIMO_B: 
    163         rx_db0_control = new db_flex400_rx_mimo_b(usrp_rx, 0); 
    164         break; 
    165     case USRP_DBID_FLEX_900_RX: 
    166         //rx_db0_control = new db_flex900_rx(usrp_rx, 0); 
    167         PrintDaughterboardWarning("USRP_DBID_FLEX_900_RX"); 
    168         break; 
    169     case USRP_DBID_FLEX_900_RX_MIMO_A: 
    170         //rx_db0_control = new db_flex900_rx_mimo_a(usrp_rx, 0); 
    171         PrintDaughterboardWarning("USRP_DBID_FLEX_900_MIMO_A"); 
    172         break; 
    173     case USRP_DBID_FLEX_900_RX_MIMO_B: 
    174         rx_db0_control = new db_flex900_rx_mimo_b(usrp_rx, 0); 
    175         break; 
    176     case USRP_DBID_FLEX_1200_RX: 
    177         //rx_db0_control = new db_flex1200_rx(usrp_rx, 0); 
    178         PrintDaughterboardWarning("USRP_DBID_FLEX_1200_RX"); 
    179         break; 
    180     case USRP_DBID_FLEX_1200_RX_MIMO_A: 
    181         //rx_db0_control = new db_flex1200_rx_mimo_a(usrp_rx, 0); 
    182         PrintDaughterboardWarning("USRP_DBID_FLEX_1200_RX_MIMO_A"); 
    183         break; 
    184     case USRP_DBID_FLEX_1200_RX_MIMO_B: 
    185         rx_db0_control = new db_flex1200_rx_mimo_b(usrp_rx, 0); 
    186         break; 
    187 /* 
    188     case USRP_DBID_FLEX_1800_RX: 
    189         //rx_db0_control = new db_flex1800_rx(usrp_rx, 0); 
    190         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_RX"); 
    191         break; 
    192     case USRP_DBID_FLEX_1800_RX_MIMO_A: 
    193         //rx_db0_control = new db_flex1800_rx_mimo_a(usrp_rx, 0); 
    194         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_RX_MIMO_A"); 
    195         break; 
    196     case USRP_DBID_FLEX_1800_RX_MIMO_B: 
    197         //rx_db0_control = new db_flex1800_rx_mimo_b(usrp_rx, 0); 
    198         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_RX_MIMO_B"); 
    199         break; 
    200 */ 
    201     case USRP_DBID_FLEX_2400_RX: 
    202         rx_db0_control = new db_flex2400_rx(usrp_rx, 0); 
    203         break; 
    204     case USRP_DBID_FLEX_2400_RX_MIMO_A: 
    205         //rx_db0_control = new db_flex2400_rx_mimo_a(usrp_rx, 0); 
    206         PrintDaughterboardWarning("USRP_DBID_FLEX_2400_RX_MIMO_A"); 
    207         break; 
    208     case USRP_DBID_FLEX_2400_RX_MIMO_B: 
    209         //rx_db0_control = new db_flex2400_rx_mimo_b(usrp_rx, 0); 
    210         PrintDaughterboardWarning("USRP_DBID_FLEX_2400_RX_MIMO_B"); 
    211         break; 
    212     case USRP_DBID_BASIC_RX: 
    213         rx_db0_control = new db_basic_rx(usrp_rx, 0); 
    214         break; 
    215     case USRP_DBID_DBS_RX: 
    216         rx_db0_control = new dbsrx(usrp_rx, 0); 
    217         break; 
    218     case USRP_DBID_DBS_RX_REV_2_1: 
    219         //rx_db0_control = new dbsrx(usrp_rx, 0); 
    220         PrintDaughterboardWarning("USRP_DBID_DBS_RX_REV_2_1"); 
    221         break; 
    222     case USRP_DBID_TV_RX: 
    223         //rx_db0_control = new tvrx(usrp_rx, 0); 
    224         PrintDaughterboardWarning("USRP_DBID_TV_RX"); 
    225         break; 
    226     case USRP_DBID_TV_RX_REV_2: 
    227         //rx_db0_control = new tvrx_rev2(usrp_rx, 0); 
    228         PrintDaughterboardWarning("USRP_DBID_TV_RX_REV_2"); 
    229         break; 
    230 /* 
    231     case USRP_DBID_TV_RX_REV_3: 
    232         //rx_db0_control = new tvrx_rev3(usrp_rx, 0); 
    233         PrintDaughterboardWarning("USRP_DBID_TV_RX_REV_3"); 
    234         break;  
    235 */ 
    236     case USRP_DBID_LF_RX: 
    237         rx_db0_control = new db_lf_rx(usrp_rx, 0); 
    238         break; 
    239     } 
    240  
    241     switch (rx_db1) { 
    242     case USRP_DBID_FLEX_400_RX: 
    243         rx_db1_control = new db_flex400_rx(usrp_rx, 1); 
    244         break; 
    245     case USRP_DBID_FLEX_400_RX_MIMO_A: 
    246         //rx_db1_control = new db_flex400_rx_mimo_a(usrp_rx, 1); 
    247         PrintDaughterboardWarning("USRP_DBID_FLEX_400_MIMO_A"); 
    248         break; 
    249     case USRP_DBID_FLEX_400_RX_MIMO_B: 
    250         rx_db1_control = new db_flex400_rx_mimo_b(usrp_rx, 1); 
    251         break; 
    252     case USRP_DBID_FLEX_900_RX: 
    253         //rx_db1_control = new db_flex900_rx(usrp_rx, 1); 
    254         PrintDaughterboardWarning("USRP_DBID_FLEX_900_RX"); 
    255         break; 
    256     case USRP_DBID_FLEX_900_RX_MIMO_A: 
    257         //rx_db1_control = new db_flex900_rx_mimo_a(usrp_rx, 1); 
    258         PrintDaughterboardWarning("USRP_DBID_FLEX_900_RX_MIMO_A"); 
    259         break; 
    260     case USRP_DBID_FLEX_900_RX_MIMO_B: 
    261         rx_db1_control = new db_flex900_rx_mimo_b(usrp_rx, 1); 
    262         break; 
    263     case USRP_DBID_FLEX_1200_RX: 
    264         //rx_db1_control = new db_flex1200_rx(usrp_rx, 1); 
    265         PrintDaughterboardWarning("USRP_DBID_FLEX_1200_RX"); 
    266         break; 
    267     case USRP_DBID_FLEX_1200_RX_MIMO_A: 
    268         //rx_db1_control = new db_flex1200_rx_mimo_a(usrp_rx, 1); 
    269         PrintDaughterboardWarning("USRP_DBID_FLEX_1200_RX_MIMO_A"); 
    270         break; 
    271     case USRP_DBID_FLEX_1200_RX_MIMO_B: 
    272         rx_db1_control = new db_flex1200_rx_mimo_b(usrp_rx, 1); 
    273         break; 
    274 /* 
    275     case USRP_DBID_FLEX_1800_RX: 
    276         //rx_db1_control = new db_flex1800_rx(usrp_rx, 1); 
    277         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_RX"); 
    278         break; 
    279     case USRP_DBID_FLEX_1800_RX_MIMO_A: 
    280         //rx_db1_control = new db_flex1800_rx_mimo_a(usrp_rx, 1); 
    281         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_RX_MIMO_A"); 
    282         break; 
    283     case USRP_DBID_FLEX_1800_RX_MIMO_B: 
    284         //rx_db1_control = new db_flex1800_rx_mimo_b(usrp_rx, 1); 
    285         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_RX_MIMO_B"); 
    286         break; 
    287 */ 
    288     case USRP_DBID_FLEX_2400_RX: 
    289         rx_db1_control = new db_flex2400_rx(usrp_rx, 1); 
    290         break; 
    291     case USRP_DBID_FLEX_2400_RX_MIMO_A: 
    292         //rx_db1_control = new db_flex2400_rx_mimo_a(usrp_rx, 1); 
    293         PrintDaughterboardWarning("USRP_DBID_FLEX_2400_RX_MIMO_A"); 
    294         break; 
    295     case USRP_DBID_FLEX_2400_RX_MIMO_B: 
    296         //rx_db1_control = new db_flex2400_rx_mimo_b(usrp_rx, 1); 
    297         PrintDaughterboardWarning("USRP_DBID_FLEX_2400_RX_MIMO_B"); 
    298         break; 
    299     case USRP_DBID_BASIC_RX: 
    300         rx_db1_control = new db_basic_rx(usrp_rx, 1); 
    301         break; 
    302     case USRP_DBID_DBS_RX: 
    303         rx_db1_control = new dbsrx(usrp_rx, 1); 
    304         break; 
    305     case USRP_DBID_DBS_RX_REV_2_1: 
    306         //rx_db1_control = new dbsrx(usrp_rx, 1); 
    307         PrintDaughterboardWarning("USRP_DBID_DBS_RX_REV_2_1"); 
    308         break; 
    309     case USRP_DBID_TV_RX: 
    310         //rx_db1_control = new tvrx(usrp_rx, 1); 
    311         PrintDaughterboardWarning("USRP_DBID_TV_RX"); 
    312         break; 
    313     case USRP_DBID_TV_RX_REV_2: 
    314         //rx_db1_control = new tvrx_rev2(usrp_rx, 1); 
    315         PrintDaughterboardWarning("USRP_DBID_TV_RX_REV_2"); 
    316         break; 
    317 /* 
    318     case USRP_DBID_TV_RX_REV_3: 
    319         //rx_db1_control = new tvrx_rev3(usrp_rx, 1); 
    320         std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org:8080/trac" << std::endl; 
    321         break; 
    322 */ 
    323     case USRP_DBID_LF_RX: 
    324         rx_db1_control = new db_lf_rx(usrp_rx, 1); 
    325         break; 
    326  
    327     } 
    328  
    329     // Check for TX daughterboards 
    330  
    331     tx_db0 = usrp_tx->daughterboard_id(0); 
    332     tx_db1 = usrp_tx->daughterboard_id(1); 
    333  
    334     switch (tx_db0) { 
    335     case USRP_DBID_FLEX_400_TX: 
    336         tx_db0_control = new db_flex400_tx(usrp_tx, 0); 
    337         break; 
    338     case USRP_DBID_FLEX_400_TX_MIMO_A: 
    339         //tx_db0_control = new db_flex400_tx_mimo_a(usrp_tx, 0); 
    340         PrintDaughterboardWarning("USRP_DBID_FLEX_400_TX_MIMO_A"); 
    341         break; 
    342     case USRP_DBID_FLEX_400_TX_MIMO_B: 
    343         tx_db0_control = new db_flex400_tx_mimo_b(usrp_tx, 0); 
    344         break; 
    345     case USRP_DBID_FLEX_900_TX: 
    346         //tx_db0_control = new db_flex900_tx(usrp_tx, 0); 
    347         PrintDaughterboardWarning("USRP_DBID_FLEX_900_TX"); 
    348         break; 
    349     case USRP_DBID_FLEX_900_TX_MIMO_A: 
    350         //tx_db0_control = new db_flex900_tx_mimo_a(usrp_tx, 0); 
    351         PrintDaughterboardWarning("USRP_DBID_FLEX_900_TX_MIMO_A"); 
    352         break; 
    353     case USRP_DBID_FLEX_900_TX_MIMO_B: 
    354         tx_db0_control = new db_flex900_tx_mimo_b(usrp_tx, 0); 
    355         break; 
    356     case USRP_DBID_FLEX_1200_TX: 
    357         //tx_db0_control = new db_flex1200_tx(usrp_tx, 0); 
    358         PrintDaughterboardWarning("USRP_DBID_FLEX_1200_TX"); 
    359         break; 
    360     case USRP_DBID_FLEX_1200_TX_MIMO_A: 
    361         //tx_db0_control = new db_flex1200_tx_mimo_a(usrp_tx, 0); 
    362         PrintDaughterboardWarning("USRP_DBID_FLEX_1200_TX_MIMO_A"); 
    363         break; 
    364     case USRP_DBID_FLEX_1200_TX_MIMO_B: 
    365         tx_db0_control = new db_flex1200_tx_mimo_b(usrp_tx, 0); 
    366         break; 
    367 /* 
    368     case USRP_DBID_FLEX_1800_TX: 
    369         //tx_db0_control = new db_flex1800_tx(usrp_tx, 0); 
    370         PrintDaughterboardWarning("USRP_DBID_FLEX_1800"); 
    371         break; 
    372     case USRP_DBID_FLEX_1800_TX_MIMO_A: 
    373         //tx_db0_control = new db_flex1800_tx_mimo_a(usrp_tx, 0); 
    374         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_TX_MIMO_A"); 
    375         break; 
    376     case USRP_DBID_FLEX_1800_TX_MIMO_B: 
    377         //tx_db0_control = new db_flex1800_tx_mimo_b(usrp_tx, 0); 
    378         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_TX_MIMO_B"); 
    379         break; 
    380 */ 
    381     case USRP_DBID_FLEX_2400_TX: 
    382         tx_db0_control = new db_flex2400_tx(usrp_tx, 0); 
    383         break; 
    384     case USRP_DBID_FLEX_2400_TX_MIMO_A: 
    385         //tx_db0_control = new db_flex2400_tx_mimo_a(usrp_tx, 0); 
    386         PrintDaughterboardWarning("USRP_DBID_FLEX_2400_TX_MIMO_A"); 
    387         break; 
    388     case USRP_DBID_FLEX_2400_TX_MIMO_B: 
    389         //tx_db0_control = new db_flex2400_tx_mimo_b(usrp_tx, 0); 
    390         PrintDaughterboardWarning("USRP_DBID_FLEX_2400_TX_MIMO_B"); 
    391         break; 
    392     case USRP_DBID_BASIC_TX: 
    393         tx_db0_control = new db_basic_tx(usrp_tx, 0); 
    394         break; 
    395     case USRP_DBID_LF_TX: 
    396         tx_db0_control = new db_lf_tx(usrp_tx, 0); 
    397         break; 
    398  
    399  
    400     } 
    401  
    402     switch (tx_db1) { 
    403     case USRP_DBID_FLEX_400_TX: 
    404         tx_db1_control = new db_flex400_tx(usrp_tx, 1); 
    405         break; 
    406     case USRP_DBID_FLEX_400_TX_MIMO_A: 
    407         //tx_db1_control = new db_flex400_tx_mimo_a(usrp_tx, 1); 
    408         PrintDaughterboardWarning("USRP_DBID_FLEX_400_TX_MIMO_A"); 
    409         break; 
    410     case USRP_DBID_FLEX_400_TX_MIMO_B: 
    411         tx_db1_control = new db_flex400_tx_mimo_b(usrp_tx, 1); 
    412         break; 
    413     case USRP_DBID_FLEX_900_TX: 
    414         //tx_db1_control = new db_flex900_tx(usrp_tx, 1); 
    415         PrintDaughterboardWarning("USRP_DBID_FLEX_900_TX"); 
    416         break; 
    417     case USRP_DBID_FLEX_900_TX_MIMO_A: 
    418         //tx_db1_control = new db_flex900_tx_mimo_a(usrp_tx, 1); 
    419         PrintDaughterboardWarning("USRP_DBID_FLEX_900_TX_MIMO_A"); 
    420         break; 
    421     case USRP_DBID_FLEX_900_TX_MIMO_B: 
    422         tx_db1_control = new db_flex900_tx_mimo_b(usrp_tx, 1); 
    423         break; 
    424     case USRP_DBID_FLEX_1200_TX: 
    425         //tx_db1_control = new db_flex1200_tx(usrp_tx, 1); 
    426         PrintDaughterboardWarning("USRP_DBID_FLEX_1200_TX"); 
    427         break; 
    428     case USRP_DBID_FLEX_1200_TX_MIMO_A: 
    429         //tx_db1_control = new db_flex1200_tx_mimo_a(usrp_tx, 1); 
    430         PrintDaughterboardWarning("USRP_DBID_FLEX_1200_TX_MIMO_A"); 
    431         break; 
    432     case USRP_DBID_FLEX_1200_TX_MIMO_B: 
    433         tx_db1_control = new db_flex1200_tx_mimo_b(usrp_tx, 1); 
    434         break; 
    435 /* 
    436     case USRP_DBID_FLEX_1800_TX: 
    437         //tx_db1_control = new db_flex1800_tx(usrp_tx, 1); 
    438         PrintDaughterboardWarning("USRP_DBID_FLEX_1800"); 
    439         break; 
    440     case USRP_DBID_FLEX_1800_TX_MIMO_A: 
    441         //tx_db1_control = new db_flex1800_tx_mimo_a(usrp_tx, 1); 
    442         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_TX_MIMO_A"); 
    443         break; 
    444     case USRP_DBID_FLEX_1800_TX_MIMO_B: 
    445         //tx_db1_control = new db_flex1800_tx_mimo_b(usrp_tx, 1); 
    446         PrintDaughterboardWarning("USRP_DBID_FLEX_1800_TX_MIMO_B"); 
    447         break; 
    448 */ 
    449     case USRP_DBID_FLEX_2400_TX: 
    450         tx_db1_control = new db_flex2400_tx(usrp_tx, 1); 
    451         break; 
    452     case USRP_DBID_FLEX_2400_TX_MIMO_A: 
    453         //tx_db1_control = new db_flex2400_tx_mimo_a(usrp_tx, 1); 
    454         PrintDaughterboardWarning("USRP_DBID_FLEX_2400_TX_MIMO_A"); 
    455         break; 
    456     case USRP_DBID_FLEX_2400_TX_MIMO_B: 
    457         //tx_db1_control = new db_flex2400_tx_mimo_b(usrp_tx, 1); 
    458         PrintDaughterboardWarning("USRP_DBID_FLEX_2400_TX_MIMO_B"); 
    459         break; 
    460     case USRP_DBID_BASIC_TX: 
    461         tx_db1_control = new db_basic_tx(usrp_tx, 1); 
    462         break; 
    463     case USRP_DBID_LF_TX: 
    464         tx_db1_control = new db_lf_tx(usrp_tx, 1); 
    465         break; 
    466  
    467     } 
    468  
    469  
    470122    DEBUG(1, USRP, "TX daughterboard slot 0 : " << usrp_dbid_to_string(tx_db0)) 
    471123    DEBUG(1, USRP, "TX daughterboard slot 1 : " << usrp_dbid_to_string(tx_db1)) 
     
    473125} 
    474126 
    475  
    476127void USRP_i::configure(const CF::Properties &configProperties) 
    477     throw (CORBA::SystemException, 
    478            CF::PropertySet::InvalidConfiguration, 
     128    throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, 
    479129           CF::PropertySet::PartialConfiguration) 
    480130{ 
     
    482132} 
    483133 
    484 void USRP_i::query(CF::Properties &configProperties) throw (CORBA::SystemException, CF::UnknownProperties) 
    485 { 
    486  
    487 } 
    488  
    489  
    490 void USRP_i::releaseObject() throw (CF::LifeCycle::ReleaseError, CORBA::SystemException) 
    491  
     134void USRP_i::query(CF::Properties &configProperties) 
     135    throw (CORBA::SystemException, CF::UnknownProperties) 
     136{ 
     137 
     138} 
     139 
     140 
     141void USRP_i::releaseObject() 
     142    throw (CF::LifeCycle::ReleaseError, CORBA::SystemException) 
    492143{ 
    493144 
     
    496147 
    497148void USRP_i::rx_data_process() 
    498  
    499149{ 
    500150    short *rx_buffer; 
     
    534184        if (rx_packet_count != -1) 
    535185            --rx_packet_count; 
    536  
    537186    } 
    538187 
     
    547196// Helper function for tx_data_process 
    548197inline static void tx_with_usrp( 
    549     usrp_standard_tx *usrp_tx, 
     198    usrp_standard_tx_sptr usrp_tx, 
    550199    short *tx_buf, 
    551200    unsigned int tx_buf_len, 
     
    588237    short tx_buf[tx_buf_len]; 
    589238 
    590 #ifdef LOG_DATA 
    591     std::ofstream *ofile = new std::ofstream("I_out.dat"); 
    592 #endif 
    593  
    594239    DEBUG(3, USRP, "Starting tx_data_process thread.") 
    595240 
     
    599244 
    600245        tx_data_port->getData(I_in, Q_in); 
    601  
    602246        unsigned int data_length(I_in->length()); 
    603247 
     
    605249            tx_buf[tx_buf_idx] = convertToLE((*I_in)[i]); 
    606250            ++tx_buf_idx; 
    607 #ifdef LOG_DATA 
    608             *ofile << (*I_in)[i] << std::endl; 
    609 #endif 
    610251            tx_buf[tx_buf_idx] = convertToLE((*Q_in)[i]); 
    611252            ++tx_buf_idx; 
     
    616257            }             
    617258        } 
    618  
    619259        tx_data_port->bufferEmptied(); 
    620260    } 
    621 #ifdef LOG_DATA 
    622     delete ofile; 
    623 #endif 
    624261 
    625262    DEBUG(3, USRP, "Exiting tx_data_process thread.") 
    626263    usrp_tx->stop(); 
    627264    tx_thread->exit(); 
    628 } 
     265 
     266} 
  • ossiedev/branches/ttsou/dist/platform/USRP/src/USRP.h

    r5860 r8606  
    3939#include "ossie/Device_impl.h" 
    4040 
    41 #include "flex.h" 
    42 #include "dbsrx.h" 
    43 #include "tvrx.h" 
    44  
    4541// Definitions for provides ports 
    4642class USRP_i; 
    4743 
    48 class USRP_RX_Control_i : public standardInterfaces_i::RX_Control_p 
    49  
    50 { 
    51  
     44class USRP_RX_Control_i : public standardInterfaces_i::RX_Control_p, 
     45                          boost::noncopyable 
     46{ 
    5247  public: 
    5348    USRP_RX_Control_i(USRP_i *_usrp, const char* _name, const char* _domain); 
     49 
    5450    void set_number_of_channels(CORBA::ULong num); 
    5551    void get_number_of_channels(CORBA::ULong &num); 
    56  
    57     void get_gain_range(CORBA::ULong channel, CORBA::Float &gmin, CORBA::Float &gmax, CORBA::Float &gstep); 
     52    void get_gain_range(CORBA::ULong channel, CORBA::Float &gmin, 
     53                        CORBA::Float &gmax, CORBA::Float &gstep); 
    5854    void set_gain(CORBA::ULong channel, CORBA::Float gain); 
    5955    void get_gain(CORBA::ULong channel, CORBA::Float &gain); 
    60  
    61     void get_frequency_range(CORBA::ULong channel, CORBA::Float &fmin, CORBA::Float &fmax, CORBA::Float &fstep); 
     56    void get_frequency_range(CORBA::ULong channel, CORBA::Float &fmin, 
     57                            CORBA::Float &fmax, CORBA::Float &fstep); 
    6258    void set_frequency(CORBA::ULong channel, CORBA::Float f); 
    6359    void get_frequency(CORBA::ULong channel, CORBA::Float &f); 
     
    6763 
    6864    void set_values(const CF::Properties &values); 
    69  
    7065    void set_decimation_rate(CORBA::ULong channel, CORBA::ULong M); 
    71     void get_decimation_range(CORBA::ULong channel, CORBA::ULong &dmin, CORBA::ULong &dmax, CORBA::ULong &dstep); 
    72  
     66    void get_decimation_range(CORBA::ULong channel, CORBA::ULong &dmin, 
     67                              CORBA::ULong &dmax, CORBA::ULong &dstep); 
    7368    void set_data_packet_size(CORBA::ULong channel, CORBA::ULong N); 
    7469 
    7570 private: 
    7671    USRP_RX_Control_i();  // No default constructor 
    77     USRP_RX_Control_i(const USRP_RX_Control_i &); // No copying 
    78   
    7972    USRP_i *usrp; 
    80  
    81     float db_lo_freq; 
    82     float db_lo_offset; 
    83     bool lo_locked; 
    84  
    85 }; 
    86  
    87 class USRP_TX_Control_i : public standardInterfaces_i::TX_Control_p 
    88  
     73}; 
     74 
     75class USRP_TX_Control_i : public standardInterfaces_i::TX_Control_p, 
     76                          boost::noncopyable 
    8977{ 
    9078  public: 
    9179    USRP_TX_Control_i(USRP_i *_usrp, const char* _name, const char* _domain); 
     80 
    9281    void set_number_of_channels(CORBA::ULong num); 
    9382    void get_number_of_channels(CORBA::ULong &num); 
    94  
    95     void get_gain_range(CORBA::ULong channel, CORBA::Float &gmin, CORBA::Float &gmax, CORBA::Float &gstep); 
     83    void get_gain_range(CORBA::ULong channel, CORBA::Float &gmin, 
     84                        CORBA::Float &gmax, CORBA::Float &gstep); 
    9685    void set_gain(CORBA::ULong channel, CORBA::Float gain); 
    9786    void get_gain(CORBA::ULong channel, CORBA::Float &gain); 
    98  
    99     void get_frequency_range(CORBA::ULong channel, CORBA::Float &fmin, CORBA::Float &fmax, CORBA::Float &fstep); 
     87    void get_frequency_range(CORBA::ULong channel, CORBA::Float &fmin, 
     88                            CORBA::Float &fmax, CORBA::Float &fstep); 
    10089    void set_frequency(CORBA::ULong channel, CORBA::Float f); 
    10190    void get_frequency(CORBA::ULong channel, CORBA::Float &f); 
     
    10594 
    10695    void set_values(const CF::Properties &values); 
    107  
    10896    void set_interpolation_rate(CORBA::ULong channel, CORBA::ULong I); 
    109     void get_interpolation_range(CORBA::ULong channel, CORBA::ULong &imin, CORBA::ULong &imax, CORBA::ULong &istep); 
     97    void get_interpolation_range(CORBA::ULong channel, CORBA::ULong &imin, 
     98                                 CORBA::ULong &imax, CORBA::ULong &istep); 
    11099 
    111100 private: 
    112101    USRP_TX_Control_i();  // No default constructor 
    113     USRP_TX_Control_i(const USRP_TX_Control_i &); // No copying 
    114  
    115102    USRP_i *usrp; 
    116  
    117     float db_lo_freq; 
    118     float db_lo_offset; 
    119     bool lo_locked; 
    120103}; 
    121104 
    122105class TX_data_i : public POA_standardInterfaces::complexShort 
    123  
    124106{ 
    125107  public: 
     
    127109    ~TX_data_i(); 
    128110 
    129     void pushPacket(const PortTypes::ShortSequence &I, const PortTypes::ShortSequence &Q); 
     111    void pushPacket(const PortTypes::ShortSequence &I, 
     112                    const PortTypes::ShortSequence &Q); 
    130113 
    131114 private: 
     
    135118    unsigned int tx_buf_idx; 
    136119    int tx_buf_len; 
    137  
    138120    unsigned int tx_underruns; 
    139121}; 
    140122 
    141 // Definitions for uses ports 
    142  
    143 // Main USRP device definition 
    144 void rx_data_process(void *data); 
    145  
    146 class USRP_i : public virtual Device_impl 
    147  
     123class USRP_i : public virtual Device_impl, boost::noncopyable 
    148124{ 
    149125    friend class USRP_RX_Control_i; 
    150126    friend class USRP_TX_Control_i; 
    151127 
    152     friend void rx_data_process(void *); 
    153  
    154128  public: 
    155129    USRP_i(char *id, char *label, char *profile); 
    156130 
    157     static void do_rx_data_process(void *u) {((USRP_i *)u)->rx_data_process(); }; 
    158     static void do_tx_data_process(void *u) {((USRP_i *)u)->tx_data_process(); }; 
     131    static void do_rx_data_process(void *u) {((USRP_i *)u)->rx_data_process();}; 
     132    static void do_tx_data_process(void *u) {((USRP_i *)u)->tx_data_process();}; 
    159133 
    160134    // Methods from the SCA definition 
    161     void start() throw (CF::Resource::StartError, CORBA::SystemException); 
    162     void stop() throw (CF::Resource::StopError, CORBA::SystemException); 
    163     CORBA::Object_ptr getPort(const char* portName) throw(CF::PortSupplier::UnknownPort, CORBA::SystemException); 
    164     void initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException); 
    165     void configure(const CF::Properties &configProperties) throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, CF::PropertySet::PartialConfiguration); 
    166     void query(CF::Properties &configProperties) throw (CORBA::SystemException, CF::UnknownProperties); 
    167  
    168     void releaseObject() throw (CF::LifeCycle::ReleaseError, CORBA::SystemException); 
     135    void start() 
     136        throw (CF::Resource::StartError, CORBA::SystemException); 
     137    void stop() 
     138        throw (CF::Resource::StopError, CORBA::SystemException); 
     139    CORBA::Object_ptr getPort(const char* portName) 
     140        throw(CF::PortSupplier::UnknownPort, CORBA::SystemException); 
     141    void initialize() 
     142        throw (CF::LifeCycle::InitializeError, CORBA::SystemException); 
     143    void configure(const CF::Properties &configProperties) 
     144        throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, 
     145               CF::PropertySet::PartialConfiguration); 
     146    void query(CF::Properties &configProperties) 
     147        throw (CORBA::SystemException, CF::UnknownProperties); 
     148    void releaseObject() 
     149        throw (CF::LifeCycle::ReleaseError, CORBA::SystemException); 
    169150 
    170151    omni_mutex rx_run; 
     
    174155    omni_mutex tx_control_access; 
    175156 
    176  
    177157 private: 
    178158    USRP_i();  // No default constructor 
    179     USRP_i(const USRP_i&);  // No copying 
    180  
    181     // RX data processing thread 
    182     //    static void rx_data_process(void * data); ///\todo verify statis is the online way 
    183  
    184     /// Prints warning about unsupported USRP daughter boards 
    185     void PrintDaughterboardWarning(const char * db_name); 
    186159 
    187160    // Port objects 
     
    195168 
    196169    // usrp variables 
    197  
    198     usrp_standard_rx *usrp_rx; 
    199     usrp_standard_tx *usrp_tx; 
     170    usrp_standard_rx_sptr usrp_rx; 
     171    usrp_standard_tx_sptr usrp_tx; 
    200172 
    201173    // Daughterboard data 
     174    //  
     175    // A vector of subdevices is associated for each daughterboard with libusrp. 
     176    // Only a single subdevice (the first) is supported at this time. 
    202177    int rx_db0; 
    203178    int rx_db1; 
     
    205180    int tx_db1; 
    206181 
    207     db_base *rx_db0_control; 
    208     db_base *rx_db1_control; 
    209     db_base *tx_db0_control; 
    210     db_base *tx_db1_control; 
     182    db_base_sptr rx_db0_control; 
     183    db_base_sptr rx_db1_control; 
     184    db_base_sptr tx_db0_control; 
     185    db_base_sptr tx_db1_control; 
    211186 
    212187    omni_thread *rx_thread; 
     
    226201    bool rx_active; 
    227202    bool tx_active; 
    228  
    229 }; 
     203}; 
  • ossiedev/branches/ttsou/dist/platform/USRP/src/main.cpp

    r8105 r8606  
    2323 
    2424#include <iostream> 
    25 #include <cstdlib> 
    2625#include <sched.h> 
    2726 
     
    3130#include "USRP.h" 
    3231 
    33  
    3432int main(int argc, char* argv[]) 
    35  
    3633{ 
    37  
    3834    if (argc != 4) { 
    39         std::cerr << argv[0] << " <identifier> <usage name> <software profile>" << std::endl; 
     35        std::cerr << argv[0] << " <identifier>" 
     36                             << " <usage name>" 
     37                             << " <software profile>" << std::endl; 
    4038        exit (-1); 
    4139    } 
    42  
    43     ossieDebugLevel = 3; 
    44  
    45     struct sched_param prio; 
    46  
    47     prio.sched_priority = 5; 
    48  
    49     int rc = sched_setscheduler(0, SCHED_RR, &prio); 
    50  
    51     if (rc < 0) 
    52         std::cerr << "Failed to set RR scheduler for USRP device." << std::endl; 
    53  
    54     ossieSupport::ORB *orb = new ossieSupport::ORB; 
    5540 
    5641    char *id = argv[1]; 
     
    5843    char *profile = argv[3];  
    5944 
     45    ossieDebugLevel = 3; 
    6046 
     47    ossieSupport::ORB *orb = new ossieSupport::ORB; 
    6148    USRP_i* usrp_servant; 
    6249    CF::Device_var usrp_var; 
    6350 
    6451    // Create the USRP device servant and object reference 
    65  
    6652    usrp_servant = new USRP_i(id, label, profile); 
    6753    usrp_var = usrp_servant->_this(); 
     
    7157    orb->bind_object_to_name((CORBA::Object_ptr) usrp_var, objName.c_str()); 
    7258 
    73  
    7459    // Start the orb 
    7560    orb->orb->run(); 
    76  
    7761} 
  • ossiedev/branches/ttsou/dist/platform/USRP/src/port_impl.cpp

    r8274 r8606  
    2323 
    2424#include <iostream> 
    25  
    2625#include <omniORB4/CORBA.h> 
    27  
    2826#include "ossie/debug.h" 
    29  
    3027#include "USRP.h" 
    31 #include "flex.h" 
    32  
    33 USRP_TX_Control_i::USRP_TX_Control_i(USRP_i *_usrp, const char* _name, const char* _domain) : standardInterfaces_i::TX_Control_p(_name, _domain), usrp(_usrp), db_lo_freq(0), db_lo_offset(-8e6), lo_locked(false) 
     28 
     29USRP_TX_Control_i::USRP_TX_Control_i(USRP_i *_usrp, const char* _name, const char* _domain) : standardInterfaces_i::TX_Control_p(_name, _domain), usrp(_usrp)  
    3430{ 
    3531    DEBUG(3, USRP, "TX Control port constructor called") 
     
    4541void USRP_TX_Control_i::get_number_of_channels(CORBA::ULong &num) 
    4642{ 
    47     omni_mutex_lock l(usrp->tx_control_access); 
    4843    num = usrp->usrp_tx->nchannels(); 
    4944} 
     
    5146void USRP_TX_Control_i::get_gain_range(CORBA::ULong channel, CORBA::Float &gmin, CORBA::Float &gmax, CORBA::Float &gstep) 
    5247{ 
    53     omni_mutex_lock l(usrp->tx_control_access); 
    54     if (channel == 0) { 
    55         if (usrp->tx_db0_control) 
    56             usrp->tx_db0_control->get_gain_range(gmin, gmax, gstep); 
    57     } else if (channel == 1) { 
    58         if (usrp->tx_db1_control) 
    59             usrp->tx_db1_control->get_gain_range(gmin, gmax, gstep); 
     48    if (channel == 0) { 
     49        if (usrp->tx_db0_control) { 
     50            gmin = usrp->tx_db0_control->gain_min(); 
     51            gmax = usrp->tx_db0_control->gain_max(); 
     52            gstep = usrp->tx_db0_control->gain_db_per_step(); 
     53        } 
     54    } else if (channel == 1) { 
     55        if (usrp->tx_db1_control) { 
     56            gmin = usrp->tx_db1_control->gain_min(); 
     57            gmax = usrp->tx_db1_control->gain_max(); 
     58            gstep = usrp->tx_db1_control->gain_db_per_step(); 
     59        } 
    6060    } else { 
    6161        return; ///\todo throw bad channel exception 
     
    6767    omni_mutex_lock l(usrp->tx_control_access); 
    6868    if (channel == 0) { 
    69         if (usrp->tx_db0_control) 
     69        if (usrp->tx_db0_control) { 
    7070            usrp->tx_db0_control->set_gain(gain); 
     71        } 
    7172    } else if (channel == 1) { 
    7273        if (usrp->tx_db1_control) 
     
    7980void USRP_TX_Control_i::get_gain(CORBA::ULong channel, CORBA::Float &gain) 
    8081{ 
    81         gain = usrp->usrp_tx->pga(channel); 
     82    gain = usrp->usrp_tx->pga(channel); 
    8283} 
    8384 
    8485void USRP_TX_Control_i::get_frequency_range(CORBA::ULong channel, CORBA::Float &fmin, CORBA::Float &fmax, CORBA::Float &fstep) 
    8586{ 
    86     omni_mutex_lock l(usrp->tx_control_access); 
    87     if (channel == 0) { 
    88         if (usrp->tx_db0_control) 
    89             usrp->tx_db0_control->get_freq_range(fmin, fmax, fstep); 
    90     } else if (channel == 1) { 
    91         if (usrp->tx_db1_control) 
    92             usrp->tx_db1_control->get_freq_range(fmin, fmax, fstep); 
     87    if (channel == 0) { 
     88        if (usrp->tx_db0_control) { 
     89            fmin = usrp->tx_db0_control->freq_min(); 
     90            fmax = usrp->tx_db0_control->freq_max(); 
     91            fstep = 0;  
     92        } 
     93    } else if (channel == 1) { 
     94        if (usrp->tx_db1_control) { 
     95            fmin = usrp->tx_db1_control->freq_min(); 
     96            fmax = usrp->tx_db1_control->freq_max(); 
     97            fstep = 0;  
     98        } 
    9399    } else { 
    94100        return; ///\todo throw bad channel exception 
     
    98104void USRP_TX_Control_i::set_frequency(CORBA::ULong channel, CORBA::Float f) 
    99105{ 
    100     /// \todo move this into db code to avoid the test for db have lo (maybe) 
    101  
    102     class db_base *db(NULL); 
    103  
    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     } 
    114  
    115     if (!db) 
    116         return;  // No daughter board present 
    117  
    118     if (db->db_has_lo()) { 
    119         float fmin, fmax, fstep; 
    120         db->get_freq_range(fmin, fmax, fstep); 
    121         if ((f < fmin) || (f > fmax)) 
    122             return;  /// \todo throw exception 
    123          
    124         if (!lo_locked) { 
    125             float db_lo_freq_set = f + db_lo_offset; 
    126             if (db_lo_freq_set < fmin) 
    127                 db_lo_freq_set = fmin; 
    128             else if (db_lo_freq_set > fmax) 
    129                 db_lo_freq_set = fmax; 
    130              
    131             db->set_db_freq(db_lo_freq_set, db_lo_freq); 
    132         } 
    133     } else 
    134         db_lo_freq = 0.0; 
    135  
    136     float ddc_freq = f - db_lo_freq; 
    137     if ((ddc_freq < 0.0) || (ddc_freq > 32e6)) 
    138         return; ///\todo throw an exception 
    139      
    140     usrp->usrp_tx->set_tx_freq(channel, ddc_freq); 
     106    DEBUG(3, USRP, "In TX Control set frequency channel: " << channel << ", frequency: " << f); 
     107 
     108    db_base_sptr db; 
     109    usrp_tune_result result; 
     110 
     111    omni_mutex_lock l(usrp->tx_control_access); 
     112 
     113    if (channel == 0) { 
     114        db = usrp->tx_db0_control; 
     115    } else if (channel == 1) { 
     116        db = usrp->tx_db1_control; 
     117    } else { 
     118        DEBUG(3, USRP, "USRP TX set_frequency (invalid channel)"); 
     119        return;  
     120    } 
     121 
     122    if (!usrp->usrp_tx->tune(channel, db, f, &result)) { 
     123        DEBUG(3, USRP, "USRP TX set_frequency tune failed"); 
     124        return; // throw exception 
     125    } 
     126 
     127    DEBUG(3, USRP, "USRP TX tune_result:" << 
     128                   " baseband_freq="      << result.baseband_freq << 
     129                   " dxc_freq="           << result.dxc_freq      << 
     130                   " residual_freq="      << result.residual_freq << 
     131                   " inverted="           << result.inverted); 
    141132 
    142133} 
     
    149140void USRP_TX_Control_i::start(CORBA::ULong channel) 
    150141{ 
    151  
    152142    omni_mutex_lock l(usrp->tx_control_access); 
    153143    if (channel == 0) { 
     
    166156    usrp->tx_thread = new omni_thread(USRP_i::do_tx_data_process, ((void *)usrp)); 
    167157    usrp->tx_thread->start(); 
    168  
    169158} 
    170159 
    171160void USRP_TX_Control_i::stop(CORBA::ULong channel) 
    172161{ 
    173  
    174162    omni_mutex_lock l(usrp->tx_control_access); 
    175163    if (channel == 0) { 
     
    181169    } 
    182170 
     171    usrp->tx_active = false; 
     172 
    183173    if (usrp->tx_active) 
    184174        usrp->usrp_tx->stop(); 
    185     usrp->tx_active = false; 
    186175} 
    187176 
     
    217206void USRP_TX_Control_i::set_interpolation_rate(CORBA::ULong channel, CORBA::ULong I) 
    218207{ 
    219  
    220208    // USRP interpolation rate applies to all channels, ignore channel 
    221209    omni_mutex_lock l(usrp->tx_control_access); 
     
    225213void USRP_TX_Control_i::get_interpolation_range(CORBA::ULong channel, CORBA::ULong &imin, CORBA::ULong &imax, CORBA::ULong &istep) 
    226214{ 
    227  
    228215    imin = 4; 
    229216    imax = 512; 
     
    231218} 
    232219 
    233 USRP_RX_Control_i::USRP_RX_Control_i(USRP_i *_usrp, const char* _name, const char* _domain) : standardInterfaces_i::RX_Control_p(_name, _domain), usrp(_usrp), db_lo_freq(0), db_lo_offset(-8e6), lo_locked(false) 
     220USRP_RX_Control_i::USRP_RX_Control_i(USRP_i *_usrp, const char* _name, const char* _domain) : standardInterfaces_i::RX_Control_p(_name, _domain), usrp(_usrp) 
    234221{ 
    235222    DEBUG(3, USRP, "RX Control port constructor called") 
     
    253240    omni_mutex_lock l(usrp->rx_control_access); 
    254241    if (channel == 0) { 
    255         if (usrp->rx_db0_control) 
    256             usrp->rx_db0_control->get_gain_range(gmin, gmax, gstep); 
    257     } else if (channel == 1) { 
    258         if (usrp->rx_db1_control) 
    259             usrp->rx_db1_control->get_gain_range(gmin, gmax, gstep); 
     242        if (usrp->rx_db0_control) { 
     243            gmin = usrp->rx_db0_control->gain_min(); 
     244            gmax = usrp->rx_db0_control->gain_max();; 
     245            gstep = usrp->rx_db0_control->gain_db_per_step(); 
     246        } 
     247    } else if (channel == 1) { 
     248        if (usrp->rx_db1_control) { 
     249            gmin = usrp->rx_db1_control->gain_min(); 
     250            gmax = usrp->rx_db1_control->gain_max();; 
     251            gstep = usrp->rx_db1_control->gain_db_per_step(); 
     252        }          
    260253    } else { 
    261254        return; ///\todo throw bad channel exception 
     
    265258void USRP_RX_Control_i::set_gain(CORBA::ULong channel, CORBA::Float gain) 
    266259{ 
     260    DEBUG(1, USRP, "set gain "); 
     261 
    267262    omni_mutex_lock l(usrp->rx_control_access); 
    268263    if (channel == 0) { 
     
    286281        // for now adding temp_gain and temp_aux.....PHELPS with fix it 
    287282        gain = temp_gain + temp_aux; 
    288          
    289283} 
    290284 
     
    293287    omni_mutex_lock l(usrp->rx_control_access); 
    294288    if (channel == 0) { 
    295         if (usrp->rx_db0_control)  
    296             usrp->rx_db0_control->get_freq_range(fmin, fmax, fstep); 
    297     } else if (channel == 1) { 
    298         if (usrp->rx_db1_control) 
    299             usrp->rx_db1_control->get_freq_range(fmin, fmax, fstep); 
     289        if (usrp->rx_db0_control) { 
     290            fmin = usrp->rx_db0_control->freq_min(); 
     291            fmax = usrp->rx_db0_control->freq_max(); 
     292            fstep = 0; 
     293        } 
     294    } else if (channel == 1) { 
     295        if (usrp->rx_db1_control) { 
     296            fmin = usrp->rx_db1_control->freq_min(); 
     297            fmax = usrp->rx_db1_control->freq_max(); 
     298            fstep = 0; 
     299        } 
    300300    } else { 
    301301        return; ///\todo throw bad channel exception 
     
    307307    DEBUG(3, USRP, "In RX Control set frequency channel: " << channel << ", frequency: " << f); 
    308308 
    309     class db_base *db(NULL); 
     309    db_base_sptr db; 
     310    usrp_tune_result result; 
    310311 
    311312    omni_mutex_lock l(usrp->rx_control_access); 
     
    321322    } 
    322323     
    323     if (!db) { 
    324         DEBUG(1, USRP, "Attempt to set frequency for slot with no board."); 
    325         return;  // No daughter board present 
    326     } 
    327  
    328     float fmin, fmax, fstep; 
    329     db->get_freq_range(fmin, fmax, fstep); 
    330     if ((f < fmin) || (f > fmax)) { 
    331         std::cerr << "Frequency setting not in range " << fmin << " < " << f << " < " << fmax << std::endl; 
    332         return;  /// \todo throw exception 
    333     } 
    334  
    335     if (db->db_has_lo()) { 
    336         if (!lo_locked) { 
    337             float db_lo_freq_set = f + db_lo_offset; 
    338             if (db_lo_freq_set < fmin) 
    339                 db_lo_freq_set = fmin; 
    340             else if (db_lo_freq_set > fmax) 
    341                 db_lo_freq_set = fmax; 
    342              
    343             bool freq_set = db->set_db_freq(db_lo_freq_set, db_lo_freq); 
    344             if (freq_set) 
    345                     DEBUG(3, USRP, "Set db lo to " << (long)db_lo_freq_set << ", Actual setting " << (float) db_lo_freq) 
    346             else 
    347                 std::cerr << "Failed to set db lo to " << (float) db_lo_freq_set << std::endl; 
    348         } 
    349     } else 
    350         db_lo_freq = 0.0; 
    351  
    352     float ddc_freq = f - db_lo_freq; 
    353     if ((ddc_freq < 0e6) || (ddc_freq > 32e6)) { 
    354         std::cerr << "Frequency for DDC not in range 0 < " << ddc_freq << " < 32e6" << std::endl; 
    355         return; ///\todo throw an exception 
    356     } 
    357  
    358     usrp->usrp_rx->set_rx_freq(channel, ddc_freq); 
    359     DEBUG(3, USRP, "Setting ddc lo to " << (long)ddc_freq << " Actual frequency "  << (long)usrp->usrp_rx->rx_freq(channel)) 
    360  
     324    if (!usrp->usrp_rx->tune(channel, db, f, &result)) { 
     325        DEBUG(3, USRP, "USRP RX set_frequency failed"); 
     326        return; // throw exception 
     327    } 
     328 
     329    DEBUG(3, USRP, "USRP RX tune_result:" << 
     330                   " baseband_freq="      << result.baseband_freq << 
     331                   " dxc_freq="           << result.dxc_freq      << 
     332                   " residual_freq="      << result.residual_freq << 
     333                   " inverted="           << result.inverted); 
    361334} 
    362335 
     
    368341void USRP_RX_Control_i::start(CORBA::ULong channel) 
    369342{ 
    370  
    371343    omni_mutex_lock l(usrp->rx_control_access); 
    372344