move set_antennas() from UHD to generic radioDevice base class

Change-Id: I806143e9db21f0be4dcc6a376b3a630be7aeb3ba
This commit is contained in:
Harald Welte 2018-06-13 19:32:15 +02:00
parent ff4418539c
commit 2407314f2e
4 changed files with 29 additions and 33 deletions

View File

@ -196,8 +196,6 @@ public:
inline double numberWritten() {
return samplesWritten;
}
std::vector < std::string > tx_paths, rx_paths;
};
#endif // _LMS_DEVICE_H_

View File

@ -19,6 +19,7 @@
#include <vector>
#include "GSMCommon.h"
#include "Logger.h"
extern "C" {
#include "config_defs.h"
@ -163,6 +164,34 @@ class RadioDevice {
virtual double numberRead()=0;
virtual double numberWritten()=0;
std::vector<std::string> tx_paths, rx_paths;
bool set_antennas() {
unsigned int i;
for (i = 0; i < tx_paths.size(); i++) {
if (tx_paths[i] == "")
continue;
LOG(DEBUG) << "Configuring channel " << i << " with antenna " << tx_paths[i];
if (!setTxAntenna(tx_paths[i], i)) {
LOG(ALERT) << "Failed configuring channel " << i << " with antenna " << tx_paths[i];
return false;
}
}
for (i = 0; i < rx_paths.size(); i++) {
if (rx_paths[i] == "")
continue;
LOG(DEBUG) << "Configuring channel " << i << " with antenna " << rx_paths[i];
if (!setRxAntenna(rx_paths[i], i)) {
LOG(ALERT) << "Failed configuring channel " << i << " with antenna " << rx_paths[i];
return false;
}
}
LOG(INFO) << "Antennas configured successfully";
return true;
}
};
#endif

View File

@ -291,7 +291,6 @@ private:
std::vector<double> tx_gains, rx_gains;
std::vector<double> tx_freqs, rx_freqs;
std::vector<std::string> tx_paths, rx_paths;
size_t tx_spp, rx_spp;
bool started;
@ -307,7 +306,6 @@ private:
void init_gains();
void set_channels(bool swap);
void set_rates();
bool set_antennas();
bool parse_dev_type();
bool flush_recv(size_t num_pkts);
int check_rx_md_err(uhd::rx_metadata_t &md, ssize_t num_smpls);
@ -458,33 +456,6 @@ void uhd_device::set_rates()
LOG(INFO) << "Rates configured for " << desc.str;
}
bool uhd_device::set_antennas()
{
unsigned int i;
for (i = 0; i < tx_paths.size(); i++) {
if (tx_paths[i] == "")
continue;
LOG(DEBUG) << "Configuring channel " << i << " with antenna " << tx_paths[i];
if (!setTxAntenna(tx_paths[i], i)) {
LOG(ALERT) << "Failed configuring channel " << i << " with antenna " << tx_paths[i];
return false;
}
}
for (i = 0; i < rx_paths.size(); i++) {
if (rx_paths[i] == "")
continue;
LOG(DEBUG) << "Configuring channel " << i << " with antenna " << rx_paths[i];
if (!setRxAntenna(rx_paths[i], i)) {
LOG(ALERT) << "Failed configuring channel " << i << " with antenna " << rx_paths[i];
return false;
}
}
LOG(INFO) << "Antennas configured successfully";
return true;
}
double uhd_device::setTxGain(double db, size_t chan)
{
if (iface == MULTI_ARFCN)

View File

@ -203,8 +203,6 @@ private:
inline double getSampleRate() { return actualSampleRate; }
inline double numberRead() { return samplesRead; }
inline double numberWritten() { return samplesWritten; }
std::vector<std::string> tx_paths, rx_paths;
};
#endif // _USRP_DEVICE_H_