Hi,Well I am implementing the given task by picking up selected function
from usrp_prims, usrp_standard, usrp_basic and fusb_generic etc in a program
of my own. As these are just simple classes which define particular
functions, I was confused and could not very much clearly understand that in
which order should I be calling all those functions defined in the above
mentioned classes because they are so inter-related. So I implemented my own
program according to my own understanding (which I am not re-writing, just
picking up function definitions from the classes) which follows these basic
steps:
1. running libusb core functions first:
usb_init(); /* initialize the library */
usb_find_busses(); /* find all busses */
usb_find_devices(); /* find all connected devices */
as done in usrp_primss.cc in usrp_one_time_init()
2. then find the device on the bus and open it using usb_open()
usb_dev_handle *open_dev(void)
{
struct usb_bus *bus;
struct usb_device *device;
for(bus = usb_get_busses(); bus; bus = bus->next)
{
for(device = bus->devices; device; device = device->next)
{
if(device->descriptor.idVendor == MY_VID
&& device->descriptor.idProduct == MY_PID)
{
myDev = device;
return usb_open(device);
}
}
}
return NULL;
}
as done in usrp_prims.cc in struct usb_device *usrp_find_device (int nth,
bool fx2_ok_p)
3. Then open USRP command interface by calling following functions:
if(usb_set_configuration(udh, 1) < 0)
{
printf("error: setting config 1 failed\n");
usb_close(udh);
return 0;
}
if(usb_claim_interface(udh, 0) < 0 )
{
printf("error: claiming interface 0 failed\n");
usb_close(udh);
return 0;
}
as done in usrp_prims.cc in usrp_open_interface (struct usb_device *dev, int
interface, int altinterface) by calling usrp_open_cmd_interface (struct
usb_device *dev)
4. Then open USRP RX interface by calling following functions:
Where bulk_udh is a usb device handle for RX interface.
if(!(bulk_udh = usb_open(myDev)))
{
printf("error: device not found!\n");
return 0;
}
if(usb_set_configuration(bulk_udh, 1) < 0)
{
printf("error: setting config 1 failed\n");
usb_close(bulk_udh);
return 0;
}
if (usb_claim_interface (bulk_udh, USRP_RX_INTERFACE) < 0){
printf("error: claming interface failed!\n");
usb_close (bulk_udh);
return 0;
}
if (usb_set_altinterface (bulk_udh,USRP_RX_ALTINTERFACE) < 0){
printf("error: setting altinterface failed!\n");
usb_release_interface (bulk_udh, USRP_RX_INTERFACE);
usb_close (bulk_udh);
return 0;
}
as done in usrp_prims.cc in usrp_open_interface (struct usb_device *dev, int
interface, int altinterface) by calling usrp_open_rx_interface (struct
usb_device *dev)
but here the bulk_udh fails to claim the interface
5. Then calling the functions:
set_rx_freq (0, 0);
set_nchannels (1);
set_pga (0, 0);
set_mux(0x32103210); // Board A only
set_decim_rate(8);
set_ddc_phase(0,0);
from usrp_standard class
6. And performing bulk read through usb_bulk_read function
Can you please tell me if these sequence of steps is correct? And if I am
going in the right direction?
Thanks.
On Thu, Mar 12, 2009 at 9:54 PM, Eric Blossom <[email protected]> wrote:
> On Thu, Mar 12, 2009 at 09:03:23PM +0500, Ujala Qasim wrote:
> > Hi!
> > I am trying to write a program in C that interfaces between USRP and
> > Windows, this is my initial code:
>
> ...
>
> > However, the claiming of interface always fails on bulk_udh. Please guide
> me
> > in this regard as to what I am doing wrong?
>
> Instead of attempting to rewrite all of the well tested USRP C++ code
> into C, have you considered writing a small shim that would create a C
> friendly interface to the usrp_standard_tx and usrp_standard_rx
> classes? It is possible to write C++ code that can call C++ code, yet
> is callable from C by using the C++ extern "C" { ... } feature.
> Of course the C interface can only use C data types, not C++ classes.
> See a good C++ book for details and/or search for "C linkage".
>
> Please don't ask quesions about how to do this on this list. It has
> nothing to do with GNU Radio in particular, and everything to do with
> generic C and C++ programming. If you're not familiar with C++,
> perhaps you can find a local C++ hacker who can assist you. Another
> approach may be to write your application in the subset of C++ that
> looks pretty much like C...
>
> Eric
>
_______________________________________________
Discuss-gnuradio mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio