| 1 | /**************************************************************************** |
|---|
| 2 | |
|---|
| 3 | Copyright 2005,2006 Virginia Polytechnic Institute and State University |
|---|
| 4 | |
|---|
| 5 | This file is part of the OSSIE USRP Device. |
|---|
| 6 | |
|---|
| 7 | OSSIE USRP Device is free software; you can redistribute it and/or modify |
|---|
| 8 | it under the terms of the GNU General Public License as published by |
|---|
| 9 | the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | (at your option) any later version. |
|---|
| 11 | |
|---|
| 12 | OSSIE USRP Device is distributed in the hope that it will be useful, |
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | GNU General Public License for more details. |
|---|
| 16 | |
|---|
| 17 | You should have received a copy of the GNU General Public License |
|---|
| 18 | along with OSSIE USRP Device; if not, write to the Free Software |
|---|
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | ****************************************************************************/ |
|---|
| 23 | |
|---|
| 24 | // Defining LOG_DATA writes the I channel data sent to the USRP to I_out.dat |
|---|
| 25 | //#define LOG_DATA |
|---|
| 26 | |
|---|
| 27 | #include <iostream> |
|---|
| 28 | #include <string> |
|---|
| 29 | #ifdef LOG_DATA |
|---|
| 30 | #include <fstream> |
|---|
| 31 | #endif |
|---|
| 32 | |
|---|
| 33 | #include <byteswap.h> |
|---|
| 34 | |
|---|
| 35 | #include "ossie/cf.h" |
|---|
| 36 | #include "ossie/PortTypes.h" |
|---|
| 37 | |
|---|
| 38 | #include "ossie/ossieSupport.h" |
|---|
| 39 | #include "ossie/debug.h" |
|---|
| 40 | |
|---|
| 41 | #ifdef HAVE_USRP |
|---|
| 42 | #include "usrp_standard.h" |
|---|
| 43 | #include "usrp_dbid.h" |
|---|
| 44 | #include "usrp_prims.h" |
|---|
| 45 | #endif |
|---|
| 46 | |
|---|
| 47 | #include "USRP.h" |
|---|
| 48 | #include "flex.h" |
|---|
| 49 | #include "basic.h" |
|---|
| 50 | #include "lf.h" |
|---|
| 51 | #include "dbsrx.h" |
|---|
| 52 | #include "tvrx.h" |
|---|
| 53 | |
|---|
| 54 | USRP_i::USRP_i(char *id, char *label, char *profile) : Device_impl(id, label, profile), rx_db0_control(NULL), rx_db1_control(NULL), tx_db0_control(NULL), tx_db1_control(NULL), set_rx_packet_count(-1), rx_packet_count(1024), rx_packet_size(1024), rx_data_size(2), number_of_channels(1), complex(true), rx_overruns(0), rx_active(0), tx_active(0) |
|---|
| 55 | { |
|---|
| 56 | // Create device ports |
|---|
| 57 | // Create USRP Control ports for TX and RX |
|---|
| 58 | |
|---|
| 59 | rx_control_port = new USRP_RX_Control_i(this, "RX_Control", "DomainName1"); |
|---|
| 60 | |
|---|
| 61 | tx_control_port = new USRP_TX_Control_i(this, "TX_Control", "DomainName1"); |
|---|
| 62 | |
|---|
| 63 | // Create the ports for TX data |
|---|
| 64 | |
|---|
| 65 | tx_data_port = new standardInterfaces_i::complexShort_p("TX_Data", "DomainName1"); |
|---|
| 66 | |
|---|
| 67 | // Create the ports for RX Data |
|---|
| 68 | |
|---|
| 69 | rx_data_1_port = new standardInterfaces_i::complexShort_u("RX_Data_1", "DomainName1"); |
|---|
| 70 | rx_data_2_port = new standardInterfaces_i::complexShort_u("RX_Data_2", "DomainName1"); |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | void USRP_i::start() throw (CF::Resource::StartError, CORBA::SystemException) |
|---|
| 78 | |
|---|
| 79 | { |
|---|
| 80 | DEBUG(3, USRP, "Start USRP called") |
|---|
| 81 | |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | void USRP_i::stop() throw (CF::Resource::StopError, CORBA::SystemException) |
|---|
| 85 | |
|---|
| 86 | { |
|---|
| 87 | DEBUG(3, USRP, "Stop USRP called") |
|---|
| 88 | |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | CORBA::Object_ptr USRP_i::getPort(const char* portName) throw(CF::PortSupplier::UnknownPort, CORBA::SystemException) |
|---|
| 92 | |
|---|
| 93 | { |
|---|
| 94 | DEBUG(3, USRP, "USRP getPort called with : " << portName) |
|---|
| 95 | |
|---|
| 96 | CORBA::Object_var p; |
|---|
| 97 | |
|---|
| 98 | if (!CORBA::is_nil(p = rx_control_port->getPort(portName))) |
|---|
| 99 | return p._retn(); |
|---|
| 100 | else if (!CORBA::is_nil(p = rx_data_1_port->getPort(portName))) |
|---|
| 101 | return p._retn(); |
|---|
| 102 | else if (!CORBA::is_nil(p = rx_data_1_port->getPort(portName))) { |
|---|
| 103 | return p._retn(); |
|---|
| 104 | } else if (!CORBA::is_nil(p = tx_control_port->getPort(portName))) { |
|---|
| 105 | return p._retn(); |
|---|
| 106 | } else if (!CORBA::is_nil(p = tx_data_port->getPort(portName))) { |
|---|
| 107 | return p._retn(); |
|---|
| 108 | } |
|---|
| 109 | std::cerr << "Couldn't find port " << portName << "Throwing exception" << std::endl; |
|---|
| 110 | throw CF::PortSupplier::UnknownPort(); |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | void USRP_i::initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException) |
|---|
| 114 | |
|---|
| 115 | { |
|---|
| 116 | DEBUG(3, USRP, "USRP Initialize called") |
|---|
| 117 | |
|---|
| 118 | usrp_rx = usrp_standard_rx::make(0, 256); |
|---|
| 119 | |
|---|
| 120 | if (!usrp_rx) { |
|---|
| 121 | std::cerr << "Failed to create usrp rx" << std::endl; |
|---|
| 122 | throw CF::LifeCycle::InitializeError(); |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | //usrp_tx = usrp_standard_tx::make(0,512, 1, 0xba98, 4096, 16); |
|---|
| 126 | usrp_tx = usrp_standard_tx::make(0,512); |
|---|
| 127 | |
|---|
| 128 | if (!usrp_tx) { |
|---|
| 129 | std::cerr << "Failed to create usrp tx" << std::endl; |
|---|
| 130 | throw CF::LifeCycle::InitializeError(); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | // Check for RX daughterboards |
|---|
| 135 | |
|---|
| 136 | rx_db0 = usrp_rx->daughterboard_id(0); |
|---|
| 137 | rx_db1 = usrp_rx->daughterboard_id(1); |
|---|
| 138 | |
|---|
| 139 | DEBUG(1, USRP, "RX daughterboard slot 0 : " << usrp_dbid_to_string(rx_db0)) |
|---|
| 140 | DEBUG(1, USRP, "RX daughterboard slot 1 : " << usrp_dbid_to_string(rx_db1)) |
|---|
| 141 | |
|---|
| 142 | switch (rx_db0) { |
|---|
| 143 | case USRP_DBID_FLEX_400_RX: |
|---|
| 144 | rx_db0_control = new db_flex400_rx(usrp_rx, 0); |
|---|
| 145 | break; |
|---|
| 146 | case USRP_DBID_FLEX_400_RX_MIMO_A: |
|---|
| 147 | //rx_db0_control = new db_flex400_rx_mimo_a(usrp_rx, 0); |
|---|
| 148 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 149 | break; |
|---|
| 150 | case USRP_DBID_FLEX_400_RX_MIMO_B: |
|---|
| 151 | rx_db0_control = new db_flex400_rx_mimo_b(usrp_rx, 0); |
|---|
| 152 | //std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 153 | break; |
|---|
| 154 | case USRP_DBID_FLEX_900_RX: |
|---|
| 155 | //rx_db0_control = new db_flex900_rx(usrp_rx, 0); |
|---|
| 156 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 157 | break; |
|---|
| 158 | case USRP_DBID_FLEX_900_RX_MIMO_A: |
|---|
| 159 | //rx_db0_control = new db_flex900_rx_mimo_a(usrp_rx, 0); |
|---|
| 160 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 161 | break; |
|---|
| 162 | case USRP_DBID_FLEX_900_RX_MIMO_B: |
|---|
| 163 | rx_db0_control = new db_flex900_rx_mimo_b(usrp_rx, 0); |
|---|
| 164 | break; |
|---|
| 165 | case USRP_DBID_FLEX_1200_RX: |
|---|
| 166 | //rx_db0_control = new db_flex1200_rx(usrp_rx, 0); |
|---|
| 167 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 168 | break; |
|---|
| 169 | case USRP_DBID_FLEX_1200_RX_MIMO_A: |
|---|
| 170 | //rx_db0_control = new db_flex1200_rx_mimo_a(usrp_rx, 0); |
|---|
| 171 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 172 | break; |
|---|
| 173 | case USRP_DBID_FLEX_1200_RX_MIMO_B: |
|---|
| 174 | rx_db0_control = new db_flex1200_rx_mimo_b(usrp_rx, 0); |
|---|
| 175 | //std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 176 | break; |
|---|
| 177 | /* |
|---|
| 178 | case USRP_DBID_FLEX_1800_RX: |
|---|
| 179 | //rx_db0_control = new db_flex1800_rx(usrp_rx, 0); |
|---|
| 180 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 181 | break; |
|---|
| 182 | case USRP_DBID_FLEX_1800_RX_MIMO_A: |
|---|
| 183 | //rx_db0_control = new db_flex1800_rx_mimo_a(usrp_rx, 0); |
|---|
| 184 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 185 | break; |
|---|
| 186 | case USRP_DBID_FLEX_1800_RX_MIMO_B: |
|---|
| 187 | //rx_db0_control = new db_flex1800_rx_mimo_b(usrp_rx, 0); |
|---|
| 188 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 189 | break; |
|---|
| 190 | */ |
|---|
| 191 | case USRP_DBID_FLEX_2400_RX: |
|---|
| 192 | rx_db0_control = new db_flex2400_rx(usrp_rx, 0); |
|---|
| 193 | break; |
|---|
| 194 | case USRP_DBID_FLEX_2400_RX_MIMO_A: |
|---|
| 195 | //rx_db0_control = new db_flex2400_rx_mimo_a(usrp_rx, 0); |
|---|
| 196 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 197 | break; |
|---|
| 198 | case USRP_DBID_FLEX_2400_RX_MIMO_B: |
|---|
| 199 | //rx_db0_control = new db_flex2400_rx_mimo_b(usrp_rx, 0); |
|---|
| 200 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 201 | break; |
|---|
| 202 | case USRP_DBID_BASIC_RX: |
|---|
| 203 | rx_db0_control = new db_basic_rx(usrp_rx, 0); |
|---|
| 204 | break; |
|---|
| 205 | case USRP_DBID_DBS_RX: |
|---|
| 206 | rx_db0_control = new dbsrx(usrp_rx, 0); |
|---|
| 207 | break; |
|---|
| 208 | case USRP_DBID_DBS_RX_REV_2_1: |
|---|
| 209 | //rx_db0_control = new dbsrx(usrp_rx, 0); |
|---|
| 210 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 211 | break; |
|---|
| 212 | case USRP_DBID_TV_RX: |
|---|
| 213 | //rx_db0_control = new tvrx(usrp_rx, 0); |
|---|
| 214 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 215 | break; |
|---|
| 216 | case USRP_DBID_TV_RX_REV_2: |
|---|
| 217 | //rx_db0_control = new tvrx_rev2(usrp_rx, 0); |
|---|
| 218 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 219 | break; |
|---|
| 220 | /* |
|---|
| 221 | case USRP_DBID_TV_RX_REV_3: |
|---|
| 222 | //rx_db0_control = new tvrx_rev3(usrp_rx, 0); |
|---|
| 223 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 224 | break; |
|---|
| 225 | */ |
|---|
| 226 | case USRP_DBID_LF_RX: |
|---|
| 227 | rx_db0_control = new db_lf_rx(usrp_rx, 0); |
|---|
| 228 | break; |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | switch (rx_db1) { |
|---|
| 232 | case USRP_DBID_FLEX_400_RX: |
|---|
| 233 | rx_db1_control = new db_flex400_rx(usrp_rx, 1); |
|---|
| 234 | break; |
|---|
| 235 | case USRP_DBID_FLEX_400_RX_MIMO_A: |
|---|
| 236 | //rx_db1_control = new db_flex400_rx_mimo_a(usrp_rx, 1); |
|---|
| 237 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 238 | break; |
|---|
| 239 | case USRP_DBID_FLEX_400_RX_MIMO_B: |
|---|
| 240 | rx_db1_control = new db_flex400_rx_mimo_b(usrp_rx, 1); |
|---|
| 241 | //std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 242 | break; |
|---|
| 243 | case USRP_DBID_FLEX_900_RX: |
|---|
| 244 | //rx_db1_control = new db_flex900_rx(usrp_rx, 1); |
|---|
| 245 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 246 | break; |
|---|
| 247 | case USRP_DBID_FLEX_900_RX_MIMO_A: |
|---|
| 248 | //rx_db1_control = new db_flex900_rx_mimo_a(usrp_rx, 1); |
|---|
| 249 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 250 | break; |
|---|
| 251 | case USRP_DBID_FLEX_900_RX_MIMO_B: |
|---|
| 252 | rx_db1_control = new db_flex900_rx_mimo_b(usrp_rx, 1); |
|---|
| 253 | break; |
|---|
| 254 | case USRP_DBID_FLEX_1200_RX: |
|---|
| 255 | //rx_db1_control = new db_flex1200_rx(usrp_rx, 1); |
|---|
| 256 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 257 | break; |
|---|
| 258 | case USRP_DBID_FLEX_1200_RX_MIMO_A: |
|---|
| 259 | //rx_db1_control = new db_flex1200_rx_mimo_a(usrp_rx, 1); |
|---|
| 260 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 261 | break; |
|---|
| 262 | case USRP_DBID_FLEX_1200_RX_MIMO_B: |
|---|
| 263 | rx_db1_control = new db_flex1200_rx_mimo_b(usrp_rx, 1); |
|---|
| 264 | //std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 265 | break; |
|---|
| 266 | /* |
|---|
| 267 | case USRP_DBID_FLEX_1800_RX: |
|---|
| 268 | //rx_db1_control = new db_flex1800_rx(usrp_rx, 1); |
|---|
| 269 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 270 | break; |
|---|
| 271 | case USRP_DBID_FLEX_1800_RX_MIMO_A: |
|---|
| 272 | //rx_db1_control = new db_flex1800_rx_mimo_a(usrp_rx, 1); |
|---|
| 273 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 274 | break; |
|---|
| 275 | case USRP_DBID_FLEX_1800_RX_MIMO_B: |
|---|
| 276 | //rx_db1_control = new db_flex1800_rx_mimo_b(usrp_rx, 1); |
|---|
| 277 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 278 | break; |
|---|
| 279 | */ |
|---|
| 280 | case USRP_DBID_FLEX_2400_RX: |
|---|
| 281 | rx_db1_control = new db_flex2400_rx(usrp_rx, 1); |
|---|
| 282 | break; |
|---|
| 283 | case USRP_DBID_FLEX_2400_RX_MIMO_A: |
|---|
| 284 | //rx_db1_control = new db_flex2400_rx_mimo_a(usrp_rx, 1); |
|---|
| 285 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 286 | break; |
|---|
| 287 | case USRP_DBID_FLEX_2400_RX_MIMO_B: |
|---|
| 288 | //rx_db1_control = new db_flex2400_rx_mimo_b(usrp_rx, 1); |
|---|
| 289 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 290 | break; |
|---|
| 291 | case USRP_DBID_BASIC_RX: |
|---|
| 292 | rx_db1_control = new db_basic_rx(usrp_rx, 1); |
|---|
| 293 | break; |
|---|
| 294 | case USRP_DBID_DBS_RX: |
|---|
| 295 | rx_db1_control = new dbsrx(usrp_rx, 1); |
|---|
| 296 | break; |
|---|
| 297 | case USRP_DBID_DBS_RX_REV_2_1: |
|---|
| 298 | //rx_db1_control = new dbsrx(usrp_rx, 1); |
|---|
| 299 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 300 | break; |
|---|
| 301 | case USRP_DBID_TV_RX: |
|---|
| 302 | //rx_db1_control = new tvrx(usrp_rx, 1); |
|---|
| 303 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 304 | break; |
|---|
| 305 | case USRP_DBID_TV_RX_REV_2: |
|---|
| 306 | //rx_db1_control = new tvrx_rev2(usrp_rx, 1); |
|---|
| 307 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 308 | break; |
|---|
| 309 | /* |
|---|
| 310 | case USRP_DBID_TV_RX_REV_3: |
|---|
| 311 | //rx_db1_control = new tvrx_rev3(usrp_rx, 1); |
|---|
| 312 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 313 | break; |
|---|
| 314 | */ |
|---|
| 315 | case USRP_DBID_LF_RX: |
|---|
| 316 | rx_db1_control = new db_lf_rx(usrp_rx, 1); |
|---|
| 317 | break; |
|---|
| 318 | |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | // Check for TX daughterboards |
|---|
| 322 | |
|---|
| 323 | tx_db0 = usrp_tx->daughterboard_id(0); |
|---|
| 324 | tx_db1 = usrp_tx->daughterboard_id(1); |
|---|
| 325 | |
|---|
| 326 | switch (tx_db0) { |
|---|
| 327 | case USRP_DBID_FLEX_400_TX: |
|---|
| 328 | tx_db0_control = new db_flex400_tx(usrp_tx, 0); |
|---|
| 329 | break; |
|---|
| 330 | case USRP_DBID_FLEX_400_TX_MIMO_A: |
|---|
| 331 | //tx_db0_control = new db_flex400_tx_mimo_a(usrp_tx, 0); |
|---|
| 332 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 333 | break; |
|---|
| 334 | case USRP_DBID_FLEX_400_TX_MIMO_B: |
|---|
| 335 | tx_db0_control = new db_flex400_tx_mimo_b(usrp_tx, 0); |
|---|
| 336 | //std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 337 | break; |
|---|
| 338 | case USRP_DBID_FLEX_900_TX: |
|---|
| 339 | //tx_db0_control = new db_flex900_tx(usrp_tx, 0); |
|---|
| 340 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 341 | break; |
|---|
| 342 | case USRP_DBID_FLEX_900_TX_MIMO_A: |
|---|
| 343 | //tx_db0_control = new db_flex900_tx_mimo_a(usrp_tx, 0); |
|---|
| 344 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 345 | break; |
|---|
| 346 | case USRP_DBID_FLEX_900_TX_MIMO_B: |
|---|
| 347 | tx_db0_control = new db_flex900_tx_mimo_b(usrp_tx, 0); |
|---|
| 348 | break; |
|---|
| 349 | case USRP_DBID_FLEX_1200_TX: |
|---|
| 350 | //tx_db0_control = new db_flex1200_tx(usrp_tx, 0); |
|---|
| 351 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 352 | break; |
|---|
| 353 | case USRP_DBID_FLEX_1200_TX_MIMO_A: |
|---|
| 354 | //tx_db0_control = new db_flex1200_tx_mimo_a(usrp_tx, 0); |
|---|
| 355 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 356 | break; |
|---|
| 357 | case USRP_DBID_FLEX_1200_TX_MIMO_B: |
|---|
| 358 | tx_db0_control = new db_flex1200_tx_mimo_b(usrp_tx, 0); |
|---|
| 359 | //std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 360 | break; |
|---|
| 361 | /* |
|---|
| 362 | case USRP_DBID_FLEX_1800_TX: |
|---|
| 363 | //tx_db0_control = new db_flex1800_tx(usrp_tx, 0); |
|---|
| 364 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 365 | break; |
|---|
| 366 | case USRP_DBID_FLEX_1800_TX_MIMO_A: |
|---|
| 367 | //tx_db0_control = new db_flex1800_tx_mimo_a(usrp_tx, 0); |
|---|
| 368 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 369 | break; |
|---|
| 370 | case USRP_DBID_FLEX_1800_TX_MIMO_B: |
|---|
| 371 | //tx_db0_control = new db_flex1800_tx_mimo_b(usrp_tx, 0); |
|---|
| 372 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 373 | break; |
|---|
| 374 | */ |
|---|
| 375 | case USRP_DBID_FLEX_2400_TX: |
|---|
| 376 | tx_db0_control = new db_flex2400_tx(usrp_tx, 0); |
|---|
| 377 | break; |
|---|
| 378 | case USRP_DBID_FLEX_2400_TX_MIMO_A: |
|---|
| 379 | //tx_db0_control = new db_flex2400_tx_mimo_a(usrp_tx, 0); |
|---|
| 380 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 381 | break; |
|---|
| 382 | case USRP_DBID_FLEX_2400_TX_MIMO_B: |
|---|
| 383 | //tx_db0_control = new db_flex2400_tx_mimo_b(usrp_tx, 0); |
|---|
| 384 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 385 | break; |
|---|
| 386 | case USRP_DBID_BASIC_TX: |
|---|
| 387 | tx_db0_control = new db_basic_tx(usrp_tx, 0); |
|---|
| 388 | break; |
|---|
| 389 | case USRP_DBID_LF_TX: |
|---|
| 390 | tx_db0_control = new db_lf_tx(usrp_tx, 0); |
|---|
| 391 | break; |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | } |
|---|
| 395 | |
|---|
| 396 | switch (tx_db1) { |
|---|
| 397 | case USRP_DBID_FLEX_400_TX: |
|---|
| 398 | tx_db1_control = new db_flex400_tx(usrp_tx, 1); |
|---|
| 399 | break; |
|---|
| 400 | case USRP_DBID_FLEX_400_TX_MIMO_A: |
|---|
| 401 | //tx_db1_control = new db_flex400_tx_mimo_a(usrp_tx, 1); |
|---|
| 402 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 403 | break; |
|---|
| 404 | case USRP_DBID_FLEX_400_TX_MIMO_B: |
|---|
| 405 | tx_db1_control = new db_flex400_tx_mimo_b(usrp_tx, 1); |
|---|
| 406 | //std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 407 | break; |
|---|
| 408 | case USRP_DBID_FLEX_900_TX: |
|---|
| 409 | //tx_db1_control = new db_flex900_tx(usrp_tx, 1); |
|---|
| 410 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 411 | break; |
|---|
| 412 | case USRP_DBID_FLEX_900_TX_MIMO_A: |
|---|
| 413 | //tx_db1_control = new db_flex900_tx_mimo_a(usrp_tx, 1); |
|---|
| 414 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 415 | break; |
|---|
| 416 | case USRP_DBID_FLEX_900_TX_MIMO_B: |
|---|
| 417 | tx_db1_control = new db_flex900_tx_mimo_b(usrp_tx, 1); |
|---|
| 418 | break; |
|---|
| 419 | case USRP_DBID_FLEX_1200_TX: |
|---|
| 420 | //tx_db1_control = new db_flex1200_tx(usrp_tx, 1); |
|---|
| 421 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 422 | break; |
|---|
| 423 | case USRP_DBID_FLEX_1200_TX_MIMO_A: |
|---|
| 424 | //tx_db1_control = new db_flex1200_tx_mimo_a(usrp_tx, 1); |
|---|
| 425 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 426 | break; |
|---|
| 427 | case USRP_DBID_FLEX_1200_TX_MIMO_B: |
|---|
| 428 | tx_db1_control = new db_flex1200_tx_mimo_b(usrp_tx, 1); |
|---|
| 429 | //std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 430 | break; |
|---|
| 431 | /* |
|---|
| 432 | case USRP_DBID_FLEX_1800_TX: |
|---|
| 433 | //tx_db1_control = new db_flex1800_tx(usrp_tx, 1); |
|---|
| 434 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 435 | break; |
|---|
| 436 | case USRP_DBID_FLEX_1800_TX_MIMO_A: |
|---|
| 437 | //tx_db1_control = new db_flex1800_tx_mimo_a(usrp_tx, 1); |
|---|
| 438 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 439 | break; |
|---|
| 440 | case USRP_DBID_FLEX_1800_TX_MIMO_B: |
|---|
| 441 | //tx_db1_control = new db_flex1800_tx_mimo_b(usrp_tx, 1); |
|---|
| 442 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 443 | break; |
|---|
| 444 | */ |
|---|
| 445 | case USRP_DBID_FLEX_2400_TX: |
|---|
| 446 | tx_db1_control = new db_flex2400_tx(usrp_tx, 1); |
|---|
| 447 | break; |
|---|
| 448 | case USRP_DBID_FLEX_2400_TX_MIMO_A: |
|---|
| 449 | //tx_db1_control = new db_flex2400_tx_mimo_a(usrp_tx, 1); |
|---|
| 450 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 451 | break; |
|---|
| 452 | case USRP_DBID_FLEX_2400_TX_MIMO_B: |
|---|
| 453 | //tx_db1_control = new db_flex2400_tx_mimo_b(usrp_tx, 1); |
|---|
| 454 | std::cout << "The daughterboard is not yet tested: Please contact OSSIE team to verify and activate. http://ossie-dev.mprg.org" << std::endl; |
|---|
| 455 | break; |
|---|
| 456 | case USRP_DBID_BASIC_TX: |
|---|
| 457 | tx_db1_control = new db_basic_tx(usrp_tx, 1); |
|---|
| 458 | break; |
|---|
| 459 | case USRP_DBID_LF_TX: |
|---|
| 460 | tx_db1_control = new db_lf_tx(usrp_tx, 1); |
|---|
| 461 | break; |
|---|
| 462 | |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | |
|---|
| 466 | DEBUG(1, USRP, "TX daughterboard slot 0 : " << usrp_dbid_to_string(tx_db0)) |
|---|
| 467 | DEBUG(1, USRP, "TX daughterboard slot 1 : " << usrp_dbid_to_string(tx_db1)) |
|---|
| 468 | |
|---|
| 469 | } |
|---|
| 470 | |
|---|
| 471 | |
|---|
| 472 | void USRP_i::configure(const CF::Properties &configProperties) throw (CORBA::SystemException, CF::PropertySet::InvalidConfiguration, CF::PropertySet::PartialConfiguration) |
|---|
| 473 | { |
|---|
| 474 | |
|---|
| 475 | } |
|---|
| 476 | |
|---|
| 477 | void USRP_i::query(CF::Properties &configProperties) throw (CORBA::SystemException, CF::UnknownProperties) |
|---|
| 478 | { |
|---|
| 479 | |
|---|
| 480 | } |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | void USRP_i::releaseObject() throw (CF::LifeCycle::ReleaseError, CORBA::SystemException) |
|---|
| 484 | |
|---|
| 485 | { |
|---|
| 486 | |
|---|
| 487 | DEBUG(3, USRP, "USRP releaseObject called") |
|---|
| 488 | } |
|---|
| 489 | |
|---|
| 490 | void USRP_i::rx_data_process() |
|---|
| 491 | |
|---|
| 492 | { |
|---|
| 493 | short *rx_buffer; |
|---|
| 494 | |
|---|
| 495 | ///\todo this assumes USRP is sending shorts, fix to match USRP config |
|---|
| 496 | ///\todo assumes one channel operation |
|---|
| 497 | unsigned int buf_size = rx_packet_size * number_of_channels * (complex ? 2 : 1); |
|---|
| 498 | |
|---|
| 499 | rx_buffer = new short[buf_size*2]; |
|---|
| 500 | |
|---|
| 501 | PortTypes::ShortSequence I; |
|---|
| 502 | PortTypes::ShortSequence Q; |
|---|
| 503 | |
|---|
| 504 | I.length(rx_packet_size); |
|---|
| 505 | Q.length(rx_packet_size); |
|---|
| 506 | |
|---|
| 507 | DEBUG(3, USRP, "RX packet count " << rx_packet_count) |
|---|
| 508 | |
|---|
| 509 | usrp_rx->start(); |
|---|
| 510 | |
|---|
| 511 | while (rx_active && ((rx_packet_count == -1) || (rx_packet_count > 0))) { |
|---|
| 512 | bool overrun = 0; |
|---|
| 513 | usrp_rx->read(rx_buffer, buf_size * 2, &overrun); |
|---|
| 514 | if (overrun) { |
|---|
| 515 | std::cerr << "RX Overrun occurred" << std::endl; |
|---|
| 516 | ++rx_overruns; |
|---|
| 517 | } |
|---|
| 518 | |
|---|
| 519 | for (unsigned int i = 0; i < rx_packet_size * 2; i += 2) { |
|---|
| 520 | if (i < 0) |
|---|
| 521 | DEBUG(5, USRP, "I - " << rx_buffer[i] << " Q - " << rx_buffer[i+1]) |
|---|
| 522 | I[i/2] = (CORBA::Short) rx_buffer[i]; |
|---|
| 523 | Q[i/2] = (CORBA::Short) rx_buffer[i+1]; |
|---|
| 524 | } |
|---|
| 525 | rx_data_1_port->pushPacket(I, Q); |
|---|
| 526 | |
|---|
| 527 | if (rx_packet_count != -1) |
|---|
| 528 | --rx_packet_count; |
|---|
| 529 | |
|---|
| 530 | } |
|---|
| 531 | |
|---|
| 532 | DEBUG(3, USRP, "Exiting rx_data_process thread") |
|---|
| 533 | |
|---|
| 534 | usrp_rx->stop(); |
|---|
| 535 | rx_active = 0; |
|---|
| 536 | rx_thread->exit(); |
|---|
| 537 | } |
|---|
| 538 | |
|---|
| 539 | |
|---|
| 540 | // Helper function for tx_data_process |
|---|
| 541 | inline static void tx_with_usrp(usrp_standard_tx *usrp_tx, short *tx_buf, unsigned int tx_buf_len, unsigned int &tx_underruns) |
|---|
| 542 | { |
|---|
| 543 | bool underrun_occured; |
|---|
| 544 | |
|---|
| 545 | int rc = usrp_tx->write(tx_buf, tx_buf_len * 2, &underrun_occured); |
|---|
| 546 | if (underrun_occured) { |
|---|
| 547 | ++tx_underruns; |
|---|
| 548 | std::cerr << "USRP TX Underrun occured, total underruns - " << tx_underruns << std::endl; |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | if (rc < 0) { |
|---|
| 552 | std::cerr << "USRP TX error detected" << std::endl; |
|---|
| 553 | } else if (rc != (int) tx_buf_len * 2) { |
|---|
| 554 | std::cerr << "USRP TX attempted to write " << tx_buf_len << " bytes, but only " << rc << "bytes actually written." << std::endl; |
|---|
| 555 | } |
|---|
| 556 | } |
|---|
| 557 | |
|---|
| 558 | // USRP Expects data in little endian format |
|---|
| 559 | static inline short convertToLE(short s) |
|---|
| 560 | { |
|---|
| 561 | #ifdef __powerpc__ |
|---|
| 562 | s = bswap_16(s); |
|---|
| 563 | #endif |
|---|
| 564 | |
|---|
| 565 | return s; |
|---|
| 566 | } |
|---|
| 567 | |
|---|
| 568 | void USRP_i::tx_data_process() |
|---|
| 569 | |
|---|
| 570 | { |
|---|
| 571 | PortTypes::ShortSequence *I_in, *Q_in; |
|---|
| 572 | |
|---|
| 573 | const unsigned int tx_buf_len(512*1); // Must be a multiple of 512 |
|---|
| 574 | |
|---|
| 575 | unsigned int tx_buf_idx(0), tx_underruns(0); |
|---|
| 576 | short tx_buf[tx_buf_len]; |
|---|
| 577 | |
|---|
| 578 | #ifdef LOG_DATA |
|---|
| 579 | std::ofstream *ofile = new std::ofstream("I_out.dat"); |
|---|
| 580 | #endif |
|---|
| 581 | |
|---|
| 582 | DEBUG(3, USRP, "Starting tx_data_process thread.") |
|---|
| 583 | |
|---|
| 584 | tx_active = true; // Cleared to stop TX in USRP_TX_Control->stop() |
|---|
| 585 | |
|---|
| 586 | while (tx_active) { |
|---|
| 587 | |
|---|
| 588 | tx_data_port->getData(I_in, Q_in); |
|---|
| 589 | |
|---|
| 590 | unsigned int data_length(I_in->length()); |
|---|
| 591 | |
|---|
| 592 | for (unsigned int i = 0; i < data_length; ++i) { |
|---|
| 593 | tx_buf[tx_buf_idx] = convertToLE((*I_in)[i]); |
|---|
| 594 | ++tx_buf_idx; |
|---|
| 595 | #ifdef LOG_DATA |
|---|
| 596 | *ofile << (*I_in)[i] << std::endl; |
|---|
| 597 | #endif |
|---|
| 598 | tx_buf[tx_buf_idx] = convertToLE((*Q_in)[i]); |
|---|
| 599 | ++tx_buf_idx; |
|---|
| 600 | |
|---|
| 601 | if (tx_buf_idx == tx_buf_len) { |
|---|
| 602 | tx_with_usrp(usrp_tx, tx_buf, tx_buf_len, tx_underruns); |
|---|
| 603 | tx_buf_idx = 0; |
|---|
| 604 | } |
|---|
| 605 | } |
|---|
| 606 | |
|---|
| 607 | tx_data_port->bufferEmptied(); |
|---|
| 608 | } |
|---|
| 609 | #ifdef LOG_DATA |
|---|
| 610 | delete ofile; |
|---|
| 611 | #endif |
|---|
| 612 | |
|---|
| 613 | DEBUG(3, USRP, "Exiting tx_data_process thread.") |
|---|
| 614 | usrp_tx->stop(); |
|---|
| 615 | tx_thread->exit(); |
|---|
| 616 | } |
|---|