2011-10-12 07:44:40 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2008, 2009 Free Software Foundation, Inc.
|
|
|
|
*
|
2019-07-22 10:05:52 +00:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0+
|
|
|
|
*
|
2011-10-12 07:44:40 +00:00
|
|
|
* This software is distributed under the terms of the GNU Affero Public License.
|
|
|
|
* See the COPYING file in the main directory for details.
|
|
|
|
*
|
|
|
|
* This use of this software may be subject to additional restrictions.
|
|
|
|
* See the LEGAL file in the main directory for details.
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Compilation Flags
|
|
|
|
|
|
|
|
SWLOOPBACK compile for software loopback testing
|
2018-02-05 12:04:41 +00:00
|
|
|
*/
|
2011-10-12 07:44:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2018-01-12 14:04:02 +00:00
|
|
|
#include "Logger.h"
|
2011-10-12 07:44:40 +00:00
|
|
|
#include "Threads.h"
|
|
|
|
#include "USRPDevice.h"
|
|
|
|
|
2011-11-26 03:19:22 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2011-10-12 07:44:40 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2011-11-26 03:16:48 +00:00
|
|
|
enum dboardConfigType {
|
|
|
|
TXA_RXB,
|
|
|
|
TXB_RXA,
|
|
|
|
TXA_RXA,
|
|
|
|
TXB_RXB
|
|
|
|
};
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2011-11-26 03:19:22 +00:00
|
|
|
#ifdef SINGLEDB
|
|
|
|
const dboardConfigType dboardConfig = TXA_RXA;
|
|
|
|
#else
|
2011-11-26 03:16:48 +00:00
|
|
|
const dboardConfigType dboardConfig = TXA_RXB;
|
2011-11-26 03:19:22 +00:00
|
|
|
#endif
|
|
|
|
|
2011-11-26 03:16:48 +00:00
|
|
|
const double USRPDevice::masterClockRate = 52.0e6;
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2018-06-13 21:21:57 +00:00
|
|
|
USRPDevice::USRPDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface,
|
2020-01-13 15:00:04 +00:00
|
|
|
size_t chan_num, double lo_offset,
|
2018-06-13 21:21:57 +00:00
|
|
|
const std::vector<std::string>& tx_paths,
|
|
|
|
const std::vector<std::string>& rx_paths):
|
2020-01-13 15:00:04 +00:00
|
|
|
RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths)
|
2011-10-12 07:44:40 +00:00
|
|
|
{
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "creating USRP device...";
|
2013-10-11 17:49:55 +00:00
|
|
|
|
2018-06-13 20:47:48 +00:00
|
|
|
decimRate = (unsigned int) round(masterClockRate/((GSMRATE) * (double) tx_sps));
|
2011-10-12 07:44:40 +00:00
|
|
|
actualSampleRate = masterClockRate/decimRate;
|
|
|
|
rxGain = 0;
|
2019-09-13 14:53:31 +00:00
|
|
|
txGain = 0;
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2013-10-11 17:49:55 +00:00
|
|
|
/*
|
|
|
|
* Undetermined delay b/w ping response timestamp and true
|
|
|
|
* receive timestamp. Values are empirically measured. With
|
|
|
|
* split sample rate Tx/Rx - 4/1 sps we need to need to
|
|
|
|
* compensate for advance rather than delay.
|
|
|
|
*/
|
2018-06-13 20:47:48 +00:00
|
|
|
if (tx_sps == 1)
|
2013-10-11 17:49:55 +00:00
|
|
|
pingOffset = 272;
|
2018-06-13 20:47:48 +00:00
|
|
|
else if (tx_sps == 4)
|
2013-10-11 17:49:55 +00:00
|
|
|
pingOffset = 269 - 7500;
|
|
|
|
else
|
|
|
|
pingOffset = 0;
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
#ifdef SWLOOPBACK
|
2011-10-12 07:44:40 +00:00
|
|
|
samplePeriod = 1.0e6/actualSampleRate;
|
|
|
|
loopbackBufferSize = 0;
|
|
|
|
gettimeofday(&lastReadTime,NULL);
|
|
|
|
firstRead = false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-07-18 02:29:08 +00:00
|
|
|
int USRPDevice::open(const std::string &, int, bool)
|
2011-10-12 07:44:40 +00:00
|
|
|
{
|
|
|
|
writeLock.unlock();
|
|
|
|
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "opening USRP device..";
|
2018-02-05 12:04:41 +00:00
|
|
|
#ifndef SWLOOPBACK
|
2011-10-12 07:44:40 +00:00
|
|
|
string rbf = "std_inband.rbf";
|
2018-02-05 12:04:41 +00:00
|
|
|
//string rbf = "inband_1rxhb_1tx.rbf";
|
2011-10-12 07:44:40 +00:00
|
|
|
m_uRx.reset();
|
|
|
|
try {
|
2013-10-11 17:49:55 +00:00
|
|
|
m_uRx = usrp_standard_rx_sptr(usrp_standard_rx::make(
|
2018-06-13 20:47:48 +00:00
|
|
|
0, decimRate * tx_sps, 1, -1,
|
2013-10-11 17:49:55 +00:00
|
|
|
usrp_standard_rx::FPGA_MODE_NORMAL,
|
|
|
|
1024, 16 * 8, rbf));
|
2011-10-12 07:44:40 +00:00
|
|
|
m_uRx->set_fpga_master_clock_freq(masterClockRate);
|
|
|
|
}
|
2013-10-11 18:55:31 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
catch(...) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "make failed on Rx";
|
2011-10-12 07:44:40 +00:00
|
|
|
m_uRx.reset();
|
2013-04-08 18:18:26 +00:00
|
|
|
return -1;
|
2011-10-12 07:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_uRx->fpga_master_clock_freq() != masterClockRate)
|
|
|
|
{
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "WRONG FPGA clock freq = " << m_uRx->fpga_master_clock_freq()
|
2011-10-12 07:44:40 +00:00
|
|
|
<< ", desired clock freq = " << masterClockRate;
|
|
|
|
m_uRx.reset();
|
2013-04-08 18:18:26 +00:00
|
|
|
return -1;
|
2011-10-12 07:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2013-10-11 17:49:55 +00:00
|
|
|
m_uTx = usrp_standard_tx_sptr(usrp_standard_tx::make(
|
|
|
|
0, decimRate * 2, 1, -1,
|
|
|
|
1024, 16 * 8, rbf));
|
2011-10-12 07:44:40 +00:00
|
|
|
m_uTx->set_fpga_master_clock_freq(masterClockRate);
|
|
|
|
}
|
2013-10-11 18:55:31 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
catch(...) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "make failed on Tx";
|
2011-10-12 07:44:40 +00:00
|
|
|
m_uTx.reset();
|
2013-04-08 18:18:26 +00:00
|
|
|
return -1;
|
2011-10-12 07:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_uTx->fpga_master_clock_freq() != masterClockRate)
|
|
|
|
{
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "WRONG FPGA clock freq = " << m_uTx->fpga_master_clock_freq()
|
2011-10-12 07:44:40 +00:00
|
|
|
<< ", desired clock freq = " << masterClockRate;
|
|
|
|
m_uTx.reset();
|
2013-04-08 18:18:26 +00:00
|
|
|
return -1;
|
2011-10-12 07:44:40 +00:00
|
|
|
}
|
|
|
|
|
2019-01-11 20:36:34 +00:00
|
|
|
m_uRx->stop();
|
2011-10-12 07:44:40 +00:00
|
|
|
m_uTx->stop();
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
#endif
|
|
|
|
|
2011-11-26 03:16:48 +00:00
|
|
|
switch (dboardConfig) {
|
|
|
|
case TXA_RXB:
|
|
|
|
txSubdevSpec = usrp_subdev_spec(0,0);
|
|
|
|
rxSubdevSpec = usrp_subdev_spec(1,0);
|
|
|
|
break;
|
|
|
|
case TXB_RXA:
|
|
|
|
txSubdevSpec = usrp_subdev_spec(1,0);
|
|
|
|
rxSubdevSpec = usrp_subdev_spec(0,0);
|
|
|
|
break;
|
|
|
|
case TXA_RXA:
|
|
|
|
txSubdevSpec = usrp_subdev_spec(0,0);
|
|
|
|
rxSubdevSpec = usrp_subdev_spec(0,0);
|
|
|
|
break;
|
|
|
|
case TXB_RXB:
|
|
|
|
txSubdevSpec = usrp_subdev_spec(1,0);
|
|
|
|
rxSubdevSpec = usrp_subdev_spec(1,0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
txSubdevSpec = usrp_subdev_spec(0,0);
|
|
|
|
rxSubdevSpec = usrp_subdev_spec(1,0);
|
|
|
|
}
|
|
|
|
|
2011-11-26 03:17:59 +00:00
|
|
|
m_dbTx = m_uTx->selected_subdev(txSubdevSpec);
|
|
|
|
m_dbRx = m_uRx->selected_subdev(rxSubdevSpec);
|
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
started = false;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2013-04-08 18:18:26 +00:00
|
|
|
return NORMAL;
|
2011-10-12 07:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
bool USRPDevice::start()
|
2011-10-12 07:44:40 +00:00
|
|
|
{
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "starting USRP...";
|
2018-02-05 12:04:41 +00:00
|
|
|
#ifndef SWLOOPBACK
|
2019-01-11 20:36:34 +00:00
|
|
|
if (!m_uRx) return false;
|
2011-10-12 07:44:40 +00:00
|
|
|
if (!m_uTx) return false;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2019-01-11 20:36:34 +00:00
|
|
|
m_uRx->stop();
|
2011-10-12 07:44:40 +00:00
|
|
|
m_uTx->stop();
|
|
|
|
|
|
|
|
writeLock.lock();
|
|
|
|
// power up and configure daughterboards
|
2011-11-26 03:16:48 +00:00
|
|
|
m_dbTx->set_enable(true);
|
|
|
|
m_uTx->set_mux(m_uTx->determine_tx_mux_value(txSubdevSpec));
|
|
|
|
m_uRx->set_mux(m_uRx->determine_rx_mux_value(rxSubdevSpec));
|
|
|
|
|
|
|
|
if (!m_dbRx->select_rx_antenna(1))
|
|
|
|
m_dbRx->select_rx_antenna(0);
|
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
writeLock.unlock();
|
|
|
|
|
2011-11-26 03:16:48 +00:00
|
|
|
// Set gains to midpoint
|
|
|
|
setTxGain((minTxGain() + maxTxGain()) / 2);
|
|
|
|
setRxGain((minRxGain() + maxRxGain()) / 2);
|
2011-10-12 07:44:40 +00:00
|
|
|
|
|
|
|
data = new short[currDataSize];
|
|
|
|
dataStart = 0;
|
|
|
|
dataEnd = 0;
|
|
|
|
timeStart = 0;
|
|
|
|
timeEnd = 0;
|
|
|
|
timestampOffset = 0;
|
|
|
|
latestWriteTimestamp = 0;
|
|
|
|
lastPktTimestamp = 0;
|
|
|
|
hi32Timestamp = 0;
|
|
|
|
isAligned = false;
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
started = (m_uRx->start() && m_uTx->start());
|
|
|
|
return started;
|
|
|
|
#else
|
|
|
|
gettimeofday(&lastReadTime,NULL);
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
bool USRPDevice::stop()
|
2011-10-12 07:44:40 +00:00
|
|
|
{
|
2018-02-05 12:04:41 +00:00
|
|
|
#ifndef SWLOOPBACK
|
2011-10-12 07:44:40 +00:00
|
|
|
if (!m_uRx) return false;
|
|
|
|
if (!m_uTx) return false;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
delete[] currData;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
started = !(m_uRx->stop() && m_uTx->stop());
|
|
|
|
return !started;
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-11-26 03:16:48 +00:00
|
|
|
double USRPDevice::maxTxGain()
|
|
|
|
{
|
|
|
|
return m_dbTx->gain_max();
|
|
|
|
}
|
|
|
|
|
|
|
|
double USRPDevice::minTxGain()
|
|
|
|
{
|
|
|
|
return m_dbTx->gain_min();
|
|
|
|
}
|
|
|
|
|
|
|
|
double USRPDevice::maxRxGain()
|
|
|
|
{
|
|
|
|
return m_dbRx->gain_max();
|
2018-02-05 12:04:41 +00:00
|
|
|
}
|
2011-11-26 03:16:48 +00:00
|
|
|
|
|
|
|
double USRPDevice::minRxGain()
|
|
|
|
{
|
|
|
|
return m_dbRx->gain_min();
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
double USRPDevice::setTxGain(double dB, size_t chan)
|
|
|
|
{
|
|
|
|
if (chan) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Invalid channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return 0.0;
|
|
|
|
}
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
writeLock.lock();
|
|
|
|
if (dB > maxTxGain())
|
|
|
|
dB = maxTxGain();
|
|
|
|
if (dB < minTxGain())
|
|
|
|
dB = minTxGain();
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, NOTICE) << "Setting TX gain to " << dB << " dB.";
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
if (!m_dbTx->set_gain(dB))
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ERR) << "Error setting TX gain";
|
2019-09-13 14:53:31 +00:00
|
|
|
else
|
|
|
|
txGain = dB;
|
2013-10-29 22:34:16 +00:00
|
|
|
writeLock.unlock();
|
|
|
|
|
2019-09-13 14:53:31 +00:00
|
|
|
return txGain;
|
2011-10-12 07:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
double USRPDevice::setRxGain(double dB, size_t chan)
|
|
|
|
{
|
|
|
|
if (chan) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Invalid channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return 0.0;
|
|
|
|
}
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
dB = 47.0;
|
2011-11-26 03:16:48 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
writeLock.lock();
|
|
|
|
if (dB > maxRxGain())
|
|
|
|
dB = maxRxGain();
|
|
|
|
if (dB < minRxGain())
|
|
|
|
dB = minRxGain();
|
|
|
|
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, NOTICE) << "Setting RX gain to " << dB << " dB.";
|
2013-10-29 22:34:16 +00:00
|
|
|
|
|
|
|
if (!m_dbRx->set_gain(dB))
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ERR) << "Error setting RX gain";
|
2019-09-13 14:36:25 +00:00
|
|
|
else
|
|
|
|
rxGain = dB;
|
2013-10-29 22:34:16 +00:00
|
|
|
writeLock.unlock();
|
|
|
|
|
2019-09-13 14:36:25 +00:00
|
|
|
return rxGain;
|
2011-10-12 07:44:40 +00:00
|
|
|
}
|
|
|
|
|
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 USRPDevice::setRxAntenna(const std::string &ant, 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 false;
|
|
|
|
}
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Not implemented";
|
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 true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string USRPDevice::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 "";
|
|
|
|
}
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Not implemented";
|
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 "";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool USRPDevice::setTxAntenna(const std::string &ant, 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 false;
|
|
|
|
}
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Not implemented";
|
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 true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string USRPDevice::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 "";
|
|
|
|
}
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Not implemented";
|
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 "";
|
|
|
|
}
|
|
|
|
|
2018-04-24 15:48:52 +00:00
|
|
|
bool USRPDevice::requiresRadioAlign()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2018-04-24 16:43:51 +00:00
|
|
|
GSM::Time USRPDevice::minLatency() {
|
|
|
|
return GSM::Time(1,1);
|
|
|
|
}
|
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
// NOTE: Assumes sequential reads
|
2013-10-29 22:34:16 +00:00
|
|
|
int USRPDevice::readSamples(std::vector<short *> &bufs, int len, bool *overrun,
|
2020-03-12 18:08:46 +00:00
|
|
|
TIMESTAMP timestamp, bool *underrun)
|
2011-10-12 07:44:40 +00:00
|
|
|
{
|
2018-02-05 12:04:41 +00:00
|
|
|
#ifndef SWLOOPBACK
|
2013-10-29 22:34:16 +00:00
|
|
|
if (!m_uRx)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
short *buf = bufs[0];
|
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
timestamp += timestampOffset;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
if (timestamp + len < timeStart) {
|
|
|
|
memset(buf,0,len*2*sizeof(short));
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2019-07-29 18:25:44 +00:00
|
|
|
*underrun = false;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
uint32_t readBuf[2000];
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
while (1) {
|
|
|
|
//guestimate USB read size
|
|
|
|
int readLen=0;
|
|
|
|
{
|
|
|
|
int numSamplesNeeded = timestamp + len - timeEnd;
|
|
|
|
if (numSamplesNeeded <=0) break;
|
|
|
|
readLen = 512 * ((int) ceil((float) numSamplesNeeded/126.0));
|
|
|
|
if (readLen > 8000) readLen= (8000/512)*512;
|
|
|
|
}
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
// read USRP packets, parse and save A/D data as needed
|
|
|
|
readLen = m_uRx->read((void *)readBuf,readLen,overrun);
|
2018-09-10 08:36:04 +00:00
|
|
|
for (int pktNum = 0; pktNum < (readLen/512); pktNum++) {
|
2011-10-12 07:44:40 +00:00
|
|
|
// tmpBuf points to start of a USB packet
|
|
|
|
uint32_t* tmpBuf = (uint32_t *) (readBuf+pktNum*512/4);
|
|
|
|
TIMESTAMP pktTimestamp = usrp_to_host_u32(tmpBuf[1]);
|
|
|
|
uint32_t word0 = usrp_to_host_u32(tmpBuf[0]);
|
|
|
|
uint32_t chan = (word0 >> 16) & 0x1f;
|
|
|
|
unsigned payloadSz = word0 & 0x1ff;
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "first two bytes: " << hex << word0 << " " << dec << pktTimestamp;
|
2011-10-12 07:44:40 +00:00
|
|
|
|
|
|
|
bool incrementHi32 = ((lastPktTimestamp & 0x0ffffffffll) > pktTimestamp);
|
|
|
|
if (incrementHi32 && (timeStart!=0)) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "high 32 increment!!!";
|
2011-10-12 07:44:40 +00:00
|
|
|
hi32Timestamp++;
|
|
|
|
}
|
|
|
|
pktTimestamp = (((TIMESTAMP) hi32Timestamp) << 32) | pktTimestamp;
|
|
|
|
lastPktTimestamp = pktTimestamp;
|
|
|
|
|
|
|
|
if (chan == 0x01f) {
|
|
|
|
// control reply, check to see if its ping reply
|
|
|
|
uint32_t word2 = usrp_to_host_u32(tmpBuf[2]);
|
|
|
|
if ((word2 >> 16) == ((0x01 << 8) | 0x02)) {
|
|
|
|
timestamp -= timestampOffset;
|
2013-10-11 17:49:55 +00:00
|
|
|
timestampOffset = pktTimestamp - pingTimestamp + pingOffset;
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "updating timestamp offset to: " << timestampOffset;
|
2011-10-12 07:44:40 +00:00
|
|
|
timestamp += timestampOffset;
|
|
|
|
isAligned = true;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (chan != 0) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "chan: " << chan << ", timestamp: " << pktTimestamp << ", sz:" << payloadSz;
|
2011-10-12 07:44:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((word0 >> 28) & 0x04) {
|
2019-07-29 18:25:44 +00:00
|
|
|
*underrun = true;
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "UNDERRUN in TRX->USRP interface";
|
2011-10-12 07:44:40 +00:00
|
|
|
}
|
2020-03-12 18:08:46 +00:00
|
|
|
#if 0
|
|
|
|
/* FIXME: Do something with this ? */
|
|
|
|
unsigned RSSI = (word0 >> 21) & 0x3f;
|
|
|
|
#endif
|
2011-10-12 07:44:40 +00:00
|
|
|
if (!isAligned) continue;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
unsigned cursorStart = pktTimestamp - timeStart + dataStart;
|
|
|
|
while (cursorStart*2 > currDataSize) {
|
|
|
|
cursorStart -= currDataSize/2;
|
|
|
|
}
|
|
|
|
if (cursorStart*2 + payloadSz/2 > currDataSize) {
|
|
|
|
// need to circle around buffer
|
|
|
|
memcpy(data+cursorStart*2,tmpBuf+2,(currDataSize-cursorStart*2)*sizeof(short));
|
|
|
|
memcpy(data,tmpBuf+2+(currDataSize/2-cursorStart),payloadSz-(currDataSize-cursorStart*2)*sizeof(short));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memcpy(data+cursorStart*2,tmpBuf+2,payloadSz);
|
|
|
|
}
|
2018-02-05 12:04:41 +00:00
|
|
|
if (pktTimestamp + payloadSz/2/sizeof(short) > timeEnd)
|
2011-10-12 07:44:40 +00:00
|
|
|
timeEnd = pktTimestamp+payloadSz/2/sizeof(short);
|
|
|
|
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "timeStart: " << timeStart << ", timeEnd: " << timeEnd << ", pktTimestamp: " << pktTimestamp;
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
// copy desired data to buf
|
|
|
|
unsigned bufStart = dataStart+(timestamp-timeStart);
|
2018-02-05 12:04:41 +00:00
|
|
|
if (bufStart + len < currDataSize/2) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "bufStart: " << bufStart;
|
2011-10-12 07:44:40 +00:00
|
|
|
memcpy(buf,data+bufStart*2,len*2*sizeof(short));
|
|
|
|
memset(data+bufStart*2,0,len*2*sizeof(short));
|
|
|
|
}
|
|
|
|
else {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "len: " << len << ", currDataSize/2: " << currDataSize/2 << ", bufStart: " << bufStart;
|
2011-10-12 07:44:40 +00:00
|
|
|
unsigned firstLength = (currDataSize/2-bufStart);
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, DEBUG) << "firstLength: " << firstLength;
|
2011-10-12 07:44:40 +00:00
|
|
|
memcpy(buf,data+bufStart*2,firstLength*2*sizeof(short));
|
|
|
|
memset(data+bufStart*2,0,firstLength*2*sizeof(short));
|
|
|
|
memcpy(buf+firstLength*2,data,(len-firstLength)*2*sizeof(short));
|
|
|
|
memset(data,0,(len-firstLength)*2*sizeof(short));
|
|
|
|
}
|
|
|
|
dataStart = (bufStart + len) % (currDataSize/2);
|
|
|
|
timeStart = timestamp + len;
|
|
|
|
|
|
|
|
return len;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
#else
|
|
|
|
if (loopbackBufferSize < 2) return 0;
|
|
|
|
int numSamples = 0;
|
|
|
|
struct timeval currTime;
|
|
|
|
gettimeofday(&currTime,NULL);
|
2018-02-05 12:04:41 +00:00
|
|
|
double timeElapsed = (currTime.tv_sec - lastReadTime.tv_sec)*1.0e6 +
|
2011-10-12 07:44:40 +00:00
|
|
|
(currTime.tv_usec - lastReadTime.tv_usec);
|
|
|
|
if (timeElapsed < samplePeriod) {return 0;}
|
|
|
|
int numSamplesToRead = (int) floor(timeElapsed/samplePeriod);
|
|
|
|
if (numSamplesToRead < len) return 0;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
if (numSamplesToRead > len) numSamplesToRead = len;
|
|
|
|
if (numSamplesToRead > loopbackBufferSize/2) {
|
2018-02-05 12:04:41 +00:00
|
|
|
firstRead =false;
|
2011-10-12 07:44:40 +00:00
|
|
|
numSamplesToRead = loopbackBufferSize/2;
|
|
|
|
}
|
|
|
|
memcpy(buf,loopbackBuffer,sizeof(short)*2*numSamplesToRead);
|
|
|
|
loopbackBufferSize -= 2*numSamplesToRead;
|
|
|
|
memcpy(loopbackBuffer,loopbackBuffer+2*numSamplesToRead,
|
|
|
|
sizeof(short)*loopbackBufferSize);
|
|
|
|
numSamples = numSamplesToRead;
|
|
|
|
if (firstRead) {
|
|
|
|
int new_usec = lastReadTime.tv_usec + (int) round((double) numSamplesToRead * samplePeriod);
|
|
|
|
lastReadTime.tv_sec = lastReadTime.tv_sec + new_usec/1000000;
|
|
|
|
lastReadTime.tv_usec = new_usec % 1000000;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gettimeofday(&lastReadTime,NULL);
|
|
|
|
firstRead = true;
|
|
|
|
}
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
return numSamples;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-03-12 18:35:33 +00:00
|
|
|
int USRPDevice::writeSamplesControl(std::vector<short *> &bufs, int len,
|
|
|
|
bool *underrun, unsigned long long timestamp, bool isControl)
|
2011-10-12 07:44:40 +00:00
|
|
|
{
|
|
|
|
writeLock.lock();
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
#ifndef SWLOOPBACK
|
2013-10-29 22:34:16 +00:00
|
|
|
if (!m_uTx)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
short *buf = bufs[0];
|
|
|
|
|
2011-11-02 00:06:34 +00:00
|
|
|
static uint32_t outData[128*20];
|
2013-10-29 22:34:16 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
for (int i = 0; i < len*2; i++) {
|
|
|
|
buf[i] = host_to_usrp_short(buf[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
int numWritten = 0;
|
|
|
|
unsigned isStart = 1;
|
|
|
|
unsigned RSSI = 0;
|
|
|
|
unsigned CHAN = (isControl) ? 0x01f : 0x00;
|
|
|
|
len = len*2*sizeof(short);
|
|
|
|
int numPkts = (int) ceil((float)len/(float)504);
|
|
|
|
unsigned isEnd = (numPkts < 2);
|
|
|
|
uint32_t *outPkt = outData;
|
|
|
|
int pktNum = 0;
|
|
|
|
while (numWritten < len) {
|
|
|
|
// pkt is pointer to start of a USB packet
|
|
|
|
uint32_t *pkt = outPkt + pktNum*128;
|
|
|
|
isEnd = (len - numWritten <= 504);
|
|
|
|
unsigned payloadLen = ((len - numWritten) < 504) ? (len-numWritten) : 504;
|
|
|
|
pkt[0] = (isStart << 12 | isEnd << 11 | (RSSI & 0x3f) << 5 | CHAN) << 16 | payloadLen;
|
|
|
|
pkt[1] = timestamp & 0x0ffffffffll;
|
|
|
|
memcpy(pkt+2,buf+(numWritten/sizeof(short)),payloadLen);
|
|
|
|
numWritten += payloadLen;
|
|
|
|
timestamp += payloadLen/2/sizeof(short);
|
|
|
|
isStart = 0;
|
|
|
|
pkt[0] = host_to_usrp_u32(pkt[0]);
|
|
|
|
pkt[1] = host_to_usrp_u32(pkt[1]);
|
|
|
|
pktNum++;
|
|
|
|
}
|
|
|
|
m_uTx->write((const void*) outPkt,sizeof(uint32_t)*128*numPkts,NULL);
|
|
|
|
|
|
|
|
writeLock.unlock();
|
|
|
|
|
|
|
|
return len/2/sizeof(short);
|
|
|
|
#else
|
|
|
|
int retVal = len;
|
|
|
|
memcpy(loopbackBuffer+loopbackBufferSize,buf,sizeof(short)*2*len);
|
|
|
|
loopbackBufferSize += retVal*2;
|
2018-02-05 12:04:41 +00:00
|
|
|
|
2011-10-12 07:44:40 +00:00
|
|
|
return retVal;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-03-12 18:35:33 +00:00
|
|
|
int USRPDevice::writeSamples(std::vector<short *> &bufs, int len,
|
|
|
|
bool *underrun, unsigned long long timestamp)
|
|
|
|
{
|
|
|
|
return writeSamplesControl(bufs, len, underrun, timestamp, false);
|
|
|
|
}
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
bool USRPDevice::updateAlignment(TIMESTAMP timestamp)
|
2011-10-12 07:44:40 +00:00
|
|
|
{
|
2018-02-05 12:04:41 +00:00
|
|
|
#ifndef SWLOOPBACK
|
2011-10-12 07:44:40 +00:00
|
|
|
short data[] = {0x00,0x02,0x00,0x00};
|
|
|
|
uint32_t *wordPtr = (uint32_t *) data;
|
2011-11-02 00:06:34 +00:00
|
|
|
*wordPtr = host_to_usrp_u32(*wordPtr);
|
2011-10-12 07:44:40 +00:00
|
|
|
bool tmpUnderrun;
|
2013-10-29 22:34:16 +00:00
|
|
|
|
|
|
|
std::vector<short *> buf(1, data);
|
2020-03-12 18:35:33 +00:00
|
|
|
if (writeSamplesControl(buf, 1, &tmpUnderrun, timestamp & 0x0ffffffffll, true)) {
|
2011-10-12 07:44:40 +00:00
|
|
|
pingTimestamp = timestamp;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-02-05 12:04:41 +00:00
|
|
|
#ifndef SWLOOPBACK
|
2013-10-29 22:34:16 +00:00
|
|
|
bool USRPDevice::setTxFreq(double wFreq, size_t chan)
|
2011-11-26 03:16:48 +00:00
|
|
|
{
|
|
|
|
usrp_tune_result result;
|
2011-10-12 07:44:40 +00:00
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
if (chan) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Invalid channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-26 03:17:59 +00:00
|
|
|
if (m_uTx->tune(txSubdevSpec.side, m_dbTx, wFreq, &result)) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "set TX: " << wFreq << std::endl
|
2011-11-26 03:16:48 +00:00
|
|
|
<< " baseband freq: " << result.baseband_freq << std::endl
|
|
|
|
<< " DDC freq: " << result.dxc_freq << std::endl
|
|
|
|
<< " residual freq: " << result.residual_freq;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
2019-01-11 21:41:58 +00:00
|
|
|
LOGC(DDEV, ALERT) << "set TX: " << wFreq << " failed" << std::endl
|
2011-11-26 03:16:48 +00:00
|
|
|
<< " baseband freq: " << result.baseband_freq << std::endl
|
|
|
|
<< " DDC freq: " << result.dxc_freq << std::endl
|
|
|
|
<< " residual freq: " << result.residual_freq;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
bool USRPDevice::setRxFreq(double wFreq, size_t chan)
|
2011-11-26 03:16:48 +00:00
|
|
|
{
|
|
|
|
usrp_tune_result result;
|
|
|
|
|
2013-10-29 22:34:16 +00:00
|
|
|
if (chan) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ALERT) << "Invalid channel " << chan;
|
2013-10-29 22:34:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-11-26 03:16:48 +00:00
|
|
|
if (m_uRx->tune(0, m_dbRx, wFreq, &result)) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, INFO) << "set RX: " << wFreq << std::endl
|
2011-11-26 03:16:48 +00:00
|
|
|
<< " baseband freq: " << result.baseband_freq << std::endl
|
|
|
|
<< " DDC freq: " << result.dxc_freq << std::endl
|
|
|
|
<< " residual freq: " << result.residual_freq;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
2019-01-11 21:41:58 +00:00
|
|
|
LOGC(DDEV, ALERT) << "set RX: " << wFreq << " failed" << std::endl
|
2011-11-26 03:16:48 +00:00
|
|
|
<< " baseband freq: " << result.baseband_freq << std::endl
|
|
|
|
<< " DDC freq: " << result.dxc_freq << std::endl
|
|
|
|
<< " residual freq: " << result.residual_freq;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2011-10-12 07:44:40 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
bool USRPDevice::setTxFreq(double wFreq) { return true;};
|
|
|
|
bool USRPDevice::setRxFreq(double wFreq) { return true;};
|
|
|
|
#endif
|
2011-11-26 03:16:54 +00:00
|
|
|
|
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:42:19 +00:00
|
|
|
if (tx_sps != rx_sps) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ERROR) << "USRP1 requires tx_sps == rx_sps";
|
2018-06-13 21:42:19 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (chans != 1) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ERROR) << "USRP1 supports only 1 channel";
|
2018-06-13 21:42:19 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (lo_offset != 0.0) {
|
2018-08-17 17:55:38 +00:00
|
|
|
LOGC(DDEV, ERROR) << "USRP1 doesn't support lo_offset";
|
2018-06-13 21:42:19 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2018-06-13 21:21:57 +00:00
|
|
|
return new USRPDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths);
|
2011-11-26 03:16:54 +00:00
|
|
|
}
|