21 #ifndef INCLUDED_BLADERF_COMMON_H 22 #define INCLUDED_BLADERF_COMMON_H 29 #include <boost/thread/mutex.hpp> 30 #include <boost/weak_ptr.hpp> 32 #include <libbladeRF.h> 41 typedef ptrdiff_t ssize_t;
44 #define BLADERF_DEBUG_ENABLE 46 typedef boost::shared_ptr<struct bladerf> bladerf_sptr;
63 #define BLADERF_THROW(message) \ 65 throw std::runtime_error(std::string(__FUNCTION__) + ": " + message); \ 68 #define BLADERF_THROW_STATUS(status, message) \ 70 BLADERF_THROW(boost::str(boost::format("%s: %s (%d)") % message \ 71 % bladerf_strerror(status) % status)); \ 75 #define BLADERF_WARNING(message) \ 77 std::cerr << _pfx << __FUNCTION__ << ": " << message << std::endl; \ 80 #define BLADERF_WARN_STATUS(status, message) \ 82 BLADERF_WARNING(message << ": " << bladerf_strerror(status)); \ 86 #define BLADERF_INFO(message) \ 88 std::cout << _pfx << __FUNCTION__ << ": " << message << std::endl; \ 92 #ifdef BLADERF_DEBUG_ENABLE 93 #define BLADERF_DEBUG(message) BLADERF_INFO("DEBUG: " << message) 95 #define BLADERF_DEBUG(message) 96 #endif // BLADERF_DEBUG_ENABLE 154 void init(
dict_t const &dict, bladerf_direction direction);
157 static std::vector<std::string>
devices();
170 bladerf_channel
str2channel(std::string
const &ch);
177 bladerf_channel
chan2channel(bladerf_direction direction,
size_t chan = 0);
210 bladerf_gain_mode agc_mode = BLADERF_GAIN_DEFAULT);
215 double set_gain(
double gain, bladerf_channel ch);
217 double set_gain(
double gain, std::string
const &name, bladerf_channel ch);
219 double get_gain(bladerf_channel ch);
221 double get_gain(std::string
const &name, bladerf_channel ch);
224 std::vector<std::string>
get_antennas(bladerf_direction dir);
225 bool set_antenna(bladerf_direction dir,
size_t chan,
const std::string &antenna);
228 int set_dc_offset(std::complex<double>
const &offset, bladerf_channel ch);
230 int set_iq_balance(std::complex<double>
const &balance, bladerf_channel ch);
277 bladerf_sptr open(
const std::string &device_name);
279 static void close(
void *dev);
281 static bladerf_sptr get_cached_device(
struct bladerf_devinfo devinfo);
283 void print_device_info();
285 bool is_antenna_valid(bladerf_direction dir,
const std::string &antenna);
290 static boost::mutex _devs_mutex;
291 static std::list<boost::weak_ptr<struct bladerf>> _devs;
osmosdr::meta_range_t sample_rates(bladerf_channel ch)
size_t _num_transfers
Definition: bladerf_common.h:253
double get_center_freq(bladerf_channel ch)
std::map< bladerf_channel, int > bladerf_channel_map
Definition: bladerf_common.h:60
bladerf_board_type get_board_type()
bladerf_channel_map _chanmap
Definition: bladerf_common.h:258
std::vector< std::string > get_gain_names(bladerf_channel ch)
size_t _samples_per_buffer
Definition: bladerf_common.h:252
size_t _num_buffers
Definition: bladerf_common.h:251
int set_iq_balance(std::complex< double > const &balance, bladerf_channel ch)
std::string channel2str(bladerf_channel ch)
void set_clock_source(std::string const &source, size_t mboard=0)
Definition: bladerf_common.h:52
bool set_gain_mode(bool automatic, bladerf_channel ch, bladerf_gain_mode agc_mode=BLADERF_GAIN_DEFAULT)
static const unsigned int MAX_CONSECUTIVE_FAILURES
Definition: bladerf_common.h:265
unsigned int _failures
Definition: bladerf_common.h:249
void set_verbosity(std::string const &verbosity)
double set_sample_rate(double rate, bladerf_channel ch)
Definition: bladerf_common.h:50
osmosdr::freq_range_t filter_bandwidths(bladerf_channel ch)
static const int16_t PHASE_SCALE
Definition: bladerf_common.h:270
void init(dict_t const &dict, bladerf_direction direction)
double get_gain(bladerf_channel ch)
bladerf_channel str2channel(std::string const &ch)
Definition: bladerf_common.h:51
std::vector< std::string > get_antennas(bladerf_direction dir)
bool get_channel_enable(bladerf_channel ch)
double get_sample_rate(bladerf_channel ch)
static const int16_t DCOFF_SCALE
Definition: bladerf_common.h:268
double set_gain(double gain, bladerf_channel ch)
size_t get_max_channels(bladerf_direction direction)
std::map< bladerf_channel, bool > bladerf_channel_enable_map
Definition: bladerf_common.h:57
unsigned int _stream_timeout
Definition: bladerf_common.h:254
bladerf_format _format
Definition: bladerf_common.h:256
int set_dc_offset(std::complex< double > const &offset, bladerf_channel ch)
int channel2rfport(bladerf_channel ch)
static const int16_t GAIN_SCALE
Definition: bladerf_common.h:269
Definition: bladerf_common.h:104
double get_bandwidth(bladerf_channel ch)
bool set_antenna(bladerf_direction dir, size_t chan, const std::string &antenna)
double set_bandwidth(double bandwidth, bladerf_channel ch)
bladerf_channel_enable_map _enables
Definition: bladerf_common.h:259
bladerf_channel chan2channel(bladerf_direction direction, size_t chan=0)
osmosdr::gain_range_t get_gain_range(bladerf_channel ch)
osmosdr::freq_range_t freq_range(bladerf_channel ch)
double get_smb_frequency()
std::vector< std::string > get_clock_sources(size_t mboard=0)
bladerf_board_type
Definition: bladerf_common.h:49
bool get_gain_mode(bladerf_channel ch)
std::string _pfx
Definition: bladerf_common.h:248
size_t num_streams(bladerf_channel_layout layout)
std::map< std::string, std::string > dict_t
Definition: arg_helpers.h:35
static std::vector< std::string > devices()
std::string get_clock_source(size_t mboard=0)
bladerf_sptr _dev
Definition: bladerf_common.h:247
void set_smb_frequency(double frequency)
Definition: bladerf_common.h:53
void set_channel_enable(bladerf_channel ch, bool enable)
double set_center_freq(double freq, bladerf_channel ch)