summaryrefslogtreecommitdiff
path: root/usrp/host/lib
diff options
context:
space:
mode:
authorttsou2009-09-09 14:46:57 -0400
committerttsou2009-09-16 17:08:51 -0400
commite6cb4a4c14d9aa92d024727965bd45e68c6620ce (patch)
treea8705202c36e1fcf7d4d88ca823a4de46e419d43 /usrp/host/lib
parent158caeaa92df7ffdf363236985f4b8e7825f3950 (diff)
downloadgnuradio-e6cb4a4c14d9aa92d024727965bd45e68c6620ce.tar.gz
gnuradio-e6cb4a4c14d9aa92d024727965bd45e68c6620ce.tar.bz2
gnuradio-e6cb4a4c14d9aa92d024727965bd45e68c6620ce.zip
Intermediate fix to simplify usrp_one_time_init api
Diffstat (limited to 'usrp/host/lib')
-rw-r--r--usrp/host/lib/usrp_basic_libusb1.cc10
-rw-r--r--usrp/host/lib/usrp_prims_libusb.cc24
-rw-r--r--usrp/host/lib/usrp_prims_libusb1.cc21
3 files changed, 49 insertions, 6 deletions
diff --git a/usrp/host/lib/usrp_basic_libusb1.cc b/usrp/host/lib/usrp_basic_libusb1.cc
index 6c22b5c6f..b1e3a5e3e 100644
--- a/usrp/host/lib/usrp_basic_libusb1.cc
+++ b/usrp/host/lib/usrp_basic_libusb1.cc
@@ -103,7 +103,8 @@ usrp_basic::usrp_basic (int which_board,
*/
memset (d_fpga_shadows, 0, sizeof (d_fpga_shadows));
- d_ctx = usrp_one_time_init(true);
+// d_ctx = usrp_one_time_init(true);
+ usrp_one_time_init (&d_ctx);
if (!usrp_load_standard_bits (which_board, false, fpga_filename, firmware_filename, d_ctx))
throw std::runtime_error ("usrp_basic/usrp_load_standard_bits");
@@ -144,9 +145,10 @@ usrp_basic::~usrp_basic ()
libusb_close (d_udh);
// Each object should be running in it's own context. If running in default
- // (NULL) context then something went wrong.
+ // context then leave the instance open as it may be shared. This might
+ // occur in mixed libusb-0.12 and libusb-1.0 environments.
- assert (d_ctx != NULL);
- libusb_exit (d_ctx);
+ if (d_ctx != NULL)
+ libusb_exit (d_ctx);
}
diff --git a/usrp/host/lib/usrp_prims_libusb.cc b/usrp/host/lib/usrp_prims_libusb.cc
index 716e9fd70..4c826fa55 100644
--- a/usrp/host/lib/usrp_prims_libusb.cc
+++ b/usrp/host/lib/usrp_prims_libusb.cc
@@ -64,12 +64,34 @@ static const char *default_fpga_filename = "std_2rxhb_2tx.rbf";
#include "std_paths.h"
#include <stdio.h>
+/*
void
usrp_one_time_init ()
{
static bool first = true;
- if (first){
+ if (first) {
+ first = false;
+ usb_init (); // usb library init
+ usb_find_busses ();
+ usb_find_devices ();
+ }
+}
+
+libusb_context *
+usrp_one_time_init (bool new_context)
+{
+ usrp_one_time_init ();
+ return NULL;
+}
+*/
+
+void
+usrp_one_time_init (libusb_context **ctx)
+{
+ static bool first = true;
+
+ if (first) {
first = false;
usb_init (); // usb library init
usb_find_busses ();
diff --git a/usrp/host/lib/usrp_prims_libusb1.cc b/usrp/host/lib/usrp_prims_libusb1.cc
index a99adafb3..d75430fe3 100644
--- a/usrp/host/lib/usrp_prims_libusb1.cc
+++ b/usrp/host/lib/usrp_prims_libusb1.cc
@@ -64,6 +64,24 @@ static const char *default_fpga_filename = "std_2rxhb_2tx.rbf";
#include "std_paths.h"
#include <stdio.h>
+/*
+void
+usrp_one_time_init ()
+{
+ usrp_one_time_init (false);
+}
+*/
+
+void
+usrp_one_time_init (libusb_context **ctx)
+{
+ int ret;
+
+ if ((ret = libusb_init (ctx)) < 0)
+ fprintf (stderr, "usrp: libusb_init failed %i\n", ret);
+}
+
+/*
libusb_context *
usrp_one_time_init (bool new_context)
{
@@ -74,7 +92,7 @@ usrp_one_time_init (bool new_context)
// On first call create default context in addition to any new requested
// context. The default context is probably useless in this form, but keep
- // it for now due to compatibility reasons.
+ // it for now due to possible compatibility reasons.
if (first) {
first = false;
@@ -89,6 +107,7 @@ usrp_one_time_init (bool new_context)
return ctx;
}
+*/
void
usrp_rescan ()