From 09befd7a06877094653456942605b63c6dccb1d4 Mon Sep 17 00:00:00 2001 From: Thomas Tsou Date: Tue, 7 Oct 2014 19:37:37 -0700 Subject: ms: Add command line option and allow negative Tx/Rx offset The +/- 3 frame offset for Tx/Rx is setup in the RadioInterface constructor, so we need to know whether we are operating in MS or BTS mode at the very beginning. For MS mode, handle negative frame offsets, which would previously cause an assertion error. Signed-off-by: Thomas Tsou --- Transceiver52M/osmo-trx.cpp | 26 +++++++++++++++++++++++--- Transceiver52M/radioInterface.cpp | 6 +++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index 9215fa5..b3b0c2d 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -68,6 +68,7 @@ struct trx_config { bool extref; bool filler; bool diversity; + bool ms; double offset; }; @@ -118,7 +119,7 @@ bool testConfig() */ bool trx_setup_config(struct trx_config *config) { - std::string refstr, fillstr, divstr; + std::string refstr, fillstr, divstr, msstr; if (!testConfig()) return false; @@ -167,6 +168,7 @@ bool trx_setup_config(struct trx_config *config) refstr = config->extref ? "Enabled" : "Disabled"; fillstr = config->filler ? "Enabled" : "Disabled"; divstr = config->diversity ? "Enabled" : "Disabled"; + msstr = config->ms ? "Enabled" : "Disabled"; std::ostringstream ost(""); ost << "Config Settings" << std::endl; @@ -179,6 +181,7 @@ bool trx_setup_config(struct trx_config *config) ost << " External Reference...... " << refstr << std::endl; ost << " C0 Filler Table......... " << fillstr << std::endl; ost << " Diversity............... " << divstr << std::endl; + ost << " MS Mode................. " << msstr << std::endl; ost << " Tuning offset........... " << config->offset << std::endl; std::cout << ost << std::endl; @@ -196,10 +199,22 @@ RadioInterface *makeRadioInterface(struct trx_config *config, RadioDevice *usrp, int type) { RadioInterface *radio = NULL; + size_t div = 1; + int offset = 3; + + if (config->ms) { + if (type != RadioDevice::NORMAL) { + LOG(ALERT) << "Unsupported configuration"; + return NULL; + } + + offset *= -1; + } switch (type) { case RadioDevice::NORMAL: - radio = new RadioInterface(usrp, config->sps, config->chans); + radio = new RadioInterface(usrp, config->sps, + config->chans, div, offset); break; case RadioDevice::RESAMP_64M: case RadioDevice::RESAMP_100M: @@ -286,6 +301,7 @@ static void print_help() " -s Samples-per-symbol (1 or 4)\n" " -c Number of ARFCN channels (default=1)\n" " -f Enable C0 filler table\n" + " -m Enable MS mode\n" " -o Set baseband frequency offset (default=auto)\n", "EMERG, ALERT, CRT, ERR, WARNING, NOTICE, INFO, DEBUG"); } @@ -300,9 +316,10 @@ static void handle_options(int argc, char **argv, struct trx_config *config) config->extref = false; config->filler = false; config->diversity = false; + config->ms = false; config->offset = 0.0; - while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:s:")) != -1) { + while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:ms:")) != -1) { switch (option) { case 'h': print_help(); @@ -335,6 +352,9 @@ static void handle_options(int argc, char **argv, struct trx_config *config) case 'o': config->offset = atof(optarg); break; + case 'm': + config->ms = true; + break; case 's': config->sps = atoi(optarg); if ((config->sps != 1) && (config->sps != 4)) { diff --git a/Transceiver52M/radioInterface.cpp b/Transceiver52M/radioInterface.cpp index 3d91cd1..e55f66b 100644 --- a/Transceiver52M/radioInterface.cpp +++ b/Transceiver52M/radioInterface.cpp @@ -238,7 +238,11 @@ bool RadioInterface::driveReceiveRadio() pullBuffer(); GSM::Time rcvClock = mClock.get(); - rcvClock.decTN(receiveOffset); + if (receiveOffset < 0) + rcvClock.incTN(-receiveOffset); + else + rcvClock.decTN(receiveOffset); + unsigned tN = rcvClock.TN(); int recvSz = recvCursor; int readSz = 0; -- cgit v1.2.3