discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] How to write USB 2.0 interface for Windows in C++?


From: Ujala Qasim
Subject: [Discuss-gnuradio] How to write USB 2.0 interface for Windows in C++?
Date: Mon, 2 Feb 2009 17:22:23 +0500

Hi,

I am trying to capture USB 2.0 packets sent over by the USRP in a C++ program. I was able to found a code that does the similar job in Linux:

#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;
}


I was able to successfully achieve my goal through this code in Linux. However, I need to implement the same task in Windows. I was initially suggested to look for usrp_standard.h but I have no idea how to write a code (like the one above) which will incorporate this header file and be able to do the actual communication. Please provide me with some guidelines in this regard.

Thanks.
Ujala

reply via email to

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