#include "fpga_regs_standard.h"
#include "fusb.h"
#include "db_boards.h"
-#include <usb.h>
+#include <libusb-1.0/libusb.h>
#include <stdexcept>
#include <assert.h>
#include <math.h>
////////////////////////////////////////////////////////////////
-static struct usb_dev_handle *
-open_rx_interface (struct usb_device *dev)
+static struct libusb_device_handle *
+open_rx_interface (struct libusb_device *dev)
{
- struct usb_dev_handle *udh = usrp_open_rx_interface (dev);
+ struct libusb_device_handle *udh = usrp_open_rx_interface (dev);
if (udh == 0){
fprintf (stderr, "usrp_basic_rx: can't open rx interface\n");
- usb_strerror ();
}
return udh;
}
-static struct usb_dev_handle *
-open_tx_interface (struct usb_device *dev)
+static struct libusb_device_handle *
+open_tx_interface (struct libusb_device *dev)
{
- struct usb_dev_handle *udh = usrp_open_tx_interface (dev);
+ struct libusb_device_handle *udh = usrp_open_tx_interface (dev);
if (udh == 0){
fprintf (stderr, "usrp_basic_tx: can't open tx interface\n");
- usb_strerror ();
}
return udh;
}
usrp_basic::usrp_basic (int which_board,
- struct usb_dev_handle *
- open_interface (struct usb_device *dev),
+ struct libusb_device_handle *
+ open_interface (struct libusb_device *dev),
const std::string fpga_filename,
const std::string firmware_filename)
: d_udh (0),
if (!usrp_load_standard_bits (which_board, false, fpga_filename, firmware_filename))
throw std::runtime_error ("usrp_basic/usrp_load_standard_bits");
- struct usb_device *dev = usrp_find_device (which_board);
+ struct libusb_device *dev = usrp_find_device (which_board);
if (dev == 0){
fprintf (stderr, "usrp_basic: can't find usrp[%d]\n", which_board);
throw std::runtime_error ("usrp_basic/usrp_find_device");
d_db.resize(0); // forget db shared ptrs
if (d_udh)
- usb_close (d_udh);
+ libusb_close (d_udh);
+
+ // There's no reference count on the number of times libusb is initialized.
+ // libusb_init can be called multiple times, but libusb_exit shuts down
+ // everything. Leave libusb running for now. Need to add a count so that it
+ // exits nicely.
+
+ //libusb_exit (NULL);
}
void
{
if (!set_rx_enable (false)){
fprintf (stderr, "usrp_basic_rx: set_fpga_rx_enable failed\n");
- usb_strerror ();
}
d_ephandle->stop ();
if (!d_ephandle->start ()){
fprintf (stderr, "usrp_basic_rx: failed to start end point streaming");
- usb_strerror ();
return false;
}
if (!set_rx_enable (true)){
fprintf (stderr, "usrp_basic_rx: set_rx_enable failed\n");
- usb_strerror ();
return false;
}
if (!set_rx_enable(false)){
fprintf (stderr, "usrp_basic_rx: set_rx_enable(false) failed\n");
- usb_strerror ();
ok = false;
}
if (!d_ephandle->stop()){
fprintf (stderr, "usrp_basic_rx: failed to stop end point streaming");
- usb_strerror ();
ok = false;
}
d_bytes_seen = 0;
if (!usrp_check_rx_overrun (d_udh, overrun)){
fprintf (stderr, "usrp_basic_rx: usrp_check_rx_overrun failed\n");
- usb_strerror ();
}
}
if (!set_tx_enable (true)){
fprintf (stderr, "usrp_basic_tx: set_tx_enable failed\n");
- usb_strerror ();
return false;
}
if (!d_ephandle->start ()){
fprintf (stderr, "usrp_basic_tx: failed to start end point streaming");
- usb_strerror ();
return false;
}
if (!d_ephandle->stop ()){
fprintf (stderr, "usrp_basic_tx: failed to stop end point streaming");
- usb_strerror ();
ok = false;
}
if (!set_tx_enable (false)){
fprintf (stderr, "usrp_basic_tx: set_tx_enable(false) failed\n");
- usb_strerror ();
ok = false;
}
d_bytes_seen = 0;
if (!usrp_check_tx_underrun (d_udh, underrun)){
fprintf (stderr, "usrp_basic_tx: usrp_check_tx_underrun failed\n");
- usb_strerror ();
}
}