transceiver: pass cfg struct instead of args
Passing 7 args is a bit much, just pass the config struct instead. Change-Id: I48386900d15ff4d770c70a4efc246d32f921904b
This commit is contained in:
parent
a98521ac05
commit
19e134a626
|
@ -607,7 +607,7 @@ static int config_write_trx(struct vty *vty)
|
|||
vty_out(vty, " remote-ip %s%s", trx->cfg.remote_addr, VTY_NEWLINE);
|
||||
if (trx->cfg.base_port != DEFAULT_TRX_PORT)
|
||||
vty_out(vty, " base-port %u%s", trx->cfg.base_port, VTY_NEWLINE);
|
||||
if (trx->cfg.dev_args)
|
||||
if (strlen(trx->cfg.dev_args))
|
||||
vty_out(vty, " dev-args %s%s", trx->cfg.dev_args, VTY_NEWLINE);
|
||||
if (trx->cfg.tx_sps != DEFAULT_TX_SPS)
|
||||
vty_out(vty, " tx-sps %u%s", trx->cfg.tx_sps, VTY_NEWLINE);
|
||||
|
@ -760,6 +760,7 @@ struct trx_ctx *vty_trx_ctx_alloc(void *talloc_ctx)
|
|||
trx->cfg.rx_sps = DEFAULT_RX_SPS;
|
||||
trx->cfg.filler = FILLER_ZERO;
|
||||
trx->cfg.rssi_offset = 0.0f;
|
||||
trx->cfg.dev_args = "";
|
||||
|
||||
return trx;
|
||||
}
|
||||
|
|
|
@ -84,11 +84,10 @@ static double TxPower2TxGain(const dev_band_desc &desc, double tx_power_dbm)
|
|||
return desc.nom_uhd_tx_gain - (desc.nom_out_tx_power - tx_power_dbm);
|
||||
}
|
||||
|
||||
blade_device::blade_device(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset,
|
||||
const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths)
|
||||
: RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths), dev(nullptr), rx_gain_min(0.0),
|
||||
rx_gain_max(0.0), band_ass_curr_sess(false), band((enum gsm_band)0), tx_spp(0), rx_spp(0), started(false),
|
||||
aligned(false), drop_cnt(0), prev_ts(0), ts_initial(0), ts_offset(0), async_event_thrd(NULL)
|
||||
blade_device::blade_device(InterfaceType iface, const struct trx_cfg *cfg)
|
||||
: RadioDevice(iface, cfg), dev(nullptr), rx_gain_min(0.0), rx_gain_max(0.0), band_ass_curr_sess(false),
|
||||
band((enum gsm_band)0), tx_spp(0), rx_spp(0), started(false), aligned(false), drop_cnt(0), prev_ts(0),
|
||||
ts_initial(0), ts_offset(0), async_event_thrd(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -312,15 +311,15 @@ int blade_device::getNominalTxPower(size_t chan)
|
|||
return desc.nom_out_tx_power;
|
||||
}
|
||||
|
||||
int blade_device::open(const std::string &args, int ref, bool swap_channels)
|
||||
int blade_device::open()
|
||||
{
|
||||
bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_VERBOSE);
|
||||
bladerf_set_usb_reset_on_open(true);
|
||||
auto success = bladerf_open(&dev, args.c_str());
|
||||
auto success = bladerf_open(&dev, cfg->dev_args);
|
||||
if (success != 0) {
|
||||
struct bladerf_devinfo *info;
|
||||
auto num_devs = bladerf_get_device_list(&info);
|
||||
LOGC(DDEV, ALERT) << "No bladerf devices found with identifier '" << args << "'";
|
||||
LOGC(DDEV, ALERT) << "No bladerf devices found with identifier '" << cfg->dev_args << "'";
|
||||
if (num_devs) {
|
||||
for (int i = 0; i < num_devs; i++)
|
||||
LOGC(DDEV, ALERT) << "Found device:" << info[i].product << " serial " << info[i].serial;
|
||||
|
@ -346,7 +345,7 @@ int blade_device::open(const std::string &args, int ref, bool swap_channels)
|
|||
rx_gains.resize(chans);
|
||||
rx_buffers.resize(chans);
|
||||
|
||||
switch (ref) {
|
||||
switch (cfg->clock_ref) {
|
||||
case REF_INTERNAL:
|
||||
case REF_EXTERNAL:
|
||||
break;
|
||||
|
@ -355,7 +354,7 @@ int blade_device::open(const std::string &args, int ref, bool swap_channels)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (ref == REF_EXTERNAL) {
|
||||
if (cfg->clock_ref == REF_EXTERNAL) {
|
||||
bool is_locked;
|
||||
int status = bladerf_set_pll_enable(dev, true);
|
||||
CHKRET()
|
||||
|
@ -374,7 +373,8 @@ int blade_device::open(const std::string &args, int ref, bool swap_channels)
|
|||
}
|
||||
}
|
||||
|
||||
LOGC(DDEV, INFO) << "Selected clock source is " << ((ref == REF_INTERNAL) ? "internal" : "external 10Mhz");
|
||||
LOGC(DDEV, INFO)
|
||||
<< "Selected clock source is " << ((cfg->clock_ref == REF_INTERNAL) ? "internal" : "external 10Mhz");
|
||||
|
||||
set_rates();
|
||||
|
||||
|
@ -687,8 +687,7 @@ double blade_device::fullScaleOutputValue()
|
|||
return (double)2047;
|
||||
}
|
||||
|
||||
RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chans, double lo_offset,
|
||||
const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths)
|
||||
RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg)
|
||||
{
|
||||
return new blade_device(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths);
|
||||
return new blade_device(type, cfg);
|
||||
}
|
||||
|
|
|
@ -54,11 +54,10 @@ struct dev_band_desc {
|
|||
|
||||
class blade_device : public RadioDevice {
|
||||
public:
|
||||
blade_device(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chan_num, double offset,
|
||||
const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths);
|
||||
blade_device(InterfaceType iface, const struct trx_cfg *cfg);
|
||||
~blade_device();
|
||||
|
||||
int open(const std::string &args, int ref, bool swap_channels);
|
||||
int open();
|
||||
bool start();
|
||||
bool stop();
|
||||
bool restart();
|
||||
|
|
|
@ -51,13 +51,10 @@ class RadioDevice {
|
|||
MULTI_ARFCN,
|
||||
};
|
||||
|
||||
static RadioDevice *make(size_t tx_sps, size_t rx_sps, InterfaceType type,
|
||||
size_t chans = 1, double offset = 0.0,
|
||||
const std::vector<std::string>& tx_paths = std::vector<std::string>(1, ""),
|
||||
const std::vector<std::string>& rx_paths = std::vector<std::string>(1, ""));
|
||||
static RadioDevice *make(InterfaceType type, const struct trx_cfg *cfg);
|
||||
|
||||
/** Initialize the USRP */
|
||||
virtual int open(const std::string &args, int ref, bool swap_channels)=0;
|
||||
virtual int open() = 0;
|
||||
|
||||
virtual ~RadioDevice() { }
|
||||
|
||||
|
@ -164,23 +161,30 @@ class RadioDevice {
|
|||
double lo_offset;
|
||||
std::vector<std::string> tx_paths, rx_paths;
|
||||
std::vector<struct device_counters> m_ctr;
|
||||
const struct trx_cfg *cfg;
|
||||
|
||||
RadioDevice(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chan_num, double offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths):
|
||||
tx_sps(tx_sps), rx_sps(rx_sps), iface(type), chans(chan_num), lo_offset(offset),
|
||||
tx_paths(tx_paths), rx_paths(rx_paths), m_ctr(chans)
|
||||
{
|
||||
if (iface == MULTI_ARFCN) {
|
||||
LOGC(DDEV, INFO) << "Multi-ARFCN: "<< chan_num << " logical chans -> 1 physical chans";
|
||||
chans = 1;
|
||||
}
|
||||
#define charp2str(a) ((a) ? std::string(a) : std::string(""))
|
||||
|
||||
for (size_t i = 0; i < chans; i++) {
|
||||
memset(&m_ctr[i], 0, sizeof(m_ctr[i]));
|
||||
m_ctr[i].chan = i;
|
||||
}
|
||||
}
|
||||
RadioDevice(InterfaceType type, const struct trx_cfg *cfg)
|
||||
: tx_sps(cfg->tx_sps), rx_sps(cfg->rx_sps), iface(type), chans(cfg->num_chans), lo_offset(cfg->offset),
|
||||
m_ctr(chans), cfg(cfg)
|
||||
{
|
||||
/* Generate vector of rx/tx_path: */
|
||||
for (unsigned int i = 0; i < cfg->num_chans; i++) {
|
||||
rx_paths.push_back(charp2str(cfg->chans[i].rx_path));
|
||||
tx_paths.push_back(charp2str(cfg->chans[i].tx_path));
|
||||
}
|
||||
|
||||
if (iface == MULTI_ARFCN) {
|
||||
LOGC(DDEV, INFO) << "Multi-ARFCN: " << chans << " logical chans -> 1 physical chans";
|
||||
chans = 1;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < chans; i++) {
|
||||
memset(&m_ctr[i], 0, sizeof(m_ctr[i]));
|
||||
m_ctr[i].chan = i;
|
||||
}
|
||||
}
|
||||
|
||||
bool set_antennas() {
|
||||
unsigned int i;
|
||||
|
|
|
@ -56,11 +56,10 @@ using namespace std;
|
|||
|
||||
static int ipc_chan_sock_cb(struct osmo_fd *bfd, unsigned int flags);
|
||||
|
||||
IPCDevice::IPCDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset,
|
||||
const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths)
|
||||
: RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths), sk_chan_state(chans, ipc_per_trx_sock_state()),
|
||||
tx_attenuation(), tmp_state(IPC_IF_MSG_GREETING_REQ), shm(NULL), shm_dec(0),
|
||||
rx_buffers(chans), started(false), tx_gains(chans), rx_gains(chans)
|
||||
IPCDevice::IPCDevice(InterfaceType iface, const struct trx_cfg *cfg)
|
||||
: RadioDevice(iface, cfg), sk_chan_state(chans, ipc_per_trx_sock_state()), tx_attenuation(),
|
||||
tmp_state(IPC_IF_MSG_GREETING_REQ), shm(NULL), shm_dec(0), rx_buffers(chans), started(false), tx_gains(chans),
|
||||
rx_gains(chans)
|
||||
{
|
||||
LOGC(DDEV, INFO) << "creating IPC device...";
|
||||
|
||||
|
@ -771,11 +770,12 @@ static int ipc_chan_sock_cb(struct osmo_fd *bfd, unsigned int flags)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int IPCDevice::open(const std::string &args, int ref, bool swap_channels)
|
||||
int IPCDevice::open()
|
||||
{
|
||||
std::string k, v;
|
||||
std::string::size_type keyend;
|
||||
int rc;
|
||||
std::string args(cfg->dev_args);
|
||||
|
||||
if ((keyend = args.find('=')) != std::string::npos) {
|
||||
k = args.substr(0, keyend++);
|
||||
|
@ -810,7 +810,7 @@ int IPCDevice::open(const std::string &args, int ref, bool swap_channels)
|
|||
while (tmp_state != IPC_IF_MSG_INFO_CNF)
|
||||
osmo_select_main(0);
|
||||
|
||||
ipc_tx_open_req(&master_sk_state, chans, ref);
|
||||
ipc_tx_open_req(&master_sk_state, chans, cfg->clock_ref);
|
||||
/* Wait until confirmation is recieved */
|
||||
while (tmp_state != IPC_IF_MSG_OPEN_CNF)
|
||||
osmo_select_main(0);
|
||||
|
@ -1259,16 +1259,15 @@ bool IPCDevice::setRxFreq(double wFreq, size_t chan)
|
|||
return send_chan_wait_rsp(chan, msg, IPC_IF_MSG_SETFREQ_CNF);
|
||||
}
|
||||
|
||||
RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chans, double lo_offset,
|
||||
const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths)
|
||||
RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg)
|
||||
{
|
||||
if (tx_sps != rx_sps) {
|
||||
if (cfg->tx_sps != cfg->rx_sps) {
|
||||
LOGC(DDEV, ERROR) << "IPC Requires tx_sps == rx_sps";
|
||||
return NULL;
|
||||
}
|
||||
if (lo_offset != 0.0) {
|
||||
if (cfg->offset != 0.0) {
|
||||
LOGC(DDEV, ERROR) << "IPC doesn't support lo_offset";
|
||||
return NULL;
|
||||
}
|
||||
return new IPCDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths);
|
||||
return new IPCDevice(type, cfg);
|
||||
}
|
||||
|
|
|
@ -115,12 +115,11 @@ class IPCDevice : public RadioDevice {
|
|||
int ipc_chan_sock_write(osmo_fd *bfd);
|
||||
|
||||
/** Object constructor */
|
||||
IPCDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset,
|
||||
const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths);
|
||||
IPCDevice(InterfaceType iface, const struct trx_cfg *cfg);
|
||||
virtual ~IPCDevice() override;
|
||||
|
||||
/** Instantiate the IPC */
|
||||
virtual int open(const std::string &args, int ref, bool swap_channels) override;
|
||||
virtual int open() override;
|
||||
|
||||
/** Start the IPC */
|
||||
virtual bool start() override;
|
||||
|
|
|
@ -35,9 +35,12 @@ extern "C" {
|
|||
#include "Threads.h"
|
||||
#include "Utils.h"
|
||||
|
||||
int uhd_wrap::open(const std::string &args, int ref, bool swap_channels)
|
||||
// no vty source for cfg params here, so we have to build our own
|
||||
static struct trx_cfg actual_cfg = {};
|
||||
|
||||
int uhd_wrap::open()
|
||||
{
|
||||
int rv = uhd_device::open(args, ref, swap_channels);
|
||||
int rv = uhd_device::open();
|
||||
samps_per_buff_rx = rx_stream->get_max_num_samps();
|
||||
samps_per_buff_tx = tx_stream->get_max_num_samps();
|
||||
channel_count = usrp_dev->get_rx_num_channels();
|
||||
|
@ -84,36 +87,33 @@ int uhd_wrap::wrap_read(TIMESTAMP *timestamp)
|
|||
|
||||
extern "C" void *uhdwrap_open(struct ipc_sk_if_open_req *open_req)
|
||||
{
|
||||
unsigned int rx_sps, tx_sps;
|
||||
actual_cfg.num_chans = open_req->num_chans;
|
||||
actual_cfg.swap_channels = false;
|
||||
/* FIXME: this is actually the sps value, not the sample rate!
|
||||
* sample rate is looked up according to the sps rate by uhd backend */
|
||||
actual_cfg.rx_sps = open_req->rx_sample_freq_num / open_req->rx_sample_freq_den;
|
||||
actual_cfg.tx_sps = open_req->tx_sample_freq_num / open_req->tx_sample_freq_den;
|
||||
|
||||
/* FIXME: dev arg string* */
|
||||
/* FIXME: rx frontend bw? */
|
||||
/* FIXME: tx frontend bw? */
|
||||
ReferenceType cref;
|
||||
switch (open_req->clockref) {
|
||||
case FEATURE_MASK_CLOCKREF_EXTERNAL:
|
||||
cref = ReferenceType::REF_EXTERNAL;
|
||||
actual_cfg.clock_ref = ReferenceType::REF_EXTERNAL;
|
||||
break;
|
||||
case FEATURE_MASK_CLOCKREF_INTERNAL:
|
||||
default:
|
||||
cref = ReferenceType::REF_INTERNAL;
|
||||
actual_cfg.clock_ref = ReferenceType::REF_INTERNAL;
|
||||
break;
|
||||
}
|
||||
|
||||
std::vector<std::string> tx_paths;
|
||||
std::vector<std::string> rx_paths;
|
||||
for (unsigned int i = 0; i < open_req->num_chans; i++) {
|
||||
tx_paths.push_back(open_req->chan_info[i].tx_path);
|
||||
rx_paths.push_back(open_req->chan_info[i].rx_path);
|
||||
actual_cfg.chans[i].rx_path = open_req->chan_info[i].tx_path;
|
||||
actual_cfg.chans[i].tx_path = open_req->chan_info[i].rx_path;
|
||||
}
|
||||
|
||||
/* FIXME: this is actually the sps value, not the sample rate!
|
||||
* sample rate is looked up according to the sps rate by uhd backend */
|
||||
rx_sps = open_req->rx_sample_freq_num / open_req->rx_sample_freq_den;
|
||||
tx_sps = open_req->tx_sample_freq_num / open_req->tx_sample_freq_den;
|
||||
uhd_wrap *uhd_wrap_dev =
|
||||
new uhd_wrap(tx_sps, rx_sps, RadioDevice::NORMAL, open_req->num_chans, 0.0, tx_paths, rx_paths);
|
||||
uhd_wrap_dev->open("", cref, false);
|
||||
uhd_wrap *uhd_wrap_dev = new uhd_wrap(RadioDevice::NORMAL, &actual_cfg);
|
||||
uhd_wrap_dev->open();
|
||||
|
||||
return uhd_wrap_dev;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class uhd_wrap : public uhd_device {
|
|||
|
||||
// void ipc_sock_close() override {};
|
||||
int wrap_read(TIMESTAMP *timestamp);
|
||||
virtual int open(const std::string &args, int ref, bool swap_channels) override;
|
||||
virtual int open() override;
|
||||
|
||||
// bool start() override;
|
||||
// bool stop() override;
|
||||
|
|
|
@ -131,12 +131,9 @@ static enum lms_dev_type parse_dev_type(lms_device_t *m_lms_dev)
|
|||
return LMS_DEV_UNKNOWN;
|
||||
}
|
||||
|
||||
LMSDevice::LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths):
|
||||
RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths),
|
||||
m_lms_dev(NULL), started(false), band_ass_curr_sess(false), band((enum gsm_band)0),
|
||||
m_dev_type(LMS_DEV_UNKNOWN)
|
||||
LMSDevice::LMSDevice(InterfaceType iface, const struct trx_cfg *cfg)
|
||||
: RadioDevice(iface, cfg), m_lms_dev(NULL), started(false), band_ass_curr_sess(false), band((enum gsm_band)0),
|
||||
m_dev_type(LMS_DEV_UNKNOWN)
|
||||
{
|
||||
LOGC(DDEV, INFO) << "creating LMS device...";
|
||||
|
||||
|
@ -264,7 +261,7 @@ void LMSDevice::get_dev_band_desc(dev_band_desc& desc)
|
|||
desc = band_desc;
|
||||
}
|
||||
|
||||
int LMSDevice::open(const std::string &args, int ref, bool swap_channels)
|
||||
int LMSDevice::open()
|
||||
{
|
||||
lms_info_str_t* info_list;
|
||||
lms_range_t range_sr;
|
||||
|
@ -292,9 +289,9 @@ int LMSDevice::open(const std::string &args, int ref, bool swap_channels)
|
|||
for (i = 0; i < n; i++)
|
||||
LOGC(DDEV, INFO) << "Device [" << i << "]: " << info_list[i];
|
||||
|
||||
dev_id = info_list_find(info_list, n, args);
|
||||
dev_id = info_list_find(info_list, n, cfg->dev_args);
|
||||
if (dev_id == -1) {
|
||||
LOGC(DDEV, ERROR) << "No LMS device found with address '" << args << "'";
|
||||
LOGC(DDEV, ERROR) << "No LMS device found with address '" << cfg->dev_args << "'";
|
||||
delete[] info_list;
|
||||
return -1;
|
||||
}
|
||||
|
@ -312,13 +309,13 @@ int LMSDevice::open(const std::string &args, int ref, bool swap_channels)
|
|||
m_dev_type = parse_dev_type(m_lms_dev);
|
||||
dev_desc = dev_param_map.at(m_dev_type);
|
||||
|
||||
if ((ref != REF_EXTERNAL) && (ref != REF_INTERNAL)){
|
||||
if ((cfg->clock_ref != REF_EXTERNAL) && (cfg->clock_ref != REF_INTERNAL)) {
|
||||
LOGC(DDEV, ERROR) << "Invalid reference type";
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
/* if reference clock is external, setup must happen _before_ calling LMS_Init */
|
||||
if (ref == REF_EXTERNAL) {
|
||||
if (cfg->clock_ref == REF_EXTERNAL) {
|
||||
LOGC(DDEV, INFO) << "Setting External clock reference to 10MHz";
|
||||
/* FIXME: Assume an external 10 MHz reference clock. make
|
||||
external reference frequency configurable */
|
||||
|
@ -333,7 +330,7 @@ int LMSDevice::open(const std::string &args, int ref, bool swap_channels)
|
|||
}
|
||||
|
||||
/* if reference clock is internal, setup must happen _after_ calling LMS_Init */
|
||||
if (ref == REF_INTERNAL) {
|
||||
if (cfg->clock_ref == REF_INTERNAL) {
|
||||
LOGC(DDEV, INFO) << "Setting Internal clock reference";
|
||||
/* Internal freq param is not used */
|
||||
if (!do_clock_src_freq(REF_INTERNAL, 0))
|
||||
|
@ -1060,18 +1057,15 @@ bool LMSDevice::setRxFreq(double wFreq, size_t chan)
|
|||
return true;
|
||||
}
|
||||
|
||||
RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps,
|
||||
InterfaceType iface, size_t chans, double lo_offset,
|
||||
const std::vector < std::string > &tx_paths,
|
||||
const std::vector < std::string > &rx_paths)
|
||||
RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg)
|
||||
{
|
||||
if (tx_sps != rx_sps) {
|
||||
LOGC(DDEV, ERROR) << "LMS Requires tx_sps == rx_sps";
|
||||
if (cfg->tx_sps != cfg->rx_sps) {
|
||||
LOGC(DDEV, ERROR) << "LMS requires tx_sps == rx_sps";
|
||||
return NULL;
|
||||
}
|
||||
if (lo_offset != 0.0) {
|
||||
if (cfg->offset != 0.0) {
|
||||
LOGC(DDEV, ERROR) << "LMS doesn't support lo_offset";
|
||||
return NULL;
|
||||
}
|
||||
return new LMSDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths);
|
||||
return new LMSDevice(type, cfg);
|
||||
}
|
||||
|
|
|
@ -107,23 +107,22 @@ private:
|
|||
public:
|
||||
|
||||
/** Object constructor */
|
||||
LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths);
|
||||
~LMSDevice();
|
||||
LMSDevice(InterfaceType iface, const struct trx_cfg *cfg);
|
||||
~LMSDevice();
|
||||
|
||||
/** Instantiate the LMS */
|
||||
int open(const std::string &args, int ref, bool swap_channels);
|
||||
/** Instantiate the LMS */
|
||||
int open();
|
||||
|
||||
/** Start the LMS */
|
||||
bool start();
|
||||
/** Start the LMS */
|
||||
bool start();
|
||||
|
||||
/** Stop the LMS */
|
||||
bool stop();
|
||||
/** Stop the LMS */
|
||||
bool stop();
|
||||
|
||||
enum TxWindowType getWindowType() {
|
||||
return TX_WINDOW_LMS1;
|
||||
}
|
||||
enum TxWindowType getWindowType()
|
||||
{
|
||||
return TX_WINDOW_LMS1;
|
||||
}
|
||||
|
||||
/**
|
||||
Read samples from the LMS.
|
||||
|
|
|
@ -220,15 +220,10 @@ static double TxPower2TxGain(const dev_band_desc &desc, double tx_power_dbm)
|
|||
return desc.nom_uhd_tx_gain - (desc.nom_out_tx_power - tx_power_dbm);
|
||||
}
|
||||
|
||||
uhd_device::uhd_device(size_t tx_sps, size_t rx_sps,
|
||||
InterfaceType iface, size_t chan_num, double lo_offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths)
|
||||
: RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths),
|
||||
rx_gain_min(0.0), rx_gain_max(0.0), band_ass_curr_sess(false),
|
||||
band((enum gsm_band)0), tx_spp(0), rx_spp(0),
|
||||
started(false), aligned(false), drop_cnt(0),
|
||||
prev_ts(0,0), ts_initial(0), ts_offset(0), async_event_thrd(NULL)
|
||||
uhd_device::uhd_device(InterfaceType iface, const struct trx_cfg *cfg)
|
||||
: RadioDevice(iface, cfg), rx_gain_min(0.0), rx_gain_max(0.0), band_ass_curr_sess(false),
|
||||
band((enum gsm_band)0), tx_spp(0), rx_spp(0), started(false), aligned(false), drop_cnt(0), prev_ts(0, 0),
|
||||
ts_initial(0), ts_offset(0), async_event_thrd(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -548,7 +543,7 @@ void uhd_device::set_channels(bool swap)
|
|||
}
|
||||
}
|
||||
|
||||
int uhd_device::open(const std::string &args, int ref, bool swap_channels)
|
||||
int uhd_device::open()
|
||||
{
|
||||
const char *refstr;
|
||||
int clock_lock_attempts = 15;
|
||||
|
@ -564,10 +559,10 @@ int uhd_device::open(const std::string &args, int ref, bool swap_channels)
|
|||
#endif
|
||||
|
||||
// Find UHD devices
|
||||
uhd::device_addr_t addr(args);
|
||||
uhd::device_addr_t addr(cfg->dev_args);
|
||||
uhd::device_addrs_t dev_addrs = uhd::device::find(addr);
|
||||
if (dev_addrs.size() == 0) {
|
||||
LOGC(DDEV, ALERT) << "No UHD devices found with address '" << args << "'";
|
||||
LOGC(DDEV, ALERT) << "No UHD devices found with address '" << cfg->dev_args << "'";
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -576,7 +571,7 @@ int uhd_device::open(const std::string &args, int ref, bool swap_channels)
|
|||
try {
|
||||
usrp_dev = uhd::usrp::multi_usrp::make(addr);
|
||||
} catch(uhd::key_error::exception &e) {
|
||||
LOGC(DDEV, ALERT) << "UHD make failed, device " << args << ", exception:\n" << e.what();
|
||||
LOGC(DDEV, ALERT) << "UHD make failed, device " << cfg->dev_args << ", exception:\n" << e.what();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -590,8 +585,8 @@ int uhd_device::open(const std::string &args, int ref, bool swap_channels)
|
|||
}
|
||||
|
||||
try {
|
||||
set_channels(swap_channels);
|
||||
} catch (const std::exception &e) {
|
||||
set_channels(cfg->swap_channels);
|
||||
} catch (const std::exception &e) {
|
||||
LOGC(DDEV, ALERT) << "Channel setting failed - " << e.what();
|
||||
return -1;
|
||||
}
|
||||
|
@ -607,7 +602,7 @@ int uhd_device::open(const std::string &args, int ref, bool swap_channels)
|
|||
rx_gains.resize(chans);
|
||||
rx_buffers.resize(chans);
|
||||
|
||||
switch (ref) {
|
||||
switch (cfg->clock_ref) {
|
||||
case REF_INTERNAL:
|
||||
refstr = "internal";
|
||||
break;
|
||||
|
@ -1378,11 +1373,8 @@ std::string uhd_device::str_code(uhd::async_metadata_t metadata)
|
|||
}
|
||||
|
||||
#ifndef IPCMAGIC
|
||||
RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps,
|
||||
InterfaceType iface, size_t chans, double lo_offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths)
|
||||
RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg)
|
||||
{
|
||||
return new uhd_device(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths);
|
||||
return new uhd_device(type, cfg);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -80,17 +80,17 @@ struct dev_band_desc {
|
|||
*/
|
||||
class uhd_device : public RadioDevice {
|
||||
public:
|
||||
uhd_device(size_t tx_sps, size_t rx_sps, InterfaceType type,
|
||||
size_t chan_num, double offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths);
|
||||
~uhd_device();
|
||||
uhd_device(InterfaceType iface, const struct trx_cfg *cfg);
|
||||
~uhd_device();
|
||||
|
||||
int open(const std::string &args, int ref, bool swap_channels);
|
||||
bool start();
|
||||
bool stop();
|
||||
bool restart();
|
||||
enum TxWindowType getWindowType() { return tx_window; }
|
||||
int open();
|
||||
bool start();
|
||||
bool stop();
|
||||
bool restart();
|
||||
enum TxWindowType getWindowType()
|
||||
{
|
||||
return tx_window;
|
||||
}
|
||||
|
||||
int readSamples(std::vector<short *> &bufs, int len, bool *overrun,
|
||||
TIMESTAMP timestamp, bool *underrun);
|
||||
|
|
|
@ -60,11 +60,7 @@ const dboardConfigType dboardConfig = TXA_RXB;
|
|||
|
||||
const double USRPDevice::masterClockRate = 52.0e6;
|
||||
|
||||
USRPDevice::USRPDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface,
|
||||
size_t chan_num, double lo_offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths):
|
||||
RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths)
|
||||
USRPDevice::USRPDevice(InterfaceType iface, const struct trx_cfg *cfg) : RadioDevice(iface, cfg)
|
||||
{
|
||||
LOGC(DDEV, INFO) << "creating USRP device...";
|
||||
|
||||
|
@ -94,7 +90,7 @@ USRPDevice::USRPDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface,
|
|||
#endif
|
||||
}
|
||||
|
||||
int USRPDevice::open(const std::string &, int, bool)
|
||||
int USRPDevice::open()
|
||||
{
|
||||
writeLock.unlock();
|
||||
|
||||
|
@ -658,22 +654,19 @@ bool USRPDevice::setTxFreq(double wFreq) { return true;};
|
|||
bool USRPDevice::setRxFreq(double wFreq) { return true;};
|
||||
#endif
|
||||
|
||||
RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps,
|
||||
InterfaceType iface, size_t chans, double lo_offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths)
|
||||
RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg)
|
||||
{
|
||||
if (tx_sps != rx_sps) {
|
||||
LOGC(DDEV, ERROR) << "USRP1 requires tx_sps == rx_sps";
|
||||
return NULL;
|
||||
}
|
||||
if (chans != 1) {
|
||||
LOGC(DDEV, ERROR) << "USRP1 supports only 1 channel";
|
||||
return NULL;
|
||||
}
|
||||
if (lo_offset != 0.0) {
|
||||
LOGC(DDEV, ERROR) << "USRP1 doesn't support lo_offset";
|
||||
return NULL;
|
||||
}
|
||||
return new USRPDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths);
|
||||
if (cfg->tx_sps != cfg->rx_sps) {
|
||||
LOGC(DDEV, ERROR) << "USRP1 requires tx_sps == rx_sps";
|
||||
return NULL;
|
||||
}
|
||||
if (cfg->num_chans != 1) {
|
||||
LOGC(DDEV, ERROR) << "USRP1 supports only 1 channel";
|
||||
return NULL;
|
||||
}
|
||||
if (cfg->offset != 0.0) {
|
||||
LOGC(DDEV, ERROR) << "USRP1 doesn't support lo_offset";
|
||||
return NULL;
|
||||
}
|
||||
return new USRPDevice(type, cfg);
|
||||
}
|
||||
|
|
|
@ -104,20 +104,21 @@ private:
|
|||
public:
|
||||
|
||||
/** Object constructor */
|
||||
USRPDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset,
|
||||
const std::vector<std::string>& tx_paths,
|
||||
const std::vector<std::string>& rx_paths);
|
||||
USRPDevice(InterfaceType iface, const struct trx_cfg *cfg);
|
||||
|
||||
/** Instantiate the USRP */
|
||||
int open(const std::string &, int, bool);
|
||||
/** Instantiate the USRP */
|
||||
int open();
|
||||
|
||||
/** Start the USRP */
|
||||
bool start();
|
||||
/** Start the USRP */
|
||||
bool start();
|
||||
|
||||
/** Stop the USRP */
|
||||
bool stop();
|
||||
/** Stop the USRP */
|
||||
bool stop();
|
||||
|
||||
enum TxWindowType getWindowType() { return TX_WINDOW_USRP1; }
|
||||
enum TxWindowType getWindowType()
|
||||
{
|
||||
return TX_WINDOW_USRP1;
|
||||
}
|
||||
|
||||
/**
|
||||
Read samples from the USRP.
|
||||
|
|
|
@ -571,24 +571,14 @@ static void trx_stop()
|
|||
static int trx_start(struct trx_ctx *trx)
|
||||
{
|
||||
int type, chans;
|
||||
unsigned int i;
|
||||
std::vector<std::string> rx_paths, tx_paths;
|
||||
RadioDevice::InterfaceType iface = RadioDevice::NORMAL;
|
||||
|
||||
/* Create the low level device object */
|
||||
if (trx->cfg.multi_arfcn)
|
||||
iface = RadioDevice::MULTI_ARFCN;
|
||||
|
||||
/* Generate vector of rx/tx_path: */
|
||||
for (i = 0; i < trx->cfg.num_chans; i++) {
|
||||
rx_paths.push_back(charp2str(trx->cfg.chans[i].rx_path));
|
||||
tx_paths.push_back(charp2str(trx->cfg.chans[i].tx_path));
|
||||
}
|
||||
|
||||
usrp = RadioDevice::make(trx->cfg.tx_sps, trx->cfg.rx_sps, iface,
|
||||
trx->cfg.num_chans, trx->cfg.offset,
|
||||
tx_paths, rx_paths);
|
||||
type = usrp->open(charp2str(trx->cfg.dev_args), trx->cfg.clock_ref, trx->cfg.swap_channels);
|
||||
usrp = RadioDevice::make(iface, &trx->cfg);
|
||||
type = usrp->open();
|
||||
if (type < 0) {
|
||||
LOG(ALERT) << "Failed to create radio device" << std::endl;
|
||||
goto shutdown;
|
||||
|
|
Loading…
Reference in New Issue