2011-11-26 03:16:54 +00:00
|
|
|
/*
|
2018-02-05 12:04:41 +00:00
|
|
|
* Device support for Ettus Research UHD driver
|
2011-11-26 03:18:26 +00:00
|
|
|
*
|
|
|
|
* Copyright 2010,2011 Free Software Foundation, Inc.
|
2016-06-22 23:09:44 +00:00
|
|
|
* Copyright (C) 2015 Ettus Research LLC
|
|
|
|
*
|
|
|
|
* Author: Tom Tsou <tom.tsou@ettus.com>
|
2011-11-26 03:18:26 +00:00
|
|
|
*
|
2019-07-22 10:05:52 +00:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0+
|
|
|
|
*
|
2011-11-26 03:18:26 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* See the COPYING file in the main directory for details.
|
|
|
|
*/
|
2011-11-26 03:16:54 +00:00
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
#include <map>
|
2011-11-26 03:16:54 +00:00
|
|
|
#include "radioDevice.h"
|
2019-04-29 15:23:21 +00:00
|
|
|
#include "UHDDevice.h"
|
2011-11-26 03:16:54 +00:00
|
|
|
#include "Threads.h"
|
|
|
|
#include "Logger.h"
|
|
|
|
|
2011-11-26 03:18:39 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2017-03-07 22:16:46 +00:00
|
|
|
#ifndef USE_UHD_3_11
|
|
|
|
#include <uhd/utils/msg.hpp>
|
2018-08-30 15:24:49 +00:00
|
|
|
#include <uhd/utils/thread_priority.hpp>
|
|
|
|
#else
|
|
|
|
#include <uhd/utils/thread.hpp>
|
2017-03-07 22:16:46 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-25 11:22:37 +00:00
|
|
|
#define USRP_TX_AMPL 0.3
|
|
|
|
#define UMTRX_TX_AMPL 0.7
|
2016-02-05 08:52:49 +00:00
|
|
|
#define LIMESDR_TX_AMPL 0.3
|
2013-04-06 00:42:41 +00:00
|
|
|
#define SAMPLE_BUF_SZ (1 << 20)
|
2013-04-05 19:36:30 +00:00
|
|
|
|
2014-11-26 00:06:32 +00:00
|
|
|
/*
|
|
|
|
* UHD timeout value on streaming (re)start
|
|
|
|
*
|
|
|
|
* Allow some time for streaming to commence after the start command is issued,
|
|
|
|
* but consider a wait beyond one second to be a definite error condition.
|
|
|
|
*/
|
|
|
|
#define UHD_RESTART_TIMEOUT 1.0
|
|
|
|
|
2014-04-19 13:25:00 +00:00
|
|
|
/*
|
|
|
|
* UmTRX specific settings
|
|
|
|
*/
|
|
|
|
#define UMTRX_VGA1_DEF -18
|
|
|
|
|
2015-08-22 01:28:52 +00:00
|
|
|
/*
|
|
|
|
* USRP version dependent device timings
|
|
|
|
*/
|
2017-03-07 22:16:46 +00:00
|
|
|
#if defined(USE_UHD_3_9) || defined(USE_UHD_3_11)
|
2015-08-22 01:28:52 +00:00
|
|
|
#define B2XX_TIMING_1SPS 1.7153e-4
|
|
|
|
#define B2XX_TIMING_4SPS 1.1696e-4
|
2016-04-27 02:28:59 +00:00
|
|
|
#define B2XX_TIMING_4_4SPS 6.18462e-5
|
2017-03-08 01:54:06 +00:00
|
|
|
#define B2XX_TIMING_MCBTS 7e-5
|
2017-01-19 21:44:02 +00:00
|
|
|
#else
|
|
|
|
#define B2XX_TIMING_1SPS 9.9692e-5
|
|
|
|
#define B2XX_TIMING_4SPS 6.9248e-5
|
|
|
|
#define B2XX_TIMING_4_4SPS 4.52308e-5
|
2017-03-08 01:54:06 +00:00
|
|
|
#define B2XX_TIMING_MCBTS 6.42452e-5
|
2017-01-19 21:44:02 +00:00
|
|
|
#endif
|
2015-08-22 01:28:52 +00:00
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
/*
|
2013-04-06 00:42:41 +00:00
|
|
|
* Tx / Rx sample offset values. In a perfect world, there is no group delay
|
|
|
|
* though analog components, and behaviour through digital filters exactly
|
|
|
|
* matches calculated values. In reality, there are unaccounted factors,
|
|
|
|
* which are captured in these empirically measured (using a loopback test)
|
|
|
|
* timing correction values.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* USRP1 with timestamps is not supported by UHD.
|
|
|
|
*/
|
2013-04-08 18:18:26 +00:00
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
/* Device Type, Tx-SPS, Rx-SPS */
|
|
|
|
typedef std::tuple<uhd_dev_type, int, int> dev_key;
|
2016-06-24 21:25:39 +00:00
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
/* Device parameter descriptor */
|
|
|
|
struct dev_desc {
|
|
|
|
unsigned channels;
|
|
|
|
double mcr;
|
|
|
|
double rate;
|
|
|
|
double offset;
|
|
|
|
std::string str;
|
|
|
|
};
|
2013-04-08 18:18:26 +00:00
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
static const std::map<dev_key, dev_desc> dev_param_map {
|
|
|
|
{ std::make_tuple(USRP2, 1, 1), { 1, 0.0, 390625, 1.2184e-4, "N2XX 1 SPS" } },
|
|
|
|
{ std::make_tuple(USRP2, 4, 1), { 1, 0.0, 390625, 7.6547e-5, "N2XX 4/1 Tx/Rx SPS" } },
|
|
|
|
{ std::make_tuple(USRP2, 4, 4), { 1, 0.0, 390625, 4.6080e-5, "N2XX 4 SPS" } },
|
|
|
|
{ std::make_tuple(B100, 1, 1), { 1, 0.0, 400000, 1.2104e-4, "B100 1 SPS" } },
|
|
|
|
{ std::make_tuple(B100, 4, 1), { 1, 0.0, 400000, 7.9307e-5, "B100 4/1 Tx/Rx SPS" } },
|
|
|
|
{ std::make_tuple(B200, 1, 1), { 1, 26e6, GSMRATE, B2XX_TIMING_1SPS, "B200 1 SPS" } },
|
|
|
|
{ std::make_tuple(B200, 4, 1), { 1, 26e6, GSMRATE, B2XX_TIMING_4SPS, "B200 4/1 Tx/Rx SPS" } },
|
|
|
|
{ std::make_tuple(B200, 4, 4), { 1, 26e6, GSMRATE, B2XX_TIMING_4_4SPS, "B200 4 SPS" } },
|
|
|
|
{ std::make_tuple(B210, 1, 1), { 2, 26e6, GSMRATE, B2XX_TIMING_1SPS, "B210 1 SPS" } },
|
|
|
|
{ std::make_tuple(B210, 4, 1), { 2, 26e6, GSMRATE, B2XX_TIMING_4SPS, "B210 4/1 Tx/Rx SPS" } },
|
|
|
|
{ std::make_tuple(B210, 4, 4), { 2, 26e6, GSMRATE, B2XX_TIMING_4_4SPS, "B210 4 SPS" } },
|
|
|
|
{ std::make_tuple(E1XX, 1, 1), { 1, 52e6, GSMRATE, 9.5192e-5, "E1XX 1 SPS" } },
|
|
|
|
{ std::make_tuple(E1XX, 4, 1), { 1, 52e6, GSMRATE, 6.5571e-5, "E1XX 4/1 Tx/Rx SPS" } },
|
|
|
|
{ std::make_tuple(E3XX, 1, 1), { 2, 26e6, GSMRATE, 1.8462e-4, "E3XX 1 SPS" } },
|
|
|
|
{ std::make_tuple(E3XX, 4, 1), { 2, 26e6, GSMRATE, 1.2923e-4, "E3XX 4/1 Tx/Rx SPS" } },
|
|
|
|
{ std::make_tuple(X3XX, 1, 1), { 2, 0.0, 390625, 1.5360e-4, "X3XX 1 SPS" } },
|
|
|
|
{ std::make_tuple(X3XX, 4, 1), { 2, 0.0, 390625, 1.1264e-4, "X3XX 4/1 Tx/Rx SPS" } },
|
|
|
|
{ std::make_tuple(X3XX, 4, 4), { 2, 0.0, 390625, 5.6567e-5, "X3XX 4 SPS" } },
|
|
|
|
{ std::make_tuple(UMTRX, 1, 1), { 2, 0.0, GSMRATE, 9.9692e-5, "UmTRX 1 SPS" } },
|
|
|
|
{ std::make_tuple(UMTRX, 4, 1), { 2, 0.0, GSMRATE, 7.3846e-5, "UmTRX 4/1 Tx/Rx SPS"} },
|
|
|
|
{ std::make_tuple(UMTRX, 4, 4), { 2, 0.0, GSMRATE, 5.1503e-5, "UmTRX 4 SPS" } },
|
2017-06-26 17:13:25 +00:00
|
|
|
{ std::make_tuple(LIMESDR, 4, 4), { 1, GSMRATE*32, GSMRATE, 8.9e-5, "LimeSDR 4 SPS" } },
|
2017-06-09 02:41:48 +00:00
|
|
|
{ std::make_tuple(B2XX_MCBTS, 4, 4), { 1, 51.2e6, MCBTS_SPACING*4, B2XX_TIMING_MCBTS, "B200/B210 4 SPS Multi-ARFCN" } },
|
|
|
|
};
|
2013-04-08 18:18:26 +00:00
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
void *async_event_loop(uhd_device *dev)
|
|
|
|
{
|
2018-09-20 16:04:46 +00:00
|
|
|
set_selfthread_name("UHDAsyncEvent");
|
2013-11-08 17:50:03 +00:00
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
while (1) {
|
|
|
|
dev->recv_async_msg();
|
|
|
|
pthread_testcancel();
|
|
|
|
}
|
2013-11-15 21:32:54 +00:00
|
|
|
|
|
|
|
return NULL;
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2017-03-07 22:16:46 +00:00
|
|
|
#ifndef USE_UHD_3_11
|
|
|
|
/*
|
2011-11-26 03:18:51 +00:00
|
|
|
Catch and drop underrun 'U' and overrun 'O' messages from stdout
|
|
|
|
since we already report using the logging facility. Direct
|
|
|
|
everything else appropriately.
|
|
|
|
*/
|
|
|
|
void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case uhd::msg::status:
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << msg;
|
2011-11-26 03:18:51 +00:00
|
|
|
break;
|
|
|
|
case uhd::msg::warning:
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, WARNING) << msg;
|
2011-11-26 03:18:51 +00:00
|
|
|
break;
|
|
|
|
case uhd::msg::error:
|
2019-04-30 16:19:54 +00:00
|
|
|
LOGC(DDEV, ERROR) << msg;
|
2011-11-26 03:18:51 +00:00
|
|
|
break;
|
|
|
|
case uhd::msg::fastpath:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-03-07 22:16:46 +00:00
|
|
|
#endif
|
2011-11-26 03:18:51 +00:00
|
|
|
|
2016-03-06 09:28:40 +00:00
|
|
|
uhd_device::uhd_device(size_t tx_sps, size_t rx_sps,
|
2018-06-13 21:21:57 +00:00
|
|
|
InterfaceType iface, size_t chans, double lo_offset,
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
const std::vector<std::string>& tx_paths,
|
|
|
|
const std::vector<std::string>& rx_paths)
|
2018-06-13 21:21:57 +00:00
|
|
|
: RadioDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths),
|
|
|
|
tx_gain_min(0.0), tx_gain_max(0.0),
|
2013-10-29 22:34:16 +00:00
|
|
|
rx_gain_min(0.0), rx_gain_max(0.0),
|
|
|
|
tx_spp(0), rx_spp(0),
|
2019-04-30 17:01:37 +00:00
|
|
|
started(false), aligned(false), drop_cnt(0),
|
2018-02-09 15:19:31 +00:00
|
|
|
prev_ts(0,0), ts_initial(0), ts_offset(0), async_event_thrd(NULL)
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uhd_device::~uhd_device()
|
|
|
|
{
|
|
|
|
stop();
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
for (size_t i = 0; i < rx_buffers.size(); i++)
|
|
|
|
delete rx_buffers[i];
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 03:17:18 +00:00
|
|
|
void uhd_device::init_gains()
|
|
|
|
{
|
|
|
|
uhd::gain_range_t range;
|
|
|
|
|
2014-04-19 13:25:00 +00:00
|
|
|
if (dev_type == UMTRX) {
|
|
|
|
std::vector<std::string> gain_stages = usrp_dev->get_tx_gain_names(0);
|
|
|
|
if (gain_stages[0] == "VGA") {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, WARNING) << "Update your UHD version for a proper Tx gain support";
|
2014-04-19 13:25:00 +00:00
|
|
|
}
|
|
|
|
if (gain_stages[0] == "VGA" || gain_stages[0] == "PA") {
|
|
|
|
range = usrp_dev->get_tx_gain_range();
|
|
|
|
tx_gain_min = range.start();
|
|
|
|
tx_gain_max = range.stop();
|
|
|
|
} else {
|
|
|
|
range = usrp_dev->get_tx_gain_range("VGA2");
|
|
|
|
tx_gain_min = UMTRX_VGA1_DEF + range.start();
|
|
|
|
tx_gain_max = UMTRX_VGA1_DEF + range.stop();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
range = usrp_dev->get_tx_gain_range();
|
|
|
|
tx_gain_min = range.start();
|
|
|
|
tx_gain_max = range.stop();
|
|
|
|
}
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Supported Tx gain range [" << tx_gain_min << "; " << tx_gain_max << "]";
|
2011-11-26 03:17:18 +00:00
|
|
|
|
|
|
|
range = usrp_dev->get_rx_gain_range();
|
|
|
|
rx_gain_min = range.start();
|
|
|
|
rx_gain_max = range.stop();
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Supported Rx gain range [" << rx_gain_min << "; " << rx_gain_max << "]";
|
2011-11-26 03:17:18 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
for (size_t i = 0; i < tx_gains.size(); i++) {
|
2015-05-18 03:25:57 +00:00
|
|
|
double gain = (tx_gain_min + tx_gain_max) / 2;
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Default setting Tx gain for channel " << i << " to " << gain;
|
2015-05-18 03:25:57 +00:00
|
|
|
usrp_dev->set_tx_gain(gain, i);
|
2013-10-29 22:34:16 +00:00
|
|
|
tx_gains[i] = usrp_dev->get_tx_gain(i);
|
|
|
|
}
|
2011-11-26 03:17:18 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
for (size_t i = 0; i < rx_gains.size(); i++) {
|
2015-05-18 03:25:57 +00:00
|
|
|
double gain = (rx_gain_min + rx_gain_max) / 2;
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Default setting Rx gain for channel " << i << " to " << gain;
|
2015-05-18 03:25:57 +00:00
|
|
|
usrp_dev->set_rx_gain(gain, i);
|
2013-10-29 22:34:16 +00:00
|
|
|
rx_gains[i] = usrp_dev->get_rx_gain(i);
|
|
|
|
}
|
2011-11-26 03:17:18 +00:00
|
|
|
|
|
|
|
return;
|
2013-10-29 22:34:16 +00:00
|
|
|
|
2011-11-26 03:17:18 +00:00
|
|
|
}
|
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
void uhd_device::set_rates()
|
2016-05-04 02:02:24 +00:00
|
|
|
{
|
2017-06-09 02:41:48 +00:00
|
|
|
dev_desc desc = dev_param_map.at(dev_key(dev_type, tx_sps, rx_sps));
|
|
|
|
if (desc.mcr != 0.0)
|
|
|
|
usrp_dev->set_master_clock_rate(desc.mcr);
|
2016-05-04 02:02:24 +00:00
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
tx_rate = (dev_type != B2XX_MCBTS) ? desc.rate * tx_sps : desc.rate;
|
|
|
|
rx_rate = (dev_type != B2XX_MCBTS) ? desc.rate * rx_sps : desc.rate;
|
2016-05-04 02:02:24 +00:00
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
usrp_dev->set_tx_rate(tx_rate);
|
|
|
|
usrp_dev->set_rx_rate(rx_rate);
|
|
|
|
tx_rate = usrp_dev->get_tx_rate();
|
|
|
|
rx_rate = usrp_dev->get_rx_rate();
|
2016-05-04 02:02:24 +00:00
|
|
|
|
2017-06-15 22:31:08 +00:00
|
|
|
ts_offset = static_cast<TIMESTAMP>(desc.offset * rx_rate);
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Rates configured for " << desc.str;
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
double uhd_device::setTxGain(double db, size_t chan)
|
2011-11-26 03:17:10 +00:00
|
|
|
{
|
2016-06-24 21:25:39 +00:00
|
|
|
if (iface == MULTI_ARFCN)
|
|
|
|
chan = 0;
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
if (chan >= tx_gains.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel" << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2014-04-19 13:25:00 +00:00
|
|
|
if (dev_type == UMTRX) {
|
|
|
|
std::vector<std::string> gain_stages = usrp_dev->get_tx_gain_names(0);
|
|
|
|
if (gain_stages[0] == "VGA" || gain_stages[0] == "PA") {
|
|
|
|
usrp_dev->set_tx_gain(db, chan);
|
|
|
|
} else {
|
|
|
|
// New UHD versions support split configuration of
|
|
|
|
// Tx gain stages. We utilize this to set the gain
|
|
|
|
// configuration, optimal for the Tx signal quality.
|
|
|
|
// From our measurements, VGA1 must be 18dB plus-minus
|
|
|
|
// one and VGA2 is the best when 23dB or lower.
|
|
|
|
usrp_dev->set_tx_gain(UMTRX_VGA1_DEF, "VGA1", chan);
|
|
|
|
usrp_dev->set_tx_gain(db-UMTRX_VGA1_DEF, "VGA2", chan);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
usrp_dev->set_tx_gain(db, chan);
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
tx_gains[chan] = usrp_dev->get_tx_gain(chan);
|
2011-11-26 03:17:10 +00:00
|
|
|
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Set TX gain to " << tx_gains[chan] << "dB (asked for " << db << "dB)";
|
2011-11-26 03:17:10 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
return tx_gains[chan];
|
2011-11-26 03:17:10 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
double uhd_device::setRxGain(double db, size_t chan)
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
2018-11-01 17:30:12 +00:00
|
|
|
if (iface == MULTI_ARFCN)
|
|
|
|
chan = 0;
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
if (chan >= rx_gains.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return 0.0f;
|
|
|
|
}
|
2011-11-26 03:17:10 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
usrp_dev->set_rx_gain(db, chan);
|
|
|
|
rx_gains[chan] = usrp_dev->get_rx_gain(chan);
|
2011-11-26 03:17:10 +00:00
|
|
|
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Set RX gain to " << rx_gains[chan] << "dB (asked for " << db << "dB)";
|
2013-10-29 22:34:16 +00:00
|
|
|
|
|
|
|
return rx_gains[chan];
|
|
|
|
}
|
|
|
|
|
|
|
|
double uhd_device::getRxGain(size_t chan)
|
|
|
|
{
|
2016-06-24 21:25:39 +00:00
|
|
|
if (iface == MULTI_ARFCN)
|
|
|
|
chan = 0;
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
if (chan >= rx_gains.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rx_gains[chan];
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 03:18:57 +00:00
|
|
|
/*
|
|
|
|
Parse the UHD device tree and mboard name to find out what device we're
|
2013-04-05 19:36:30 +00:00
|
|
|
dealing with. We need the window type so that the transceiver knows how to
|
2011-11-26 03:18:57 +00:00
|
|
|
deal with the transport latency. Reject the USRP1 because UHD doesn't
|
|
|
|
support timestamped samples with it.
|
|
|
|
*/
|
|
|
|
bool uhd_device::parse_dev_type()
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
2017-06-09 02:41:48 +00:00
|
|
|
uhd::property_tree::sptr prop_tree = usrp_dev->get_device()->get_tree();
|
|
|
|
std::string devString = prop_tree->access<std::string>("/name").get();
|
|
|
|
std::string mboardString = usrp_dev->get_mboard_name();
|
|
|
|
|
|
|
|
const std::map<std::string, std::pair<uhd_dev_type, TxWindowType>> devStringMap {
|
|
|
|
{ "B100", { B100, TX_WINDOW_USRP1 } },
|
|
|
|
{ "B200", { B200, TX_WINDOW_USRP1 } },
|
|
|
|
{ "B200mini", { B200, TX_WINDOW_USRP1 } },
|
2017-12-03 17:29:16 +00:00
|
|
|
{ "B205mini", { B200, TX_WINDOW_USRP1 } },
|
2017-06-09 02:41:48 +00:00
|
|
|
{ "B210", { B210, TX_WINDOW_USRP1 } },
|
|
|
|
{ "E100", { E1XX, TX_WINDOW_FIXED } },
|
|
|
|
{ "E110", { E1XX, TX_WINDOW_FIXED } },
|
|
|
|
{ "E310", { E3XX, TX_WINDOW_FIXED } },
|
|
|
|
{ "E3XX", { E3XX, TX_WINDOW_FIXED } },
|
|
|
|
{ "X300", { X3XX, TX_WINDOW_FIXED } },
|
|
|
|
{ "X310", { X3XX, TX_WINDOW_FIXED } },
|
2017-06-15 16:16:53 +00:00
|
|
|
{ "USRP2", { USRP2, TX_WINDOW_FIXED } },
|
2017-06-09 02:41:48 +00:00
|
|
|
{ "UmTRX", { UMTRX, TX_WINDOW_FIXED } },
|
2017-06-13 20:37:46 +00:00
|
|
|
{ "LimeSDR", { LIMESDR, TX_WINDOW_FIXED } },
|
2017-06-09 02:41:48 +00:00
|
|
|
};
|
2011-11-26 03:18:57 +00:00
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
// Compare UHD motherboard and device strings */
|
2017-06-15 16:16:53 +00:00
|
|
|
auto mapIter = devStringMap.begin();
|
|
|
|
while (mapIter != devStringMap.end()) {
|
|
|
|
if (devString.find(mapIter->first) != std::string::npos ||
|
|
|
|
mboardString.find(mapIter->first) != std::string::npos) {
|
|
|
|
dev_type = std::get<0>(mapIter->second);
|
|
|
|
tx_window = std::get<1>(mapIter->second);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
mapIter++;
|
2013-11-09 07:25:41 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Unsupported device " << devString;
|
2017-06-15 16:16:53 +00:00
|
|
|
return false;
|
2011-11-26 03:18:57 +00:00
|
|
|
}
|
2011-11-26 03:16:54 +00:00
|
|
|
|
2016-05-04 02:04:15 +00:00
|
|
|
/*
|
|
|
|
* Check for UHD version > 3.9.0 for E3XX support
|
|
|
|
*/
|
|
|
|
static bool uhd_e3xx_version_chk()
|
|
|
|
{
|
|
|
|
std::string ver = uhd::get_version_string();
|
|
|
|
std::string major_str(ver.begin(), ver.begin() + 3);
|
|
|
|
std::string minor_str(ver.begin() + 4, ver.begin() + 7);
|
|
|
|
|
|
|
|
int major_val = atoi(major_str.c_str());
|
|
|
|
int minor_val = atoi(minor_str.c_str());
|
|
|
|
|
|
|
|
if (major_val < 3)
|
|
|
|
return false;
|
|
|
|
if (minor_val < 9)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-06-09 22:37:19 +00:00
|
|
|
void uhd_device::set_channels(bool swap)
|
|
|
|
{
|
|
|
|
if (iface == MULTI_ARFCN) {
|
|
|
|
if (dev_type != B200 && dev_type != B210)
|
|
|
|
throw std::invalid_argument("Device does not support MCBTS");
|
|
|
|
dev_type = B2XX_MCBTS;
|
|
|
|
chans = 1;
|
|
|
|
}
|
|
|
|
|
2017-06-26 17:13:25 +00:00
|
|
|
if (chans > dev_param_map.at(dev_key(dev_type, tx_sps, rx_sps)).channels)
|
2017-06-09 22:37:19 +00:00
|
|
|
throw std::invalid_argument("Device does not support number of requested channels");
|
|
|
|
|
|
|
|
std::string subdev_string;
|
|
|
|
switch (dev_type) {
|
|
|
|
case B210:
|
|
|
|
case E3XX:
|
|
|
|
if (chans == 1)
|
|
|
|
subdev_string = swap ? "A:B" : "A:A";
|
|
|
|
else if (chans == 2)
|
|
|
|
subdev_string = swap ? "A:B A:A" : "A:A A:B";
|
|
|
|
break;
|
|
|
|
case X3XX:
|
|
|
|
case UMTRX:
|
|
|
|
if (chans == 1)
|
|
|
|
subdev_string = swap ? "B:0" : "A:0";
|
|
|
|
else if (chans == 2)
|
|
|
|
subdev_string = swap ? "B:0 A:0" : "A:0 B:0";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!subdev_string.empty()) {
|
|
|
|
uhd::usrp::subdev_spec_t spec(subdev_string);
|
|
|
|
usrp_dev->set_tx_subdev_spec(spec);
|
|
|
|
usrp_dev->set_rx_subdev_spec(spec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-18 02:29:08 +00:00
|
|
|
int uhd_device::open(const std::string &args, int ref, bool swap_channels)
|
2011-11-26 03:18:57 +00:00
|
|
|
{
|
2016-07-18 02:29:08 +00:00
|
|
|
const char *refstr;
|
|
|
|
|
2011-11-28 06:26:04 +00:00
|
|
|
// Find UHD devices
|
2012-10-22 00:07:14 +00:00
|
|
|
uhd::device_addr_t addr(args);
|
|
|
|
uhd::device_addrs_t dev_addrs = uhd::device::find(addr);
|
2011-11-28 06:26:04 +00:00
|
|
|
if (dev_addrs.size() == 0) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "No UHD devices found with address '" << args << "'";
|
2013-04-08 18:18:26 +00:00
|
|
|
return -1;
|
2011-11-28 06:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Use the first found device
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Using discovered UHD device " << dev_addrs[0].to_string();
|
2011-11-26 03:16:54 +00:00
|
|
|
try {
|
2015-05-18 23:51:44 +00:00
|
|
|
usrp_dev = uhd::usrp::multi_usrp::make(addr);
|
2018-12-01 16:02:15 +00:00
|
|
|
} catch(uhd::key_error::exception &e) {
|
|
|
|
LOGC(DDEV, ALERT) << "UHD make failed, device " << args << ", exception:\n" << e.what();
|
2013-04-08 18:18:26 +00:00
|
|
|
return -1;
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2011-11-28 06:26:01 +00:00
|
|
|
// Check for a valid device type and set bus type
|
|
|
|
if (!parse_dev_type())
|
2013-04-08 18:18:26 +00:00
|
|
|
return -1;
|
2011-11-28 06:26:01 +00:00
|
|
|
|
2016-05-04 02:04:15 +00:00
|
|
|
if ((dev_type == E3XX) && !uhd_e3xx_version_chk()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "E3XX requires UHD 003.009.000 or greater";
|
2016-05-04 02:04:15 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-06-09 22:37:19 +00:00
|
|
|
try {
|
|
|
|
set_channels(swap_channels);
|
|
|
|
} catch (const std::exception &e) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Channel setting failed - " << e.what();
|
2013-10-29 22:34:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
if (!set_antennas()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "UHD antenna setting failed";
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
tx_freqs.resize(chans);
|
|
|
|
rx_freqs.resize(chans);
|
|
|
|
tx_gains.resize(chans);
|
|
|
|
rx_gains.resize(chans);
|
|
|
|
rx_buffers.resize(chans);
|
|
|
|
|
2016-07-18 02:29:08 +00:00
|
|
|
switch (ref) {
|
|
|
|
case REF_INTERNAL:
|
|
|
|
refstr = "internal";
|
|
|
|
break;
|
|
|
|
case REF_EXTERNAL:
|
|
|
|
refstr = "external";
|
|
|
|
break;
|
|
|
|
case REF_GPS:
|
|
|
|
refstr = "gpsdo";
|
|
|
|
break;
|
|
|
|
default:
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Invalid reference type";
|
2016-07-18 02:29:08 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
usrp_dev->set_clock_source(refstr);
|
2013-10-16 04:31:18 +00:00
|
|
|
|
2017-06-09 02:41:48 +00:00
|
|
|
try {
|
|
|
|
set_rates();
|
|
|
|
} catch (const std::exception &e) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "UHD rate setting failed - " << e.what();
|
2013-04-08 18:18:26 +00:00
|
|
|
return -1;
|
2017-06-09 02:41:48 +00:00
|
|
|
}
|
2011-11-26 03:16:54 +00:00
|
|
|
|
2015-04-29 03:09:02 +00:00
|
|
|
// Set RF frontend bandwidth
|
|
|
|
if (dev_type == UMTRX) {
|
|
|
|
// Setting LMS6002D LPF to 500kHz gives us the best signal quality
|
|
|
|
for (size_t i = 0; i < chans; i++) {
|
|
|
|
usrp_dev->set_tx_bandwidth(500*1000*2, i);
|
2017-03-31 00:22:58 +00:00
|
|
|
usrp_dev->set_rx_bandwidth(500*1000*2, i);
|
2015-04-29 03:09:02 +00:00
|
|
|
}
|
2016-02-05 08:52:49 +00:00
|
|
|
} else if (dev_type == LIMESDR) {
|
|
|
|
for (size_t i = 0; i < chans; i++) {
|
2018-05-08 18:49:00 +00:00
|
|
|
usrp_dev->set_tx_bandwidth(5.2e6, i);
|
|
|
|
usrp_dev->set_rx_bandwidth(1.4001e6, i);
|
2016-02-05 08:52:49 +00:00
|
|
|
}
|
2015-04-29 03:09:02 +00:00
|
|
|
}
|
|
|
|
|
2014-03-27 17:44:09 +00:00
|
|
|
/* Create TX and RX streamers */
|
|
|
|
uhd::stream_args_t stream_args("sc16");
|
|
|
|
for (size_t i = 0; i < chans; i++)
|
|
|
|
stream_args.channels.push_back(i);
|
|
|
|
|
|
|
|
tx_stream = usrp_dev->get_tx_stream(stream_args);
|
|
|
|
rx_stream = usrp_dev->get_rx_stream(stream_args);
|
|
|
|
|
|
|
|
/* Number of samples per over-the-wire packet */
|
|
|
|
tx_spp = tx_stream->get_max_num_samps();
|
|
|
|
rx_spp = rx_stream->get_max_num_samps();
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
// Create receive buffer
|
2013-04-06 00:42:41 +00:00
|
|
|
size_t buf_len = SAMPLE_BUF_SZ / sizeof(uint32_t);
|
2013-10-29 22:34:16 +00:00
|
|
|
for (size_t i = 0; i < rx_buffers.size(); i++)
|
2019-05-03 12:38:36 +00:00
|
|
|
rx_buffers[i] = new smpl_buf(buf_len);
|
2011-11-26 03:16:54 +00:00
|
|
|
|
2019-04-30 16:51:00 +00:00
|
|
|
// Create vector buffer
|
|
|
|
pkt_bufs = std::vector<std::vector<short> >(chans, std::vector<short>(2 * rx_spp));
|
|
|
|
for (size_t i = 0; i < pkt_bufs.size(); i++)
|
|
|
|
pkt_ptrs.push_back(&pkt_bufs[i].front());
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
// Initialize and shadow gain values
|
2011-11-26 03:17:10 +00:00
|
|
|
init_gains();
|
2011-11-26 03:16:54 +00:00
|
|
|
|
|
|
|
// Print configuration
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "\n" << usrp_dev->get_pp_string();
|
2011-11-26 03:16:54 +00:00
|
|
|
|
2016-06-24 21:25:39 +00:00
|
|
|
if (iface == MULTI_ARFCN)
|
|
|
|
return MULTI_ARFCN;
|
2013-11-14 04:38:09 +00:00
|
|
|
|
2013-10-15 03:56:51 +00:00
|
|
|
switch (dev_type) {
|
|
|
|
case B100:
|
|
|
|
return RESAMP_64M;
|
|
|
|
case USRP2:
|
2014-12-04 02:47:20 +00:00
|
|
|
case X3XX:
|
2013-10-15 03:56:51 +00:00
|
|
|
return RESAMP_100M;
|
2014-02-13 19:46:23 +00:00
|
|
|
case B200:
|
|
|
|
case B210:
|
2014-04-02 02:31:44 +00:00
|
|
|
case E1XX:
|
2014-12-04 02:47:20 +00:00
|
|
|
case E3XX:
|
2016-02-05 08:52:49 +00:00
|
|
|
case LIMESDR:
|
2013-11-14 04:38:09 +00:00
|
|
|
default:
|
|
|
|
break;
|
2013-10-15 03:56:51 +00:00
|
|
|
}
|
2013-04-08 18:18:26 +00:00
|
|
|
|
|
|
|
return NORMAL;
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 03:16:57 +00:00
|
|
|
bool uhd_device::flush_recv(size_t num_pkts)
|
|
|
|
{
|
2011-11-26 03:18:02 +00:00
|
|
|
uhd::rx_metadata_t md;
|
2011-11-26 03:16:57 +00:00
|
|
|
size_t num_smpls;
|
2014-11-26 00:06:32 +00:00
|
|
|
float timeout = UHD_RESTART_TIMEOUT;
|
2011-11-26 03:17:40 +00:00
|
|
|
|
2014-02-13 19:55:23 +00:00
|
|
|
ts_initial = 0;
|
|
|
|
while (!ts_initial || (num_pkts-- > 0)) {
|
|
|
|
num_smpls = rx_stream->recv(pkt_ptrs, rx_spp, md,
|
2013-04-05 19:11:35 +00:00
|
|
|
timeout, true);
|
2011-11-26 03:18:02 +00:00
|
|
|
if (!num_smpls) {
|
|
|
|
switch (md.error_code) {
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Device timed out";
|
2014-11-26 00:06:32 +00:00
|
|
|
return false;
|
2011-11-26 03:18:02 +00:00
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2014-02-13 19:55:23 +00:00
|
|
|
|
2015-08-22 02:21:28 +00:00
|
|
|
ts_initial = md.time_spec.to_ticks(rx_rate);
|
2011-11-26 03:16:57 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Initial timestamp " << ts_initial << std::endl;
|
2014-02-13 19:55:23 +00:00
|
|
|
|
2011-11-26 03:16:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-26 00:06:32 +00:00
|
|
|
bool uhd_device::restart()
|
2011-11-26 03:17:23 +00:00
|
|
|
{
|
2014-03-27 17:52:58 +00:00
|
|
|
/* Allow 100 ms delay to align multi-channel streams */
|
|
|
|
double delay = 0.1;
|
|
|
|
|
2011-11-26 03:17:28 +00:00
|
|
|
aligned = false;
|
|
|
|
|
2014-03-27 17:52:58 +00:00
|
|
|
uhd::time_spec_t current = usrp_dev->get_time_now();
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
uhd::stream_cmd_t cmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
|
2014-03-27 17:52:58 +00:00
|
|
|
cmd.stream_now = false;
|
|
|
|
cmd.time_spec = uhd::time_spec_t(current.get_real_secs() + delay);
|
2013-10-29 22:34:16 +00:00
|
|
|
|
2011-11-26 03:17:28 +00:00
|
|
|
usrp_dev->issue_stream_cmd(cmd);
|
2014-02-13 19:55:23 +00:00
|
|
|
|
2014-11-26 00:06:32 +00:00
|
|
|
return flush_recv(10);
|
2011-11-26 03:17:23 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
bool uhd_device::start()
|
|
|
|
{
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "Starting USRP...";
|
2011-11-26 03:16:54 +00:00
|
|
|
|
|
|
|
if (started) {
|
2019-04-30 16:19:54 +00:00
|
|
|
LOGC(DDEV, ERROR) << "Device already started";
|
2011-11-26 03:16:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-07 22:16:46 +00:00
|
|
|
#ifndef USE_UHD_3_11
|
2013-10-16 00:31:44 +00:00
|
|
|
// Register msg handler
|
|
|
|
uhd::msg::register_handler(&uhd_msg_handler);
|
2017-03-07 22:16:46 +00:00
|
|
|
#endif
|
2011-11-26 03:16:54 +00:00
|
|
|
// Start asynchronous event (underrun check) loop
|
2014-11-26 00:06:32 +00:00
|
|
|
async_event_thrd = new Thread();
|
|
|
|
async_event_thrd->start((void * (*)(void*))async_event_loop, (void*)this);
|
2011-11-26 03:16:54 +00:00
|
|
|
|
|
|
|
// Start streaming
|
2014-11-26 00:06:32 +00:00
|
|
|
if (!restart())
|
|
|
|
return false;
|
2011-11-26 03:16:57 +00:00
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
// Display usrp time
|
|
|
|
double time_now = usrp_dev->get_time_now().get_real_secs();
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "The current time is " << time_now << " seconds";
|
2011-11-26 03:16:54 +00:00
|
|
|
|
|
|
|
started = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool uhd_device::stop()
|
|
|
|
{
|
2013-11-16 04:00:28 +00:00
|
|
|
if (!started)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
uhd::stream_cmd_t stream_cmd =
|
2011-11-26 03:16:54 +00:00
|
|
|
uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS;
|
|
|
|
|
|
|
|
usrp_dev->issue_stream_cmd(stream_cmd);
|
|
|
|
|
2014-11-26 00:06:32 +00:00
|
|
|
async_event_thrd->cancel();
|
|
|
|
async_event_thrd->join();
|
|
|
|
delete async_event_thrd;
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
started = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-11-26 03:17:46 +00:00
|
|
|
int uhd_device::check_rx_md_err(uhd::rx_metadata_t &md, ssize_t num_smpls)
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
2011-11-26 03:17:46 +00:00
|
|
|
if (!num_smpls) {
|
2019-04-30 16:19:54 +00:00
|
|
|
LOGC(DDEV, ERROR) << str_code(md);
|
2011-11-26 03:17:46 +00:00
|
|
|
|
|
|
|
switch (md.error_code) {
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "UHD: Receive timed out";
|
2014-11-26 00:06:32 +00:00
|
|
|
return ERROR_TIMEOUT;
|
2011-11-26 03:17:46 +00:00
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_LATE_COMMAND:
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_BROKEN_CHAIN:
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_BAD_PACKET:
|
|
|
|
default:
|
|
|
|
return ERROR_UNHANDLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
// Missing timestamp
|
|
|
|
if (!md.has_time_spec) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "UHD: Received packet missing timestamp";
|
2011-11-26 03:17:46 +00:00
|
|
|
return ERROR_UNRECOVERABLE;
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Monotonicity check
|
2017-03-08 01:54:06 +00:00
|
|
|
if (md.time_spec < prev_ts) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "UHD: Loss of monotonic time";
|
|
|
|
LOGC(DDEV, ALERT) << "Current time: " << md.time_spec.get_real_secs() << ", "
|
2012-03-13 02:20:01 +00:00
|
|
|
<< "Previous time: " << prev_ts.get_real_secs();
|
2011-11-26 03:17:46 +00:00
|
|
|
return ERROR_TIMING;
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2017-03-08 01:54:06 +00:00
|
|
|
// Workaround for UHD tick rounding bug
|
|
|
|
TIMESTAMP ticks = md.time_spec.to_ticks(rx_rate);
|
|
|
|
if (ticks - prev_ts.to_ticks(rx_rate) == rx_spp - 1)
|
|
|
|
md.time_spec = uhd::time_spec_t::from_ticks(++ticks, rx_rate);
|
|
|
|
|
|
|
|
prev_ts = md.time_spec;
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
int uhd_device::readSamples(std::vector<short *> &bufs, int len, bool *overrun,
|
|
|
|
TIMESTAMP timestamp, bool *underrun, unsigned *RSSI)
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
|
|
|
ssize_t rc;
|
|
|
|
uhd::time_spec_t ts;
|
|
|
|
uhd::rx_metadata_t metadata;
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
if (bufs.size() != chans) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Invalid channel combination " << bufs.size();
|
2013-10-29 22:34:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-11-26 03:16:54 +00:00
|
|
|
|
2013-10-25 14:42:00 +00:00
|
|
|
*overrun = false;
|
|
|
|
*underrun = false;
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
// Shift read time with respect to transmit clock
|
|
|
|
timestamp += ts_offset;
|
|
|
|
|
2015-08-22 02:21:28 +00:00
|
|
|
ts = uhd::time_spec_t::from_ticks(timestamp, rx_rate);
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "Requested timestamp = " << ts.get_real_secs();
|
2011-11-26 03:16:54 +00:00
|
|
|
|
|
|
|
// Check that timestamp is valid
|
2013-10-29 22:34:16 +00:00
|
|
|
rc = rx_buffers[0]->avail_smpls(timestamp);
|
2011-11-26 03:16:54 +00:00
|
|
|
if (rc < 0) {
|
2019-04-30 16:19:54 +00:00
|
|
|
LOGC(DDEV, ERROR) << rx_buffers[0]->str_code(rc);
|
|
|
|
LOGC(DDEV, ERROR) << rx_buffers[0]->str_status(timestamp);
|
2011-11-26 03:16:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Receive samples from the usrp until we have enough
|
2013-10-29 22:34:16 +00:00
|
|
|
while (rx_buffers[0]->avail_smpls(timestamp) < len) {
|
2014-11-26 00:06:32 +00:00
|
|
|
thread_enable_cancel(false);
|
2013-10-29 22:34:16 +00:00
|
|
|
size_t num_smpls = rx_stream->recv(pkt_ptrs, rx_spp,
|
|
|
|
metadata, 0.1, true);
|
2014-11-26 00:06:32 +00:00
|
|
|
thread_enable_cancel(true);
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
// Check for errors
|
2011-11-26 03:17:46 +00:00
|
|
|
rc = check_rx_md_err(metadata, num_smpls);
|
|
|
|
switch (rc) {
|
|
|
|
case ERROR_UNRECOVERABLE:
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "UHD: Version " << uhd::get_version_string();
|
|
|
|
LOGC(DDEV, ALERT) << "UHD: Unrecoverable error, exiting...";
|
2011-11-26 03:17:46 +00:00
|
|
|
exit(-1);
|
2014-11-26 00:06:32 +00:00
|
|
|
case ERROR_TIMEOUT:
|
|
|
|
// Assume stopping condition
|
|
|
|
return 0;
|
2011-11-26 03:17:46 +00:00
|
|
|
case ERROR_TIMING:
|
2014-03-27 17:52:58 +00:00
|
|
|
restart();
|
2011-11-26 03:17:46 +00:00
|
|
|
case ERROR_UNHANDLED:
|
2011-11-26 03:18:36 +00:00
|
|
|
continue;
|
2011-11-26 03:17:23 +00:00
|
|
|
}
|
2011-11-26 03:16:54 +00:00
|
|
|
|
|
|
|
ts = metadata.time_spec;
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "Received timestamp = " << ts.get_real_secs();
|
2011-11-26 03:16:54 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
for (size_t i = 0; i < rx_buffers.size(); i++) {
|
|
|
|
rc = rx_buffers[i]->write((short *) &pkt_bufs[i].front(),
|
|
|
|
num_smpls,
|
2019-04-29 15:46:34 +00:00
|
|
|
metadata.time_spec.to_ticks(rx_rate));
|
2013-10-29 22:34:16 +00:00
|
|
|
|
|
|
|
// Continue on local overrun, exit on other errors
|
|
|
|
if ((rc < 0)) {
|
2019-04-30 16:19:54 +00:00
|
|
|
LOGC(DDEV, ERROR) << rx_buffers[i]->str_code(rc);
|
|
|
|
LOGC(DDEV, ERROR) << rx_buffers[i]->str_status(timestamp);
|
2013-10-29 22:34:16 +00:00
|
|
|
if (rc != smpl_buf::ERROR_OVERFLOW)
|
|
|
|
return 0;
|
|
|
|
}
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We have enough samples
|
2013-10-29 22:34:16 +00:00
|
|
|
for (size_t i = 0; i < rx_buffers.size(); i++) {
|
|
|
|
rc = rx_buffers[i]->read(bufs[i], len, timestamp);
|
|
|
|
if ((rc < 0) || (rc != len)) {
|
2019-04-30 16:19:54 +00:00
|
|
|
LOGC(DDEV, ERROR) << rx_buffers[i]->str_code(rc);
|
|
|
|
LOGC(DDEV, ERROR) << rx_buffers[i]->str_status(timestamp);
|
2013-10-29 22:34:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
int uhd_device::writeSamples(std::vector<short *> &bufs, int len, bool *underrun,
|
|
|
|
unsigned long long timestamp,bool isControl)
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
|
|
|
uhd::tx_metadata_t metadata;
|
|
|
|
metadata.has_time_spec = true;
|
|
|
|
metadata.start_of_burst = false;
|
|
|
|
metadata.end_of_burst = false;
|
2015-08-22 02:21:28 +00:00
|
|
|
metadata.time_spec = uhd::time_spec_t::from_ticks(timestamp, tx_rate);
|
2011-11-26 03:16:54 +00:00
|
|
|
|
2013-10-25 14:42:00 +00:00
|
|
|
*underrun = false;
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
// No control packets
|
|
|
|
if (isControl) {
|
2019-04-30 16:19:54 +00:00
|
|
|
LOGC(DDEV, ERROR) << "Control packets not supported";
|
2011-11-26 03:16:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
if (bufs.size() != chans) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Invalid channel combination " << bufs.size();
|
2013-10-29 22:34:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
// Drop a fixed number of packets (magic value)
|
|
|
|
if (!aligned) {
|
|
|
|
drop_cnt++;
|
|
|
|
|
|
|
|
if (drop_cnt == 1) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "Aligning transmitter: stop burst";
|
2012-08-08 00:51:34 +00:00
|
|
|
*underrun = true;
|
2011-11-26 03:16:54 +00:00
|
|
|
metadata.end_of_burst = true;
|
|
|
|
} else if (drop_cnt < 30) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "Aligning transmitter: packet advance";
|
2011-11-26 03:16:54 +00:00
|
|
|
return len;
|
|
|
|
} else {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "Aligning transmitter: start burst";
|
2011-11-26 03:16:54 +00:00
|
|
|
metadata.start_of_burst = true;
|
|
|
|
aligned = true;
|
|
|
|
drop_cnt = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-26 00:06:32 +00:00
|
|
|
thread_enable_cancel(false);
|
2013-10-29 22:34:16 +00:00
|
|
|
size_t num_smpls = tx_stream->send(bufs, len, metadata);
|
2014-11-26 00:06:32 +00:00
|
|
|
thread_enable_cancel(true);
|
|
|
|
|
2012-01-09 18:11:34 +00:00
|
|
|
if (num_smpls != (unsigned) len) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "UHD: Device send timed out";
|
2012-01-09 18:11:34 +00:00
|
|
|
}
|
2011-11-26 03:16:54 +00:00
|
|
|
|
|
|
|
return num_smpls;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool uhd_device::updateAlignment(TIMESTAMP timestamp)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-13 20:09:00 +00:00
|
|
|
uhd::tune_request_t uhd_device::select_freq(double freq, size_t chan, bool tx)
|
|
|
|
{
|
|
|
|
double rf_spread, rf_freq;
|
|
|
|
std::vector<double> freqs;
|
|
|
|
uhd::tune_request_t treq(freq);
|
|
|
|
|
2015-04-09 15:55:02 +00:00
|
|
|
if (dev_type == UMTRX) {
|
2018-06-13 21:21:57 +00:00
|
|
|
if (lo_offset != 0.0)
|
|
|
|
return uhd::tune_request_t(freq, lo_offset);
|
2015-04-09 15:55:02 +00:00
|
|
|
|
|
|
|
// Don't use DSP tuning, because LMS6002D PLL steps are small enough.
|
|
|
|
// We end up with DSP tuning just for 2-3Hz, which is meaningless and
|
|
|
|
// only distort the signal (because cordic is not ideal).
|
|
|
|
treq.target_freq = freq;
|
|
|
|
treq.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL;
|
|
|
|
treq.rf_freq = freq;
|
|
|
|
treq.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL;
|
|
|
|
treq.dsp_freq = 0.0;
|
2015-06-19 21:05:51 +00:00
|
|
|
return treq;
|
2015-04-09 15:55:02 +00:00
|
|
|
} else if (chans == 1) {
|
2018-06-13 21:21:57 +00:00
|
|
|
if (lo_offset == 0.0)
|
2014-03-06 19:16:11 +00:00
|
|
|
return treq;
|
|
|
|
|
2018-06-13 21:21:57 +00:00
|
|
|
return uhd::tune_request_t(freq, lo_offset);
|
2014-03-06 19:16:11 +00:00
|
|
|
} else if ((dev_type != B210) || (chans > 2) || (chan > 1)) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << chans << " channels unsupported";
|
2014-02-13 20:09:00 +00:00
|
|
|
return treq;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tx)
|
|
|
|
freqs = tx_freqs;
|
|
|
|
else
|
|
|
|
freqs = rx_freqs;
|
|
|
|
|
|
|
|
/* Tune directly if other channel isn't tuned */
|
|
|
|
if (freqs[!chan] < 10.0)
|
|
|
|
return treq;
|
|
|
|
|
|
|
|
/* Find center frequency between channels */
|
|
|
|
rf_spread = fabs(freqs[!chan] - freq);
|
2017-06-26 17:13:25 +00:00
|
|
|
if (rf_spread > dev_param_map.at(dev_key(B210, tx_sps, rx_sps)).mcr) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << rf_spread << "Hz tuning spread not supported\n";
|
2014-02-13 20:09:00 +00:00
|
|
|
return treq;
|
|
|
|
}
|
|
|
|
|
|
|
|
rf_freq = (freqs[!chan] + freq) / 2.0f;
|
|
|
|
|
|
|
|
treq.rf_freq_policy = uhd::tune_request_t::POLICY_MANUAL;
|
|
|
|
treq.target_freq = freq;
|
|
|
|
treq.rf_freq = rf_freq;
|
|
|
|
|
|
|
|
return treq;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool uhd_device::set_freq(double freq, size_t chan, bool tx)
|
|
|
|
{
|
|
|
|
std::vector<double> freqs;
|
|
|
|
uhd::tune_result_t tres;
|
|
|
|
uhd::tune_request_t treq = select_freq(freq, chan, tx);
|
|
|
|
|
|
|
|
if (tx) {
|
|
|
|
tres = usrp_dev->set_tx_freq(treq, chan);
|
|
|
|
tx_freqs[chan] = usrp_dev->get_tx_freq(chan);
|
|
|
|
} else {
|
|
|
|
tres = usrp_dev->set_rx_freq(treq, chan);
|
|
|
|
rx_freqs[chan] = usrp_dev->get_rx_freq(chan);
|
|
|
|
}
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "\n" << tres.to_pp_string() << std::endl;
|
2014-02-13 20:09:00 +00:00
|
|
|
|
2014-03-06 19:16:11 +00:00
|
|
|
if ((chans == 1) || ((chans == 2) && dev_type == UMTRX))
|
|
|
|
return true;
|
|
|
|
|
2014-02-13 20:09:00 +00:00
|
|
|
/* Manual RF policy means we intentionally tuned with a baseband
|
|
|
|
* offset for dual-channel purposes. Now retune the other channel
|
|
|
|
* with the opposite corresponding frequency offset
|
|
|
|
*/
|
|
|
|
if (treq.rf_freq_policy == uhd::tune_request_t::POLICY_MANUAL) {
|
|
|
|
if (tx) {
|
|
|
|
treq = select_freq(tx_freqs[!chan], !chan, true);
|
|
|
|
tres = usrp_dev->set_tx_freq(treq, !chan);
|
|
|
|
tx_freqs[!chan] = usrp_dev->get_tx_freq(!chan);
|
|
|
|
} else {
|
|
|
|
treq = select_freq(rx_freqs[!chan], !chan, false);
|
|
|
|
tres = usrp_dev->set_rx_freq(treq, !chan);
|
|
|
|
rx_freqs[!chan] = usrp_dev->get_rx_freq(!chan);
|
|
|
|
|
|
|
|
}
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "\n" << tres.to_pp_string() << std::endl;
|
2014-02-13 20:09:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
bool uhd_device::setTxFreq(double wFreq, size_t chan)
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
2013-10-29 22:34:16 +00:00
|
|
|
if (chan >= tx_freqs.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-12-16 04:23:33 +00:00
|
|
|
ScopedLock lock(tune_lock);
|
2013-10-29 22:34:16 +00:00
|
|
|
|
2014-02-13 20:09:00 +00:00
|
|
|
return set_freq(wFreq, chan, true);
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
bool uhd_device::setRxFreq(double wFreq, size_t chan)
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
2013-10-29 22:34:16 +00:00
|
|
|
if (chan >= rx_freqs.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-12-16 04:23:33 +00:00
|
|
|
ScopedLock lock(tune_lock);
|
2013-10-29 22:34:16 +00:00
|
|
|
|
2014-02-13 20:09:00 +00:00
|
|
|
return set_freq(wFreq, chan, false);
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
double uhd_device::getTxFreq(size_t chan)
|
|
|
|
{
|
|
|
|
if (chan >= tx_freqs.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return tx_freqs[chan];
|
|
|
|
}
|
|
|
|
|
|
|
|
double uhd_device::getRxFreq(size_t chan)
|
|
|
|
{
|
|
|
|
if (chan >= rx_freqs.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rx_freqs[chan];
|
|
|
|
}
|
|
|
|
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
bool uhd_device::setRxAntenna(const std::string &ant, size_t chan)
|
|
|
|
{
|
|
|
|
std::vector<std::string> avail;
|
|
|
|
if (chan >= rx_paths.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
avail = usrp_dev->get_rx_antennas(chan);
|
|
|
|
if (std::find(avail.begin(), avail.end(), ant) == avail.end()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent Rx antenna " << ant << " on channel " << chan;
|
|
|
|
LOGC(DDEV, INFO) << "Available Rx antennas: ";
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
for (std::vector<std::string>::const_iterator i = avail.begin(); i != avail.end(); ++i)
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "- '" << *i << "'";
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
usrp_dev->set_rx_antenna(ant, chan);
|
|
|
|
rx_paths[chan] = usrp_dev->get_rx_antenna(chan);
|
|
|
|
|
|
|
|
if (ant != rx_paths[chan]) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Failed setting antenna " << ant << " on channel " << chan << ", got instead " << rx_paths[chan];
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string uhd_device::getRxAntenna(size_t chan)
|
|
|
|
{
|
|
|
|
if (chan >= rx_paths.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return usrp_dev->get_rx_antenna(chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool uhd_device::setTxAntenna(const std::string &ant, size_t chan)
|
|
|
|
{
|
|
|
|
std::vector<std::string> avail;
|
|
|
|
if (chan >= tx_paths.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
avail = usrp_dev->get_tx_antennas(chan);
|
|
|
|
if (std::find(avail.begin(), avail.end(), ant) == avail.end()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent Tx antenna " << ant << " on channel " << chan;
|
|
|
|
LOGC(DDEV, INFO) << "Available Tx antennas: ";
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
for (std::vector<std::string>::const_iterator i = avail.begin(); i != avail.end(); ++i)
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "- '" << *i << "'";
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
usrp_dev->set_tx_antenna(ant, chan);
|
|
|
|
tx_paths[chan] = usrp_dev->get_tx_antenna(chan);
|
|
|
|
|
|
|
|
if (ant != tx_paths[chan]) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Failed setting antenna " << ant << " on channel " << chan << ", got instead " << tx_paths[chan];
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string uhd_device::getTxAntenna(size_t chan)
|
|
|
|
{
|
|
|
|
if (chan >= tx_paths.size()) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan;
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return usrp_dev->get_tx_antenna(chan);
|
|
|
|
}
|
|
|
|
|
2018-04-24 15:48:52 +00:00
|
|
|
bool uhd_device::requiresRadioAlign()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-04-24 16:43:51 +00:00
|
|
|
GSM::Time uhd_device::minLatency() {
|
|
|
|
/* Empirical data from a handful of
|
|
|
|
relatively recent machines shows that the B100 will underrun when
|
|
|
|
the transmit threshold is reduced to a time of 6 and a half frames,
|
|
|
|
so we set a minimum 7 frame threshold. */
|
|
|
|
return GSM::Time(6,7);
|
|
|
|
}
|
|
|
|
|
2016-03-06 09:28:40 +00:00
|
|
|
/*
|
|
|
|
* Only allow sampling the Rx path lower than Tx and not vice-versa.
|
|
|
|
* Using Tx with 4 SPS and Rx at 1 SPS is the only allowed mixed
|
|
|
|
* combination.
|
|
|
|
*/
|
|
|
|
TIMESTAMP uhd_device::initialWriteTimestamp()
|
|
|
|
{
|
2016-06-24 21:25:39 +00:00
|
|
|
if ((iface == MULTI_ARFCN) || (rx_sps == tx_sps))
|
2016-03-06 09:28:40 +00:00
|
|
|
return ts_initial;
|
|
|
|
else
|
|
|
|
return ts_initial * tx_sps;
|
|
|
|
}
|
|
|
|
|
|
|
|
TIMESTAMP uhd_device::initialReadTimestamp()
|
|
|
|
{
|
|
|
|
return ts_initial;
|
|
|
|
}
|
|
|
|
|
2015-03-25 11:22:37 +00:00
|
|
|
double uhd_device::fullScaleInputValue()
|
|
|
|
{
|
2016-02-05 08:52:49 +00:00
|
|
|
if (dev_type == LIMESDR)
|
2017-06-13 20:37:46 +00:00
|
|
|
return (double) SHRT_MAX * LIMESDR_TX_AMPL;
|
2015-03-25 11:22:37 +00:00
|
|
|
if (dev_type == UMTRX)
|
|
|
|
return (double) SHRT_MAX * UMTRX_TX_AMPL;
|
|
|
|
else
|
|
|
|
return (double) SHRT_MAX * USRP_TX_AMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
double uhd_device::fullScaleOutputValue()
|
|
|
|
{
|
|
|
|
return (double) SHRT_MAX;
|
|
|
|
}
|
|
|
|
|
2011-11-26 03:16:54 +00:00
|
|
|
bool uhd_device::recv_async_msg()
|
|
|
|
{
|
2012-08-08 23:30:23 +00:00
|
|
|
uhd::async_metadata_t md;
|
2014-11-26 00:06:32 +00:00
|
|
|
|
|
|
|
thread_enable_cancel(false);
|
|
|
|
bool rc = usrp_dev->get_device()->recv_async_msg(md);
|
|
|
|
thread_enable_cancel(true);
|
|
|
|
if (!rc)
|
2011-11-26 03:16:54 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Assume that any error requires resynchronization
|
2012-08-08 23:30:23 +00:00
|
|
|
if (md.event_code != uhd::async_metadata_t::EVENT_CODE_BURST_ACK) {
|
2011-11-26 03:16:54 +00:00
|
|
|
aligned = false;
|
2012-08-08 23:30:23 +00:00
|
|
|
|
|
|
|
if ((md.event_code != uhd::async_metadata_t::EVENT_CODE_UNDERFLOW) &&
|
|
|
|
(md.event_code != uhd::async_metadata_t::EVENT_CODE_TIME_ERROR)) {
|
2019-04-30 16:19:54 +00:00
|
|
|
LOGC(DDEV, ERROR) << str_code(md);
|
2012-08-08 23:30:23 +00:00
|
|
|
}
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string uhd_device::str_code(uhd::rx_metadata_t metadata)
|
|
|
|
{
|
|
|
|
std::ostringstream ost("UHD: ");
|
|
|
|
|
|
|
|
switch (metadata.error_code) {
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_NONE:
|
|
|
|
ost << "No error";
|
|
|
|
break;
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
|
|
|
|
ost << "No packet received, implementation timed-out";
|
|
|
|
break;
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_LATE_COMMAND:
|
|
|
|
ost << "A stream command was issued in the past";
|
|
|
|
break;
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_BROKEN_CHAIN:
|
|
|
|
ost << "Expected another stream command";
|
|
|
|
break;
|
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
|
|
|
|
ost << "An internal receive buffer has filled";
|
|
|
|
break;
|
2014-02-13 20:09:00 +00:00
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_ALIGNMENT:
|
|
|
|
ost << "Multi-channel alignment failed";
|
|
|
|
break;
|
2011-11-26 03:16:54 +00:00
|
|
|
case uhd::rx_metadata_t::ERROR_CODE_BAD_PACKET:
|
|
|
|
ost << "The packet could not be parsed";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ost << "Unknown error " << metadata.error_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (metadata.has_time_spec)
|
|
|
|
ost << " at " << metadata.time_spec.get_real_secs() << " sec.";
|
|
|
|
|
|
|
|
return ost.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string uhd_device::str_code(uhd::async_metadata_t metadata)
|
|
|
|
{
|
|
|
|
std::ostringstream ost("UHD: ");
|
|
|
|
|
|
|
|
switch (metadata.event_code) {
|
|
|
|
case uhd::async_metadata_t::EVENT_CODE_BURST_ACK:
|
|
|
|
ost << "A packet was successfully transmitted";
|
|
|
|
break;
|
|
|
|
case uhd::async_metadata_t::EVENT_CODE_UNDERFLOW:
|
|
|
|
ost << "An internal send buffer has emptied";
|
|
|
|
break;
|
|
|
|
case uhd::async_metadata_t::EVENT_CODE_SEQ_ERROR:
|
|
|
|
ost << "Packet loss between host and device";
|
|
|
|
break;
|
|
|
|
case uhd::async_metadata_t::EVENT_CODE_TIME_ERROR:
|
|
|
|
ost << "Packet time was too late or too early";
|
|
|
|
break;
|
|
|
|
case uhd::async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET:
|
|
|
|
ost << "Underflow occurred inside a packet";
|
|
|
|
break;
|
|
|
|
case uhd::async_metadata_t::EVENT_CODE_SEQ_ERROR_IN_BURST:
|
|
|
|
ost << "Packet loss within a burst";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ost << "Unknown error " << metadata.event_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (metadata.has_time_spec)
|
|
|
|
ost << " at " << metadata.time_spec.get_real_secs() << " sec.";
|
|
|
|
|
|
|
|
return ost.str();
|
|
|
|
}
|
|
|
|
|
2016-03-06 09:28:40 +00:00
|
|
|
RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps,
|
2018-06-13 21:21:57 +00:00
|
|
|
InterfaceType iface, size_t chans, double lo_offset,
|
Add support to set Rx/TxAntenna
Some devices have different Rx or Tx ports with different RF characteristics.
For instance LimeSDR has H (High), L (Low) and W (Wide) band Rx ports,
each of one being more suitable to a specific range of frequencies.
In case one wants to support several GSM bands, the best option is to
use the WideBand port and connect the antenna physically to that port in
the board. Then the firmware must be instructed ro read from that port.
Support for Rx/Tx port configuration is already in there for all the
layers (Limesuite, SoapySDR, SoapyUHD, UHD), but we are missing the
required bits in osmo-trx to make use of the available UHD API. This
commit addresses it.
Before this patch, the Rx/Tx paths configured could be changed by means
of the LimeSuiteGUI app, but after running osmo-trx, the values were
changed to the default ones.
One can now start using osmo-trx with 1 channel and specific Rx/Tx ports
by using for instance: osmo-trx -c 1 -y BAND1 -z LNAW
Default behaviour if no specific path or an empry path is passed ("") is
to do the same as preiously, ie. nothing by not calling the
set{T,R}xAntenna APIs.
One can also configure only specific channels, for instance to configure
only the first Tx channel and the second Rx channel:
osmo-trx -c 2 -y BAND1, -z ,LNAW
Change-Id: I1735e6ab05a05b0312d6d679b16ebd4a2260fa23
2018-02-05 12:05:06 +00:00
|
|
|
const std::vector<std::string>& tx_paths,
|
|
|
|
const std::vector<std::string>& rx_paths)
|
2011-11-26 03:16:54 +00:00
|
|
|
{
|
2018-06-13 21:21:57 +00:00
|
|
|
return new uhd_device(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths);
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|