projects
/
debian
/
gnuradio
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
158caea
)
Intermediate fix to simplify usrp_one_time_init api
author
ttsou
<ttsou@vt.edu>
Wed, 9 Sep 2009 18:46:57 +0000
(14:46 -0400)
committer
ttsou
<ttsou@vt.edu>
Wed, 16 Sep 2009 21:08:51 +0000
(17:08 -0400)
usrp/host/apps/usrper.cc
patch
|
blob
|
history
usrp/host/include/usrp/usrp_prims.h.in
patch
|
blob
|
history
usrp/host/lib/usrp_basic_libusb1.cc
patch
|
blob
|
history
usrp/host/lib/usrp_prims_libusb.cc
patch
|
blob
|
history
usrp/host/lib/usrp_prims_libusb1.cc
patch
|
blob
|
history
diff --git
a/usrp/host/apps/usrper.cc
b/usrp/host/apps/usrper.cc
index 9c6403c9d64f623a7d9d05729a01f5f688ebb9f4..f8e98341ff3e070bda229bf642199bd31247ddf7 100644
(file)
--- 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
*/
* 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>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@
-34,7
+38,6
@@
char *prog_name;
char *prog_name;
-
static void
set_progname (char *path)
{
static void
set_progname (char *path)
{
@@
-191,10
+194,10
@@
main (int argc, char **argv)
const char *cmd = argv[optind++];
nopts--;
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);
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 5e3df3389d39c009fe3cf1708beb499754b3440e..bf71e3b88c6e0c57fcf6cb79f0ab40f56d0ce4e8 100644
(file)
--- 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.
*/
* 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
/*
* 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 6c22b5c6f2f95c92ba5392130ab8084a796e62e0..b1e3a5e3ee3d8d01d36366f7e05cd2454ce48667 100644
(file)
--- 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));
*/
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");
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
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 716e9fd70cba1d4beb132a86d8dc2d3cf73b4c6b..4c826fa558c7762404e7f9d4bcd34a1f72134fdc 100644
(file)
--- 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>
#include "std_paths.h"
#include <stdio.h>
+/*
void
usrp_one_time_init ()
{
static bool first = true;
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 ();
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 a99adafb3ecd3b7b617fada34d5bc3693b3ab35d..d75430fe35287eadd3d02f72b8e70d00948ad8ef 100644
(file)
--- 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>
#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)
{
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
// 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;
if (first) {
first = false;
@@
-89,6
+107,7
@@
usrp_one_time_init (bool new_context)
return ctx;
}
return ctx;
}
+*/
void
usrp_rescan ()
void
usrp_rescan ()