discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Re: Definition of USB Interfaces is different in


From: Ujala Qasim
Subject: Re: [Discuss-gnuradio] Re: Definition of USB Interfaces is different in Windows
Date: Sun, 26 Apr 2009 13:29:39 +0600

Eric, I tried implementing the given task of developing a USB interface for Windows by using the following main program that is written for Linux and successfully executes on it. However, when I tried to use the same code with Windows I faced a problem. The code includes usrp_standard.h, which includes further libraries, and like this libraries are nested within libraries. It became very cumbersome for me to download all those usrp libraries manually. Plus, there are some libraries that work with Linux only, like sys/cdefs etc. So only after trying this approach and failing I switched over to the approach of extracting only specific functions from usrp libraries. Is there any other approach that I can try? 

#include "usrp_standard.h"
// Dumy Function to process USRP data
void process_data(int *buffer)
{
}
#define SAMPELS_PER_READ (512) // Must be a multiple of 128
int main (int argc, char **argv)
{
bool loopback_p = false;
bool counting_p = false;
bool width_8_p = false;
int which_board = 0;
int decim = 8; // 32 MB/sec
double center_freq = 0;
int fusb_block_size = 0;
int fusb_nblocks = 0;
int nchannels = 1;
int gain = 0;
int mode = 0;
int noverruns = 0;
bool overrun;
int total_reads = 10000;
int i;
int buf[SAMPELS_PER_READ];
int bufsize = SAMPELS_PER_READ*4;

if (loopback_p) mode |= usrp_standard_rx::FPGA_MODE_LOOPBACK;

if (counting_p) mode |= usrp_standard_rx::FPGA_MODE_COUNTING;

usrp_standard_rx *urx = usrp_standard_rx::make (which_board, decim, 1, -1, mode, fusb_block_size, fusb_nblocks);

if (urx == 0)
{
fprintf (stderr, "Error: usrp_standard_rx::make\n");
exit (1);
}

if (width_8_p)
{
int width = 8;
int shift = 8;
bool want_q = true;
if (!urx->set_format(usrp_standard_rx::make_format(width, shift, want_q)))
{
fprintf (stderr, "Error: urx->set_format\n");
exit (1);
}
}
// Set DDC center frequency
urx->set_rx_freq (0, center_freq);
// Set Number of channels
urx->set_nchannels(1);
// Set ADC PGA gain
urx->set_pga(0,gain);
// Set FPGA Mux
urx->set_mux(0x32103210); // Board A only
// Set DDC decimation rate
urx->set_decim_rate(decim);
// Set DDC phase
urx->set_ddc_phase(0,0);

urx->start(); // Start data transfer

printf("USRP Transfer Started\n");
// Do USRP Samples Reading
for (i = 0; i < total_reads; i++)
{
urx->read(&buf, bufsize, &overrun);
if (overrun)
{
printf ("USRP Rx Overrun\n");
noverruns++;
}
// Do whatever you want with the data
process_data(&buf[0]);
}

urx->stop(); // Stop data transfer
printf("USRP Transfer Stoped\n");

delete urx;
return 0;
}

Thanks.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]