aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/osmo-trx.cpp
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-02-05 13:05:06 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2018-02-07 13:43:42 +0100
commit77ce99ac6720896f504a0581a5c57b2929a13cef (patch)
tree8124086d3ab9bc1742acb928253889090a3783e7 /Transceiver52M/osmo-trx.cpp
parentf58cd8ac837d13237cf88e93e45550b90d085b15 (diff)
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
Diffstat (limited to 'Transceiver52M/osmo-trx.cpp')
-rw-r--r--Transceiver52M/osmo-trx.cpp64
1 files changed, 60 insertions, 4 deletions
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 44da638..8c34893 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -28,6 +28,10 @@
#include <stdlib.h>
#include <unistd.h>
#include <sched.h>
+#include <vector>
+#include <string>
+#include <sstream>
+#include <iostream>
#include <GSMCommon.h>
#include <Logger.h>
@@ -79,6 +83,8 @@ struct trx_config {
bool swap_channels;
bool edge;
int sched_rr;
+ std::vector<std::string> rx_paths;
+ std::vector<std::string> tx_paths;
};
volatile bool gshutdown = false;
@@ -93,6 +99,7 @@ volatile bool gshutdown = false;
bool trx_setup_config(struct trx_config *config)
{
std::string refstr, fillstr, divstr, mcstr, edgestr;
+ std::vector<std::string>::const_iterator si;
if (config->mcbts && config->chans > 5) {
std::cout << "Unsupported number of channels" << std::endl;
@@ -144,8 +151,16 @@ bool trx_setup_config(struct trx_config *config)
ost << " Tuning offset........... " << config->offset << std::endl;
ost << " RSSI to dBm offset...... " << config->rssi_offset << std::endl;
ost << " Swap channels........... " << config->swap_channels << std::endl;
- std::cout << ost << std::endl;
+ ost << " Tx Antennas.............";
+ for (si = config->tx_paths.begin(); si != config->tx_paths.end(); ++si)
+ ost << " '" << ((*si != "") ? *si : "<default>") << "'";
+ ost << std::endl;
+ ost << " Rx Antennas.............";
+ for (si = config->rx_paths.begin(); si != config->rx_paths.end(); ++si)
+ ost << " '" << ((*si != "") ? *si : "<default>") << "'";
+ ost << std::endl;
+ std::cout << ost << std::endl;
return true;
}
@@ -241,6 +256,21 @@ static void setup_signal_handlers()
}
}
+
+static std::vector<std::string> comma_delimited_to_vector(char* opt) {
+ std::string str = std::string(opt);
+ std::vector<std::string> result;
+ std::stringstream ss(str);
+
+ while( ss.good() )
+ {
+ std::string substr;
+ getline(ss, substr, ',');
+ result.push_back(substr);
+ }
+ return result;
+}
+
static void print_help()
{
fprintf(stdout, "Options:\n"
@@ -263,13 +293,16 @@ static void print_help()
" -A Random Access Burst test mode with delay\n"
" -R RSSI to dBm offset in dB (default=0)\n"
" -S Swap channels (UmTRX only)\n"
- " -t SCHED_RR real-time priority (1..32)\n",
+ " -t SCHED_RR real-time priority (1..32)\n"
+ " -y comma-delimited list of Tx paths (num elements matches -c)\n"
+ " -z comma-delimited list of Rx paths (num elements matches -c)\n",
"EMERG, ALERT, CRT, ERR, WARNING, NOTICE, INFO, DEBUG");
}
static void handle_options(int argc, char **argv, struct trx_config *config)
{
int option;
+ bool tx_path_set = false, rx_path_set = false;
config->log_level = "NOTICE";
config->local_addr = DEFAULT_TRX_IP;
@@ -289,8 +322,10 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
config->swap_channels = false;
config->edge = false;
config->sched_rr = -1;
+ config->tx_paths = std::vector<std::string>(DEFAULT_CHANS, "");
+ config->rx_paths = std::vector<std::string>(DEFAULT_CHANS, "");
- while ((option = getopt(argc, argv, "ha:l:i:j:p:c:dmxgfo:s:b:r:A:R:Set:")) != -1) {
+ while ((option = getopt(argc, argv, "ha:l:i:j:p:c:dmxgfo:s:b:r:A:R:Set:y:z:")) != -1) {
switch (option) {
case 'h':
print_help();
@@ -355,6 +390,14 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
case 't':
config->sched_rr = atoi(optarg);
break;
+ case 'y':
+ config->tx_paths = comma_delimited_to_vector(optarg);
+ tx_path_set = true;
+ break;
+ case 'z':
+ config->rx_paths = comma_delimited_to_vector(optarg);
+ rx_path_set = true;
+ break;
default:
print_help();
exit(0);
@@ -391,6 +434,19 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
goto bad_config;
}
+ if (!tx_path_set) {
+ config->tx_paths = std::vector<std::string>(config->chans, "");
+ } else if (config->tx_paths.size() != config->chans) {
+ printf("Num of channels and num of Tx Antennas doesn't match\n\n");
+ goto bad_config;
+ }
+ if (!rx_path_set) {
+ config->rx_paths = std::vector<std::string>(config->chans, "");
+ } else if (config->rx_paths.size() != config->chans) {
+ printf("Num of channels and num of Rx Antennas doesn't match\n\n");
+ goto bad_config;
+ }
+
return;
bad_config:
@@ -480,7 +536,7 @@ int main(int argc, char *argv[])
ref = RadioDevice::REF_INTERNAL;
usrp = RadioDevice::make(config.tx_sps, config.rx_sps, iface,
- config.chans, config.offset);
+ config.chans, config.offset, config.tx_paths, config.rx_paths);
type = usrp->open(config.dev_args, ref, config.swap_channels);
if (type < 0) {
LOG(ALERT) << "Failed to create radio device" << std::endl;