From df127bc74e5032020dc5bacd8bb52cd82f936b68 Mon Sep 17 00:00:00 2001 From: Alexander Chemeris Date: Sun, 7 Jun 2015 01:07:45 -0400 Subject: osmo-trx: Add an option to swap channels on UmTRX. --- Transceiver52M/UHDDevice.cpp | 6 +++--- Transceiver52M/USRPDevice.cpp | 2 +- Transceiver52M/USRPDevice.h | 2 +- Transceiver52M/osmo-trx.cpp | 13 ++++++++++--- Transceiver52M/radioDevice.h | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index 9043318..9038bc1 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -290,7 +290,7 @@ public: uhd_device(size_t sps, size_t chans, bool diversity, double offset); ~uhd_device(); - int open(const std::string &args, bool extref); + int open(const std::string &args, bool extref, bool swap_channels); bool start(); bool stop(); bool restart(); @@ -694,7 +694,7 @@ bool uhd_device::parse_dev_type() return true; } -int uhd_device::open(const std::string &args, bool extref) +int uhd_device::open(const std::string &args, bool extref, bool swap_channels) { // Find UHD devices uhd::device_addr_t addr(args); @@ -720,7 +720,7 @@ int uhd_device::open(const std::string &args, bool extref) // Verify and set channels if ((dev_type == B210) && (chans == 2)) { } else if ((dev_type == UMTRX) && (chans == 2)) { - uhd::usrp::subdev_spec_t subdev_spec("A:0 B:0"); + uhd::usrp::subdev_spec_t subdev_spec(swap_channels?"B:0 A:0":"A:0 B:0"); usrp_dev->set_tx_subdev_spec(subdev_spec); usrp_dev->set_rx_subdev_spec(subdev_spec); } else if (chans != 1) { diff --git a/Transceiver52M/USRPDevice.cpp b/Transceiver52M/USRPDevice.cpp index bba8bb9..568f0e5 100644 --- a/Transceiver52M/USRPDevice.cpp +++ b/Transceiver52M/USRPDevice.cpp @@ -89,7 +89,7 @@ USRPDevice::USRPDevice(size_t sps, size_t, bool) #endif } -int USRPDevice::open(const std::string &, bool) +int USRPDevice::open(const std::string &, bool, bool) { writeLock.unlock(); diff --git a/Transceiver52M/USRPDevice.h b/Transceiver52M/USRPDevice.h index 0807127..3f06c88 100644 --- a/Transceiver52M/USRPDevice.h +++ b/Transceiver52M/USRPDevice.h @@ -99,7 +99,7 @@ private: USRPDevice(size_t sps, size_t chans = 1, bool diversity = false); /** Instantiate the USRP */ - int open(const std::string &, bool); + int open(const std::string &, bool, bool); /** Start the USRP */ bool start(); diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index 048b9f8..7b9fd7c 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -71,6 +71,7 @@ struct trx_config { bool diversity; double offset; double rssi_offset; + bool swap_channels; }; ConfigurationTable gConfig; @@ -187,6 +188,7 @@ bool trx_setup_config(struct trx_config *config) ost << " Diversity............... " << divstr << std::endl; 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; return true; @@ -295,7 +297,8 @@ static void print_help() " -f Enable C0 filler table\n" " -o Set baseband frequency offset (default=auto)\n" " -r Random burst test mode with TSC\n" - " -R RSSI to dBm offset in dB (default=0)\n", + " -R RSSI to dBm offset in dB (default=0)\n" + " -S Swap channels (UmTRX only)\n", "EMERG, ALERT, CRT, ERR, WARNING, NOTICE, INFO, DEBUG"); } @@ -312,8 +315,9 @@ static void handle_options(int argc, char **argv, struct trx_config *config) config->diversity = false; config->offset = 0.0; config->rssi_offset = 0.0; + config->swap_channels = false; - while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:s:r:R:")) != -1) { + while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:s:r:R:S")) != -1) { switch (option) { case 'h': print_help(); @@ -356,6 +360,9 @@ static void handle_options(int argc, char **argv, struct trx_config *config) case 'R': config->rssi_offset = atof(optarg); break; + case 'S': + config->swap_channels = true; + break; default: print_help(); exit(0); @@ -400,7 +407,7 @@ int main(int argc, char *argv[]) /* Create the low level device object */ usrp = RadioDevice::make(config.sps, config.chans, config.diversity, config.offset); - type = usrp->open(config.dev_args, config.extref); + type = usrp->open(config.dev_args, config.extref, config.swap_channels); if (type < 0) { LOG(ALERT) << "Failed to create radio device" << std::endl; goto shutdown; diff --git a/Transceiver52M/radioDevice.h b/Transceiver52M/radioDevice.h index 6273bcc..dd4928c 100644 --- a/Transceiver52M/radioDevice.h +++ b/Transceiver52M/radioDevice.h @@ -41,7 +41,7 @@ class RadioDevice { bool diversity = false, double offset = 0.0); /** Initialize the USRP */ - virtual int open(const std::string &args = "", bool extref = false)=0; + virtual int open(const std::string &args = "", bool extref = false, bool swap_channels = false)=0; virtual ~RadioDevice() { } -- cgit v1.2.3