From f60dafa4ff101800efd8b332498971ca22489bb7 Mon Sep 17 00:00:00 2001 From: ttsou Date: Mon, 22 Oct 2012 00:07:14 +0000 Subject: [PATCH] Transceiver52M: UHD: Setup option to pass arguments from command line UHD accepts optional 'args' that can be used for device descriptions such as IP address, device type, etc. Allow these to be passed in on the transceiver command line as the third argument (number of supported carriers is the second argument). This option benefits those who may have multiple UHD devices attached to a single system. This option is not yet supported by GSM core and requires starting the transceiver independently on the command line. This option has no effect when USRP1 is used. Signed-off-by: Thomas Tsou git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@4315 19bc5d8c-e614-43d4-8b26-e1612bc8e597 --- Transceiver52M/UHDDevice.cpp | 10 +++++----- Transceiver52M/USRPDevice.cpp | 2 +- Transceiver52M/USRPDevice.h | 2 +- Transceiver52M/USRPping.cpp | 2 +- Transceiver52M/radioDevice.h | 3 ++- Transceiver52M/runTransceiver.cpp | 13 ++++++++++++- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index 1bc0519f..78e9e57e 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -151,7 +151,7 @@ public: uhd_device(double rate, bool skip_rx); ~uhd_device(); - bool open(); + bool open(const std::string &args); bool start(); bool stop(); void restart(uhd::time_spec_t ts); @@ -422,16 +422,16 @@ bool uhd_device::parse_dev_type() return true; } -bool uhd_device::open() +bool uhd_device::open(const std::string &args) { // Register msg handler uhd::msg::register_handler(&uhd_msg_handler); // Find UHD devices - uhd::device_addr_t args(""); - uhd::device_addrs_t dev_addrs = uhd::device::find(args); + uhd::device_addr_t addr(args); + uhd::device_addrs_t dev_addrs = uhd::device::find(addr); if (dev_addrs.size() == 0) { - LOG(ALERT) << "No UHD devices found"; + LOG(ALERT) << "No UHD devices found with address '" << args << "'"; return false; } diff --git a/Transceiver52M/USRPDevice.cpp b/Transceiver52M/USRPDevice.cpp index d9eefc8d..237c5f1b 100644 --- a/Transceiver52M/USRPDevice.cpp +++ b/Transceiver52M/USRPDevice.cpp @@ -75,7 +75,7 @@ USRPDevice::USRPDevice (double _desiredSampleRate, bool skipRx) #endif } -bool USRPDevice::open() +bool USRPDevice::open(const std::string &) { writeLock.unlock(); diff --git a/Transceiver52M/USRPDevice.h b/Transceiver52M/USRPDevice.h index 700f1ca0..b88afcb9 100644 --- a/Transceiver52M/USRPDevice.h +++ b/Transceiver52M/USRPDevice.h @@ -115,7 +115,7 @@ private: USRPDevice (double _desiredSampleRate, bool skipRx); /** Instantiate the USRP */ - bool open(); + bool open(const std::string &); /** Start the USRP */ bool start(); diff --git a/Transceiver52M/USRPping.cpp b/Transceiver52M/USRPping.cpp index 62f7de64..9c09e2a8 100644 --- a/Transceiver52M/USRPping.cpp +++ b/Transceiver52M/USRPping.cpp @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) { RadioDevice *usrp = RadioDevice::make(52.0e6/192.0); - usrp->open(); + usrp->open(""); TIMESTAMP timestamp; diff --git a/Transceiver52M/radioDevice.h b/Transceiver52M/radioDevice.h index 47012a1f..f7dcb03e 100644 --- a/Transceiver52M/radioDevice.h +++ b/Transceiver52M/radioDevice.h @@ -15,6 +15,7 @@ #ifndef __RADIO_DEVICE_H__ #define __RADIO_DEVICE_H__ +#include #ifdef HAVE_CONFIG_H #include "config.h" @@ -33,7 +34,7 @@ class RadioDevice { static RadioDevice *make(double desiredSampleRate, bool skipRx = false); /** Initialize the USRP */ - virtual bool open()=0; + virtual bool open(const std::string &args)=0; /** Start the USRP */ virtual bool start()=0; diff --git a/Transceiver52M/runTransceiver.cpp b/Transceiver52M/runTransceiver.cpp index 1b8df360..b95c28ed 100644 --- a/Transceiver52M/runTransceiver.cpp +++ b/Transceiver52M/runTransceiver.cpp @@ -57,6 +57,17 @@ static void ctrlCHandler(int signo) int main(int argc, char *argv[]) { + std::string deviceArgs; + + if (argc == 3) + { + deviceArgs = std::string(argv[2]); + } + else + { + deviceArgs = ""; + } + if ( signal( SIGINT, ctrlCHandler ) == SIG_ERR ) { cerr << "Couldn't install signal handler for SIGINT" << endl; @@ -79,7 +90,7 @@ int main(int argc, char *argv[]) int mOversamplingRate = numARFCN/2 + numARFCN; RadioDevice *usrp = RadioDevice::make(DEVICERATE); - if (!usrp->open()) { + if (!usrp->open(deviceArgs)) { LOG(ALERT) << "Transceiver exiting..." << std::endl; return EXIT_FAILURE; }