use abstract "address" instead of explicit device name

This commit is contained in:
Dimitri Stolnikov 2012-01-13 22:28:14 +01:00
parent 3dd0f54a5b
commit 2beba60c27
6 changed files with 27 additions and 23 deletions

View File

@ -11,9 +11,13 @@
class osmosdr_control
{
public:
osmosdr_control(const std::string &device_name);
osmosdr_control(const std::string &addr);
virtual ~osmosdr_control();
/*!
* Discovers all devices connected to the host computer.
* \return a vector of device addresses
*/
static std::vector< std::string > find_devices();
protected:
@ -27,7 +31,7 @@ protected:
class osmosdr_rx_control : public osmosdr_control
{
public:
osmosdr_rx_control(const std::string &device_name);
osmosdr_rx_control(const std::string &addr);
virtual ~osmosdr_rx_control();
#if 0
/*!
@ -179,7 +183,7 @@ public:
class osmosdr_tx_control : public osmosdr_control
{
public:
osmosdr_tx_control(const std::string &device_name);
osmosdr_tx_control(const std::string &addr);
virtual ~osmosdr_tx_control();
/*! TODO: add more */

View File

@ -48,7 +48,7 @@ typedef boost::shared_ptr<osmosdr_sink_c> osmosdr_sink_c_sptr;
* constructor is private. osmosdr_make_sink_c is the public
* interface for creating new instances.
*/
OSMOSDR_API osmosdr_sink_c_sptr osmosdr_make_sink_c (const std::string & device_name = "");
OSMOSDR_API osmosdr_sink_c_sptr osmosdr_make_sink_c (const std::string & addr = "");
/*!
* \brief Takes a stream of complex samples.
@ -63,12 +63,12 @@ private:
// The friend declaration allows osmosdr_make_sink_c to
// access the private constructor.
friend OSMOSDR_API osmosdr_sink_c_sptr osmosdr_make_sink_c (const std::string & device_name);
friend OSMOSDR_API osmosdr_sink_c_sptr osmosdr_make_sink_c (const std::string & addr);
/*!
* \brief Takes a stream of complex samples.
*/
osmosdr_sink_c (const std::string & device_name); // private constructor
osmosdr_sink_c (const std::string & addr); // private constructor
public:
~osmosdr_sink_c (); // public destructor

View File

@ -48,7 +48,7 @@ typedef boost::shared_ptr<osmosdr_source_c> osmosdr_source_c_sptr;
* constructor is private. osmosdr_make_source_c is the public
* interface for creating new instances.
*/
OSMOSDR_API osmosdr_source_c_sptr osmosdr_make_source_c (const std::string & device_name = "");
OSMOSDR_API osmosdr_source_c_sptr osmosdr_make_source_c (const std::string & addr = "");
/*!
* \brief Provides a stream of complex samples.
@ -63,12 +63,12 @@ private:
// The friend declaration allows osmosdr_make_source_c to
// access the private constructor.
friend OSMOSDR_API osmosdr_source_c_sptr osmosdr_make_source_c (const std::string & device_name);
friend OSMOSDR_API osmosdr_source_c_sptr osmosdr_make_source_c (const std::string & addr);
/*!
* \brief Provides a stream of complex samples.
*/
osmosdr_source_c (const std::string & device_name); // private constructor
osmosdr_source_c (const std::string & addr); // private constructor
public:
~osmosdr_source_c (); // public destructor

View File

@ -1,11 +1,11 @@
#include "osmosdr_control.h"
osmosdr_control::osmosdr_control(const std::string &device_name)
osmosdr_control::osmosdr_control(const std::string &addr)
{
/* lookup acm control channel device name for a given alsa device name */
/*
if (device_name.empty())
if (addr.empty())
pick first available device or throw an exception();
*/
}
@ -31,8 +31,8 @@ std::string osmosdr_control::control_dev_name()
return "/dev/ttyUSB0";
}
osmosdr_rx_control::osmosdr_rx_control(const std::string &device_name) :
osmosdr_control(device_name)
osmosdr_rx_control::osmosdr_rx_control(const std::string &addr) :
osmosdr_control(addr)
{
}
@ -40,8 +40,8 @@ osmosdr_rx_control::~osmosdr_rx_control()
{
}
osmosdr_tx_control::osmosdr_tx_control(const std::string &device_name) :
osmosdr_control(device_name)
osmosdr_tx_control::osmosdr_tx_control(const std::string &addr) :
osmosdr_control(addr)
{
}

View File

@ -39,9 +39,9 @@
* a boost shared_ptr. This is effectively the public constructor.
*/
osmosdr_sink_c_sptr
osmosdr_make_sink_c (const std::string &device_name)
osmosdr_make_sink_c (const std::string &addr)
{
return gnuradio::get_initial_sptr(new osmosdr_sink_c (device_name));
return gnuradio::get_initial_sptr(new osmosdr_sink_c (addr));
}
/*
@ -61,11 +61,11 @@ static const int MAX_OUT = 0; // maximum number of output streams
/*
* The private constructor
*/
osmosdr_sink_c::osmosdr_sink_c (const std::string & device_name)
osmosdr_sink_c::osmosdr_sink_c (const std::string & addr)
: gr_hier_block2 ("osmosdr_sink_c",
gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)),
gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex))),
osmosdr_tx_control(device_name)
osmosdr_tx_control(addr)
{
throw std::runtime_error("FIXME: OsmoSDR sink is not yet implemented");

View File

@ -39,9 +39,9 @@
* a boost shared_ptr. This is effectively the public constructor.
*/
osmosdr_source_c_sptr
osmosdr_make_source_c (const std::string &device_name)
osmosdr_make_source_c (const std::string &addr)
{
return gnuradio::get_initial_sptr(new osmosdr_source_c (device_name));
return gnuradio::get_initial_sptr(new osmosdr_source_c (addr));
}
/*
@ -61,11 +61,11 @@ static const int MAX_OUT = 1; // maximum number of output streams
/*
* The private constructor
*/
osmosdr_source_c::osmosdr_source_c (const std::string &device_name)
osmosdr_source_c::osmosdr_source_c (const std::string &addr)
: gr_hier_block2 ("osmosdr_source_c",
gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)),
gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex))),
osmosdr_rx_control(device_name)
osmosdr_rx_control(addr)
{
/* Audio source; sample rate is 96kHz by default */
audio_source::sptr src = audio_make_source(96000, audio_dev_name(), true);