3 * Copyright 2003 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
29 * This is bad, but it works for now. The fusb header files are not installed.
37 struct libusb_device_handle;
39 struct usb_dev_handle;
40 typedef usb_dev_handle libusb_device_handle;
43 struct libusb_context;
47 * \brief abstract usb device handle
49 class fusb_devhandle {
52 fusb_devhandle (const fusb_devhandle &rhs); // no copy constructor
53 fusb_devhandle &operator= (const fusb_devhandle &rhs); // no assignment operator
56 libusb_device_handle *d_udh;
60 fusb_devhandle (libusb_device_handle *udh);
61 virtual ~fusb_devhandle ();
66 * \brief return an ephandle of the correct subtype
68 virtual fusb_ephandle *make_ephandle (int endpoint, bool input_p,
69 int block_size = 0, int nblocks = 0) = 0;
72 libusb_device_handle *get_usb_dev_handle () const { return d_udh; }
77 * \brief abstract usb end point handle
82 fusb_ephandle (const fusb_ephandle &rhs); // no copy constructor
83 fusb_ephandle &operator= (const fusb_ephandle &rhs); // no assignment operator
93 fusb_ephandle (int endpoint, bool input_p,
94 int block_size = 0, int nblocks = 0);
95 virtual ~fusb_ephandle ();
97 virtual bool start () = 0; //!< begin streaming i/o
98 virtual bool stop () = 0; //!< stop streaming i/o
101 * \returns \p nbytes if write was successfully enqueued, else -1.
102 * Will block if no free buffers available.
104 virtual int write (const void *buffer, int nbytes) = 0;
107 * \returns number of bytes read or -1 if error.
108 * number of bytes read will be <= nbytes.
109 * Will block if no input available.
111 virtual int read (void *buffer, int nbytes) = 0;
114 * block until all outstanding writes have completed
116 virtual void wait_for_completion () = 0;
119 * \brief returns current block size.
121 int block_size () { return d_block_size; };
126 * \brief factory for creating concrete instances of the appropriate subtype.
128 class fusb_sysconfig {
131 * \brief returns fusb_devhandle or throws if trouble
133 static fusb_devhandle *make_devhandle (libusb_device_handle *udh,
134 libusb_context *ctx = 0);
137 * \brief Returns max block size in bytes (hard limit).
139 static int max_block_size ();
142 * \brief Returns default block size in bytes.
144 static int default_block_size ();
147 * \brief Returns the default buffer size in bytes.
149 static int default_buffer_size ();
153 #endif /* _FUSB_H_ */