Skip to content

Commit

Permalink
Added BiasT support for default API
Browse files Browse the repository at this point in the history
  • Loading branch information
racerxdl committed Feb 20, 2017
1 parent ffeb385 commit 7a8084b
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 1 deletion.
13 changes: 13 additions & 0 deletions include/osmosdr/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,19 @@ class OSMOSDR_API source : virtual public gr::hier_block2
* \param time_spec the new time
*/
virtual void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec) = 0;


/*!
* Enabled the Bias T (Power Injection) for supported radios.
* \param enabled true for enabled
*/
virtual void set_biast( bool enabled ) = 0;

/*!
* Gets the state of Bias T for supported radios.
*/
virtual bool get_biast() = 0;

};

} /* namespace osmosdr */
Expand Down
9 changes: 9 additions & 0 deletions lib/airspy/airspy_source_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -654,3 +654,12 @@ osmosdr::freq_range_t airspy_source_c::get_bandwidth_range( size_t chan )

return bandwidths;
}

void airspy_source_c::set_biast( bool enabled ) {
airspy_set_rf_bias(_dev, enabled ? 1 : 0);
_biasT = enabled;
}

bool airspy_source_c::get_biast() {
return _biasT;
}
4 changes: 4 additions & 0 deletions lib/airspy/airspy_source_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class airspy_source_c :
double get_bandwidth( size_t chan = 0 );
osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 );

void set_biast( bool enabled );
bool get_biast();

private:
static int _airspy_rx_callback(airspy_transfer* transfer);
int airspy_rx_callback(void *samples, int sample_count);
Expand All @@ -148,6 +151,7 @@ class airspy_source_c :
double _mix_gain;
double _vga_gain;
double _bandwidth;
bool _biasT;
};

#endif /* INCLUDED_AIRSPY_SOURCE_C_H */
11 changes: 11 additions & 0 deletions lib/hackrf/hackrf_source_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ hackrf_source_c::hackrf_source_c (const std::string &args)

_buf_num = _buf_len = _buf_head = _buf_used = _buf_offset = 0;

_biasT = false;

if (dict.count("buffers"))
_buf_num = boost::lexical_cast< unsigned int >( dict["buffers"] );

Expand Down Expand Up @@ -766,3 +768,12 @@ osmosdr::freq_range_t hackrf_source_c::get_bandwidth_range( size_t chan )

return bandwidths;
}

void hackrf_source_c::set_biast( bool enabled ) {
hackrf_set_antenna_enable(_dev, enabled ? 1 : 0);
_biasT = enabled;
}

bool hackrf_source_c::get_biast() {
return _biasT;
}
4 changes: 4 additions & 0 deletions lib/hackrf/hackrf_source_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class hackrf_source_c :
double get_bandwidth( size_t chan = 0 );
osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 );

void set_biast( bool enabled );
bool get_biast();

private:
static int _hackrf_rx_callback(hackrf_transfer* transfer);
int hackrf_rx_callback(unsigned char *buf, uint32_t len);
Expand Down Expand Up @@ -152,6 +155,7 @@ class hackrf_source_c :
double _lna_gain;
double _vga_gain;
double _bandwidth;
bool _biasT;
};

#endif /* INCLUDED_HACKRF_SOURCE_C_H */
2 changes: 1 addition & 1 deletion lib/osmosdr/osmosdr_src_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,4 @@ std::string osmosdr_src_c::set_antenna( const std::string & antenna, size_t chan
std::string osmosdr_src_c::get_antenna( size_t chan )
{
return "RX";
}
}
12 changes: 12 additions & 0 deletions lib/source_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,18 @@ class source_iface
* \param time_spec the new time
*/
virtual void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec) { }

/*!
* Enabled the Bias T (Power Injection) for supported radios.
* \param enabled true for enabled
*/
virtual void set_biast( bool enabled ) { std::cout << "NOT IMPLEMENTED BIAST(" << enabled << ")" << std::endl; }

/*!
* Gets the state of Bias T for supported radios.
*/
virtual bool get_biast() { return false; }

};

#endif // OSMOSDR_SOURCE_IFACE_H
18 changes: 18 additions & 0 deletions lib/source_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,21 @@ void source_impl::set_time_unknown_pps(const osmosdr::time_spec_t &time_spec)
dev->set_time_unknown_pps( time_spec );
}
}


void source_impl::set_biast( bool enabled ) {
BOOST_FOREACH( source_iface *dev, _devs )
{
dev->set_biast(enabled);
}
}

bool source_impl::get_biast() {
BOOST_FOREACH( source_iface *dev, _devs )
{
if (dev->get_biast()) {
return true;
}
}
return false;
}
3 changes: 3 additions & 0 deletions lib/source_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class source_impl : public osmosdr::source
void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec);
void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec);

void set_biast( bool enabled );
bool get_biast();

private:
std::vector< source_iface * > _devs;

Expand Down

0 comments on commit 7a8084b

Please sign in to comment.