summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usrp/host/apps/usrper.cc9
-rw-r--r--usrp/host/include/usrp/usrp_prims.h.in4
-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
5 files changed, 57 insertions, 11 deletions
diff --git a/usrp/host/apps/usrper.cc b/usrp/host/apps/usrper.cc
index 9c6403c9d..f8e98341f 100644
--- a/usrp/host/apps/usrper.cc
+++ b/usrp/host/apps/usrper.cc
@@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -34,7 +38,6 @@
char *prog_name;
-
static void
set_progname (char *path)
{
@@ -191,10 +194,10 @@ main (int argc, char **argv)
const char *cmd = argv[optind++];
nopts--;
- libusb_context *ctx = usrp_one_time_init (true);
+ usrp_one_time_init ();
- struct libusb_device *udev = usrp_find_device (which_board, fx2_ok_p, ctx);
+ struct libusb_device *udev = usrp_find_device (which_board, fx2_ok_p);
if (udev == 0){
fprintf (stderr, "%s: failed to find usrp[%d]\n", prog_name, which_board);
exit (1);
diff --git a/usrp/host/include/usrp/usrp_prims.h.in b/usrp/host/include/usrp/usrp_prims.h.in
index 5e3df3389..bf71e3b88 100644
--- a/usrp/host/include/usrp/usrp_prims.h.in
+++ b/usrp/host/include/usrp/usrp_prims.h.in
@@ -11,9 +11,9 @@ enum usrp_load_status_t { ULS_ERROR = 0, ULS_OK, ULS_ALREADY_LOADED };
* initiated and return NULL. It is NOT safe to call more than once with
* new_context set to true since a new context is initiated each time.
*/
-libusb_context* usrp_one_time_init (bool new_context);
-void usrp_one_time_init ();
+//libusb_context* usrp_one_time_init (bool new_context);
+void usrp_one_time_init (libusb_context **ctx = NULL);
/*
* force a rescan of the buses and devices
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 ()