int d_data_port; // our data port number
vrt::rx::sptr d_rx; // has-a rx
- int d_band_select; // band select setting
+ std::string d_band_select; // band select setting
int d_rx_antenna; // antenna type rf/cal
int d_attenuation0; // attenuation setting
int d_attenuation1; // attenuation setting
/* convenience methods that ultimately write the dboard pins */
bool set_center_freq(double target_freq);
bool set_band_select(const std::string &band);
+ std::string get_band_select(void){return d_band_select;}
//void set_10dB_atten(bool on);
bool set_attenuation0(int attenuation);
bool select_rx_antenna(const std::string &ant);
vrt::quadradio::quadradio(const std::string &ip, size_t rx_bufsize)
: d_ctrl_fd(0), d_data_fd(0), d_data_port(0),
- d_band_select(0), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true)
+ d_band_select("A"), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true)
{
if (!open(ip.c_str()))
throw std::runtime_error("vrt::quadradio: failed to open " + ip + "\n");
bool
vrt::quadradio::set_band_select(const std::string &band){
- if (band == "A") d_band_select = 3;
- else if (band == "B") d_band_select = 2;
- else if (band == "C") d_band_select = 1;
- else if (band == "D") d_band_select = 0;
- else return false;
+ d_band_select = band;
update_dboard_pins();
return true;
}
void
vrt::quadradio::update_dboard_pins(void){
+ //convert the band ID to bits
+ int band_select;
+ if (d_band_select == "A") band_select = 3;
+ else if (d_band_select == "B") band_select = 2;
+ else if (d_band_select == "C") band_select = 1;
+ else if (d_band_select == "D") band_select = 0;
+ //calculate the control bits
int db_ctrl = \
- ((reverse_bits(d_attenuation0, 5) & 0x1f) << 10) | \
+ ((reverse_bits(d_attenuation0, 5) & 0x1f) << 10) | \
((reverse_bits(~d_attenuation1, 5) & 0x1f) << 03) | \
- ((d_band_select & 0x03) << 01) | \
- ((d_rx_antenna & 0x01) << 00);
+ ((band_select & 0x03) << 01) | \
+ ((d_rx_antenna & 0x01) << 00);
set_dboard_pins(ALL_DBOARDS, db_ctrl); // FIXME sets them all
}