1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-09-29 15:30:52 +00:00

Setting AGC mode

This commit is contained in:
Anthony Arnold 2015-05-09 12:53:17 +10:00
parent 1b0dd9e063
commit 6d16921845
3 changed files with 48 additions and 8 deletions

View File

@ -94,19 +94,20 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
// 3. set rx frequency // 3. set rx frequency
signal_source_->set_frequency(freq_); signal_source_->set_frequency(freq_);
// 4. set rx gain // TODO set rx gain
signal_source_->set_agc_mode(true);
/*if (this->AGC_enabled_ == true) /*if (this->AGC_enabled_ == true)
{ {
osmosdr_source_->set_gain_mode(true); signal_source_->set_agc_mode(true);
std::cout << "AGC enabled" << std::endl; std::cout << "AGC enabled" << std::endl;
LOG(INFO) << "AGC enabled"; LOG(INFO) << "AGC enabled";
} }
else else
{ {
osmosdr_source_->set_gain_mode(false); signal_source_->set_agc_mode(false);
osmosdr_source_->set_gain(gain_, 0); signal_source_->set_gain(gain_, 0);
osmosdr_source_->set_if_gain(if_gain_, 0); signal_source_->set_if_gain(if_gain_, 0);
osmosdr_source_->set_bb_gain(rf_gain_, 0);
}*/ }*/
} }
else else

View File

@ -46,7 +46,11 @@ enum {
// command ids // command ids
enum { enum {
CMD_ID_SET_FREQUENCY = 1, CMD_ID_SET_FREQUENCY = 1,
CMD_ID_SET_SAMPLE_RATE = 2 CMD_ID_SET_SAMPLE_RATE = 2,
CMD_ID_SET_GAIN_MODE = 3,
CMD_ID_SET_GAIN = 4,
CMD_ID_SET_IF_GAIN = 6,
CMD_ID_SET_AGC_MODE = 8
}; };
// rtl_tcp command // rtl_tcp command
@ -87,6 +91,24 @@ struct set_sample_rate_command : command {
} }
}; };
// set gain mode command
struct set_gain_mode_command : command {
set_gain_mode_command (bool manual)
: command (CMD_ID_SET_GAIN_MODE, static_cast<unsigned int>( manual ))
{
}
};
// set agc mode command
struct set_agc_mode_command : command {
set_agc_mode_command (bool manual)
: command (CMD_ID_SET_AGC_MODE, static_cast<unsigned int>( manual ))
{
}
};
rtl_tcp_signal_source_c_sptr rtl_tcp_signal_source_c_sptr
rtl_tcp_make_signal_source_c(const std::string &address, rtl_tcp_make_signal_source_c(const std::string &address,
short port) short port)
@ -181,6 +203,22 @@ void rtl_tcp_signal_source_c::set_sample_rate (int sample_rate) {
} }
} }
void rtl_tcp_signal_source_c::set_agc_mode (bool agc) {
boost::system::error_code ec =
set_gain_mode_command (!agc).send (socket_);
if (ec) {
std::cout << "Failed to set gain mode" << std::endl;
LOG (WARNING) << "Failed to set gain mode";
}
ec =
set_agc_mode_command (agc).send (socket_);
if (ec) {
std::cout << "Failed to set gain mode" << std::endl;
LOG (WARNING) << "Failed to set gain mode";
}
}
void void
rtl_tcp_signal_source_c::handle_read (const boost::system::error_code &ec, rtl_tcp_signal_source_c::handle_read (const boost::system::error_code &ec,
size_t bytes_transferred) size_t bytes_transferred)

View File

@ -70,7 +70,8 @@ public:
void set_frequency (int frequency); void set_frequency (int frequency);
void set_sample_rate (int sample_rate); void set_sample_rate (int sample_rate);
void set_agc_mode (bool agc);
private: private:
typedef boost::circular_buffer_space_optimized<float> buffer_type; typedef boost::circular_buffer_space_optimized<float> buffer_type;