Changeset 9430
- Timestamp:
- 08/26/08 21:47:00
- Files:
-
- usrp2/trunk/host-ng (modified) (1 prop)
- usrp2/trunk/host-ng/Makefile.am (modified) (1 diff)
- usrp2/trunk/host-ng/apps/rx_streaming_samples.cc (modified) (1 diff)
- usrp2/trunk/host-ng/configure.ac (modified) (1 diff)
- usrp2/trunk/host-ng/gr-usrp2 (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2)
- usrp2/trunk/host-ng/gr-usrp2/Makefile.am (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/Makefile.am)
- usrp2/trunk/host-ng/gr-usrp2/test.sh (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test.sh)
- usrp2/trunk/host-ng/gr-usrp2/test_gr_usrp2.cc (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/test_gr_usrp2.cc)
- usrp2/trunk/host-ng/gr-usrp2/usrp2.i (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2.i)
- usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.cc (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_sink_base.cc)
- usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_base.h (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_sink_base.h)
- usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.cc (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_sink_c.cc)
- usrp2/trunk/host-ng/gr-usrp2/usrp2_sink_c.h (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_sink_c.h)
- usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.cc (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_source_base.cc)
- usrp2/trunk/host-ng/gr-usrp2/usrp2_source_base.h (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_source_base.h)
- usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.cc (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_source_c.cc)
- usrp2/trunk/host-ng/gr-usrp2/usrp2_source_c.h (copied) (copied from usrp2/branches/developers/jcorgan/wip/host-ng/gr-usrp2/usrp2_source_c.h)
- usrp2/trunk/host-ng/include/usrp2/usrp2.h (modified) (3 diffs)
- usrp2/trunk/host-ng/lib/usrp2.cc (modified) (4 diffs)
- usrp2/trunk/host-ng/lib/usrp2_impl.h (modified) (2 diffs)
- usrp2/trunk/host/Makefile.am (modified) (1 diff)
- usrp2/trunk/host/configure.ac (modified) (1 diff)
- usrp2/trunk/host/gr-usrp2 (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
usrp2/trunk/host-ng
- Property svn:ignore changed from configure Makefile.in config.log config.status config.guess stamp-h1 config.h ltmain.sh config.sub config.h.in libtool autom4te.cache missing aclocal.m4 Makefile install-sh depcomp usrp2*.tar.gz to configure Makefile.in config.log config.status config.guess stamp-h1 config.h ltmain.sh config.sub config.h.in libtool autom4te.cache missing aclocal.m4 Makefile install-sh depcomp usrp2*.tar.gz py-compile
usrp2/trunk/host-ng/Makefile.am
r8515 r9430 27 27 config.h.in 28 28 29 SUBDIRS = config include lib apps29 SUBDIRS = config include lib gr-usrp2 apps usrp2/trunk/host-ng/apps/rx_streaming_samples.cc
r9215 r9430 356 356 357 357 if (verbose){ 358 printf("USRP2 MAC address: %s\n\n", u2->mac_addr().c_str()); 358 359 printf("Daughterboard configuration:\n"); 359 360 printf(" baseband_freq=%f\n", tr.baseband_freq); usrp2/trunk/host-ng/configure.ac
r9410 r9430 222 222 include/Makefile \ 223 223 include/usrp2/Makefile \ 224 gr-usrp2/Makefile \ 224 225 lib/Makefile \ 225 226 ]) usrp2/trunk/host-ng/include/usrp2/usrp2.h
r9142 r9430 75 75 * \param ifc Network interface name, e.g., "eth0" 76 76 * \param addr Network mac address, e.g., "01:02:03:04:05:06", "05:06" or "". 77 * If \p addr is HH:HH, it's treated as if it were 00:50:c2:85:HH:HH 77 78 * "" will autoselect a USRP2 if there is only a single one on the local ethernet. 78 79 */ … … 83 84 */ 84 85 ~usrp2(); 86 87 /*! 88 * Returns the MAC address associated with this USRP 89 */ 90 const std::string &mac_addr(); 85 91 86 92 /* … … 253 259 bool config_mimo(int flags); 254 260 255 256 257 261 class impl; // implementation details 258 262 259 263 private: 260 // Only usrp2::make factory function can instantiate this class 261 usrp2(const std::string &ifc, const std::string &addr); 264 // Static function to retrieve or create usrp2 instance 265 static sptr find_existing_or_make_new(const std::string &ifc, props *p); 266 267 // Only class members can instantiate this class 268 usrp2(const std::string &ifc, props *p); 262 269 263 270 // All private state is held in opaque pointer usrp2/trunk/host-ng/lib/usrp2.cc
r9411 r9430 49 49 static usrp_table s_table; 50 50 51 static usrp2::sptr 52 find_existing_or_make_new(const std::string &ifc, const std::string &mac_addr) 53 { 54 // FIXME normalize addr 55 56 if (mac_addr.size() != 17) 57 throw std::invalid_argument("invalid mac_addr: " + mac_addr); 58 59 std::string key = ifc + ":" + mac_addr; 51 usrp2::sptr 52 usrp2::find_existing_or_make_new(const std::string &ifc, props *pr) 53 { 54 std::string key = ifc + ":" + pr->addr; 60 55 61 56 boost::mutex::scoped_lock guard(s_table_mutex); … … 75 70 76 71 // create a new one and stick it in the table. 77 usrp2::sptr r = usrp2::make(ifc, mac_addr);72 usrp2::sptr r(new usrp2::usrp2(ifc, pr)); 78 73 usrp_table_entry t(key, r); 79 74 s_table.push_back(t); … … 84 79 // --- end of table code --- 85 80 86 87 // Shared pointer factory function, wraps constructor call 81 static bool 82 parse_mac_addr(const std::string &s, std::string &ns) 83 { 84 u2_mac_addr_t p; 85 86 p.addr[0] = 0x00; // Matt's IAB 87 p.addr[1] = 0x50; 88 p.addr[2] = 0xC2; 89 p.addr[3] = 0x85; 90 p.addr[4] = 0x30; 91 p.addr[5] = 0x00; 92 93 int len = s.size(); 94 switch (len) { 95 96 case 5: 97 if (sscanf(s.c_str(), "%hhx:%hhx", &p.addr[4], &p.addr[5]) != 2) 98 return false; 99 break; 100 101 case 17: 102 if (sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", 103 &p.addr[0], &p.addr[1], &p.addr[2], 104 &p.addr[3], &p.addr[4], &p.addr[5]) != 6) 105 return false; 106 break; 107 108 default: 109 return false; 110 } 111 112 char buf[128]; 113 snprintf(buf, sizeof(buf), 114 "%02x:%02x:%02x:%02x:%02x:%02x", 115 p.addr[0],p.addr[1],p.addr[2], 116 p.addr[3],p.addr[4],p.addr[5]); 117 ns = std::string(buf); 118 return true; 119 } 120 88 121 usrp2::sptr 89 122 usrp2::make(const std::string &ifc, const std::string &addr) 90 123 { 91 return usrp2::sptr(new usrp2(ifc, addr)); 124 std::string naddr = ""; 125 if (addr != "" && !parse_mac_addr(addr, naddr)) 126 throw std::runtime_error("Invalid MAC address"); 127 128 props_vector_t u2s = find(ifc, naddr); 129 if (u2s.size() != 1) 130 throw std::runtime_error("Unable to find requested USRP2."); 131 132 return find_existing_or_make_new(ifc, &u2s[0]); 92 133 } 93 134 94 135 // Private constructor. Sole function is to create an impl. 95 usrp2::usrp2(const std::string &ifc, const std::string &addr)96 : d_impl(new usrp2::impl(ifc, addr))136 usrp2::usrp2(const std::string &ifc, props *p) 137 : d_impl(new usrp2::impl(ifc, p->addr)) 97 138 { 98 139 // NOP … … 105 146 } 106 147 148 const std::string & 149 usrp2::mac_addr() 150 { 151 return d_impl->mac_addr(); 152 } 153 107 154 // Receive 108 155 usrp2/trunk/host-ng/lib/usrp2_impl.h
r9142 r9430 44 44 eth_buffer *d_eth_buf; 45 45 pktfilter *d_pf; 46 std::string d_addr; 46 std::string d_addr; // FIXME: use u2_mac_addr_t instead 47 47 usrp2_thread *d_bg_thread; 48 48 volatile bool d_bg_running; // TODO: multistate if needed … … 95 95 void bg_loop(); 96 96 97 const std::string &mac_addr() const { return d_addr; } // FIXME: convert from u2_mac_addr_t 97 98 bool set_rx_gain(double gain); 98 99 bool set_rx_center_freq(double frequency, tune_result *result); usrp2/trunk/host/Makefile.am
r8391 r9430 27 27 config.h.in 28 28 29 SUBDIRS = config lib gr-usrp2apps29 SUBDIRS = config lib apps usrp2/trunk/host/configure.ac
r8391 r9430 206 206 config/Makefile \ 207 207 apps/Makefile \ 208 gr-usrp2/Makefile \209 208 lib/Makefile \ 210 209 ])
