commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8419 - in usrp2/branches/developers/jcorgan/u2/host:


From: jcorgan
Subject: [Commit-gnuradio] r8419 - in usrp2/branches/developers/jcorgan/u2/host: apps gr-usrp2 lib
Date: Tue, 13 May 2008 19:22:40 -0600 (MDT)

Author: jcorgan
Date: 2008-05-13 19:22:38 -0600 (Tue, 13 May 2008)
New Revision: 8419

Modified:
   usrp2/branches/developers/jcorgan/u2/host/apps/Makefile.am
   usrp2/branches/developers/jcorgan/u2/host/apps/rx_streaming_samples.cc
   usrp2/branches/developers/jcorgan/u2/host/apps/tx_samples.cc
   usrp2/branches/developers/jcorgan/u2/host/apps/u2_burn_mac_addr.cc
   usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_table.cc
   usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc
   usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h
Log:
Change usrp2_basic to hold persistent mac address identity.

Modified: usrp2/branches/developers/jcorgan/u2/host/apps/Makefile.am
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/apps/Makefile.am  2008-05-14 
00:11:55 UTC (rev 8418)
+++ usrp2/branches/developers/jcorgan/u2/host/apps/Makefile.am  2008-05-14 
01:22:38 UTC (rev 8419)
@@ -27,8 +27,8 @@
        find_usrps \
        rx_streaming_samples \
        tx_samples \
-       gen_const 
-#      u2_burn_mac_addr
+       gen_const \
+       u2_burn_mac_addr
 
 find_usrps_SOURCES = find_usrps.cc
 # rx_samples_SOURCES = rx_samples.cc

Modified: usrp2/branches/developers/jcorgan/u2/host/apps/rx_streaming_samples.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/apps/rx_streaming_samples.cc      
2008-05-14 00:11:55 UTC (rev 8418)
+++ usrp2/branches/developers/jcorgan/u2/host/apps/rx_streaming_samples.cc      
2008-05-14 01:22:38 UTC (rev 8419)
@@ -220,7 +220,8 @@
   int    ch;
   double tmp;
   u2_mac_addr_t mac_addr;
-
+  bool default_mac = true;
+  
   // setvbuf(stdout, 0, _IOFBF, 64 * 1024); // make stdout fully buffered
 
   while ((ch = getopt(argc, argv, "he:m:o:f:d:N:F:S:g:")) != EOF){
@@ -237,6 +238,7 @@
        usage(argv[0]);
        exit(1);
       }
+      default_mac = false;
       break;
 
     case 'o':
@@ -312,22 +314,18 @@
     }
   }
 
-  op_id_reply_t r;
-  if (!usrp2_basic::pick_default_usrp(interface, &r)) {
-    std::cerr << "No default USRP2 found.\n";
-    return 1;
+  if (default_mac == true) {
+    op_id_reply_t r;
+    if (!usrp2_basic::pick_default_usrp(interface, &r)) {
+      std::cerr << "No default USRP2 found.\n";
+      return 1;
+    }
+    mac_addr = r.addr;
   }
-
-  usrp2_basic_sptr u2 = usrp2_make_basic();
-  if (!u2->open(interface)){
-    std::cerr << "couldn't open " << interface << std::endl;
-    return 0;
-  }
-
+    
+  usrp2_basic_sptr u2 = usrp2_make_basic(interface, mac_addr);
+  
   install_sig_handler(SIGINT, sig_handler);
-
-  u2_mac_addr_t which = r.addr;
-
   gr_rt_status_t rt = gr_enable_realtime_scheduling();
   if (rt != RT_OK)
     std::cerr << "failed to enable realtime scheduling\n";
@@ -339,28 +337,28 @@
   usrp2_tune_result tune_result;
   
   if (gain != GAIN_NOT_SET){
-    if (!u2->set_rx_gain(which, gain)){
+    if (!u2->set_rx_gain(gain)){
       std::cerr << "set_rx_gain failed\n";
       return 1;
     }
   }
 
-  if (!u2->set_rx_freq(which, freq, &tune_result)){
+  if (!u2->set_rx_freq(freq, &tune_result)){
     std::cerr << "set_rx_freq failed\n";
     return 1;
   }
 
-  if (!u2->set_rx_decim(which, decim)){
+  if (!u2->set_rx_decim(decim)){
     std::cerr << "set_rx_decim failed\n";
     return 1;
   }
 
-  if (!u2->set_rx_scale_iq(which, scale, scale)){
+  if (!u2->set_rx_scale_iq(scale, scale)){
     std::cerr << "set_rx_scale_iq failed\n";
     return 1;
   }
 
-  if (!u2->start_rx_streaming(which, samples_per_frame)){
+  if (!u2->start_rx_streaming(samples_per_frame)){
     std::cerr << "start_rx_streaming failed\n";
     return 1;
   }
@@ -374,7 +372,7 @@
     u2_eth_samples_t   pkt;
     
     // read samples
-    int n = u2->read_samples(which, &pkt);
+    int n = u2->read_samples(&pkt);
     if (n <= 0)
       break;
     
@@ -405,7 +403,7 @@
   // smp_wmb()
   rb->d_not_empty.post();      // wake up file writer 
   
-  if (!u2->stop_rx(which)){
+  if (!u2->stop_rx()){
     std::cerr << "stop_rx failed\n";
     return 1;
   }

Modified: usrp2/branches/developers/jcorgan/u2/host/apps/tx_samples.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/apps/tx_samples.cc        
2008-05-14 00:11:55 UTC (rev 8418)
+++ usrp2/branches/developers/jcorgan/u2/host/apps/tx_samples.cc        
2008-05-14 01:22:38 UTC (rev 8419)
@@ -78,7 +78,8 @@
   int    ch;
   double tmp;
   u2_mac_addr_t mac_addr;
-
+  bool default_mac = true;
+  
   while ((ch = getopt(argc, argv, "he:m:I:rf:i:F:S:g:")) != EOF){
     switch (ch){
 
@@ -93,6 +94,7 @@
        usage(argv[0]);
        return 1;
       }
+      default_mac = false;
       break;
 
     case 'I':
@@ -160,40 +162,36 @@
     return 1;
   }
 
-  op_id_reply_t r;
-  if (!usrp2_basic::pick_default_usrp(interface, &r)) {
-    std::cerr << "Unable to find USRP2." << std::endl;
-    return 1;
+  if (default_mac == true) {
+    op_id_reply_t r;
+    if (!usrp2_basic::pick_default_usrp(interface, &r)) {
+      std::cerr << "Unable to find USRP2." << std::endl;
+      return 1;
+    }
+    mac_addr = r.addr;
   }
-
-  usrp2_basic_sptr u2 = usrp2_make_basic();
-
-  if (!u2->open(interface)){
-    std::cerr << "couldn't open " << interface << std::endl;
-    return 1;
-  }
-
-  u2_mac_addr_t which = r.addr;
+  
+  usrp2_basic_sptr u2 = usrp2_make_basic(interface, mac_addr);
   usrp2_tune_result tune_result;
   
   if (gain != GAIN_NOT_SET){
-    if (!u2->set_tx_gain(which, gain)){
+    if (!u2->set_tx_gain(gain)){
       std::cerr << "set_tx_gain failed\n";
       return 1;
     }
   }
 
-  if (!u2->set_tx_freq(which, freq, &tune_result)){
+  if (!u2->set_tx_freq(freq, &tune_result)){
     std::cerr << "set_tx_freq failed\n";
     return 1;
   }
 
-  if (!u2->set_tx_interp(which, interp)){
+  if (!u2->set_tx_interp(interp)){
     std::cerr << "set_tx_interp failed\n";
     return 1;
   }
 
-  if (!u2->set_tx_scale_iq(which, scale, scale)){
+  if (!u2->set_tx_scale_iq(scale, scale)){
     std::cerr << "set_tx_scale_iq failed\n";
     return 1;
   }
@@ -218,7 +216,7 @@
 
     // FIXME if r < 9, pad to 9 for minimum packet size constraint
 
-    if (!u2->write_samples(which, &pkt, r))
+    if (!u2->write_samples(&pkt, r))
       break;
   }
 

Modified: usrp2/branches/developers/jcorgan/u2/host/apps/u2_burn_mac_addr.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/apps/u2_burn_mac_addr.cc  
2008-05-14 00:11:55 UTC (rev 8418)
+++ usrp2/branches/developers/jcorgan/u2/host/apps/u2_burn_mac_addr.cc  
2008-05-14 01:22:38 UTC (rev 8419)
@@ -77,22 +77,9 @@
     fprintf(stderr, "invalid mac address: %s\n", new_mac_addr_str);
     exit(1);
   }
-  
 
-  usrp2_basic_sptr u2 = usrp2_make_basic();
-
-  if (!u2->open(interface)){
-    std::cerr << "couldn't open " << interface << std::endl;
-    return 0;
-  }
-
-  if (!u2->find_usrp_by_mac(old_mac_addr, 0)){
-    std::cerr << "No USRP2 with address "
-             << old_mac_addr << " found.\n";
-    return 1;
-  }
-
-  if (!u2->burn_mac_addr(old_mac_addr, new_mac_addr)){
+  usrp2_basic_sptr u2 = usrp2_make_basic(interface, old_mac_addr);
+  if (!u2->burn_mac_addr(new_mac_addr)){
     std::cerr << "Failed to burn mac address\n";
     return 1;
   }
@@ -103,8 +90,9 @@
   ts.tv_nsec = 250000000;
   nanosleep(&ts, 0);
 
+
   // Now see if we can find it using it's new address
-  if (!u2->find_usrp_by_mac(new_mac_addr, 0)){
+  if (!usrp2_basic::find_usrp_by_mac(interface, new_mac_addr, 0)){
     std::cerr << "Failed to find USRP2 using new address "
              << new_mac_addr << ".\n";
     return 1;

Modified: usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_table.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_table.cc   
2008-05-14 00:11:55 UTC (rev 8418)
+++ usrp2/branches/developers/jcorgan/u2/host/gr-usrp2/usrp2_table.cc   
2008-05-14 01:22:38 UTC (rev 8419)
@@ -60,7 +60,7 @@
         return usrp2_basic_sptr(en->u2);
       }
       catch (boost::bad_weak_ptr e) { // Went out of scope
-        u2 = usrp2_make_basic();
+        u2 = usrp2_make_basic(ifc, addr);
        en->u2 = usrp2_basic_wptr(u2);
        return u2;
       }
@@ -73,7 +73,7 @@
 
   entry_t en;
   en.addr = addr;
-  u2 = usrp2_make_basic();
+  u2 = usrp2_make_basic(ifc, addr);
   en.u2 = usrp2_basic_wptr(u2);
   s_table.push_back(en);
   return u2;

Modified: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc        
2008-05-14 00:11:55 UTC (rev 8418)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.cc        
2008-05-14 01:22:38 UTC (rev 8419)
@@ -25,6 +25,7 @@
 #include "gri_pktfilter.h"
 #include <usrp2_types.h>
 #include <iostream>
+#include <stdexcept>
 #include <math.h>
 #include <time.h>      // debug
 
@@ -54,51 +55,39 @@
                           //   (14-byte ethernet hdr + 1500 byte payload)
 
 usrp2_basic_sptr 
-usrp2_make_basic()
+usrp2_make_basic(const std::string &ifc, const u2_mac_addr_t &addr)
 {
-  return usrp2_basic_sptr(new usrp2_basic());
+  return usrp2_basic_sptr(new usrp2_basic(ifc, addr));
 }
 
-usrp2_basic::usrp2_basic()
+usrp2_basic::usrp2_basic(const std::string &ifc, const u2_mac_addr_t &addr)
   : d_ethernet(new GRI_ETHERNET()), d_pf(0), d_seqno(0), d_next_rid(0)
 {
-  assert(sizeof(u2_eth_samples_t) == (size_t) MAX_PKTLEN);
   if (USRP2_BASIC_DEBUG)
     std::cout << "usrp2_basic: constructor" << std::endl;
+
+  op_id_reply_t r;
+  if (!usrp2_basic::find_usrp_by_mac(ifc, addr, &r))
+    throw std::runtime_error("Unable to find specified USRP2.");
+
+  d_ethernet->open(ifc, htons(U2_ETHERTYPE));
+  d_pf = gri_pktfilter::make_ethertype_inbound(U2_ETHERTYPE, 
d_ethernet->mac());
+  if (!d_ethernet->attach_pktfilter(d_pf))
+    throw std::runtime_error("Unable to attach packet filter.");
+  d_addr = addr;
 }
 
 usrp2_basic::~usrp2_basic()
 {
   if (USRP2_BASIC_DEBUG)
     std::cout << "usrp2_basic: destructor" << std::endl;
+
   delete d_pf;
+
+  d_ethernet->close();
   delete d_ethernet;
 }
 
-bool
-usrp2_basic::open(std::string ifname)
-{
-  if (!d_ethernet->open(ifname, htons(U2_ETHERTYPE)))
-    return false;
-
-  if (d_pf)
-    delete d_pf;
-
-  if (1){
-    d_pf = gri_pktfilter::make_ethertype_inbound(U2_ETHERTYPE, 
d_ethernet->mac());
-    if (!d_ethernet->attach_pktfilter(d_pf))
-      return false;
-  }
-
-  return true;
-}
-
-bool
-usrp2_basic::close()
-{
-  return d_ethernet->close();
-}
-
 // ------------------------------------------------------------------------
 
 // static
@@ -240,7 +229,7 @@
  */
 
 bool
-usrp2_basic::set_rx_gain(const u2_mac_addr_t &which, double gain)
+usrp2_basic::set_rx_gain(double gain)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -252,7 +241,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_CONFIG_RX_V2;
   c->op.len = sizeof(op_config_rx_v2_t);
@@ -274,8 +263,7 @@
 }
 
 bool
-usrp2_basic::set_rx_freq(const u2_mac_addr_t &which, double freq,
-                        usrp2_tune_result *result)
+usrp2_basic::set_rx_freq(double freq, usrp2_tune_result *result)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -287,7 +275,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_CONFIG_RX_V2;
   c->op.len = sizeof(op_config_rx_v2_t);
@@ -314,7 +302,7 @@
 }
 
 bool
-usrp2_basic::set_rx_decim(const u2_mac_addr_t &which, int decimation_factor)
+usrp2_basic::set_rx_decim(int decimation_factor)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -326,7 +314,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_CONFIG_RX_V2;
   c->op.len = sizeof(op_config_rx_v2_t);
@@ -348,7 +336,7 @@
 }
 
 bool
-usrp2_basic::set_rx_scale_iq(const u2_mac_addr_t &which, int scale_i, int 
scale_q)
+usrp2_basic::set_rx_scale_iq(int scale_i, int scale_q)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -360,7 +348,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_CONFIG_RX_V2;
   c->op.len = sizeof(op_config_rx_v2_t);
@@ -382,7 +370,7 @@
 }
 
 bool
-usrp2_basic::start_rx_streaming(const u2_mac_addr_t &which, unsigned int 
items_per_frame)
+usrp2_basic::start_rx_streaming(unsigned int items_per_frame)
 {
   if (items_per_frame == 0)    // provide our default
     items_per_frame = 250;
@@ -397,7 +385,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_START_RX_STREAMING;
   c->op.len = sizeof(op_start_rx_streaming_t);
@@ -414,7 +402,7 @@
 }
 
 bool
-usrp2_basic::stop_rx(const u2_mac_addr_t &which)
+usrp2_basic::stop_rx()
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -425,7 +413,7 @@
   };
     
   command      *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op_stop_rx.opcode = OP_STOP_RX;
   c->op_stop_rx.len = sizeof(op_stop_rx_t);
@@ -443,7 +431,7 @@
  */
 
 bool
-usrp2_basic::set_tx_gain(const u2_mac_addr_t &which, double gain)
+usrp2_basic::set_tx_gain(double gain)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -455,7 +443,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_CONFIG_TX_V2;
   c->op.len = sizeof(op_config_tx_v2_t);
@@ -477,8 +465,7 @@
 }
 
 bool
-usrp2_basic::set_tx_freq(const u2_mac_addr_t &which, double freq,
-                        usrp2_tune_result *result)
+usrp2_basic::set_tx_freq(double freq, usrp2_tune_result *result)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -490,7 +477,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_CONFIG_TX_V2;
   c->op.len = sizeof(op_config_tx_v2_t);
@@ -517,7 +504,7 @@
 }
 
 bool
-usrp2_basic::set_tx_interp(const u2_mac_addr_t &which, int 
interpolation_factor)
+usrp2_basic::set_tx_interp(int interpolation_factor)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -529,7 +516,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_CONFIG_TX_V2;
   c->op.len = sizeof(op_config_tx_v2_t);
@@ -551,7 +538,7 @@
 }
 
 bool
-usrp2_basic::set_tx_scale_iq(const u2_mac_addr_t &which, int scale_i, int 
scale_q)
+usrp2_basic::set_tx_scale_iq(int scale_i, int scale_q)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -563,7 +550,7 @@
   };
 
   command *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_CONFIG_TX_V2;
   c->op.len = sizeof(op_config_tx_v2_t);
@@ -595,8 +582,7 @@
 }
 
 int
-usrp2_basic::read_raw_samples(const u2_mac_addr_t &which,
-                             u2_eth_samples_t *pkt)
+usrp2_basic::read_raw_samples(u2_eth_samples_t *pkt)
 {
   int len = d_ethernet->read_packet(pkt, sizeof(*pkt));
   // printf("read_packet = %d\n", len);
@@ -618,10 +604,9 @@
 }
 
 int
-usrp2_basic::read_samples(const u2_mac_addr_t &which,
-                         u2_eth_samples_t *pkt)
+usrp2_basic::read_samples(u2_eth_samples_t *pkt)
 {
-  int r = read_raw_samples(which, pkt);
+  int r = read_raw_samples(pkt);
 
 #ifndef WORDS_BIGENDIAN
   for (int i = 0; i < r; i++)
@@ -634,13 +619,12 @@
 // ------------------------------------------------------------------------
 
 bool
-usrp2_basic::write_raw_samples(const u2_mac_addr_t &which,
-                              u2_eth_samples_t *pkt, size_t nsamples)
+usrp2_basic::write_raw_samples(u2_eth_samples_t *pkt, size_t nsamples)
 {
   if (nsamples > U2_MAX_SAMPLES)
     return false;
   
-  init_et_hdrs(&pkt->hdrs, which);
+  init_et_hdrs(&pkt->hdrs, d_addr);
 
   size_t len = sizeof(u2_eth_packet_t) + nsamples * sizeof(uint32_t);
   int n = d_ethernet->write_packet(pkt, len);
@@ -654,21 +638,19 @@
 }
 
 bool
-usrp2_basic::write_samples(const u2_mac_addr_t &which,
-                          u2_eth_samples_t *pkt, size_t nsamples)
+usrp2_basic::write_samples(u2_eth_samples_t *pkt, size_t nsamples)
 {
 #ifndef WORDS_BIGENDIAN
   for (size_t i = 0; i < nsamples; i++)
     pkt->samples[i] = htonl(pkt->samples[i]);
 #endif  
 
-  return write_raw_samples(which, pkt, nsamples);
+  return write_raw_samples(pkt, nsamples);
 }
 
 
 bool
-usrp2_basic::burn_mac_addr(const u2_mac_addr_t &which,
-                          const u2_mac_addr_t &new_addr)
+usrp2_basic::burn_mac_addr(const u2_mac_addr_t &new_addr)
 {
   uint8_t      pktbuf[MAX_PKTLEN];
   memset(pktbuf, 0, sizeof(pktbuf));
@@ -679,7 +661,7 @@
   };
     
   command      *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_BURN_MAC_ADDR;
   c->op.len = sizeof(op_burn_mac_addr_t);
@@ -747,7 +729,7 @@
 
 
 bool
-usrp2_basic::read_time(const u2_mac_addr_t &which, uint32_t *time)
+usrp2_basic::read_time(uint32_t *time)
 {
   *time = 0;
 
@@ -760,7 +742,7 @@
   };
     
   command      *c = (command *) pktbuf;
-  init_etf_hdrs(&c->h, which, 0, CONTROL_CHAN, -1);
+  init_etf_hdrs(&c->h, d_addr, 0, CONTROL_CHAN, -1);
 
   c->op.opcode = OP_READ_TIME;
   c->op.len = sizeof(op_read_time_t);

Modified: usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h
===================================================================
--- usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h 2008-05-14 
00:11:55 UTC (rev 8418)
+++ usrp2/branches/developers/jcorgan/u2/host/lib/usrp2_basic.h 2008-05-14 
01:22:38 UTC (rev 8419)
@@ -53,19 +53,20 @@
 class usrp2_basic;
 typedef boost::shared_ptr<usrp2_basic> usrp2_basic_sptr;
 
-usrp2_basic_sptr usrp2_make_basic();
+usrp2_basic_sptr usrp2_make_basic(const std::string &ifc, const u2_mac_addr_t 
&addr);
 
 class usrp2_basic : public boost::noncopyable
 {
 private:
-  friend usrp2_basic_sptr usrp2_make_basic();
-  usrp2_basic();
+  friend usrp2_basic_sptr usrp2_make_basic(const std::string &ifc, const 
u2_mac_addr_t &addr);
+  usrp2_basic(const std::string &ifc, const u2_mac_addr_t &addr);
   
   GRI_ETHERNET *d_ethernet;
   gri_pktfilter        *d_pf;
   int           d_seqno;
   int           d_next_rid;
-
+  u2_mac_addr_t  d_addr;
+  
   void init_et_hdrs(u2_eth_packet_t *p, const u2_mac_addr_t &dst);
 
   void init_etf_hdrs(u2_eth_packet_t *p,
@@ -125,65 +126,36 @@
 
   ~usrp2_basic();
 
-  /*!
-   * \param ifname interface name, e.g., "eth0"
-   */
-  bool open(std::string ifname = "eth0");
-  bool close();
-
   /*
    * Rx configuration and control
    */
-  bool set_rx_gain(const u2_mac_addr_t &which, double gain);
-  bool set_rx_freq(const u2_mac_addr_t &which, double frequency, 
usrp2_tune_result *result);
-  bool set_rx_decim(const u2_mac_addr_t &which, int decimation_factor);
-  bool set_rx_scale_iq(const u2_mac_addr_t &which, int scale_i, int scale_q);
+  bool set_rx_gain(double gain);
+  bool set_rx_freq(double frequency, usrp2_tune_result *result);
+  bool set_rx_decim(int decimation_factor);
+  bool set_rx_scale_iq(int scale_i, int scale_q);
 
   //! start streaming Rx samples
-  bool start_rx_streaming(const u2_mac_addr_t &which, unsigned int 
items_per_frame=0);
+  bool start_rx_streaming(unsigned int items_per_frame=0);
 
   //! stop streaming Rx samples
-  bool stop_rx(const u2_mac_addr_t &which);
+  bool stop_rx();
 
-  
+
   /*
    * Tx configuration and control
    */
-  bool set_tx_gain(const u2_mac_addr_t &which, double gain);
-  bool set_tx_freq(const u2_mac_addr_t &which, double frequency, 
usrp2_tune_result *result);
-  bool set_tx_interp(const u2_mac_addr_t &which, int interpolation_factor);
-  bool set_tx_scale_iq(const u2_mac_addr_t &which, int scale_i, int scale_q);
+  bool set_tx_gain(double gain);
+  bool set_tx_freq(double frequency, usrp2_tune_result *result);
+  bool set_tx_interp(int interpolation_factor);
+  bool set_tx_scale_iq(int scale_i, int scale_q);
   
-
-#if 0
-  bool start_rx(const u2_mac_addr_t &which,
-               double freq,
-               unsigned int decim,
-               unsigned int total_samples,     // 0 to begin streaming, or [9, 
2**21 - 1]
-               unsigned int samples_per_frame, // [9, 372] or [9, 506] if 
MTU==2034
-               int scale_i,                    // 16.0 fixed point format
-               int scale_q,                    // 16.0 fixed point format
-               bool rx_now = true,             // if true begin receiving now
-               uint32_t rx_time = -1           // otherwise begin receiving at 
rx_time
-               );
-
-
-  bool config_tx(const u2_mac_addr_t &which,
-                double freq,
-                unsigned int interp,
-                int scale_i,                   // 16.0 fixed point format
-                int scale_q                    // 16.0 fixed point format
-                );
-#endif
-
   /*!
    * \brief Read raw samples from USRP2.
    *
    * \param pkt contains the raw (non-endian corrected) samples
    * \returns number of valid samples in pkt.
    */
-  int read_raw_samples(const u2_mac_addr_t &which,
-                      u2_eth_samples_t *pkt);
+  int read_raw_samples(u2_eth_samples_t *pkt);
 
   /*!
    * \brief Read native-endian samples from USRP2.
@@ -191,8 +163,7 @@
    * \param pkt contains native-endian samples.
    * \returns number of valid samples in pkt.
    */
-  int read_samples(const u2_mac_addr_t &which,
-                  u2_eth_samples_t *pkt);
+  int read_samples(u2_eth_samples_t *pkt);
 
   /*!
    * \brief Write raw samples to USRP2.
@@ -205,8 +176,7 @@
    *
    * \returns true iff successful
    */
-  bool write_raw_samples(const u2_mac_addr_t &which,
-                        u2_eth_samples_t *pkt, size_t nsamples);
+  bool write_raw_samples(u2_eth_samples_t *pkt, size_t nsamples);
 
   /*!
    * \brief Write native-endian samples to USRP2.
@@ -219,8 +189,7 @@
    *
    * \returns true iff successful
    */
-  bool write_samples(const u2_mac_addr_t &which,
-                    u2_eth_samples_t *pkt, size_t nsamples);
+  bool write_samples(u2_eth_samples_t *pkt, size_t nsamples);
 
 
   /*!
@@ -229,11 +198,10 @@
    * N.B., this interface will probably change.
    * We're using it now for testing only.
    */
-  bool read_time(const u2_mac_addr_t &which, uint32_t *time);
+  bool read_time(uint32_t *time);
   
 
-  bool burn_mac_addr(const u2_mac_addr_t &which,
-                    const u2_mac_addr_t &new_addr);
+  bool burn_mac_addr(const u2_mac_addr_t &new_addr);
 
 
   //! Return frequency of master oscillator on USRP2.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]